mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
chore(async-task-manager): cancelable options
This commit is contained in:
parent
27f760b8a1
commit
f6ac57f34d
@ -148,13 +148,14 @@ export const AsyncTasks = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionText = actionTypeMap[title.actionType] || title.actionType;
|
const actionText = actionTypeMap[title.actionType] || title.actionType;
|
||||||
|
|
||||||
const taskTypeMap = {
|
const taskTypeMap = {
|
||||||
'export-attachments': t('Export {collection} attachments'),
|
'export-attachments': t('Export {collection} attachments'),
|
||||||
export: t('Export {collection} data'),
|
export: t('Export {collection} data'),
|
||||||
import: t('Import {collection} data'),
|
import: t('Import {collection} data'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskTemplate = taskTypeMap[title.actionType] || `${actionText} ${title.collection} ${t('Data')}`;
|
const taskTemplate = taskTypeMap[title.actionType] || `${actionText}`;
|
||||||
return taskTemplate.replace('{collection}', title.collection);
|
return taskTemplate.replace('{collection}', title.collection);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -275,7 +276,7 @@ export const AsyncTasks = () => {
|
|||||||
const actions = [];
|
const actions = [];
|
||||||
const isTaskCancelling = cancellingTasks.has(record.taskId);
|
const isTaskCancelling = cancellingTasks.has(record.taskId);
|
||||||
|
|
||||||
if (record.status.type === 'running' || record.status.type === 'pending') {
|
if ((record.status.type === 'running' || record.status.type === 'pending') && record.cancelable) {
|
||||||
actions.push(
|
actions.push(
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
key="cancel"
|
key="cancel"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export * from './interfaces/async-task-manager';
|
export * from './interfaces/async-task-manager';
|
||||||
|
export * from './task-type';
|
||||||
export * from './static-import';
|
export * from './static-import';
|
||||||
|
|
||||||
export { default } from './plugin';
|
export { default } from './plugin';
|
||||||
|
@ -8,6 +8,7 @@ import PluginErrorHandler, { ErrorHandler } from '@nocobase/plugin-error-handler
|
|||||||
|
|
||||||
export abstract class TaskType extends EventEmitter implements ITask {
|
export abstract class TaskType extends EventEmitter implements ITask {
|
||||||
static type: string;
|
static type: string;
|
||||||
|
static cancelable = true;
|
||||||
|
|
||||||
public status: TaskStatus;
|
public status: TaskStatus;
|
||||||
protected logger: Logger;
|
protected logger: Logger;
|
||||||
@ -168,6 +169,7 @@ export abstract class TaskType extends EventEmitter implements ITask {
|
|||||||
|
|
||||||
toJSON(options?: { raw?: boolean }) {
|
toJSON(options?: { raw?: boolean }) {
|
||||||
const json = {
|
const json = {
|
||||||
|
cancelable: (this.constructor as typeof TaskType).cancelable,
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
status: { ...this.status },
|
status: { ...this.status },
|
||||||
progress: this.progress,
|
progress: this.progress,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user