From 3809108afa0ce9fa065b8f7f62d9f2fa4ee9d53e Mon Sep 17 00:00:00 2001 From: Junyi Date: Wed, 28 Aug 2024 14:43:40 +0800 Subject: [PATCH] feat(plugin-workflow): allow to delete execution in list (#5135) * refactor(plugin-workflow): allow to delete execution in list * fix(plugin-workflow): fix mistake import --- .../src/client/schemas/executions.tsx | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/schemas/executions.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/schemas/executions.tsx index 7951fbea44..ef35b4a4cd 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/schemas/executions.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/schemas/executions.tsx @@ -13,9 +13,9 @@ import { Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { message } from 'antd'; -import { useActionContext, useRecord, useResourceActionContext, useResourceContext } from '@nocobase/client'; +import { useActionContext, useResourceActionContext, useResourceContext } from '@nocobase/client'; -import { ExecutionStatusOptions } from '../constants'; +import { ExecutionStatusOptions, EXECUTION_STATUS } from '../constants'; import { NAMESPACE } from '../locale'; import { getWorkflowDetailPath } from '../utils'; @@ -116,6 +116,19 @@ export const executionSchema = { icon: 'ReloadOutlined', }, }, + delete: { + type: 'void', + title: '{{t("Delete")}}', + 'x-component': 'Action', + 'x-component-props': { + icon: 'DeleteOutlined', + useAction: '{{ cm.useBulkDestroyAction }}', + confirm: { + title: "{{t('Delete record')}}", + content: "{{t('Are you sure you want to delete it?')}}", + }, + }, + }, clear: { type: 'void', title: '{{t("Clear")}}', @@ -148,6 +161,9 @@ export const executionSchema = { 'x-component': 'Table.Void', 'x-component-props': { rowKey: 'id', + rowSelection: { + type: 'checkbox', + }, useDataSource: '{{ cm.useDataSourceFromRAC }}', }, properties: { @@ -220,6 +236,28 @@ export const executionSchema = { type: 'void', 'x-component': 'ExecutionLink', }, + delete: { + type: 'void', + title: '{{ t("Delete") }}', + 'x-component': 'Action.Link', + 'x-component-props': { + confirm: { + title: "{{t('Delete record')}}", + content: "{{t('Are you sure you want to delete it?')}}", + }, + useAction: '{{ cm.useDestroyActionAndRefreshCM }}', + }, + 'x-reactions': [ + { + dependencies: ['..status'], + fulfill: { + state: { + visible: `{{ $deps[0] !== ${EXECUTION_STATUS.STARTED} }}`, + }, + }, + }, + ], + }, }, }, },