From 3bd16a304d17a5bde2b5663dcb8b673a7a3b1027 Mon Sep 17 00:00:00 2001 From: zzyangh <799463087@qq.com> Date: Fri, 22 Nov 2024 15:38:26 +0800 Subject: [PATCH 1/2] [feature](SqlExecWrokflow): Add associated rollback ticket link --- .../shared/lib/api/sqle/service/common.d.ts | 12 ++++- .../sqle/src/locale/zh-CN/execWorkflow.ts | 3 +- .../components/SqlBackupSwitcher.tsx | 4 +- .../components/SwitchField.tsx | 4 +- .../components/index.type.ts | 3 +- .../SqlStatementFormItem/index.tsx | 1 + .../Common/ResultCard/SqlMode.tsx | 12 ++++- .../components/RollbackWorkflowEntry.tsx | 50 +++++++++++++++++++ .../Common/ResultCard/components/style.ts | 7 +++ .../Common/ResultCard/index.type.ts | 7 ++- .../components/ModifySqlStatement/index.tsx | 6 ++- .../hooks/useWorkflowDetailAction.tsx | 22 +++++--- 12 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/RollbackWorkflowEntry.tsx diff --git a/packages/shared/lib/api/sqle/service/common.d.ts b/packages/shared/lib/api/sqle/service/common.d.ts index 41d85a881..23629e969 100644 --- a/packages/shared/lib/api/sqle/service/common.d.ts +++ b/packages/shared/lib/api/sqle/service/common.d.ts @@ -3531,6 +3531,12 @@ export interface IUpdatePipelineNode { type?: updatePipelineNodeTypeEnum; } +export interface IAssociatedRollbackWorkflow { + workflow_id?: string; + + workflow_name?: string; +} + export interface IAssociatedStageWorkflows { sql_version_stage_id?: number; @@ -3646,7 +3652,7 @@ export interface IAuditSQLResV2 { } export interface IAuditTaskSQLResV2 { - associate_workflow_ids?: string[]; + associated_rollback_workflows?: IAssociatedRollbackWorkflow[]; audit_level?: string; @@ -3670,7 +3676,7 @@ export interface IAuditTaskSQLResV2 { number?: number; - rollback_sql?: string; + rollback_sqls?: string[]; sql_source_file?: string; @@ -3974,6 +3980,8 @@ export interface IWorkflowRecordResV2 { } export interface IWorkflowResV2 { + associated_rollback_workflows?: IAssociatedRollbackWorkflow[]; + associated_stage_workflows?: IAssociatedStageWorkflows[]; create_time?: string; diff --git a/packages/sqle/src/locale/zh-CN/execWorkflow.ts b/packages/sqle/src/locale/zh-CN/execWorkflow.ts index 1dc5ae319..ad60c0bd9 100644 --- a/packages/sqle/src/locale/zh-CN/execWorkflow.ts +++ b/packages/sqle/src/locale/zh-CN/execWorkflow.ts @@ -267,7 +267,8 @@ export default { remark: '备注', addRemark: '添加备注', originSql: '原始SQL' - } + }, + associatedRollbackWorkflow: '关联回滚工单' }, audit: { diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlBackupSwitcher.tsx b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlBackupSwitcher.tsx index 42096207a..665800539 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlBackupSwitcher.tsx +++ b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlBackupSwitcher.tsx @@ -15,7 +15,8 @@ import SwitchField from './SwitchField'; const SqlBackupSwitcher: React.FC = ({ fieldPrefixPath, databaseInfo, - isSameSqlForAll + isSameSqlForAll, + isAtRejectStep }) => { const { t } = useTranslation(); @@ -73,6 +74,7 @@ const SqlBackupSwitcher: React.FC = ({ ) : t('execWorkflow.create.form.sqlInfo.cancelSwitchSqlBackupTips') } + disabled={isAtRejectStep} /> diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SwitchField.tsx b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SwitchField.tsx index bbb92923e..a02d6aafe 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SwitchField.tsx +++ b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SwitchField.tsx @@ -7,7 +7,8 @@ import { SwitcherFieldProps } from './index.type'; const SwitchField: React.FC = ({ checked, onChange, - title + title, + disabled = false }) => { const { t } = useTranslation(); @@ -29,6 +30,7 @@ const SwitchField: React.FC = ({ onCancel={hidePopconfirm} > { diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/index.type.ts b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/index.type.ts index fd5726e33..70edef2d4 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/index.type.ts +++ b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/index.type.ts @@ -25,11 +25,12 @@ export type SqlFormatterAndSubmitterProps = { export type SqlBackupSwitcherProps = Pick< SqlStatementFormItemProps, - 'fieldPrefixPath' | 'databaseInfo' | 'isSameSqlForAll' + 'fieldPrefixPath' | 'databaseInfo' | 'isSameSqlForAll' | 'isAtRejectStep' >; export type SwitcherFieldProps = { checked?: boolean; onChange?: (v: boolean) => void; title?: string; + disabled?: boolean; }; diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/index.tsx index 58b471eb3..d9b952ac5 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/index.tsx +++ b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/index.tsx @@ -89,6 +89,7 @@ const SqlStatementFormItem: React.FC = ({ fieldPrefixPath={fieldPrefixPath} databaseInfo={databaseInfo} isSameSqlForAll={isSameSqlForAll} + isAtRejectStep={isAtRejectStep} /> {/* #endif */} = ({ projectID, @@ -99,6 +100,13 @@ const SqlMode: React.FC = ({ + {/* #if [ee] */} + + + + {/* #endif */} {t('execWorkflow.audit.copyExecSql')} @@ -125,12 +133,14 @@ const SqlMode: React.FC = ({ label: t('execWorkflow.audit.table.rollback'), children: ( + {/* #if [ee] */} {props.backup_strategy_tip} + {/* #endif */} {/* #if [ee] */} = ({ /> {/* #endif */} diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/RollbackWorkflowEntry.tsx b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/RollbackWorkflowEntry.tsx new file mode 100644 index 000000000..32978d239 --- /dev/null +++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/RollbackWorkflowEntry.tsx @@ -0,0 +1,50 @@ +import { RollbackWorkflowEntryProps } from '../index.type'; +import { Dropdown, MenuProps } from 'antd'; +import { BasicButton, TypedLink } from '@actiontech/shared'; +import { DownOutlined } from '@actiontech/icons'; +import { useMemo } from 'react'; +import { ROUTE_PATHS } from '@actiontech/shared/lib/data/routePaths'; +import { useCurrentProject } from '@actiontech/shared/lib/global'; +import { useTranslation } from 'react-i18next'; +import { RollbackWorkflowItemStyleWrapper } from './style'; + +const RollbackWorkflowEntry: React.FC = ({ + workflows +}) => { + const { t } = useTranslation(); + + const { projectID } = useCurrentProject(); + + const menuItems: MenuProps['items'] = useMemo(() => { + return ( + workflows?.map((item) => { + return { + key: item.workflow_id, + label: ( + + + {item.workflow_name} + + + ), + type: 'group' + }; + }) ?? [] + ); + }, [workflows, projectID]); + + return ( + + + {t('execWorkflow.detail.associatedRollbackWorkflow')} + + + + ); +}; + +export default RollbackWorkflowEntry; diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/style.ts b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/style.ts index d5688c18f..c21548150 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/style.ts +++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/components/style.ts @@ -58,3 +58,10 @@ export const TaskResultDescribeStyleWrapper = styled('div')` font-size: 13px; } `; + +export const RollbackWorkflowItemStyleWrapper = styled('div')` + max-width: 300px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +`; diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/index.type.ts b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/index.type.ts index a1bd3e3d9..dde8b2270 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/index.type.ts +++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/ResultCard/index.type.ts @@ -1,6 +1,7 @@ import { IAuditTaskSQLResV2, - IAuditFileStatistic + IAuditFileStatistic, + IAssociatedRollbackWorkflow } from '@actiontech/shared/lib/api/sqle/service/common'; import { WorkflowResV2ExecModeEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum'; @@ -27,3 +28,7 @@ export type ResultCardProps = | (FileExecuteResultCardProps & { executeMode: WorkflowResV2ExecModeEnum.sql_file; }); + +export type RollbackWorkflowEntryProps = { + workflows?: IAssociatedRollbackWorkflow[]; +}; diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/ModifySqlStatement/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/ModifySqlStatement/index.tsx index 514e65cc5..269e5466c 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/ModifySqlStatement/index.tsx +++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/ModifySqlStatement/index.tsx @@ -193,7 +193,8 @@ const ModifySqlStatement: React.FC = ({ form.setFieldValue(SAME_SQL_MODE_DEFAULT_FIELD_KEY, { currentUploadType: currentTasks?.[0]?.sql_source, exec_mode: currentTasks?.[0]?.exec_mode, - file_sort_method: currentTasks?.[0]?.file_order_method + file_sort_method: currentTasks?.[0]?.file_order_method, + backup: currentTasks?.[0]?.enable_backup }); } else { sqlStatementTabActiveKey.set( @@ -204,7 +205,8 @@ const ModifySqlStatement: React.FC = ({ form.setFieldValue(item.task_id?.toString() ?? '', { currentUploadType: item.sql_source, exec_mode: item.exec_mode, - file_sort_method: item.file_order_method + file_sort_method: item.file_order_method, + backup: item.enable_backup }); }); } diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/PageHeaderExtra/hooks/useWorkflowDetailAction.tsx b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/PageHeaderExtra/hooks/useWorkflowDetailAction.tsx index 61f48d6cc..6a8cb7217 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Detail/components/PageHeaderExtra/hooks/useWorkflowDetailAction.tsx +++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/components/PageHeaderExtra/hooks/useWorkflowDetailAction.tsx @@ -271,12 +271,22 @@ const useWorkflowDetailAction = ({ if (!workflowInfo?.record?.status) { return false; } - return [ - WorkflowRecordResV2StatusEnum.finished, - WorkflowRecordResV2StatusEnum.exec_failed, - WorkflowRecordResV2StatusEnum.canceled - ].includes(workflowInfo.record.status); - }, [workflowInfo?.record?.status]); + + return ( + [ + WorkflowRecordResV2StatusEnum.finished, + WorkflowRecordResV2StatusEnum.exec_failed, + WorkflowRecordResV2StatusEnum.canceled + ].includes(workflowInfo.record.status) && + workflowInfo.record.workflow_step_list + ?.find((v) => v.type === WorkflowStepResV2TypeEnum.sql_execute) + ?.assignee_user_name_list?.includes(username) + ); + }, [ + workflowInfo?.record?.status, + username, + workflowInfo?.record?.workflow_step_list + ]); const rollbackWorkflow = () => { startRollback(); From a8f19664c0a25a5084a80a08b3a62193c5f2c808 Mon Sep 17 00:00:00 2001 From: zzyangh <799463087@qq.com> Date: Fri, 22 Nov 2024 15:39:33 +0800 Subject: [PATCH 2/2] [feature](DataSource): Add backup rollback configuration[skip ci] --- .../components/AddDataSource/index.tsx | 5 ++- .../page/DataSource/components/Form/index.tsx | 33 +++++++++++++++++-- .../DataSource/components/Form/index.type.ts | 1 + .../components/UpdateDataSource/index.tsx | 5 ++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/base/src/page/DataSource/components/AddDataSource/index.tsx b/packages/base/src/page/DataSource/components/AddDataSource/index.tsx index 17e92f592..ed4b90ddc 100644 --- a/packages/base/src/page/DataSource/components/AddDataSource/index.tsx +++ b/packages/base/src/page/DataSource/components/AddDataSource/index.tsx @@ -61,7 +61,10 @@ const AddDataSource = () => { // #endif additional_params: values.asyncParams, // #if [dms] - is_enable_masking: values.is_enable_masking + is_enable_masking: values.is_enable_masking, + // #endif + // #if [sqle && ee] + enable_backup: values.enableBackup // #endif }; return DBService.AddDBService({ diff --git a/packages/base/src/page/DataSource/components/Form/index.tsx b/packages/base/src/page/DataSource/components/Form/index.tsx index cc9c8df92..58cc9de42 100644 --- a/packages/base/src/page/DataSource/components/Form/index.tsx +++ b/packages/base/src/page/DataSource/components/Form/index.tsx @@ -27,7 +27,8 @@ import { FormItemBigTitle, FormItemLabel, FormItemNoLabel, - FormItemSubTitle + FormItemSubTitle, + CustomLabelContent } from '@actiontech/shared/lib/components/FormCom'; import { nameRule } from '@actiontech/shared/lib/utils/FormRule'; import DatabaseFormItem from './FormItem'; @@ -193,7 +194,10 @@ const DataSourceForm: React.FC = (props) => { business: props.defaultData.business, password: props.defaultData.password, // #if [dms] - is_enable_masking: props.defaultData.is_enable_masking + is_enable_masking: props.defaultData.is_enable_masking, + // #endif + // #if [sqle && ee] + enableBackup: props.defaultData.enable_backup // #endif }); setDatabaseType(props.defaultData.db_type ?? ''); @@ -481,6 +485,31 @@ const DataSourceForm: React.FC = (props) => { {/* #endif */} + {/* #if [sqle && ee] */} + + + + {t('dmsDataSource.dataSourceForm.sqlBackupConfiguration')} + + + } + name="enableBackup" + valuePropName="checked" + > + + + + + {/* #endif */} + {/* #if [dms] */} diff --git a/packages/base/src/page/DataSource/components/Form/index.type.ts b/packages/base/src/page/DataSource/components/Form/index.type.ts index 873b298c1..a93ddeeed 100644 --- a/packages/base/src/page/DataSource/components/Form/index.type.ts +++ b/packages/base/src/page/DataSource/components/Form/index.type.ts @@ -27,6 +27,7 @@ export type DataSourceFormField = { asyncParams?: BackendFormRequestParams[]; needUpdatePassword?: boolean; is_enable_masking?: boolean; + enableBackup?: boolean; }; export type IDataSourceFormProps = { diff --git a/packages/base/src/page/DataSource/components/UpdateDataSource/index.tsx b/packages/base/src/page/DataSource/components/UpdateDataSource/index.tsx index ba4147a81..7460602b0 100644 --- a/packages/base/src/page/DataSource/components/UpdateDataSource/index.tsx +++ b/packages/base/src/page/DataSource/components/UpdateDataSource/index.tsx @@ -75,7 +75,10 @@ const UpdateDataSource = () => { additional_params: values.asyncParams, user: values.user, // #if [dms] - is_enable_masking: values.is_enable_masking + is_enable_masking: values.is_enable_masking, + // #endif + // #if [sqle && ee] + enable_backup: values.enableBackup // #endif }, project_uid: projectID