mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +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 taskTypeMap = {
|
||||
'export-attachments': t('Export {collection} attachments'),
|
||||
export: t('Export {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);
|
||||
},
|
||||
},
|
||||
@ -275,7 +276,7 @@ export const AsyncTasks = () => {
|
||||
const actions = [];
|
||||
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(
|
||||
<Popconfirm
|
||||
key="cancel"
|
||||
|
@ -1,4 +1,5 @@
|
||||
export * from './interfaces/async-task-manager';
|
||||
export * from './task-type';
|
||||
export * from './static-import';
|
||||
|
||||
export { default } from './plugin';
|
||||
|
@ -8,6 +8,7 @@ import PluginErrorHandler, { ErrorHandler } from '@nocobase/plugin-error-handler
|
||||
|
||||
export abstract class TaskType extends EventEmitter implements ITask {
|
||||
static type: string;
|
||||
static cancelable = true;
|
||||
|
||||
public status: TaskStatus;
|
||||
protected logger: Logger;
|
||||
@ -168,6 +169,7 @@ export abstract class TaskType extends EventEmitter implements ITask {
|
||||
|
||||
toJSON(options?: { raw?: boolean }) {
|
||||
const json = {
|
||||
cancelable: (this.constructor as typeof TaskType).cancelable,
|
||||
taskId: this.taskId,
|
||||
status: { ...this.status },
|
||||
progress: this.progress,
|
||||
|
Loading…
x
Reference in New Issue
Block a user