diff --git a/packages/shared/lib/api/common/ApiBase/index.test.ts b/packages/shared/lib/api/common/ApiBase/index.test.ts
index fa1d32e89..6fcb083ad 100644
--- a/packages/shared/lib/api/common/ApiBase/index.test.ts
+++ b/packages/shared/lib/api/common/ApiBase/index.test.ts
@@ -4,6 +4,7 @@ import axios from 'axios';
import TestMockApi from '../../../testUtil/mockApi';
import { eventEmitter } from '../../../utils/EventEmitter';
import EmitterKey from '../../../data/EmitterKey';
+import 'blob-polyfill';
const downloadSpy = jest.spyOn(Download, 'downloadByCreateElementA');
const emitSpy = jest.spyOn(eventEmitter, 'emit');
@@ -131,4 +132,17 @@ describe('Api', () => {
expect(token).toBe('');
}
});
+
+ test('should return file stream when request header includes content-disposition and inline', async () => {
+ let res;
+
+ try {
+ res = await apiInstance.post('/file/stream');
+ } finally {
+ expect(downloadSpy).not.toHaveBeenCalled();
+ res?.data.text().then((res: string) => {
+ expect(res).toBe('use aaa');
+ });
+ }
+ });
});
diff --git a/packages/shared/lib/api/common/ApiBase/index.ts b/packages/shared/lib/api/common/ApiBase/index.ts
index 32532c02e..389059ee0 100644
--- a/packages/shared/lib/api/common/ApiBase/index.ts
+++ b/packages/shared/lib/api/common/ApiBase/index.ts
@@ -6,7 +6,8 @@ import store from '../../../../../base/src/store';
import {
getResponseErrorMessage,
getResponseCode,
- isExportFileResponse
+ isExportFileResponse,
+ isFileStreamResponse
} from '../../../utils/Common';
import { eventEmitter } from '../../../utils/EventEmitter';
import { NotificationInstanceKeyType } from '../../../hooks/useNotificationContext';
@@ -34,7 +35,9 @@ class ApiBase {
Download.downloadByCreateElementA(res.data, filename);
return res;
} else if (
- (res.status === 200 && code !== ResponseCode.SUCCESS) ||
+ (res.status === 200 &&
+ code !== ResponseCode.SUCCESS &&
+ !isFileStreamResponse(res)) ||
res.status !== 200
) {
const message = await getResponseErrorMessage(res);
diff --git a/packages/shared/lib/api/sqle/service/common.d.ts b/packages/shared/lib/api/sqle/service/common.d.ts
index ae3d55678..e3e231897 100644
--- a/packages/shared/lib/api/sqle/service/common.d.ts
+++ b/packages/shared/lib/api/sqle/service/common.d.ts
@@ -291,8 +291,12 @@ export interface IAuditTaskResV1 {
exec_end_time?: string;
+ exec_mode?: string;
+
exec_start_time?: string;
+ file_order_method?: string;
+
instance_db_type?: string;
instance_name?: string;
diff --git a/packages/shared/lib/api/sqle/service/workflow/index.d.ts b/packages/shared/lib/api/sqle/service/workflow/index.d.ts
index 47f3b08e6..49e3ef045 100644
--- a/packages/shared/lib/api/sqle/service/workflow/index.d.ts
+++ b/packages/shared/lib/api/sqle/service/workflow/index.d.ts
@@ -127,12 +127,6 @@ export interface IExportWorkflowV1Params {
fuzzy_keyword?: string;
}
-export interface IGetWorkflowAttachmentParams {
- project_name: string;
-
- workflow_id: string;
-}
-
export interface ITerminateMultipleTaskByWorkflowV1Params {
workflow_id: string;
@@ -141,6 +135,14 @@ export interface ITerminateMultipleTaskByWorkflowV1Params {
export interface ITerminateMultipleTaskByWorkflowV1Return extends IBaseRes {}
+export interface IGetWorkflowAttachmentParams {
+ project_name: string;
+
+ workflow_id: string;
+
+ task_id: string;
+}
+
export interface ITerminateSingleTaskByWorkflowV1Params {
workflow_id: string;
diff --git a/packages/shared/lib/api/sqle/service/workflow/index.ts b/packages/shared/lib/api/sqle/service/workflow/index.ts
index 1df250d73..68cef7bb4 100644
--- a/packages/shared/lib/api/sqle/service/workflow/index.ts
+++ b/packages/shared/lib/api/sqle/service/workflow/index.ts
@@ -21,9 +21,9 @@ import {
IBatchCompleteWorkflowsV1Params,
IBatchCompleteWorkflowsV1Return,
IExportWorkflowV1Params,
- IGetWorkflowAttachmentParams,
ITerminateMultipleTaskByWorkflowV1Params,
ITerminateMultipleTaskByWorkflowV1Return,
+ IGetWorkflowAttachmentParams,
ITerminateSingleTaskByWorkflowV1Params,
ITerminateSingleTaskByWorkflowV1Return,
IGetWorkflowV1Params,
@@ -188,8 +188,8 @@ class WorkflowService extends ServiceBase {
);
}
- public getWorkflowAttachment(
- params: IGetWorkflowAttachmentParams,
+ public terminateMultipleTaskByWorkflowV1(
+ params: ITerminateMultipleTaskByWorkflowV1Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
@@ -199,15 +199,15 @@ class WorkflowService extends ServiceBase {
const workflow_id = paramsData.workflow_id;
delete paramsData.workflow_id;
- return this.get(
- `/v1/projects/${project_name}/workflows/${workflow_id}/attachment`,
+ return this.post(
+ `/v1/projects/${project_name}/workflows/${workflow_id}/tasks/terminate`,
paramsData,
options
);
}
- public terminateMultipleTaskByWorkflowV1(
- params: ITerminateMultipleTaskByWorkflowV1Params,
+ public getWorkflowAttachment(
+ params: IGetWorkflowAttachmentParams,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
@@ -217,8 +217,11 @@ class WorkflowService extends ServiceBase {
const workflow_id = paramsData.workflow_id;
delete paramsData.workflow_id;
- return this.post(
- `/v1/projects/${project_name}/workflows/${workflow_id}/tasks/terminate`,
+ const task_id = paramsData.task_id;
+ delete paramsData.task_id;
+
+ return this.get(
+ `/v1/projects/${project_name}/workflows/${workflow_id}/tasks/${task_id}/attachment`,
paramsData,
options
);
diff --git a/packages/shared/lib/testUtil/baseApi.tsx b/packages/shared/lib/testUtil/baseApi.tsx
index 29a45529a..5597fc723 100644
--- a/packages/shared/lib/testUtil/baseApi.tsx
+++ b/packages/shared/lib/testUtil/baseApi.tsx
@@ -9,7 +9,8 @@ class MockBaseApi implements MockApi {
this.downloadFileByEnName(),
this.response500(),
this.responseToken(),
- this.mockLoginWithoutToken()
+ this.mockLoginWithoutToken(),
+ this.responseFileStream()
];
}
@@ -90,6 +91,16 @@ class MockBaseApi implements MockApi {
);
});
}
+
+ private responseFileStream() {
+ return rest.post('/file/stream', (_, res, ctx) => {
+ return res(
+ ctx.status(200),
+ ctx.set('content-disposition', `inline`),
+ ctx.body(new Blob(['use aaa']))
+ );
+ });
+ }
}
export default new MockBaseApi();
diff --git a/packages/shared/lib/utils/Common.ts b/packages/shared/lib/utils/Common.ts
index d84a9cc6b..6c69b2018 100644
--- a/packages/shared/lib/utils/Common.ts
+++ b/packages/shared/lib/utils/Common.ts
@@ -138,6 +138,10 @@ export const isExportFileResponse = (res: AxiosResponse): boolean => {
return res.headers?.['content-disposition']?.includes('attachment') ?? false;
};
+export const isFileStreamResponse = (res: AxiosResponse): boolean => {
+ return res.headers?.['content-disposition']?.includes('inline') ?? false;
+};
+
export const jsonParse = (str: string, defaultVal: any = {}): T => {
let val: any;
try {
diff --git a/packages/shared/lib/utils/__tests__/Common.test.ts b/packages/shared/lib/utils/__tests__/Common.test.ts
index ca3f32646..ff58e3107 100644
--- a/packages/shared/lib/utils/__tests__/Common.test.ts
+++ b/packages/shared/lib/utils/__tests__/Common.test.ts
@@ -10,6 +10,7 @@ import {
getResponseErrorMessage,
getResponseCode,
isExportFileResponse,
+ isFileStreamResponse,
getFileFromUploadChangeEvent,
jsonParse,
translateTimeForRequest
@@ -220,6 +221,30 @@ describe('utils/Common', () => {
).toBe(false);
});
+ test('test isFileStreamResponse', () => {
+ expect(
+ isFileStreamResponse({
+ status: 200,
+ headers: {
+ 'content-disposition': 'inline'
+ },
+ config: {},
+ statusText: '',
+ data: ''
+ })
+ ).toBe(true);
+
+ expect(
+ isFileStreamResponse({
+ status: 200,
+ headers: {},
+ config: {},
+ statusText: '',
+ data: ''
+ })
+ ).toBe(false);
+ });
+
test('test jsonParse', () => {
expect(jsonParse('')).toEqual({});
expect(jsonParse('{')).toEqual({});
diff --git a/packages/sqle/src/locale/zh-CN/execWorkflow.ts b/packages/sqle/src/locale/zh-CN/execWorkflow.ts
index f31a1fcca..adfa3cfac 100644
--- a/packages/sqle/src/locale/zh-CN/execWorkflow.ts
+++ b/packages/sqle/src/locale/zh-CN/execWorkflow.ts
@@ -103,6 +103,10 @@ export default {
executeSqlMode: 'SQL模式',
executeFileMode: '文件模式',
selectFileSortMethod: '选择文件排序方式'
+ },
+ tour: {
+ modifyName: '修改工单名称',
+ modifyDataSource: '修改数据源'
}
},
@@ -201,7 +205,8 @@ export default {
stepNumberIsUndefined: '当前节点的步骤数未定义!',
closeWorkflow: '关闭工单',
closeConfirm: '您确认关闭当前工单?',
- closeWorkflowSuccessTips: '工单关闭成功'
+ closeWorkflowSuccessTips: '工单关闭成功',
+ cloneExecWorkflow: '上线到其他实例'
},
paginationDisplay: '分页展示',
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlExecModeSelector.tsx b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlExecModeSelector.tsx
index 7020efdf2..aa629e910 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlExecModeSelector.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Common/SqlStatementFormController/SqlStatementFormItem/components/SqlExecModeSelector.tsx
@@ -35,10 +35,11 @@ const SqlExecModeSelector: React.FC = ({
const disabledSqlFileExecMode =
!isSupportFileModeExecuteSql ||
- ![
- AuditTaskResV1SqlSourceEnum.sql_file,
- AuditTaskResV1SqlSourceEnum.zip_file
- ].includes(currentSqlUploadType);
+ (!!currentSqlUploadType &&
+ ![
+ AuditTaskResV1SqlSourceEnum.sql_file,
+ AuditTaskResV1SqlSourceEnum.zip_file
+ ].includes(currentSqlUploadType));
// #if [ee]
const isSupportsFileSortUpload =
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Common/data.ts b/packages/sqle/src/page/SqlExecWorkflow/Common/data.ts
new file mode 100644
index 000000000..99dbd9f2d
--- /dev/null
+++ b/packages/sqle/src/page/SqlExecWorkflow/Common/data.ts
@@ -0,0 +1 @@
+export const SOURCE_WORKFLOW_PATH_KEY = 'sourceWorkflowId';
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.ce.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.ce.test.tsx.snap
index a228444dd..f65b1a578 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.ce.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.ce.test.tsx.snap
@@ -98,43 +98,45 @@ exports[`sqle/SqlExecWorkflow/Create ce should snapshot render initial workflow
创建工单
-
+
-
-
-
-
-
-
-
+
-
-
-
+
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
@@ -4740,43 +4748,45 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act
>
工单基本信息
-
+
@@ -4937,426 +4947,428 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act
>
审核SQL语句信息
-
-
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
@@ -8756,43 +8772,45 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act
>
工单基本信息
-
+
@@ -8953,453 +8971,455 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act
>
审核SQL语句信息
-
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+
-
+
-
-
-
+
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
+
+
+
-
-
-
+
-
-
-
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+
-
+
-
-
-
+
@@ -17720,7 +17760,7 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot render initial workflow cre
+
+
-
-
-
+ class="ant-space-item"
+ style="margin-right: 12px;"
+ >
+
+
-
-
-
+
+
+
+
-
-
-
+
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.ce.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.ce.test.tsx
index 5b567d938..5e88ee453 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.ce.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.ce.test.tsx
@@ -18,6 +18,17 @@ import {
import { mockDatabaseType } from '../../../../testUtils/mockHooks/mockDatabaseType';
import execWorkflow from '../../../../testUtils/mockApi/execWorkflow';
import instance from '../../../../testUtils/mockApi/instance';
+import { useSelector } from 'react-redux';
+import { SOURCE_WORKFLOW_PATH_KEY } from '../../Common/data';
+import {
+ AuditTaskResV1SqlSourceEnum,
+ CreateAuditTasksGroupReqV1ExecModeEnum
+} from '@actiontech/shared/lib/api/sqle/service/common.enum';
+
+jest.mock('react-redux', () => ({
+ ...jest.requireActual('react-redux'),
+ useSelector: jest.fn()
+}));
describe('sqle/SqlExecWorkflow/Create ce', () => {
const customRender = () => {
@@ -36,6 +47,7 @@ describe('sqle/SqlExecWorkflow/Create ce', () => {
mockUseCurrentUser();
execWorkflow.mockAllApi();
instance.getInstanceTipList();
+ (useSelector as jest.Mock).mockImplementation(() => jest.fn());
});
afterEach(() => {
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.test.tsx
index a4a4d5070..3b036ae48 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/index.test.tsx
@@ -24,6 +24,18 @@ import {
} from '@actiontech/shared/lib/testUtil/common';
import { formatterSQL } from '@actiontech/shared/lib/utils/FormatterSQL';
import { queryBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+import { useSelector } from 'react-redux';
+import { SOURCE_WORKFLOW_PATH_KEY } from '../../Common/data';
+import {
+ AuditTaskResV1SqlSourceEnum,
+ CreateAuditTasksGroupReqV1ExecModeEnum
+} from '@actiontech/shared/lib/api/sqle/service/common.enum';
+
+jest.mock('react-redux', () => ({
+ ...jest.requireActual('react-redux'),
+ useDispatch: jest.fn(),
+ useSelector: jest.fn()
+}));
describe('sqle/SqlExecWorkflow/Create', () => {
const projectName = mockProjectInfo.projectName;
@@ -38,6 +50,7 @@ describe('sqle/SqlExecWorkflow/Create', () => {
let auditTaskGroupId: jest.SpyInstance;
let requestGetModalStatus: jest.SpyInstance;
let batchCheckInstanceIsConnectableByName: jest.SpyInstance;
+ let getSqlFileOrderMethodV1Spy: jest.SpyInstance;
const customRender = () => {
return superRender(
);
@@ -65,8 +78,52 @@ describe('sqle/SqlExecWorkflow/Create', () => {
getAuditTaskSQLsSpy = task.getAuditTaskSQLs();
auditTaskGroupId = execWorkflow.auditTaskGroupId();
requestGetModalStatus = system.getSystemModuleStatus();
+ getSqlFileOrderMethodV1Spy = task.getSqlFileOrderMethod();
batchCheckInstanceIsConnectableByName =
instance.batchCheckInstanceIsConnectableByName();
+
+ (useSelector as jest.Mock).mockImplementation((e) =>
+ e({
+ sqlExecWorkflow: {
+ clonedExecWorkflowSqlAuditInfo: {
+ isSameSqlForAll: false,
+ databaseInfo: [
+ {
+ instanceName: 'mysql-1',
+ instanceSchema: 'test'
+ },
+ {
+ instanceName: 'mysql-1',
+ instanceSchema: 'test'
+ },
+ {
+ instanceName: 'mysql-1',
+ instanceSchema: 'test'
+ }
+ ],
+ '0': {
+ currentUploadType: AuditTaskResV1SqlSourceEnum.form_data,
+ form_data: 'SELECT * '
+ },
+ '1': {
+ currentUploadType: AuditTaskResV1SqlSourceEnum.sql_file,
+ sql_file: [new File(['test file content'], 'test.sql')],
+ exec_mode: CreateAuditTasksGroupReqV1ExecModeEnum.sqls
+ },
+ '2': {
+ currentUploadType: AuditTaskResV1SqlSourceEnum.zip_file,
+ zip_file: [new File(['test file content'], 'test.zip')],
+ exec_mode: CreateAuditTasksGroupReqV1ExecModeEnum.sql_file,
+ file_sort_method: 'file_order_method_suffix_num_asc'
+ }
+ },
+ clonedExecWorkflowBaseInfo: {
+ workflow_subject: 'workflow-name-test',
+ desc: 'test desc'
+ }
+ }
+ })
+ );
});
afterEach(() => {
@@ -88,6 +145,31 @@ describe('sqle/SqlExecWorkflow/Create', () => {
expect(baseElement).toMatchSnapshot();
});
+ it('should snapshot render initial workflow creation UI when current is clone workflow mode', async () => {
+ const { baseElement } = superRender(
, undefined, {
+ routerProps: {
+ initialEntries: [
+ `/sqle/project/700300/exec-workflow/create?${SOURCE_WORKFLOW_PATH_KEY}=123456`
+ ]
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(3000));
+ expect(getBySelector('#workflow_subject', baseElement)).toHaveValue(
+ 'workflow-name-test'
+ );
+
+ expect(getBySelector('#desc', baseElement)).toHaveValue('test desc');
+ await act(async () => jest.advanceTimersByTime(3000));
+ expect(getAllBySelector('.ant-segmented-item', baseElement)).toHaveLength(
+ 3
+ );
+ expect(requestInstanceSchemas).toHaveBeenCalledTimes(3);
+ expect(requestInstance).toHaveBeenCalledTimes(3);
+ expect(requestGetModalStatus).toHaveBeenCalledTimes(3);
+ expect(getSqlFileOrderMethodV1Spy).toHaveBeenCalledTimes(1);
+ expect(baseElement).toMatchSnapshot();
+ });
+
it('should reset form fields and snapshot UI after reset action', async () => {
const { baseElement } = customRender();
await act(async () => jest.advanceTimersByTime(3000));
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/AuditResultStep/__tests__/__snapshots__/UpdateFormDrawer.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/components/AuditResultStep/__tests__/__snapshots__/UpdateFormDrawer.test.tsx.snap
index 14400290b..ed1f3916c 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/AuditResultStep/__tests__/__snapshots__/UpdateFormDrawer.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/AuditResultStep/__tests__/__snapshots__/UpdateFormDrawer.test.tsx.snap
@@ -50,7 +50,7 @@ exports[`test UpdateFormDrawer should match snapshot 1`] = `
工单基本信息
-
}
/>
@@ -94,7 +94,7 @@ exports[`test UpdateFormDrawer should match snapshot 1`] = `
审核SQL语句信息
-
= ({ slot }) => {
- const { t } = useTranslation();
+const BaseInfoFormItem = forwardRef(
+ ({ slot }, ref) => {
+ const { t } = useTranslation();
- return (
- <>
-
-
-
+ return (
+ <>
+
- {slot}
+ {slot}
-
-
-
- >
- );
-};
+
+
+
+ >
+ );
+ }
+);
export default BaseInfoFormItem;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/BaseInfoFormItem.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/BaseInfoFormItem.test.tsx.snap
index f220c59b6..9239313f8 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/BaseInfoFormItem.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/BaseInfoFormItem.test.tsx.snap
@@ -2,28 +2,30 @@
exports[`test BaseInfoFormItem should match snapshot 1`] = `
-
-
-
+
-
-
-
+
slot
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/index.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/index.test.tsx.snap
index 27cb13e3f..d3647c597 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/index.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/__tests__/__snapshots__/index.test.tsx.snap
@@ -14,7 +14,7 @@ exports[`test BaseInfoForm should match snapshot 1`] = `
创建工单
-
+
`;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/index.tsx
index 9b2e32307..c82d68d13 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/index.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/BaseInfoForm/index.tsx
@@ -7,8 +7,9 @@ import { FormItemBigTitle } from '@actiontech/shared/lib/components/FormCom';
import BaseInfoFormItem from './BaseInfoFormItem';
import { BriefcaseFilled } from '@actiontech/icons';
import Icon from '@ant-design/icons';
+import { forwardRef } from 'react';
-const BaseInfoForm: React.FC = () => {
+const BaseInfoForm = forwardRef((props, ref) => {
const { t } = useTranslation();
return (
@@ -18,10 +19,10 @@ const BaseInfoForm: React.FC = () => {
{t('execWorkflow.create.title')}
-
+
);
-};
+});
export default BaseInfoForm;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/index.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/index.test.tsx
index a02a219ca..413e56eb9 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/index.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/index.test.tsx
@@ -13,6 +13,12 @@ import { instanceTipsMockData } from '../../../../../../../../../testUtils/mockA
import { mockDatabaseType } from '../../../../../../../../../testUtils/mockHooks/mockDatabaseType';
import { Form } from 'antd';
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser';
+import { useSelector } from 'react-redux';
+
+jest.mock('react-redux', () => ({
+ ...jest.requireActual('react-redux'),
+ useSelector: jest.fn()
+}));
describe('test DatabaseSelectionItems', () => {
beforeEach(() => {
@@ -24,6 +30,7 @@ describe('test DatabaseSelectionItems', () => {
instance.getInstanceTipList();
system.getSystemModuleStatus();
mockDatabaseType();
+ (useSelector as jest.Mock).mockImplementation(() => jest.fn());
});
afterEach(() => {
jest.useRealTimers();
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/useRenderDatabaseSelectionItems.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/useRenderDatabaseSelectionItems.test.tsx
index a1a8308f2..260ba95e6 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/useRenderDatabaseSelectionItems.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/__tests__/useRenderDatabaseSelectionItems.test.tsx
@@ -12,12 +12,40 @@ import system from '../../../../../../../../../testUtils/mockApi/system';
import { getSystemModuleStatusModuleNameEnum } from '@actiontech/shared/lib/api/sqle/service/system/index.enum';
import { superRender } from '../../../../../../../../../testUtils/customRender';
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser';
+import { useSelector } from 'react-redux';
+import * as useCreationMode from '../../../../../../hooks/useCreationMode';
+
+jest.mock('react-redux', () => ({
+ ...jest.requireActual('react-redux'),
+ useSelector: jest.fn()
+}));
describe('test useRenderDatabaseSelectionItems', () => {
beforeEach(() => {
mockUseCurrentUser();
jest.useFakeTimers();
mockUseCurrentProject();
+ (useSelector as jest.Mock).mockImplementation((e) =>
+ e({
+ sqlExecWorkflow: {
+ clonedExecWorkflowSqlAuditInfo: {
+ databaseInfo: [
+ {
+ instanceName: 'mysql-1',
+ instanceSchema: 'test'
+ },
+ {
+ instanceName: 'mysql-1',
+ instanceSchema: 'test'
+ }
+ ]
+ }
+ }
+ })
+ );
+ jest
+ .spyOn(useCreationMode, 'default')
+ .mockImplementation(() => ({ isCloneMode: false }));
});
afterEach(() => {
jest.useRealTimers();
@@ -66,7 +94,7 @@ describe('test useRenderDatabaseSelectionItems', () => {
ruleTemplate: undefined,
dbType: undefined,
testConnectResult: undefined,
- isSupportFileModeExecuteSql: false
+ isSupportFileModeExecuteSql: true
});
await act(() => jest.advanceTimersByTime(3000));
@@ -313,4 +341,22 @@ describe('test useRenderDatabaseSelectionItems', () => {
fireEvent.click(getByText('添加数据源')!);
expect(handleClickSpy).not.toHaveBeenCalled();
});
+
+ it('should get instance info when isCloneMode is true', async () => {
+ const mockGetInstanceSchemas = instance.getInstanceSchemas();
+ const mockGetInstance = instance.getInstance();
+ const mockGetSystemModuleStatus = system.getSystemModuleStatus();
+ const spy = jest.spyOn(useCreationMode, 'default');
+ spy.mockImplementation(() => ({ isCloneMode: true }));
+ renderHook(() =>
+ useRenderDatabaseSelectionItems({
+ dbSourceInfoCollection: MockSharedStepDetail.dbSourceInfoCollection,
+ sqlStatementTabActiveKey: MockSharedStepDetail.sqlStatementTabActiveKey
+ })
+ );
+ await act(async () => jest.advanceTimersByTime(3000));
+ expect(mockGetInstanceSchemas).toHaveBeenCalledTimes(2);
+ expect(mockGetInstance).toHaveBeenCalledTimes(2);
+ expect(mockGetSystemModuleStatus).toHaveBeenCalledTimes(2);
+ });
});
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/hooks/useRenderDatabaseSelectionItems.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/hooks/useRenderDatabaseSelectionItems.tsx
index 961d2a69c..817c869d1 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/hooks/useRenderDatabaseSelectionItems.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/DatabaseSelectionItems/hooks/useRenderDatabaseSelectionItems.tsx
@@ -13,6 +13,10 @@ import {
getSystemModuleStatusModuleNameEnum
} from '@actiontech/shared/lib/api/sqle/service/system/index.enum';
import useThemeStyleData from '../../../../../../../../../hooks/useThemeStyleData';
+import useCreationMode from '../../../../../../hooks/useCreationMode';
+import { useEffect } from 'react';
+import { useSelector } from 'react-redux';
+import { IReduxState } from '../../../../../../../../../store';
const useRenderDatabaseSelectionItems = ({
dbSourceInfoCollection,
@@ -24,6 +28,29 @@ const useRenderDatabaseSelectionItems = ({
const { t } = useTranslation();
const { projectName, projectID } = useCurrentProject();
const { sqleTheme } = useThemeStyleData();
+
+ const { isCloneMode } = useCreationMode();
+
+ const sqlExecWorkflowReduxState = useSelector((state: IReduxState) => {
+ return {
+ clonedExecWorkflowSqlAuditInfo:
+ state.sqlExecWorkflow.clonedExecWorkflowSqlAuditInfo
+ };
+ });
+
+ useEffect(() => {
+ if (isCloneMode) {
+ sqlExecWorkflowReduxState.clonedExecWorkflowSqlAuditInfo?.databaseInfo?.forEach(
+ (database, index) => {
+ const key = `${index}`;
+ handleInstanceChange(key, database.instanceName);
+ handleInstanceSchemaChange(key, database.instanceSchema);
+ }
+ );
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
const updateSchemaList = async (key: string, instanceName: string) => {
instance
.getInstanceSchemasV1({
@@ -87,7 +114,7 @@ const useRenderDatabaseSelectionItems = ({
ruleTemplate: undefined,
dbType: undefined,
testConnectResult: undefined,
- isSupportFileModeExecuteSql: false
+ isSupportFileModeExecuteSql: true
});
updateSchemaList(key, instanceName);
updateRuleTemplateNameAndDbType(key, instanceName);
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/__tests__/index.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/__tests__/index.test.tsx
index 24177263a..c0110ac27 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/__tests__/index.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/__tests__/index.test.tsx
@@ -8,6 +8,12 @@ import { Form } from 'antd';
import { act, renderHook } from '@testing-library/react';
import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject';
import { mockUseDbServiceDriver } from '@actiontech/shared/lib/testUtil/mockHook/mockUseDbServiceDriver';
+import { useSelector } from 'react-redux';
+
+jest.mock('react-redux', () => ({
+ ...jest.requireActual('react-redux'),
+ useSelector: jest.fn()
+}));
describe('test sqle/SqlAuditInfoForm', () => {
const customRender = (params: SharedStepDetails) => {
@@ -29,6 +35,7 @@ describe('test sqle/SqlAuditInfoForm', () => {
mockUseCurrentUser();
mockUseCurrentProject();
mockUseDbServiceDriver();
+ (useSelector as jest.Mock).mockImplementation(() => jest.fn());
});
afterEach(() => {
jest.useRealTimers();
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/index.tsx
index e6fb79a87..595ee4e32 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/index.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/SqlAuditInfoFormItem/index.tsx
@@ -13,126 +13,127 @@ import SqlStatementFormController from '../../../../../Common/SqlStatementFormCo
import { SAME_SQL_MODE_DEFAULT_FIELD_KEY } from '../../../../../Common/SqlStatementFormController/SqlStatementFormItem/index.data';
import { RingPieFilled } from '@actiontech/icons';
import { CommonIconStyleWrapper } from '@actiontech/shared/lib/styleWrapper/element';
+import { forwardRef } from 'react';
-const SqlAuditInfoFormItem: React.FC = ({
- auditAction,
- handleInstanceNameChange,
- ...sharedStepDetail
-}) => {
- const { t } = useTranslation();
- const form = Form.useFormInstance();
+const SqlAuditInfoFormItem = forwardRef(
+ ({ auditAction, handleInstanceNameChange, ...sharedStepDetail }, ref) => {
+ const { t } = useTranslation();
+ const form = Form.useFormInstance();
- const isSameSqlForAll = Form.useWatch('isSameSqlForAll', form);
+ const isSameSqlForAll = Form.useWatch('isSameSqlForAll', form);
- const databaseInfo: CreateWorkflowDatabaseInfo = useMemo(() => {
- return Object.keys(sharedStepDetail.dbSourceInfoCollection.value)
- .map((key) => {
- return {
- key,
- instanceName:
- sharedStepDetail.dbSourceInfoCollection.value?.[key]?.instanceName,
- schemaName:
- sharedStepDetail.dbSourceInfoCollection.value?.[key]?.schemaName
- };
- })
- .filter((v) => !!v.instanceName);
- }, [sharedStepDetail.dbSourceInfoCollection]);
+ const databaseInfo: CreateWorkflowDatabaseInfo = useMemo(() => {
+ return Object.keys(sharedStepDetail.dbSourceInfoCollection.value)
+ .map((key) => {
+ return {
+ key,
+ instanceName:
+ sharedStepDetail.dbSourceInfoCollection.value?.[key]
+ ?.instanceName,
+ schemaName:
+ sharedStepDetail.dbSourceInfoCollection.value?.[key]?.schemaName
+ };
+ })
+ .filter((v) => !!v.instanceName);
+ }, [sharedStepDetail.dbSourceInfoCollection]);
- const isSupportFileModeExecuteSqlRecord: Record =
- useMemo(() => {
- if (isSameSqlForAll) {
- // 相同 SQL 模式下,判断所有数据源是否都支持。虽然 相同 SQL 模式下所有数据源类型会相同,但还是做下校验
- return {
- [SAME_SQL_MODE_DEFAULT_FIELD_KEY]: Object.keys(
- sharedStepDetail.dbSourceInfoCollection.value
- ).every((key) => {
- return !!sharedStepDetail.dbSourceInfoCollection?.value?.[key]
- ?.isSupportFileModeExecuteSql;
- })
- };
- }
- //不同 SQL 模式下,每个数据源对应各自当前数据源类型是否支持文件上线模式
- return Object.keys(sharedStepDetail.dbSourceInfoCollection.value).reduce(
- (acc, key) => {
+ const isSupportFileModeExecuteSqlRecord: Record =
+ useMemo(() => {
+ if (isSameSqlForAll) {
+ // 相同 SQL 模式下,判断所有数据源是否都支持。虽然 相同 SQL 模式下所有数据源类型会相同,但还是做下校验
+ return {
+ [SAME_SQL_MODE_DEFAULT_FIELD_KEY]: Object.keys(
+ sharedStepDetail.dbSourceInfoCollection.value
+ ).every((key) => {
+ return !!sharedStepDetail.dbSourceInfoCollection?.value?.[key]
+ ?.isSupportFileModeExecuteSql;
+ })
+ };
+ }
+ //不同 SQL 模式下,每个数据源对应各自当前数据源类型是否支持文件上线模式
+ return Object.keys(
+ sharedStepDetail.dbSourceInfoCollection.value
+ ).reduce((acc, key) => {
return {
...acc,
[key]:
!!sharedStepDetail.dbSourceInfoCollection?.value?.[key]
?.isSupportFileModeExecuteSql
};
- },
- {}
- );
- }, [isSameSqlForAll, sharedStepDetail.dbSourceInfoCollection.value]);
+ }, {});
+ }, [isSameSqlForAll, sharedStepDetail.dbSourceInfoCollection.value]);
- useEffect(() => {
- const dbTypeSet = new Set(
- Object.keys(sharedStepDetail.dbSourceInfoCollection.value)
- ?.map((key) => {
- return sharedStepDetail.dbSourceInfoCollection.value?.[key].dbType;
- })
- .filter((v) => !!v)
- );
- if (dbTypeSet.size > 1) {
- form.setFieldValue('isSameSqlForAll', false);
- sharedStepDetail.isDisabledForDifferenceSql.set(true);
- } else {
- sharedStepDetail.isDisabledForDifferenceSql.set(false);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [form, sharedStepDetail.dbSourceInfoCollection.value]);
+ useEffect(() => {
+ const dbTypeSet = new Set(
+ Object.keys(sharedStepDetail.dbSourceInfoCollection.value)
+ ?.map((key) => {
+ return sharedStepDetail.dbSourceInfoCollection.value?.[key].dbType;
+ })
+ .filter((v) => !!v)
+ );
+ if (dbTypeSet.size > 1) {
+ form.setFieldValue('isSameSqlForAll', false);
+ sharedStepDetail.isDisabledForDifferenceSql.set(true);
+ } else {
+ sharedStepDetail.isDisabledForDifferenceSql.set(false);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [form, sharedStepDetail.dbSourceInfoCollection.value]);
- return (
- <>
-
+ return (
+ <>
+
-
-
-
-
-
-
- {t('execWorkflow.create.form.sqlInfo.isSameSqlForAll')}
-
-
-
- {t(
- 'execWorkflow.create.form.sqlInfo.tipsDataSourceTypeForSameSql'
- )}
+
+
+
+
+
+
+ {t('execWorkflow.create.form.sqlInfo.isSameSqlForAll')}
+
+
+
+ {t(
+ 'execWorkflow.create.form.sqlInfo.tipsDataSourceTypeForSameSql'
+ )}
+
-
- }
- labelCol={{ span: 22 }}
- wrapperCol={{ span: 2 }}
- >
-
-
+ }
+ labelCol={{ span: 22 }}
+ wrapperCol={{ span: 2 }}
+ >
+
+
-
- >
- );
-};
+
+ >
+ );
+ }
+);
export default SqlAuditInfoFormItem;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/__tests__/__snapshots__/index.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/__tests__/__snapshots__/index.test.tsx.snap
index 86eae0307..82982e157 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/__tests__/__snapshots__/index.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/SqlAuditInfoForm/__tests__/__snapshots__/index.test.tsx.snap
@@ -5,7 +5,7 @@ exports[`test SqlAuditInfoForm should match snapshot 1`] = `
审核SQL语句信息
- = (props) => {
- const { t } = useTranslation();
- return (
-
-
- {t('execWorkflow.create.form.sqlInfo.title')}
-
-
-
- );
-};
+const SqlAuditInfoForm = forwardRef(
+ (props, ref) => {
+ const { t } = useTranslation();
+ return (
+
+
+ {t('execWorkflow.create.form.sqlInfo.title')}
+
+
+
+ );
+ }
+);
export default SqlAuditInfoForm;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/__snapshots__/index.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/__snapshots__/index.test.tsx.snap
index ba885386d..78d5ad6a5 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/__snapshots__/index.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/__snapshots__/index.test.tsx.snap
@@ -50,7 +50,7 @@ exports[`test FormStep should match snapshot 1`] = `
labelAlign="left"
layout="vertical"
>
-
+
-
+
+
+
`;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/index.test.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/index.test.tsx
index dd1151a9e..94ff62ea7 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/index.test.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/__tests__/index.test.tsx
@@ -4,9 +4,13 @@ import { renderHook } from '@testing-library/react';
import { useForm } from 'antd/es/form/Form';
import { MockSharedStepDetail } from '../../../hooks/mockData';
import toJson from 'enzyme-to-json';
+import * as useCreationMode from '../../../hooks/useCreationMode';
describe('test FormStep', () => {
it('should match snapshot', () => {
+ jest
+ .spyOn(useCreationMode, 'default')
+ .mockImplementation(() => ({ isCloneMode: false }));
const { result: baseInfoFormResult } = renderHook(() => useForm());
const { result: sqlAuditInfoFormResult } = renderHook(() => useForm());
const wrapper = shallow(
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/index.tsx
index bcc53e491..0db049aec 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/index.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/components/FormStep/index.tsx
@@ -2,13 +2,17 @@ import { FormStyleWrapper } from '@actiontech/shared/lib/components/FormCom/styl
import BaseInfoForm from './BaseInfoForm';
import { CreateWorkflowFormStepProps } from './index.type';
import { PageLayoutHasFixedHeaderStyleWrapper } from '@actiontech/shared/lib/styleWrapper/element';
-import { BasicButton, PageHeader } from '@actiontech/shared';
+import { BasicButton, PageHeader, EmptyBox } from '@actiontech/shared';
import { useTranslation } from 'react-i18next';
import SqlAuditInfoForm from './SqlAuditInfoForm';
import { SqlAuditInfoFormStyleWrapper } from './style';
import { useCallback } from 'react';
import dayjs from 'dayjs';
import BackToList from '../../../Common/BackToList';
+import { Tour } from 'antd';
+import type { TourProps } from 'antd';
+import { useState, useRef, useMemo } from 'react';
+import useCreationMode from '../../hooks/useCreationMode';
const FormStep: React.FC = ({
baseInfoForm,
@@ -18,6 +22,27 @@ const FormStep: React.FC = ({
}) => {
const { t } = useTranslation();
+ const [open, setOpen] = useState(true);
+
+ const { isCloneMode } = useCreationMode();
+
+ const workflowNameFieldRef = useRef(null);
+ const dataSourceFieldRef = useRef(null);
+
+ const tourSteps: TourProps['steps'] = useMemo(
+ () => [
+ {
+ title: t('execWorkflow.create.form.tour.modifyName'),
+ target: () => workflowNameFieldRef.current!
+ },
+ {
+ title: t('execWorkflow.create.form.tour.modifyDataSource'),
+ target: () => dataSourceFieldRef.current!
+ }
+ ],
+ [t]
+ );
+
const resetAllForm = () => {
baseInfoForm.resetFields();
sqlAuditInfoForm.resetFields();
@@ -56,9 +81,8 @@ const FormStep: React.FC = ({
layout="vertical"
labelAlign="left"
>
-
+
-
= ({
handleInstanceNameChange={handleInstanceNameChange}
auditAction={auditAction}
{...sharedStepDetail}
+ ref={dataSourceFieldRef}
/>
+
+ setOpen(false)} steps={tourSteps} />
+
);
};
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/hooks/useCreationMode.ts b/packages/sqle/src/page/SqlExecWorkflow/Create/hooks/useCreationMode.ts
new file mode 100644
index 000000000..704db33f5
--- /dev/null
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/hooks/useCreationMode.ts
@@ -0,0 +1,18 @@
+import { useSearchParams } from 'react-router-dom';
+import { useMemo } from 'react';
+import { SOURCE_WORKFLOW_PATH_KEY } from '../../Common/data';
+
+const useCreationMode = () => {
+ const [searchParams] = useSearchParams();
+
+ const isCloneMode = useMemo(
+ () => searchParams.has(SOURCE_WORKFLOW_PATH_KEY),
+ [searchParams]
+ );
+
+ return {
+ isCloneMode
+ };
+};
+
+export default useCreationMode;
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/index.tsx b/packages/sqle/src/page/SqlExecWorkflow/Create/index.tsx
index a5a883c53..22ac9705b 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Create/index.tsx
+++ b/packages/sqle/src/page/SqlExecWorkflow/Create/index.tsx
@@ -9,7 +9,7 @@ import CreateResultStep from './components/CreateResultStep';
import FormStep from './components/FormStep';
import useSharedStepDetail from './hooks/useSharedStepDetail';
import useAuditWorkflow from './hooks/useAuditWorkflow';
-import { useCallback, useRef } from 'react';
+import { useCallback, useRef, useEffect } from 'react';
import AuditResultStep from './components/AuditResultStep';
import { usePrompt } from '@actiontech/shared/lib/hooks';
import { useTranslation } from 'react-i18next';
@@ -19,6 +19,9 @@ import { ResponseCode } from '@actiontech/shared/lib/enum';
import { ICreateWorkflowV2Params } from '@actiontech/shared/lib/api/sqle/service/workflow/index.d';
import useCheckTaskAuditSqlCount from './hooks/useCheckTaskAuditSqlCount';
import { LazyLoadComponent } from '@actiontech/shared';
+import { useSelector } from 'react-redux';
+import { IReduxState } from '../../../store';
+import useCreationMode from './hooks/useCreationMode';
const CreateSqlExecWorkflow: React.FC = () => {
const { t } = useTranslation();
@@ -30,6 +33,39 @@ const CreateSqlExecWorkflow: React.FC = () => {
const { updateTaskRecordCount, checkTaskCountIsEmpty } =
useCheckTaskAuditSqlCount();
+ const { isCloneMode } = useCreationMode();
+
+ const sqlExecWorkflowReduxState = useSelector((state: IReduxState) => {
+ return {
+ clonedExecWorkflowSqlAuditInfo:
+ state.sqlExecWorkflow.clonedExecWorkflowSqlAuditInfo,
+ clonedExecWorkflowBaseInfo:
+ state.sqlExecWorkflow.clonedExecWorkflowBaseInfo
+ };
+ });
+
+ useEffect(() => {
+ if (isCloneMode) {
+ baseInfoForm.setFieldsValue({
+ workflow_subject:
+ sqlExecWorkflowReduxState.clonedExecWorkflowBaseInfo
+ ?.workflow_subject ?? '',
+ desc: sqlExecWorkflowReduxState.clonedExecWorkflowBaseInfo?.desc ?? ''
+ });
+ if (sqlExecWorkflowReduxState.clonedExecWorkflowSqlAuditInfo) {
+ Object.keys(
+ sqlExecWorkflowReduxState.clonedExecWorkflowSqlAuditInfo
+ ).forEach((key) => {
+ sqlAuditInfoForm.setFieldsValue({
+ [key]:
+ sqlExecWorkflowReduxState.clonedExecWorkflowSqlAuditInfo?.[key]
+ });
+ });
+ }
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
const {
isAtFormStep,
isAtAuditResultStep,
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Detail/__tests__/__snapshots__/index.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Detail/__tests__/__snapshots__/index.test.tsx.snap
index 2c2d4100f..d57c392fc 100644
--- a/packages/sqle/src/page/SqlExecWorkflow/Detail/__tests__/__snapshots__/index.test.tsx.snap
+++ b/packages/sqle/src/page/SqlExecWorkflow/Detail/__tests__/__snapshots__/index.test.tsx.snap
@@ -71,6 +71,14 @@ exports[`sqle/ExecWorkflow/Detail render snap detail 1`] = `
role="separator"
/>
+
+
+