From 00cabc5e2325486108cc5c94cd108157f80c34c4 Mon Sep 17 00:00:00 2001 From: Junyi Date: Tue, 7 Nov 2023 23:30:53 +0800 Subject: [PATCH] refactor(plugin-workflow): change to function (#2991) --- .../src/schema-component/antd/action/Action.Designer.tsx | 6 +++++- .../@nocobase/plugin-workflow/src/client/triggers/form.tsx | 2 +- .../@nocobase/plugin-workflow/src/client/triggers/index.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index 0c53726f7..02af62f80 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -762,7 +762,11 @@ function WorkflowConfig() { const fieldSchema = useFieldSchema(); const { name: collection } = useCollection(); const workflowPlugin = usePlugin('workflow') as any; - const workflowTypes = workflowPlugin.getTriggersOptions().filter((item) => item.options.actionTriggerable); + const workflowTypes = workflowPlugin.getTriggersOptions().filter((item) => { + return typeof item.options.useActionTriggerable === 'function' + ? item.options.useActionTriggerable() + : item.options.useActionTriggerable; + }); const description = { submit: t('Workflow will be triggered after submitting succeeded.', { ns: 'workflow' }), 'customize:save': t('Workflow will be triggered after saving succeeded.', { ns: 'workflow' }), diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx index 34140482b..36ea96503 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx @@ -101,7 +101,7 @@ export default { }; }, initializers: {}, - actionTriggerable: true, + useActionTriggerable: true, }; function getFormValues({ diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/index.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/index.tsx index b01d87547..e7fd82dc7 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/index.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/index.tsx @@ -63,7 +63,7 @@ export interface Trigger { components?: { [key: string]: any }; useInitializers?(config): SchemaInitializerItemOptions | null; initializers?: any; - actionTriggerable?: boolean; + useActionTriggerable?: boolean | (() => boolean); } export const triggers = new Registry();