Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/shared/lib/api/sqle/service/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export interface IGetGlobalSqlManageStatisticsParams {
filter_instance_id?: string;

filter_project_priority?: GetGlobalSqlManageStatisticsFilterProjectPriorityEnum;

filter_current_step_assignee_user_id?: string;
}

export interface IGetGlobalSqlManageStatisticsReturn
Expand Down
20 changes: 20 additions & 0 deletions packages/shared/lib/api/sqle/service/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,20 @@ export interface IAuditedSQLCount {
total_sql_count?: number;
}

export interface IAutoCreateAndExecuteWorkflowResV1 {
code?: number;

data?: IAutoCreateAndExecuteWorkflowResV1Data;

message?: string;
}

export interface IAutoCreateAndExecuteWorkflowResV1Data {
workflow_id?: string;

workflow_status?: string;
}

export interface IBackupSqlData {
backup_result?: string;

Expand Down Expand Up @@ -4339,6 +4353,8 @@ export interface IAuditSQLResV2 {
exec_sql?: string;

number?: number;

sql_type?: string;
}

export interface IAuditTaskSQLResV2 {
Expand Down Expand Up @@ -4424,12 +4440,16 @@ export interface IDirectAuditFileReqV2 {
}

export interface IDirectAuditReqV2 {
instance_name?: string;

instance_type?: string;

project_id?: string;

rule_template_name?: string;

schema_name?: string;

sql_content?: string;

sql_type?: DirectAuditReqV2SqlTypeEnum;
Expand Down
35 changes: 35 additions & 0 deletions packages/shared/lib/api/sqle/service/workflow/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IUpdateWorkflowTemplateReqV1,
IBaseRes,
ICreateWorkflowReqV1,
IAutoCreateAndExecuteWorkflowResV1,
IBatchCancelWorkflowsReqV1,
IBatchCompleteWorkflowsReqV1,
IBackupSqlListRes,
Expand Down Expand Up @@ -42,6 +43,7 @@ import {
GetGlobalWorkflowStatisticsFilterStatusListEnum,
GetGlobalWorkflowStatisticsFilterProjectPriorityEnum,
getWorkflowsV1FilterStatusEnum,
autoCreateAndExecuteWorkflowV1ExecModeEnum,
exportWorkflowV1FilterStatusEnum,
GetBackupSqlListV1FilterExecStatusEnum
} from './index.enum';
Expand All @@ -60,6 +62,8 @@ export interface IGetGlobalDataExportWorkflowsV1Params {

filter_project_priority?: getGlobalDataExportWorkflowsV1FilterProjectPriorityEnum;

filter_current_step_assignee_user_id?: string;

page_index: number;

page_size: number;
Expand All @@ -78,6 +82,8 @@ export interface IGetGlobalDataExportWorkflowStatisticsV1Params {
filter_instance_id?: string;

filter_project_priority?: getGlobalDataExportWorkflowStatisticsV1FilterProjectPriorityEnum;

filter_current_step_assignee_user_id?: string;
}

export interface IGetGlobalDataExportWorkflowStatisticsV1Return
Expand All @@ -94,6 +100,8 @@ export interface IGetGlobalWorkflowsV1Params {

filter_project_priority?: getGlobalWorkflowsV1FilterProjectPriorityEnum;

filter_current_step_assignee_user_id?: string;

page_index: number;

page_size: number;
Expand All @@ -111,6 +119,8 @@ export interface IGetGlobalWorkflowStatisticsParams {
filter_instance_id?: string;

filter_project_priority?: GetGlobalWorkflowStatisticsFilterProjectPriorityEnum;

filter_current_step_assignee_user_id?: string;
}

export interface IGetGlobalWorkflowStatisticsReturn
Expand Down Expand Up @@ -172,6 +182,31 @@ export interface ICreateWorkflowV1Params extends ICreateWorkflowReqV1 {

export interface ICreateWorkflowV1Return extends IBaseRes {}

export interface IAutoCreateAndExecuteWorkflowV1Params {
project_name: string;

instances: string;

exec_mode?: autoCreateAndExecuteWorkflowV1ExecModeEnum;

file_order_method?: string;

sql?: string;

workflow_subject: string;

desc?: string;

input_sql_file?: any;

input_mybatis_xml_file?: any;

input_zip_file?: any;
}

export interface IAutoCreateAndExecuteWorkflowV1Return
extends IAutoCreateAndExecuteWorkflowResV1 {}

export interface IBatchCancelWorkflowsV1Params
extends IBatchCancelWorkflowsReqV1 {
project_name: string;
Expand Down
6 changes: 6 additions & 0 deletions packages/shared/lib/api/sqle/service/workflow/index.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export enum getWorkflowsV1FilterStatusEnum {
'finished' = 'finished'
}

export enum autoCreateAndExecuteWorkflowV1ExecModeEnum {
'sql_file' = 'sql_file',

'sqls' = 'sqls'
}

export enum exportWorkflowV1FilterStatusEnum {
'wait_for_audit' = 'wait_for_audit',

Expand Down
64 changes: 64 additions & 0 deletions packages/shared/lib/api/sqle/service/workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
IGetWorkflowsV1Return,
ICreateWorkflowV1Params,
ICreateWorkflowV1Return,
IAutoCreateAndExecuteWorkflowV1Params,
IAutoCreateAndExecuteWorkflowV1Return,
IBatchCancelWorkflowsV1Params,
IBatchCancelWorkflowsV1Return,
IBatchCompleteWorkflowsV1Params,
Expand Down Expand Up @@ -209,6 +211,68 @@ class WorkflowService extends ServiceBase {
);
}

public autoCreateAndExecuteWorkflowV1(
params: IAutoCreateAndExecuteWorkflowV1Params,
options?: AxiosRequestConfig
) {
const config = options || {};
const headers = config.headers ? config.headers : {};
config.headers = {
...headers,

'Content-Type': 'multipart/form-data'
};

const paramsData = new FormData();

if (params.instances != undefined) {
paramsData.append('instances', params.instances as any);
}

if (params.exec_mode != undefined) {
paramsData.append('exec_mode', params.exec_mode as any);
}

if (params.file_order_method != undefined) {
paramsData.append('file_order_method', params.file_order_method as any);
}

if (params.sql != undefined) {
paramsData.append('sql', params.sql as any);
}

if (params.workflow_subject != undefined) {
paramsData.append('workflow_subject', params.workflow_subject as any);
}

if (params.desc != undefined) {
paramsData.append('desc', params.desc as any);
}

if (params.input_sql_file != undefined) {
paramsData.append('input_sql_file', params.input_sql_file as any);
}

if (params.input_mybatis_xml_file != undefined) {
paramsData.append(
'input_mybatis_xml_file',
params.input_mybatis_xml_file as any
);
}

if (params.input_zip_file != undefined) {
paramsData.append('input_zip_file', params.input_zip_file as any);
}

const project_name = params.project_name;

return this.post<IAutoCreateAndExecuteWorkflowV1Return>(
`/v1/projects/${project_name}/workflows/auto_create_and_execute`,
paramsData,
config
);
}

public batchCancelWorkflowsV1(
params: IBatchCancelWorkflowsV1Params,
options?: AxiosRequestConfig
Expand Down
1 change: 1 addition & 0 deletions packages/sqle/src/locale/zh-CN/globalDashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default {
}
},
initiatedWorkOrder: '发起的工单',
pendingMyAction: '仅看待我操作',
filter: {
project: '项目',
instance: '数据源',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ListProjectV2ProjectPriorityEnum } from '@actiontech/shared/lib/api/bas
import eventEmitter from '../../../../../../utils/EventEmitter';
import EmitterKey from '../../../../../../data/EmitterKey';
import { paramsSerializer } from '@actiontech/dms-kit/es/utils/Common';
import { mockCurrentUserReturn } from '@actiontech/shared/lib/testUtil';

describe('sqle/GlobalDashboard/PendingWorkOrder', () => {
let getGlobalWorkflowsSpy: jest.SpyInstance;
Expand Down Expand Up @@ -40,11 +41,15 @@ describe('sqle/GlobalDashboard/PendingWorkOrder', () => {
cleanup();
});

const customRender = (filterValues: GlobalDashboardFilterType = {}) => {
const customRender = (
filterValues: GlobalDashboardFilterType = {},
filterAssignedToMe?: boolean
) => {
return sqleSuperRender(
<PendingWorkOrder
filterValues={filterValues}
updateFilterValue={updateFilterValueFn}
filterAssignedToMe={filterAssignedToMe}
/>
);
};
Expand Down Expand Up @@ -122,4 +127,17 @@ describe('sqle/GlobalDashboard/PendingWorkOrder', () => {
});
expect(getGlobalWorkflowsSpy).toHaveBeenCalledTimes(2);
});

it('render request data with filterAssignedToMe', async () => {
customRender({}, true);
await act(async () => jest.advanceTimersByTime(3000));
expect(getGlobalWorkflowsSpy).toHaveBeenCalledTimes(1);
expect(getGlobalWorkflowsSpy).toHaveBeenCalledWith(
{
...commonParams,
filter_current_step_assignee_user_id: mockCurrentUserReturn.userId
},
{ paramsSerializer }
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ import {
import { GlobalDashboardListProps } from '../../../index.type';
import { GlobalDashboardPendingWorkflowListColumn } from './column';
import { paramsSerializer } from '@actiontech/dms-kit/es/utils/Common';
import { useCurrentUser } from '@actiontech/shared/lib/features';

const PendingExecuteWorkflow: React.FC<GlobalDashboardListProps> = ({
filterValues,
updateFilterValue
updateFilterValue,
filterAssignedToMe
}) => {
const { pagination, tableChange } =
useTableRequestParams<IWorkflowDetailResV1>();

const { userId } = useCurrentUser();
const { requestErrorMessage, handleTableRequestError } =
useTableRequestError();

Expand All @@ -46,7 +48,10 @@ const PendingExecuteWorkflow: React.FC<GlobalDashboardListProps> = ({
getGlobalWorkflowsV1FilterStatusListEnum.wait_for_execution,
getGlobalWorkflowsV1FilterStatusListEnum.rejected,
getGlobalWorkflowsV1FilterStatusListEnum.exec_failed
]
],
filter_current_step_assignee_user_id: filterAssignedToMe
? userId
: undefined
};

return handleTableRequestError(
Expand All @@ -56,7 +61,7 @@ const PendingExecuteWorkflow: React.FC<GlobalDashboardListProps> = ({
);
},
{
refreshDeps: [pagination, filterValues]
refreshDeps: [pagination, filterValues, filterAssignedToMe]
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ import {
getGlobalDataExportWorkflowsV1FilterStatusListEnum
} from '@actiontech/shared/lib/api/sqle/service/workflow/index.enum';
import { paramsSerializer } from '@actiontech/dms-kit/es/utils/Common';
import { useCurrentUser } from '@actiontech/shared/lib/features';

const PendingExportWorkflowList: React.FC<GlobalDashboardListProps> = ({
filterValues,
updateFilterValue
updateFilterValue,
filterAssignedToMe
}) => {
const { pagination, tableChange } =
useTableRequestParams<IWorkflowDetailResV1>();

const { userId } = useCurrentUser();
const { requestErrorMessage, handleTableRequestError } =
useTableRequestError();

Expand All @@ -46,7 +48,10 @@ const PendingExportWorkflowList: React.FC<GlobalDashboardListProps> = ({
filter_instance_id: filterValues.instanceId,
filter_project_priority:
filterValues.projectPriority as unknown as getGlobalDataExportWorkflowsV1FilterProjectPriorityEnum,
filter_project_uid: filterValues.projectId
filter_project_uid: filterValues.projectId,
filter_current_step_assignee_user_id: filterAssignedToMe
? userId
: undefined
};

return handleTableRequestError(
Expand All @@ -56,7 +61,7 @@ const PendingExportWorkflowList: React.FC<GlobalDashboardListProps> = ({
);
},
{
refreshDeps: [pagination, filterValues]
refreshDeps: [pagination, filterValues, filterAssignedToMe]
}
);

Expand Down
Loading