Skip to content

Commit

Permalink
Merge branch 'dev-4.3.3' of https://code.alipay.com/oceanbase/oceanba…
Browse files Browse the repository at this point in the history
…se-developer-center into dev-4.3.3
  • Loading branch information
HSunboy committed Nov 6, 2024
2 parents ac62455 + baa0119 commit af9d017
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const VariableConfig: React.FC<IProps> = (props) => {
id: 'odc.DataArchiveTask.CreateModal.VariableConfig.PleaseEnter',
defaultMessage: '请输入',
})}
/*请输入*/ min={1}
/*请输入*/ min={0}
/>
</Form.Item>
<Form.Item
Expand Down
47 changes: 44 additions & 3 deletions src/component/Task/component/ActionBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ const ActionBar: React.FC<IProps> = inject(
}
};

const deleteTask = async () => {
const { id } = task;
const res = await createTask({
taskType: TaskType.ALTER_SCHEDULE,
parameters: {
taskId: id,
operationType: 'DELETE',
},
});
if (res) {
message.success('删除成功');
props?.onReloadList?.();
}
};

const download = async () => {
downloadTaskFlow(task.id);
};
Expand Down Expand Up @@ -895,7 +910,6 @@ const ActionBar: React.FC<IProps> = inject(

const getCycleTaskTools = (_task) => {
let tools = [];

if (!_task) {
return [];
}
Expand Down Expand Up @@ -998,6 +1012,14 @@ const ActionBar: React.FC<IProps> = inject(
handleApproval(false);
},
};

const deleteBtn = {
key: 'delete',
text: '删除',
type: 'button',
confirmText: '你确定要删除这个任务吗?',
action: deleteTask,
};
const isOperator = isOwner || isTaskProjectOwner;
switch (status) {
case TaskStatus.APPROVING: {
Expand Down Expand Up @@ -1060,6 +1082,24 @@ const ActionBar: React.FC<IProps> = inject(
if ([TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE].includes(task?.type)) {
tools.push(reTryBtn);
}
if (
[TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE, TaskType.SQL_PLAN].includes(task?.type)
) {
tools.push(deleteBtn);
}
} else {
tools = [viewBtn];
}
break;
}
case TaskStatus.CANCELLED: {
if (isOperator) {
tools = [viewBtn];
if (
[TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE, TaskType.SQL_PLAN].includes(task?.type)
) {
tools.push(deleteBtn);
}
} else {
tools = [viewBtn];
}
Expand All @@ -1069,10 +1109,11 @@ const ActionBar: React.FC<IProps> = inject(
}

if (isDetailModal) {
tools = tools.filter((item) => item.key !== 'view');
tools = tools.filter((item) => !['view', 'delete'].includes(item.key));
} else {
tools = [viewBtn];
tools = tools.filter((item) => ['view', 'delete'].includes(item.key));
}

// sql 计划 & 数据归档 & 数据清理 支持编辑
if (![TaskType.SQL_PLAN, TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE].includes(task?.type)) {
tools = tools.filter((item) => item.key !== 'edit');
Expand Down
1 change: 1 addition & 0 deletions src/util/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import odc from '@/plugins/odc';
import service from './service';

function getRequest() {
return odc.ODCRequest || service;
}
Expand Down
5 changes: 5 additions & 0 deletions src/util/request/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import { resolveODCError } from './errorResolve';
import notification from '../notification';
import type { AxiosInstance, AxiosHeaders } from 'axios';
import { cloneDeep } from 'lodash';
import qs from 'qs';

// https://www.axios-http.cn/docs/req_config
const service: AxiosInstance = axios.create({
baseURL: window.ODCApiHost || '',
timeout: 1000 * 60 * 60 * 10, // 后端去除了queryTimeout,前端默认给一个超大的时间
withCredentials: true,
paramsSerializer: function (params) {
return qs.stringify(params, { arrayFormat: 'repeat' });
},
});

// 错误处理器
Expand Down Expand Up @@ -54,6 +58,7 @@ service.interceptors.request.use((config) => {
Math.random().toString(36).substring(2).toUpperCase() +
Math.random().toString(36).substring(2).toUpperCase();
const extraParams = odc.requestParamsResolver?.(config, requestId) || {};

return {
...config,
data: config?.data?.data,
Expand Down

0 comments on commit af9d017

Please sign in to comment.