refactor(plugin-workflow): change to function (#2991)

This commit is contained in:
Junyi 2023-11-07 23:30:53 +08:00 committed by GitHub
parent 30de7865c5
commit 00cabc5e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -762,7 +762,11 @@ function WorkflowConfig() {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const { name: collection } = useCollection(); const { name: collection } = useCollection();
const workflowPlugin = usePlugin('workflow') as any; 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 = { const description = {
submit: t('Workflow will be triggered after submitting succeeded.', { ns: 'workflow' }), submit: t('Workflow will be triggered after submitting succeeded.', { ns: 'workflow' }),
'customize:save': t('Workflow will be triggered after saving succeeded.', { ns: 'workflow' }), 'customize:save': t('Workflow will be triggered after saving succeeded.', { ns: 'workflow' }),

View File

@ -101,7 +101,7 @@ export default {
}; };
}, },
initializers: {}, initializers: {},
actionTriggerable: true, useActionTriggerable: true,
}; };
function getFormValues({ function getFormValues({

View File

@ -63,7 +63,7 @@ export interface Trigger {
components?: { [key: string]: any }; components?: { [key: string]: any };
useInitializers?(config): SchemaInitializerItemOptions | null; useInitializers?(config): SchemaInitializerItemOptions | null;
initializers?: any; initializers?: any;
actionTriggerable?: boolean; useActionTriggerable?: boolean | (() => boolean);
} }
export const triggers = new Registry<Trigger>(); export const triggers = new Registry<Trigger>();