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 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -200,387 +202,389 @@ exports[`sqle/SqlExecWorkflow/Create ce should snapshot render initial workflow > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + + 请选择{{name}} - - - 请选择{{name}} - -
-
- +
-
-
-
-
+
+
- - - - + + + - - - + + + + + + + 请选择数据库(选填) - - - 请选择数据库(选填) - -
-
- +
- -
-
- + + + + + +
- -
-
-
+
+
- + +
- +
diff --git a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.test.tsx.snap b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.test.tsx.snap index a4510f3ff..bdb962678 100644 --- a/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/sqle/src/page/SqlExecWorkflow/Create/__tests__/__snapshots__/index.test.tsx.snap @@ -114,43 +114,45 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -218,459 +220,461 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - sqle -
- + sqle - + + + - - - + + + + + + -
+ -
- - +
- -
-
+ class="ant-space-item" + style="margin-right: 12px;" + > +
- + + + + + +
-
-
- + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -2452,43 +2456,45 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -2556,459 +2562,461 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - sqle -
- + sqle - + + + - - - + + + + + + -
+ -
- - +
- -
-
+ 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语句信息
-
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - - mysql-2 - -
-
+ - +
- -
-
-
+
+
- - - - + + + - - - + + + + + + -
+ -
- - +
- -
-
+ class="ant-space-item" + style="margin-right: 12px;" + > +
- + + + + + +
-
-
- + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -6000,43 +6012,45 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -6104,459 +6118,461 @@ exports[`sqle/SqlExecWorkflow/Create should handle form submission and audit act > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - sqle -
- + sqle - + + + - - - + + + + + + - - +
+ -
- - +
- -
-
+ 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;" + > +
- + + + + + +
-
-
- + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -10363,43 +10383,45 @@ exports[`sqle/SqlExecWorkflow/Create should reset form fields and snapshot UI af 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -10465,426 +10487,428 @@ exports[`sqle/SqlExecWorkflow/Create should reset form fields and snapshot UI af > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + + 请选择{{name}} - - - 请选择{{name}} - -
-
- -
+ + + +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + + 请选择数据库(选填) - - - 请选择数据库(选填) - -
-
- +
- -
-
- -
-
- +
+
- - - - - - + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -11571,43 +11595,45 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -11673,459 +11699,461 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - test123 -
- + test123 - + + + - - - + + + + + + - - - -
-
+ + - - +
- -
-
+ class="ant-space-item" + style="margin-right: 12px;" + > +
- + + + + + +
-
-
- + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -13115,43 +13143,45 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -13217,459 +13247,461 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in > 审核SQL语句信息 -
+
- -
-
-
-
-
-
-
-
-
-
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
-
+
+
+
+
+
+
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - test123 -
- + test123 - + + + - - - + + + + + + -
+ -
- - +
- -
-
+ class="ant-space-item" + style="margin-right: 12px;" + > +
- -
-
-
-
- +
+
+ +
- - - - - - + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -14663,43 +14695,45 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -14765,459 +14799,461 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot UI and perform SQL audit in > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + - - - -
-
- +
-
-
-
-
+
+
- - test123 -
- + test123 - + + + - - - + + + + + + -
+ -
- - +
- -
-
+ class="ant-space-item" + style="margin-right: 12px;" + > +
- + + + + + +
-
-
- + + + + + +
- -
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -16687,43 +16723,45 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot render initial workflow cre 创建工单 -
+
-
-
+
+
- +
+ +
-
+
@@ -16789,426 +16827,428 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot render initial workflow cre > 审核SQL语句信息 -
+
- -
-
+ xmlns="http://www.w3.org/2000/svg" + > + + + + + 数据源 + + +
+ class="ant-form-item-control-input" + > +
+
-
-
-
-
+
+
- - - - + + + - - - + + + + + + + 请选择{{name}} - - - 请选择{{name}} - -
-
- +
-
-
-
-
-
-
+
+
+
+
- - - - + + + - - - + + + + + + + 请选择数据库(选填) - - - 请选择数据库(选填) - -
-
- +
-
-
-
- -
-
- +
+
- - - - - - + + + + + +
-
-
-
-
+
+
- -
-
- +
+
- - 测试数据源连通性 - - + +
- +
@@ -17720,7 +17760,7 @@ exports[`sqle/SqlExecWorkflow/Create should snapshot render initial workflow cre `; -exports[`sqle/SqlExecWorkflow/Create should validate "workflow_subject" and prevent audit with invalid name 1`] = ` +exports[`sqle/SqlExecWorkflow/Create should snapshot render initial workflow creation UI when current is clone workflow mode 1`] = ` - 0 / 3000 + 9 / 3000 @@ -17960,459 +17980,3965 @@ exports[`sqle/SqlExecWorkflow/Create should validate "workflow_subject" and prev > 审核SQL语句信息 -
+
- +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + + +
+
+