From bc4c975a4d7ec8ba87297c468a8ee20cdb695c24 Mon Sep 17 00:00:00 2001 From: sealday Date: Tue, 11 Jun 2024 21:17:42 +0800 Subject: [PATCH] refactor: from hera-core to @tachybase/plugin-workflow (#1156) Co-authored-by: sealday Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1156 --- .../features/workflow-bulk/ApiTrigger.tsx | 142 ----------------- .../BulkUpdateAction.Settings.tsx | 105 ------------- .../BulkUpdateActionInitializer.tsx | 31 ---- .../client/features/workflow-bulk/index.tsx | 37 ----- .../client/features/workflow-bulk/utils.tsx | 104 ------------- .../@hera/plugin-core/src/client/index.tsx | 4 - .../src/server/features/ApiTrigger.ts | 7 - .../@hera/plugin-core/src/server/plugin.ts | 4 - .../plugin-workflow/src/client/AddButton.tsx | 6 +- .../plugin-workflow/src/client/Branch.tsx | 4 +- .../src/client/ExecutionCanvas.tsx | 14 +- .../src/client/ExecutionContextProvider.tsx | 1 - .../src/client/ExecutionLink.tsx | 4 +- .../src/client/ExecutionPage.tsx | 4 +- .../plugin-workflow/src/client/Plugin.tsx | 146 ++++++++++++++++++ .../src/client/WorkflowLink.tsx | 4 +- .../src/client/WorkflowPage.tsx | 4 +- .../configuration.test.ts | 7 +- .../ScheduleEventTrigger/workflowCRUD.test.ts | 7 +- .../calculationNode/formulaEngine.test.ts | 11 +- .../calculationNode/mathEngine.test.ts | 11 +- .../configuration.test.ts | 11 +- .../workflowCRUD.test.ts | 11 +- .../BranchIntoYesAndNoBasicType.test.ts | 11 +- .../BranchIntoYesAndNoFormulaEngine.test.ts | 11 +- .../BranchIntoYesAndNoMathEngine.test.ts | 13 +- .../continueWhenYesBasicType.test.ts | 13 +- .../continueWhenYesFormulaEngine.test.ts | 13 +- .../continueWhenYesMathEngine.test.ts | 13 +- .../createRecordNode/CreateRecord.test.ts | 7 +- .../deleteRecordNode/DeleteRecord.test.ts | 7 +- .../queryRecordNode/QueryRecord.test.ts | 7 +- .../updateRecordNode/updateInABatch.test.ts | 7 +- .../updateRecordNode/updateOneByOne.test.ts | 7 +- .../components/CheckboxGroupWithTooltip.tsx | 7 +- .../components/CollectionBlockInitializer.tsx | 5 +- .../client/components/CollectionFieldset.tsx | 12 +- .../components/DetailsBlockProvider.tsx | 8 +- .../client/components/DrawerDescription.tsx | 5 +- .../src/client/components/DrawerForm.tsx | 7 +- .../src/client/components/ExecutionStatus.tsx | 8 +- .../src/client/components/FieldsSelect.tsx | 6 +- .../components/FilterDynamicComponent.tsx | 1 - .../src/client/components/OpenDrawer.tsx | 3 +- .../src/client/components/SimpleDesigner.tsx | 3 +- .../src/client/components/ValueBlock.tsx | 7 +- .../plugin-workflow/src/client/constants.tsx | 8 +- .../features/action-trigger/ActionTrigger.tsx | 10 +- .../__e2e__/configuration.test.ts | 9 +- .../__e2e__/workflowCRUD.test.ts | 11 +- .../client/features/action-trigger/index.ts | 2 +- .../__e2e__/DataOfCollection.test.ts | 6 +- .../src/client/features/aggregate/index.ts | 2 +- .../src/client/features/delay/index.ts | 2 +- .../dynamic-calculation/DynamicExpression.tsx | 18 ++- .../features/dynamic-calculation/index.ts | 2 +- .../WorkflowTriggerInterceptor.tsx | 17 +- .../src/client/features/interceptor}/index.ts | 2 +- .../src/client/features/loop/index.ts | 2 +- .../client/features/manual/WorkflowTodo.tsx | 23 +-- .../manual/WorkflowTodoBlockInitializer.tsx | 4 +- .../manual/__e2e__/createRecordForm.test.ts | 9 +- .../manual/__e2e__/customFormBlocks.test.ts | 7 +- .../manual/__e2e__/datablocks.test.ts | 13 +- .../manual/__e2e__/updateRecordForm.test.ts | 9 +- .../manual/__e2e__/workflowTodo.test.ts | 9 +- .../src/client/features/manual/index.ts | 11 +- .../manual/instruction/AssigneesSelect.tsx | 1 + .../instruction/FormBlockInitializer.tsx | 2 - .../manual/instruction/FormBlockProvider.tsx | 5 +- .../manual/instruction/ModeConfig.tsx | 9 +- .../manual/instruction/forms/create.tsx | 2 +- .../manual/instruction/forms/custom.tsx | 20 ++- .../manual/instruction/forms/update.tsx | 10 +- .../parallel/__e2e__/parallelBranch.test.ts | 11 +- .../src/client/features/parallel/index.ts | 2 +- .../src/client/features/request/index.ts | 2 +- .../features/sql/__e2e__/dataCURD.test.ts | 21 +-- .../src/client/features/sql/index.ts | 2 +- .../variables/VariableTargetSelect.tsx | 56 +++++++ .../variables/VariablesInstruction.tsx | 34 ++++ .../src/client/features/variables/index.tsx | 10 ++ .../client/features/variables/useStyles.tsx | 11 ++ .../hooks/useTriggerWorkflowActionProps.ts | 10 +- .../plugin-workflow/src/client/index.tsx | 130 +--------------- .../src/client/nodes/create.tsx | 2 +- .../src/client/nodes/destroy.tsx | 4 +- .../plugin-workflow/src/client/nodes/end.tsx | 2 +- .../src/client/nodes/query.tsx | 9 +- .../src/client/schemas/collection.ts | 3 +- ...ustomizeSubmitToWorkflowActionSettings.tsx | 5 +- .../src/client/triggers/collection.tsx | 7 +- .../client/triggers/schedule/EndsByField.tsx | 8 +- .../src/client/triggers/schedule/OnField.tsx | 5 +- .../triggers/schedule/ScheduleConfig.tsx | 6 +- .../src/client/triggers/schedule/index.tsx | 8 +- .../plugin-workflow/src/client/variable.tsx | 9 +- .../plugin-workflow/src/server/Plugin.ts | 8 + .../plugin-workflow/src/server/Processor.ts | 3 +- .../src/server/__tests__/Plugin.test.ts | 2 +- .../src/server/__tests__/Processor.test.ts | 3 +- .../__tests__/actions/executions.test.ts | 3 +- .../server/__tests__/actions/nodes.test.ts | 2 +- .../__tests__/actions/workflows.test.ts | 2 +- .../instructions/calculation.test.ts | 3 +- .../__tests__/instructions/condition.test.ts | 3 +- .../__tests__/instructions/create.test.ts | 2 +- .../__tests__/instructions/destroy.test.ts | 2 +- .../server/__tests__/instructions/end.test.ts | 3 +- .../__tests__/instructions/query.test.ts | 3 +- .../__tests__/instructions/update.test.ts | 2 +- .../__tests__/triggers/collection.test.ts | 2 +- .../triggers/schedule/mode-date-field.test.ts | 2 +- .../triggers/schedule/mode-static.test.ts | 2 +- .../src/server/actions/executions.ts | 1 + .../src/server/actions/index.ts | 4 +- .../src/server/actions/nodes.ts | 1 + .../server/features/action-trigger/Plugin.ts | 2 +- .../aggregate/AggregateInstruction.ts | 3 +- .../src/server/features/aggregate/Plugin.ts | 2 +- .../aggregate/__tests__/instruction.test.ts | 4 +- .../server/features/delay/DelayInstruction.ts | 2 +- .../src/server/features/delay/Plugin.ts | 2 +- .../dynamic-calculation/DynamicCalculation.ts | 5 +- .../features/dynamic-calculation/Plugin.ts | 4 +- .../__tests__/instruction.test.ts | 1 - .../RequestInterceptionTrigger.ts | 7 +- .../server/features/interception/index.ts} | 2 - .../src/server/features/loop/Plugin.ts | 2 +- .../loop/__tests__/instruction.test.ts | 2 +- .../features/manual/ManualInstruction.ts | 2 +- .../src/server/features/manual/Plugin.ts | 5 +- .../src/server/features/manual/actions.ts | 2 +- .../src/server/features/manual/forms/index.ts | 2 - .../features/parallel/ParallelInstruction.ts | 2 +- .../src/server/features/parallel/Plugin.ts | 2 +- .../parallel/__tests__/instruction.test.ts | 2 +- .../src/server/features/request/Plugin.ts | 2 +- .../request/__tests__/instruction.test.ts | 11 +- .../src/server/features/sql/Plugin.ts | 2 +- .../src/server/features/sql/SQLInstruction.ts | 2 +- .../sql/__tests__/instruction.test.ts | 2 +- .../src/server/features/variables/Plugin.ts | 11 ++ .../features/variables/VariableInstruction.ts | 26 ++++ .../src/server/features/variables/index.ts | 1 + .../instructions/CalculationInstruction.ts | 10 +- .../instructions/ConditionInstruction.ts | 3 +- .../server/instructions/CreateInstruction.ts | 4 +- .../server/instructions/DestroyInstruction.ts | 2 +- .../src/server/instructions/EndInstruction.ts | 2 +- .../server/instructions/QueryInstruction.ts | 4 +- .../server/instructions/UpdateInstruction.ts | 6 +- .../src/server/instructions/index.ts | 1 - .../src/server/triggers/CollectionTrigger.ts | 5 +- .../DateFieldScheduleTrigger.ts | 4 +- .../ScheduleTrigger/StaticScheduleTrigger.ts | 2 +- .../server/triggers/ScheduleTrigger/index.ts | 1 + .../src/server/triggers/index.ts | 1 + .../src/server/types/Execution.ts | 1 + .../src/server/types/FlowNode.ts | 1 + .../plugin-workflow/src/server/types/Job.ts | 1 + .../src/server/types/Workflow.ts | 1 + 162 files changed, 726 insertions(+), 930 deletions(-) delete mode 100644 packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/ApiTrigger.tsx delete mode 100644 packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateAction.Settings.tsx delete mode 100644 packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateActionInitializer.tsx delete mode 100644 packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/index.tsx delete mode 100644 packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/utils.tsx delete mode 100644 packages/plugins/@hera/plugin-core/src/server/features/ApiTrigger.ts create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/Plugin.tsx rename packages/plugins/{@hera/plugin-core/src/client/features/workflow-interceptor => @tachybase/plugin-workflow/src/client/features/interceptor}/WorkflowTriggerInterceptor.tsx (93%) rename packages/plugins/{@hera/plugin-core/src/client/features/workflow-interceptor => @tachybase/plugin-workflow/src/client/features/interceptor}/index.ts (84%) create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/VariableTargetSelect.tsx create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/VariablesInstruction.tsx create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/index.tsx create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/useStyles.tsx rename packages/plugins/{@hera/plugin-core/src/server/features => @tachybase/plugin-workflow/src/server/features/interception}/RequestInterceptionTrigger.ts (95%) rename packages/plugins/{@hera/plugin-core/src/server/features/interception.ts => @tachybase/plugin-workflow/src/server/features/interception/index.ts} (80%) create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/server/features/variables/Plugin.ts create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/server/features/variables/VariableInstruction.ts create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/server/features/variables/index.ts diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/ApiTrigger.tsx b/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/ApiTrigger.tsx deleted file mode 100644 index 7d6fed9af..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/ApiTrigger.tsx +++ /dev/null @@ -1,142 +0,0 @@ -import { useCollectionDataSource, useCollectionManager_deprecated, useCompile } from '@tachybase/client'; -import { - CheckboxGroupWithTooltip, - CollectionBlockInitializer, - FieldsSelect, - getCollectionFieldOptions, - RadioWithTooltip, - Trigger, -} from '@tachybase/plugin-workflow/client'; - -import { lang, tval } from '../../locale'; - -const enum ACTION_TYPES { - CREATE = 'create', - UPDATE = 'update', - UPSERT = 'updateOrCreate', - DESTROY = 'destroy', -} - -function useItems(item, options) { - const compile = useCompile(); - const { getCollectionFields } = useCollectionManager_deprecated(); - return [ - { label: lang('ID'), value: 'filterByTk' }, - ...(item.action !== ACTION_TYPES.DESTROY - ? [ - { - label: lang('Values submitted'), - value: 'values', - children: getCollectionFieldOptions({ - ...options, - appends: null, - depth: 3, - collection: item.collection, - compile, - getCollectionFields, - }), - }, - ] - : []), - ]; -} -export class ApiTrigger extends Trigger { - title = lang('API event'); - description = lang('api trigger'); - fieldset = { - collection: { - type: 'string', - title: tval('Collection'), - required: true, - 'x-decorator': 'FormItem', - 'x-component': 'DataSourceCollectionCascader', - 'x-reactions': [{ target: 'changed', effects: ['onFieldValueChange'], fulfill: { state: { value: [] } } }], - }, - global: { - type: 'boolean', - title: tval('Trigger mode'), - 'x-decorator': 'FormItem', - 'x-component': 'RadioWithTooltip', - 'x-component-props': { - direction: 'vertical', - options: [ - { - label: tval('Local mode, triggered before executing the actions bound to this workflow'), - value: false, - }, - { - label: tval('Global mode, triggered before executing the following actions'), - value: true, - }, - ], - }, - default: false, - }, - actions: { - type: 'number', - title: tval('Select actions'), - 'x-decorator': 'FormItem', - 'x-component': 'CheckboxGroupWithTooltip', - 'x-component-props': { - direction: 'vertical', - options: [ - { label: tval('Create record action'), value: ACTION_TYPES.CREATE }, - { label: tval('Update record action'), value: ACTION_TYPES.UPDATE }, - { label: tval('Delete record action'), value: ACTION_TYPES.DESTROY }, - ], - }, - required: true, - 'x-reactions': [ - { dependencies: ['collection', 'global'], fulfill: { state: { visible: '{{!!$deps[0] && !!$deps[1]}}' } } }, - ], - }, - }; - scope = { useCollectionDataSource }; - components = { - FieldsSelect: FieldsSelect, - RadioWithTooltip: RadioWithTooltip, - CheckboxGroupWithTooltip: CheckboxGroupWithTooltip, - }; - isActionTriggerable = (a, u) => { - const { global: m } = a; - return !m && !u.direct; - }; - - useVariables(config, options) { - // eslint-disable-next-line react-hooks/rules-of-hooks - const compile = useCompile(); - // eslint-disable-next-line react-hooks/rules-of-hooks - const { getCollectionFields } = useCollectionManager_deprecated(); - const result = getCollectionFieldOptions({ - appends: ['user'], - ...options, - fields: [ - { - collectionName: 'users', - name: 'user', - type: 'hasOne', - target: 'users', - uiSchema: { title: tval('User acted') }, - }, - ], - compile, - getCollectionFields, - }); - // eslint-disable-next-line react-hooks/rules-of-hooks - const parametersSchema = [{ label: lang('Parameters'), value: 'params', children: useItems(config, options) }]; - return [...result, { label: lang('Role of user acted'), value: 'roleName' }, ...parametersSchema]; - } - useInitializers(item) { - return item.collection - ? { - name: 'triggerData', - type: 'item', - key: 'triggerData', - title: tval('Trigger data'), - Component: CollectionBlockInitializer, - collection: item.collection, - dataPath: '$context.params.values', - } - : null; - } -} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateAction.Settings.tsx b/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateAction.Settings.tsx deleted file mode 100644 index e1bd4d5fc..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateAction.Settings.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import { - ActionDesigner, - SchemaSettings, - SchemaSettingsItemType, - useDesignable, - useRequest, - useSchemaToolbar, -} from '@tachybase/client'; -import { useFieldSchema } from '@tachybase/schema'; - -import { useTranslation } from 'react-i18next'; - -const schemaSettingsItems: SchemaSettingsItemType[] = [ - { - name: 'editButton', - Component: ActionDesigner.ButtonEditor, - useComponentProps() { - const { buttonEditorProps } = useSchemaToolbar(); - return buttonEditorProps; - }, - }, - { - name: 'Date', - type: 'select', - useComponentProps() { - const { dn } = useDesignable(); - const { t } = useTranslation(); - const fieldSchema = useFieldSchema(); - return { - title: t('Data will be updated'), - options: [ - { label: t('Selected'), value: 'selected' }, - { label: t('All'), value: 'all' }, - ], - value: fieldSchema['x-action-settings']?.['updateMode'], - onChange: (value) => { - fieldSchema['x-action-settings']['updateMode'] = value; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - 'x-action-settings': fieldSchema['x-action-settings'], - }, - }); - }, - }; - }, - }, - { - name: 'Bind workflow', - type: 'select', - useComponentProps() { - const { dn } = useDesignable(); - const { t } = useTranslation(); - const fieldSchema = useFieldSchema(); - const { data } = useRequest({ - resource: 'workflows', - action: 'list', - params: { - filter: { - type: 'api', - }, - }, - }); - // FIXME 不会实时生效 - const options = - data?.data?.map((workflow) => ({ - label: workflow.title, - value: workflow.id, - })) ?? []; - return { - title: t('Bind workflow'), - value: fieldSchema['x-action-settings'].bindWorkflow, - options: options.concat({ - label: t('disabled'), - value: false, - }), - onChange(value) { - fieldSchema['x-action-settings'].bindWorkflow = value; - dn.emit('patch', { - schema: { - 'x-uid': fieldSchema['x-uid'], - 'x-action-settings': fieldSchema['x-action-settings'], - }, - }); - }, - }; - }, - }, - { - name: 'remove', - sort: 100, - Component: ActionDesigner.RemoveButton as any, - useComponentProps() { - const { removeButtonProps } = useSchemaToolbar(); - return removeButtonProps; - }, - }, -]; - -const bulkWorkflowActionSettings = new SchemaSettings({ - name: 'actionSettings:bulkWorkflow', - items: schemaSettingsItems, -}); - -export { bulkWorkflowActionSettings }; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateActionInitializer.tsx b/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateActionInitializer.tsx deleted file mode 100644 index 93537baa9..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/BulkUpdateActionInitializer.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import { BlockInitializer, useSchemaInitializerItem } from '@tachybase/client'; - -import { tval } from '../../locale'; - -export const BulkWorkflowActionInitializer = () => { - const itemConfig = useSchemaInitializerItem(); - const schema = { - type: 'void', - title: tval('Bulk workflow'), - 'x-component': 'Action', - 'x-use-component-props': 'useCustomizeBulkWorkflowActionProps', - 'x-align': 'right', - 'x-acl-action': 'update', - 'x-decorator': 'ACLActionProvider', - 'x-acl-action-props': { - skipScopeCheck: true, - }, - 'x-action': 'customize:bulkWorkflow', - 'x-toolbar': 'ActionSchemaToolbar', - 'x-settings': 'actionSettings:bulkWorkflow', - 'x-action-settings': { - bindWorkflow: false, - updateMode: 'selected', - }, - 'x-component-props': { - icon: 'CarryOutOutlined', - }, - }; - return ; -}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/index.tsx b/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/index.tsx deleted file mode 100644 index 238108db7..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { Plugin, useCollection } from '@tachybase/client'; -import PluginWorkflow from '@tachybase/plugin-workflow/client'; - -import { tval } from '../../locale'; -import { ApiTrigger } from './ApiTrigger'; -import { bulkWorkflowActionSettings } from './BulkUpdateAction.Settings'; -import { BulkWorkflowActionInitializer } from './BulkUpdateActionInitializer'; -import { useCustomizeBulkWorkflowActionProps } from './utils'; - -export class PluginWorkflowBulk extends Plugin { - async load() { - this.app.addComponents({ BulkWorkflowActionInitializer }); - this.app.addScopes({ useCustomizeBulkWorkflowActionProps }); - this.app.schemaSettingsManager.add(bulkWorkflowActionSettings); - - const initializerData = { - title: tval('Bulk workflow'), - Component: 'BulkWorkflowActionInitializer', - name: 'bulkWorkflow', - useVisible() { - const collection = useCollection(); - return ( - (collection.template !== 'view' || collection?.writableView) && - collection.template !== 'file' && - collection.template !== 'sql' - ); - }, - }; - - ['table', 'details'].forEach((block) => { - this.app.schemaInitializerManager.addItem(block + ':configureActions', 'customize.bulkWorkflow', initializerData); - }); - - const plugin = this.app.pm.get(PluginWorkflow) as PluginWorkflow; - plugin.registerTrigger('api', ApiTrigger); - } -} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/utils.tsx b/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/utils.tsx deleted file mode 100644 index ea5f9a627..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-bulk/utils.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { useContext } from 'react'; -import { - isVariable, - transformVariableValue, - useBlockRequestContext, - useCollection_deprecated, - useCompile, - useLocalVariables, - useRecord, - useRequest, - useTableBlockContext, - useVariables, -} from '@tachybase/client'; -import { SchemaExpressionScopeContext, useField, useFieldSchema } from '@tachybase/schema'; - -import { App } from 'antd'; -import { useNavigate } from 'react-router-dom'; - -import { useTranslation } from '../../locale'; - -export const useCustomizeBulkWorkflowActionProps = () => { - const { field, resource, __parent, service } = useBlockRequestContext(); - const expressionScope = useContext(SchemaExpressionScopeContext); - const actionSchema = useFieldSchema(); - const tableBlockContext = useTableBlockContext(); - const { rowKey } = tableBlockContext; - const selectedRecordKeys = - tableBlockContext.field?.data?.selectedRowKeys ?? expressionScope?.selectedRecordKeys ?? {}; - const navigate = useNavigate(); - const compile = useCompile(); - const { t } = useTranslation(); - const actionField: any = useField(); - const { modal } = App.useApp(); - const variables = useVariables(); - const record = useRecord(); - const { name, getField } = useCollection_deprecated(); - const localVariables = useLocalVariables(); - const { run } = useRequest( - { - resource: 'workflows', - action: 'trigger', - }, - { - manual: true, - }, - ); - - return { - async onClick() { - const { - bindWorkflow = false, - assignedValues: originalAssignedValues = {}, - updateMode, - } = actionSchema?.['x-action-settings'] ?? {}; - actionField.data = field.data || {}; - actionField.data.loading = true; - - if (!bindWorkflow) { - return modal.info({ - title: t('Not bind workflow!'), - }); - } - - const assignedValues = {}; - const waitList = Object.keys(originalAssignedValues).map(async (key) => { - const value = originalAssignedValues[key]; - const collectionField = getField(key); - - if (process.env.NODE_ENV !== 'production') { - if (!collectionField) { - throw new Error(`useCustomizeBulkUpdateActionProps: field "${key}" not found in collection "${name}"`); - } - } - - if (isVariable(value)) { - const result = await variables?.parseVariable(value, localVariables); - if (result) { - assignedValues[key] = transformVariableValue(result, { targetCollectionField: collectionField }); - } - } else if (value != null && value !== '') { - assignedValues[key] = value; - } - }); - await Promise.all(waitList); - - modal.confirm({ - title: t('Bulk update', { ns: 'client' }), - content: - updateMode === 'selected' - ? t('Update selected data?', { ns: 'client' }) - : t('Update all data?', { ns: 'client' }), - async onOk() { - run({ - filterByTk: bindWorkflow, - }); - actionField.data.loading = false; - }, - async onCancel() { - actionField.data.loading = false; - }, - }); - }, - }; -}; diff --git a/packages/plugins/@hera/plugin-core/src/client/index.tsx b/packages/plugins/@hera/plugin-core/src/client/index.tsx index a6ea247a4..c0fae740e 100644 --- a/packages/plugins/@hera/plugin-core/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/index.tsx @@ -25,8 +25,6 @@ import { PluginHeraVersion } from './features/hera-version'; import { PluginOutbound } from './features/outbound'; import { PluginPageStyle } from './features/page-style'; import { PluginPDF } from './features/pdf'; -import { PluginWorkflowBulk } from './features/workflow-bulk'; -import { PluginWorkflowInterceptor } from './features/workflow-interceptor'; import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents'; import { useGetCustomComponents } from './hooks/useGetCustomComponents'; import { @@ -82,8 +80,6 @@ export class PluginCoreClient extends Plugin { await this.app.pm.add(PluginHeraVersion); await this.app.pm.add(PluginContextMenu); await this.app.pm.add(PluginAssistant); - await this.app.pm.add(PluginWorkflowBulk); - await this.app.pm.add(PluginWorkflowInterceptor); await this.app.pm.add(PluginPDF); await this.app.pm.add(PluginExtendedFilterForm); await this.app.pm.add(PluginOutbound); diff --git a/packages/plugins/@hera/plugin-core/src/server/features/ApiTrigger.ts b/packages/plugins/@hera/plugin-core/src/server/features/ApiTrigger.ts deleted file mode 100644 index 58fdf1f59..000000000 --- a/packages/plugins/@hera/plugin-core/src/server/features/ApiTrigger.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Trigger } from '@tachybase/plugin-workflow'; - -export class ApiTrigger extends Trigger { - static TYPE = 'api'; - on() {} - off() {} -} diff --git a/packages/plugins/@hera/plugin-core/src/server/plugin.ts b/packages/plugins/@hera/plugin-core/src/server/plugin.ts index 0f9e2aceb..d39f2085d 100644 --- a/packages/plugins/@hera/plugin-core/src/server/plugin.ts +++ b/packages/plugins/@hera/plugin-core/src/server/plugin.ts @@ -5,7 +5,6 @@ import Application, { InstallOptions, NoticeLevel, Plugin, type PluginOptions } import { Container } from '@tachybase/utils'; import { DepartmentsPlugin } from './features/departments'; -import { PluginInterception } from './features/interception'; import CalcField from './fields/calc'; import TstzrangeField from './fields/tstzrange'; import { ConnectionManager } from './services/connection-manager'; @@ -15,11 +14,9 @@ import { WebControllerService as WebService } from './services/web-service'; export class PluginCoreServer extends Plugin { pluginDepartments: DepartmentsPlugin; - pluginInterception: PluginInterception; constructor(app: Application, options?: PluginOptions) { super(app, options); this.pluginDepartments = new DepartmentsPlugin(app, options); - this.pluginInterception = new PluginInterception(app, options); } async afterAdd() { this.db.registerFieldTypes({ @@ -32,7 +29,6 @@ export class PluginCoreServer extends Plugin { } async load() { await this.pluginDepartments.load(); - await this.pluginInterception.load(); try { await Container.get(ConnectionManager).load(); const fontManger = Container.get(FontManager); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/AddButton.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/AddButton.tsx index 516392ef7..6b67bdd0b 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/AddButton.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/AddButton.tsx @@ -1,9 +1,9 @@ import React, { useCallback, useMemo } from 'react'; -import { Button, Dropdown, MenuProps } from 'antd'; -import { PlusOutlined } from '@ant-design/icons'; - import { css, useAPIClient, useCompile, usePlugin } from '@tachybase/client'; +import { PlusOutlined } from '@ant-design/icons'; +import { Button, Dropdown, MenuProps } from 'antd'; + import WorkflowPlugin from '.'; import { useFlowContext } from './FlowContext'; import { NAMESPACE } from './locale'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/Branch.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/Branch.tsx index bc79630ed..3a4d515bc 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/Branch.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/Branch.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { CloseOutlined } from '@ant-design/icons'; - import { css, cx } from '@tachybase/client'; +import { CloseOutlined } from '@ant-design/icons'; + import { AddButton } from './AddButton'; import { useGetAriaLabelOfAddButton } from './hooks/useGetAriaLabelOfAddButton'; import { Node } from './nodes'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionCanvas.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionCanvas.tsx index 33370f7aa..e6e30b1c3 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionCanvas.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionCanvas.tsx @@ -1,7 +1,4 @@ import React, { useCallback, useEffect, useState } from 'react'; -import { Link, useNavigate } from 'react-router-dom'; -import { Breadcrumb, Button, Dropdown, message, Modal, Result, Space, Spin, Tag, Tooltip } from 'antd'; - import { ActionContextProvider, cx, @@ -15,16 +12,19 @@ import { } from '@tachybase/client'; import { str2moment } from '@tachybase/utils/client'; +import { DownOutlined, ExclamationCircleFilled, StopOutlined } from '@ant-design/icons'; +import { Breadcrumb, Button, Dropdown, message, Modal, Result, Space, Spin, Tag, Tooltip } from 'antd'; +import { useTranslation } from 'react-i18next'; +import { Link, useNavigate } from 'react-router-dom'; + import WorkflowPlugin from '.'; import { CanvasContent } from './CanvasContent'; +import { StatusButton } from './components/StatusButton'; import { ExecutionStatusOptionsMap, JobStatusOptions } from './constants'; import { FlowContext, useFlowContext } from './FlowContext'; import { lang, NAMESPACE } from './locale'; import useStyles from './style'; -import { linkNodes, getWorkflowDetailPath, getWorkflowExecutionsPath } from './utils'; -import { DownOutlined, ExclamationCircleFilled, StopOutlined } from '@ant-design/icons'; -import { StatusButton } from './components/StatusButton'; -import { useTranslation } from 'react-i18next'; +import { getWorkflowDetailPath, getWorkflowExecutionsPath, linkNodes } from './utils'; function attachJobs(nodes, jobs: any[] = []): void { const nodesMap = new Map(); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionContextProvider.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionContextProvider.tsx index 932acbe99..827f5d1b4 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionContextProvider.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionContextProvider.tsx @@ -1,5 +1,4 @@ import React from 'react'; - import { SchemaComponentOptions, usePlugin } from '@tachybase/client'; import PluginWorkflowClient, { FlowContext } from '.'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionLink.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionLink.tsx index a75c16fb0..a1e6b1950 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionLink.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionLink.tsx @@ -1,9 +1,9 @@ import React from 'react'; +import { useActionContext, useRecord } from '@tachybase/client'; + import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; -import { useActionContext, useRecord } from '@tachybase/client'; - import { getWorkflowExecutionsPath } from './utils'; export const ExecutionLink = () => { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionPage.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionPage.tsx index db361f2ac..b0f8d46cd 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionPage.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/ExecutionPage.tsx @@ -1,6 +1,8 @@ -import { cx, SchemaComponent } from '@tachybase/client'; import React from 'react'; +import { cx, SchemaComponent } from '@tachybase/client'; + import { useParams } from 'react-router-dom'; + import { ExecutionCanvas } from './ExecutionCanvas'; import useStyles from './style'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/Plugin.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/Plugin.tsx new file mode 100644 index 000000000..99f87217a --- /dev/null +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/Plugin.tsx @@ -0,0 +1,146 @@ +import React from 'react'; +import { Plugin } from '@tachybase/client'; +import { Registry } from '@tachybase/utils/client'; + +import { ExecutionPage } from './ExecutionPage'; +import { PluginActionTrigger } from './features/action-trigger'; +import { PluginAggregate } from './features/aggregate'; +import { PluginAPIRegularClient } from './features/api-regular'; +import { PluginDelay } from './features/delay'; +import { PluginDaynamicCalculation } from './features/dynamic-calculation'; +import { PluginWorkflowInterceptor } from './features/interceptor'; +import PluginWorkflowJSParseClient from './features/js-parse'; +import PluginWorkflowJsonParseClient from './features/json-parse'; +import { PluginLoop } from './features/loop'; +import { PluginManual } from './features/manual'; +import { PluginParallel } from './features/parallel'; +import { PluginRequest } from './features/request'; +import { PluginSql } from './features/sql'; +import { PluginVariables } from './features/variables'; +import { NAMESPACE } from './locale'; +import { Instruction } from './nodes'; +import CalculationInstruction from './nodes/calculation'; +import ConditionInstruction from './nodes/condition'; +import CreateInstruction from './nodes/create'; +import DestroyInstruction from './nodes/destroy'; +import EndInstruction from './nodes/end'; +import QueryInstruction from './nodes/query'; +import UpdateInstruction from './nodes/update'; +import { customizeSubmitToWorkflowActionSettings } from './settings/customizeSubmitToWorkflowActionSettings'; +import { Trigger } from './triggers'; +import CollectionTrigger from './triggers/collection'; +import ScheduleTrigger from './triggers/schedule'; +import { getWorkflowDetailPath, getWorkflowExecutionsPath } from './utils'; +import { WorkflowPage } from './WorkflowPage'; +import { WorkflowPane } from './WorkflowPane'; + +export class PluginWorkflow extends Plugin { + triggers = new Registry(); + instructions = new Registry(); + getTriggersOptions = () => { + return Array.from(this.triggers.getEntities()).map(([value, { title, ...options }]) => ({ + value, + label: title, + color: 'gold', + options, + })); + }; + + isWorkflowSync(workflow) { + return this.triggers.get(workflow.type).sync ?? workflow.sync; + } + + registerTrigger(type: string, trigger: Trigger | { new (): Trigger }) { + if (typeof trigger === 'function') { + this.triggers.register(type, new trigger()); + } else if (trigger) { + this.triggers.register(type, trigger); + } else { + throw new TypeError('invalid trigger type to register'); + } + } + + registerInstruction(type: string, instruction: Instruction | { new (): Instruction }) { + if (typeof instruction === 'function') { + this.instructions.register(type, new instruction()); + } else if (instruction instanceof Instruction) { + this.instructions.register(type, instruction); + } else { + throw new TypeError('invalid instruction type to register'); + } + } + + async afterAdd() { + await this.pm.add(PluginSql); + await this.pm.add(PluginRequest); + await this.pm.add(PluginParallel); + await this.pm.add(PluginManual); + await this.pm.add(PluginLoop); + await this.pm.add(PluginDaynamicCalculation); + await this.pm.add(PluginDelay); + await this.pm.add(PluginAggregate); + await this.pm.add(PluginActionTrigger); + await this.pm.add(PluginWorkflowJsonParseClient); + await this.pm.add(PluginWorkflowJSParseClient); + await this.pm.add(PluginAPIRegularClient); + await this.pm.add(PluginWorkflowInterceptor); + await this.pm.add(PluginVariables); + } + + async load() { + this.addRoutes(); + this.addComponents(); + + this.app.pluginSettingsManager.add(NAMESPACE, { + icon: 'PartitionOutlined', + title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`, + Component: WorkflowPane, + aclSnippet: 'pm.workflow.workflows', + }); + + this.app.schemaSettingsManager.add(customizeSubmitToWorkflowActionSettings); + + this.registerTrigger('collection', CollectionTrigger); + this.registerTrigger('schedule', ScheduleTrigger); + + this.registerInstruction('calculation', CalculationInstruction); + this.registerInstruction('condition', ConditionInstruction); + this.registerInstruction('end', EndInstruction); + + this.registerInstruction('query', QueryInstruction); + this.registerInstruction('create', CreateInstruction); + this.registerInstruction('update', UpdateInstruction); + this.registerInstruction('destroy', DestroyInstruction); + } + + addComponents() { + this.app.addComponents({ + WorkflowPage, + ExecutionPage, + }); + } + + addRoutes() { + this.app.router.add('admin.workflow.workflows.id', { + path: getWorkflowDetailPath(':id'), + element: , + }); + this.app.router.add('admin.workflow.executions.id', { + path: getWorkflowExecutionsPath(':id'), + element: , + }); + } +} + +export * from './Branch'; +export * from './FlowContext'; +export * from './constants'; +export * from './nodes'; +export { Trigger, useTrigger } from './triggers'; +export * from './variable'; +export * from './components'; +export * from './utils'; +export * from './hooks'; +export { default as useStyles } from './style'; +export * from './variable'; +export * from './ExecutionContextProvider'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowLink.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowLink.tsx index 088aa1ce5..518f407d8 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowLink.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowLink.tsx @@ -1,9 +1,9 @@ import React from 'react'; +import { useActionContext, useGetAriaLabelOfAction, useRecord } from '@tachybase/client'; + import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; -import { useActionContext, useGetAriaLabelOfAction, useRecord } from '@tachybase/client'; - import { getWorkflowDetailPath } from './utils'; export const WorkflowLink = () => { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowPage.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowPage.tsx index 42ece7d44..69578d4cf 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowPage.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/WorkflowPage.tsx @@ -1,6 +1,8 @@ -import { cx, SchemaComponent } from '@tachybase/client'; import React from 'react'; +import { cx, SchemaComponent } from '@tachybase/client'; + import { useParams } from 'react-router-dom'; + import useStyles from './style'; import { WorkflowCanvas } from './WorkflowCanvas'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/configuration.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/configuration.test.ts index 85e98702d..87c96a99f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/configuration.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/configuration.test.ts @@ -1,17 +1,18 @@ -import { faker } from '@faker-js/faker'; import { - ScheduleTriggerNode, - WorkflowListRecords, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiUpdateWorkflowTrigger, appendJsonCollectionName, generalWithNoRelationalFields, + ScheduleTriggerNode, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('Configuration page to configure the Trigger node', () => { test('Triggered one minute after the current time of the customized time', async ({ page, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/workflowCRUD.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/workflowCRUD.test.ts index 8dc6f736f..d7f0dfc5d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/workflowCRUD.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/ScheduleEventTrigger/workflowCRUD.test.ts @@ -1,12 +1,13 @@ -import { faker } from '@faker-js/faker'; import { - CreateWorkFlow, - EditWorkFlow, apiCreateWorkflow, apiDeleteWorkflow, + CreateWorkFlow, + EditWorkFlow, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; +import { faker } from '@faker-js/faker'; + test.describe('Filter', () => { test('filter workflow name', async ({ page }) => { //添加工作流 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/formulaEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/formulaEngine.test.ts index 7c2318502..cf0c1d5d3 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/formulaEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/formulaEngine.test.ts @@ -1,10 +1,5 @@ -import { faker } from '@faker-js/faker'; import { AggregateNode, - ClculationNode, - CollectionTriggerNode, - CreateRecordNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -14,11 +9,17 @@ import { apiUpdateWorkflowNode, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + CreateRecordNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, get trigger node single line text variable', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/mathEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/mathEngine.test.ts index 5bb8645f6..c58b27a24 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/mathEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/calculationNode/mathEngine.test.ts @@ -1,10 +1,5 @@ -import { faker } from '@faker-js/faker'; import { AggregateNode, - ClculationNode, - CollectionTriggerNode, - CreateRecordNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -14,11 +9,17 @@ import { apiUpdateWorkflowNode, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + CreateRecordNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, get trigger node single line text variable', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/configuration.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/configuration.test.ts index 3ef05aec7..bea30aa53 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/configuration.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/configuration.test.ts @@ -1,19 +1,20 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - CreateWorkFlow, - EditWorkFlow, - WorkflowListRecords, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiUpdateRecord, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, + CreateWorkFlow, + EditWorkFlow, generalWithNoRelationalFields, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; +import { faker } from '@faker-js/faker'; + test.describe('Configuration page to configure the Trigger node', () => { test('Add Data Trigger with No Filter', async ({ page, mockCollections, mockRecords }) => { //数据表后缀标识 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/workflowCRUD.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/workflowCRUD.test.ts index f4800d645..1b6071fe0 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/workflowCRUD.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/collectionEventTrigger/workflowCRUD.test.ts @@ -1,19 +1,20 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - CreateWorkFlow, - EditWorkFlow, - WorkflowListRecords, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiUpdateRecord, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, + CreateWorkFlow, + EditWorkFlow, generalWithNoRelationalFields, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; +import { faker } from '@faker-js/faker'; + test.describe('Filter', () => { test('filter workflow name', async ({ page }) => { //添加工作流 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoBasicType.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoBasicType.test.ts index 5e20c83a9..65d2c41b9 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoBasicType.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoBasicType.test.ts @@ -1,9 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -12,11 +7,17 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, determines that the trigger node single line text field variable is equal to an equal constant, passes.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoFormulaEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoFormulaEngine.test.ts index 0bfd71c96..70dcd4dc9 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoFormulaEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoFormulaEngine.test.ts @@ -1,9 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -12,11 +7,17 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event Add Data Trigger, determines that the trigger node single line text field variable is equal to an equal constant, passes.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoMathEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoMathEngine.test.ts index e70b69e7e..56d524652 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoMathEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoMathEngine.test.ts @@ -1,10 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - ConditionYesNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -13,11 +7,18 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, + ConditionYesNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, determine trigger node integer field variable is equal to an equal constant, pass.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesBasicType.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesBasicType.test.ts index 2463b2d61..00b938b74 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesBasicType.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesBasicType.test.ts @@ -1,10 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - ConditionYesNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -13,11 +7,18 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, + ConditionYesNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, determines that the trigger node single line text field variable is equal to an equal constant, passes.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesFormulaEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesFormulaEngine.test.ts index 8a9f5bde7..925f002d0 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesFormulaEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesFormulaEngine.test.ts @@ -1,10 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - ConditionYesNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -13,11 +7,18 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, + ConditionYesNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event Add Data Trigger, Formula engine, determines that the trigger node single line text field variable is equal to an equal constant, passes.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesMathEngine.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesMathEngine.test.ts index 8ff05323a..98778f631 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesMathEngine.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/conditionNode/continueWhenYesMathEngine.test.ts @@ -1,10 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - ClculationNode, - CollectionTriggerNode, - ConditionBranchNode, - ConditionYesNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -13,11 +7,18 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionBranchNode, + ConditionYesNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, Math engine, determine trigger node integer field variable is equal to an equal constant, pass.', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/createRecordNode/CreateRecord.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/createRecordNode/CreateRecord.test.ts index cfedb958d..7efbd8d5b 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/createRecordNode/CreateRecord.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/createRecordNode/CreateRecord.test.ts @@ -1,7 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - CreateRecordNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetRecord, @@ -9,11 +6,15 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, + CreateRecordNode, generalWithNoRelationalFields, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, single row text fields for common tables, set constant data', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/deleteRecordNode/DeleteRecord.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/deleteRecordNode/DeleteRecord.test.ts index f3559adc3..91a85ff40 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/deleteRecordNode/DeleteRecord.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/deleteRecordNode/DeleteRecord.test.ts @@ -1,17 +1,18 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - DeleteRecordNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetList, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, + DeleteRecordNode, generalWithNoRelationalFields, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, filter single line text field not null, delete common table data', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/queryRecordNode/QueryRecord.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/queryRecordNode/QueryRecord.test.ts index cd1c69bee..3238efdd0 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/queryRecordNode/QueryRecord.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/queryRecordNode/QueryRecord.test.ts @@ -1,18 +1,19 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - QueryRecordNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, no filter no sort query common table 1 record', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateInABatch.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateInABatch.test.ts index 4fe264072..02308680a 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateInABatch.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateInABatch.test.ts @@ -1,7 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - UpdateRecordNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetList, @@ -9,11 +6,15 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, + UpdateRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, filter single line text field not empty, common table single line text field data, set single line text field constant data', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateOneByOne.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateOneByOne.test.ts index ad7a1b4a4..2d34edabc 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateOneByOne.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/__e2e__/updateRecordNode/updateOneByOne.test.ts @@ -1,7 +1,4 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - UpdateRecordNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetList, @@ -9,11 +6,15 @@ import { apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, + UpdateRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('Collection event add data trigger, filter single line text field not empty, common table single line text field data, set single line text field constant data', async ({ page, mockCollections, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CheckboxGroupWithTooltip.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CheckboxGroupWithTooltip.tsx index 58e768313..e31746db2 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CheckboxGroupWithTooltip.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CheckboxGroupWithTooltip.tsx @@ -1,7 +1,8 @@ -import { QuestionCircleOutlined } from '@ant-design/icons'; -import { css, useCompile } from '@tachybase/client'; -import { Checkbox, Space, Tooltip } from 'antd'; import React from 'react'; +import { css, useCompile } from '@tachybase/client'; + +import { QuestionCircleOutlined } from '@ant-design/icons'; +import { Checkbox, Space, Tooltip } from 'antd'; export interface CheckboxGroupWithTooltipOption { value: any; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionBlockInitializer.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionBlockInitializer.tsx index 428ec12fc..609a893bc 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionBlockInitializer.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionBlockInitializer.tsx @@ -1,17 +1,16 @@ import React from 'react'; -import { uid } from '@tachybase/schema'; - import { CollectionProvider_deprecated, + parseCollectionName, SchemaInitializerItem, SchemaInitializerItemType, - parseCollectionName, useCollectionManager_deprecated, useRecordCollectionDataSourceItems, useSchemaInitializer, useSchemaInitializerItem, useSchemaTemplateManager, } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; import { traverseSchema } from '../utils'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionFieldset.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionFieldset.tsx index 8a62be3bf..908307441 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionFieldset.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/CollectionFieldset.tsx @@ -1,19 +1,21 @@ -import { CloseCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { observer, useField, useForm } from '@tachybase/schema'; +import React, { useMemo } from 'react'; import { CollectionField, CollectionProvider_deprecated, - SchemaComponent, - Variable, css, parseCollectionName, + SchemaComponent, useCollectionManager_deprecated, useCompile, useToken, + Variable, } from '@tachybase/client'; +import { observer, useField, useForm } from '@tachybase/schema'; + +import { CloseCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Dropdown, Form, Input, MenuProps } from 'antd'; -import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; + import { lang } from '../locale'; import { useWorkflowVariableOptions } from '../variable'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DetailsBlockProvider.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DetailsBlockProvider.tsx index a02f993a7..b7679573d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DetailsBlockProvider.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DetailsBlockProvider.tsx @@ -1,17 +1,17 @@ import React, { useMemo, useRef } from 'react'; -import { createForm } from '@tachybase/schema'; -import { useField } from '@tachybase/schema'; -import { get } from 'lodash'; import { BlockRequestContext_deprecated, CollectionProvider_deprecated, FormBlockContext, - RecordProvider, parseCollectionName, + RecordProvider, useAPIClient, useAssociationNames, useBlockRequestContext, } from '@tachybase/client'; +import { createForm, useField } from '@tachybase/schema'; + +import { get } from 'lodash'; import { useFlowContext } from '../FlowContext'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerDescription.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerDescription.tsx index 736a1dcdd..440371693 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerDescription.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerDescription.tsx @@ -1,6 +1,7 @@ -import { createStyles, cx } from '@tachybase/client'; -import { Tag } from 'antd'; import React from 'react'; +import { createStyles, cx } from '@tachybase/client'; + +import { Tag } from 'antd'; const useStyles = createStyles(({ css, token }) => { return { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerForm.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerForm.tsx index 4cf4065e1..797268005 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerForm.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/DrawerForm.tsx @@ -1,9 +1,8 @@ import React, { useCallback, useMemo, useState } from 'react'; -import { cloneDeep } from 'lodash'; -import { createForm } from '@tachybase/schema'; -import { useForm } from '@tachybase/schema'; - import { ActionContextProvider, FormProvider } from '@tachybase/client'; +import { createForm, useForm } from '@tachybase/schema'; + +import { cloneDeep } from 'lodash'; export function useFormProviderProps() { return { form: useForm() }; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/ExecutionStatus.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/ExecutionStatus.tsx index e3bc8cf58..8c67830f3 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/ExecutionStatus.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/ExecutionStatus.tsx @@ -1,10 +1,10 @@ import React, { useCallback } from 'react'; -import { Button, Modal, Select, Tag, Tooltip, message } from 'antd'; -import { ExclamationCircleFilled, StopOutlined } from '@ant-design/icons'; -import { useTranslation } from 'react-i18next'; - import { Action, css, useCompile, useRecord, useResourceActionContext, useResourceContext } from '@tachybase/client'; +import { ExclamationCircleFilled, StopOutlined } from '@ant-design/icons'; +import { Button, message, Modal, Select, Tag, Tooltip } from 'antd'; +import { useTranslation } from 'react-i18next'; + import { EXECUTION_STATUS, ExecutionStatusOptions, ExecutionStatusOptionsMap } from '../constants'; import { lang } from '../locale'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/FieldsSelect.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/FieldsSelect.tsx index 57a75f1bb..59147c092 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/FieldsSelect.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/FieldsSelect.tsx @@ -1,8 +1,8 @@ -import { observer, useForm } from '@tachybase/schema'; -import { Select } from 'antd'; import React from 'react'; - import { parseCollectionName, useCollectionManager_deprecated, useCompile } from '@tachybase/client'; +import { observer, useForm } from '@tachybase/schema'; + +import { Select } from 'antd'; function defaultFilter() { return true; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx index 7d13d0ffa..e6d25ce46 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx @@ -1,5 +1,4 @@ import React from 'react'; - import { Variable } from '@tachybase/client'; import { useWorkflowVariableOptions } from '../variable'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/OpenDrawer.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/OpenDrawer.tsx index cdf954b7c..2960a434f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/OpenDrawer.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/OpenDrawer.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; -import { useFieldSchema } from '@tachybase/schema'; - import { ActionContextProvider, SchemaComponent } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; export default function ({ component = 'div', children, ...props }) { const [visible, setVisible] = useState(false); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/SimpleDesigner.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/SimpleDesigner.tsx index 219fca06c..ddb6851de 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/SimpleDesigner.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/SimpleDesigner.tsx @@ -1,6 +1,4 @@ import React from 'react'; -import { useFieldSchema } from '@tachybase/schema'; - import { GeneralSchemaDesigner, SchemaSettingsBlockTitleItem, @@ -8,6 +6,7 @@ import { SchemaSettingsRemove, useCompile, } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; export function SimpleDesigner() { const schema = useFieldSchema(); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/components/ValueBlock.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/components/ValueBlock.tsx index 958663da0..f7244d495 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/components/ValueBlock.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/components/ValueBlock.tsx @@ -1,7 +1,8 @@ -import { useFieldSchema } from '@tachybase/schema'; -import { css, SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; -import { parse } from '@tachybase/utils/client'; import React from 'react'; +import { css, SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; +import { parse } from '@tachybase/utils/client'; + import { useFlowContext } from '../FlowContext'; import { SimpleDesigner } from './SimpleDesigner'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/constants.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/constants.tsx index 957041dc4..43d50f0ec 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/constants.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/constants.tsx @@ -1,14 +1,16 @@ import React from 'react'; + import { - CloseOutlined, - ClockCircleOutlined, CheckOutlined, - MinusOutlined, + ClockCircleOutlined, + CloseOutlined, ExclamationOutlined, HourglassOutlined, LoadingOutlined, + MinusOutlined, RedoOutlined, } from '@ant-design/icons'; + import { NAMESPACE } from './locale'; export const EXECUTION_STATUS = { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/ActionTrigger.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/ActionTrigger.tsx index 5cd0f8c71..8ebbd4b8f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/ActionTrigger.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/ActionTrigger.tsx @@ -1,16 +1,16 @@ -import { useForm } from '@tachybase/schema'; - import { SchemaInitializerItemType, useCollectionDataSource, useCollectionManager_deprecated, useCompile, } from '@tachybase/client'; -import { NAMESPACE, lang } from '../../locale'; -import { Trigger } from '../../triggers'; +import { useForm } from '@tachybase/schema'; + import { CollectionBlockInitializer } from '../../components'; -import { getCollectionFieldOptions } from '../../variable'; import { useWorkflowAnyExecuted } from '../../hooks'; +import { lang, NAMESPACE } from '../../locale'; +import { Trigger } from '../../triggers'; +import { getCollectionFieldOptions } from '../../variable'; export class ActionTrigger extends Trigger { title = `{{t("Action event", { ns: "${NAMESPACE}" })}}`; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/configuration.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/configuration.test.ts index c50cfe60c..9cce730d2 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/configuration.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/configuration.test.ts @@ -1,19 +1,20 @@ -import { faker } from '@faker-js/faker'; import { - FormEventTriggerNode, - WorkflowListRecords, apiCreateRecordTriggerFormEvent, apiCreateWorkflow, apiDeleteWorkflow, + apiGetDataSourceCount, apiGetWorkflow, apiUpdateWorkflowTrigger, appendJsonCollectionName, + FormEventTriggerNode, generalWithNoRelationalFields, - apiGetDataSourceCount, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('Configuration page to configure the Trigger node', () => { test('Form Submit Button Binding Workflow Add Data Trigger', async ({ page, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/workflowCRUD.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/workflowCRUD.test.ts index 5a1d49aed..c45814934 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/workflowCRUD.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/__e2e__/workflowCRUD.test.ts @@ -1,20 +1,21 @@ -import { faker } from '@faker-js/faker'; import { - CreateWorkFlow, - EditWorkFlow, - FormEventTriggerNode, - WorkflowListRecords, apiCreateRecordTriggerFormEvent, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CreateWorkFlow, + EditWorkFlow, + FormEventTriggerNode, generalWithNoRelationalFields, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('Filter', () => { test('filter workflow name', async ({ page }) => { //添加工作流 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/index.ts index cf74bd1d2..10e3934ba 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/action-trigger/index.ts @@ -1,6 +1,6 @@ import { Plugin, SchemaInitializerItemType } from '@tachybase/client'; -import WorkflowPlugin, { useRecordTriggerWorkflowsActionProps, useTriggerWorkflowsActionProps } from '../..'; +import WorkflowPlugin, { useRecordTriggerWorkflowsActionProps, useTriggerWorkflowsActionProps } from '../..'; import { ActionTrigger } from './ActionTrigger'; const submitToWorkflowActionInitializer: SchemaInitializerItemType = { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/__e2e__/DataOfCollection.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/__e2e__/DataOfCollection.test.ts index 647628912..06130d86f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/__e2e__/DataOfCollection.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/__e2e__/DataOfCollection.test.ts @@ -1,17 +1,19 @@ -import { faker } from '@faker-js/faker'; import { AggregateNode, - CollectionTriggerNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; + +import { faker } from '@faker-js/faker'; + test.describe('no filter', () => { test('Collection event add data trigger, normal table integer fields not de-emphasised COUNT', async ({ page, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/index.ts index 57394fe5d..4e0bb6bd8 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/aggregate/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import AggregateInstruction from './AggregateInstruction'; export class PluginAggregate extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/delay/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/delay/index.ts index a208883fd..025d2afd0 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/delay/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/delay/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import DelayInstruction from './DelayInstruction'; export class PluginDelay extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/DynamicExpression.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/DynamicExpression.tsx index 02066d036..4cee4a492 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/DynamicExpression.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/DynamicExpression.tsx @@ -1,12 +1,20 @@ -import { onFieldInputValueChange, onFormInitialValuesChange } from '@tachybase/schema'; -import { connect, mapReadPretty, observer, useField, useForm, useFormEffects } from '@tachybase/schema'; -import { Tag } from 'antd'; import React, { useMemo, useState } from 'react'; +import { useCollectionManager_deprecated, useCompile, useRecord, Variable } from '@tachybase/client'; +import { + connect, + mapReadPretty, + observer, + onFieldInputValueChange, + onFormInitialValuesChange, + useField, + useForm, + useFormEffects, +} from '@tachybase/schema'; + +import { Tag } from 'antd'; import { useTranslation } from 'react-i18next'; -import { useCollectionManager_deprecated, useCompile, useRecord, Variable } from '@tachybase/client'; import { getCollectionFieldOptions } from '../..'; - import { NAMESPACE } from '../../locale'; const InternalExpression = observer( diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/index.ts index 153a351d5..393ae6a27 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/dynamic-calculation/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import DynamicCalculation from './DynamicCalculation'; import { DynamicExpression } from './DynamicExpression'; import { ExpressionFieldInterface } from './expression'; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/WorkflowTriggerInterceptor.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/WorkflowTriggerInterceptor.tsx similarity index 93% rename from packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/WorkflowTriggerInterceptor.tsx rename to packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/WorkflowTriggerInterceptor.tsx index 363eedd9f..e44b11821 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/WorkflowTriggerInterceptor.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/WorkflowTriggerInterceptor.tsx @@ -1,14 +1,9 @@ import { useCollectionDataSource, useCollectionManager_deprecated, useCompile } from '@tachybase/client'; -import { - CheckboxGroupWithTooltip, - CollectionBlockInitializer, - FieldsSelect, - getCollectionFieldOptions, - RadioWithTooltip, - Trigger, -} from '@tachybase/plugin-workflow/client'; +import { CheckboxGroupWithTooltip, CollectionBlockInitializer, FieldsSelect, RadioWithTooltip } from '../../components'; import { lang, tval } from '../../locale'; +import { Trigger } from '../../triggers'; +import { getCollectionFieldOptions } from '../../variable'; const enum ACTION_TYPES { CREATE = 'create', @@ -96,9 +91,9 @@ export class WorkflowTriggerInterceptor extends Trigger { }; scope = { useCollectionDataSource }; components = { - FieldsSelect: FieldsSelect, - RadioWithTooltip: RadioWithTooltip, - CheckboxGroupWithTooltip: CheckboxGroupWithTooltip, + FieldsSelect, + RadioWithTooltip, + CheckboxGroupWithTooltip, }; isActionTriggerable = (a, u) => { const { global: m } = a; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/index.ts similarity index 84% rename from packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/index.ts rename to packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/index.ts index 59f977f1a..b79debcc0 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/workflow-interceptor/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/interceptor/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import PluginWorkflow from '@tachybase/plugin-workflow/client'; +import PluginWorkflow from '../..'; import { WorkflowTriggerInterceptor } from './WorkflowTriggerInterceptor'; export class PluginWorkflowInterceptor extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/loop/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/loop/index.ts index c97cd7c27..96af8ca38 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/loop/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/loop/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import LoopInstruction from './LoopInstruction'; export class PluginLoop extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodo.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodo.tsx index a1ccb5927..abbdc3524 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodo.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodo.tsx @@ -1,32 +1,33 @@ -import { observer, useField, useFieldSchema, useForm } from '@tachybase/schema'; -import { Space, Spin, Tag } from 'antd'; -import { dayjs } from '@tachybase/utils/client'; import React, { createContext, useContext, useEffect, useState } from 'react'; - -import { css, useCompile, usePlugin } from '@tachybase/client'; - import { + css, + ExtendCollectionsProvider, SchemaComponent, SchemaComponentContext, TableBlockProvider, - useAPIClient, useActionContext, + useAPIClient, + useCompile, useCurrentUserContext, useFormBlockContext, + usePlugin, useRecord, useTableBlockContext, - ExtendCollectionsProvider, } from '@tachybase/client'; +import { observer, useField, useFieldSchema, useForm } from '@tachybase/schema'; +import { dayjs } from '@tachybase/utils/client'; + +import { Space, Spin, Tag } from 'antd'; + import WorkflowPlugin, { + DetailsBlockProvider, FlowContext, linkNodes, useAvailableUpstreams, useFlowContext, - DetailsBlockProvider, } from '../..'; import { JobStatusOptions, JobStatusOptionsMap } from '../../constants'; - -import { NAMESPACE, lang } from '../../locale'; +import { lang, NAMESPACE } from '../../locale'; import { FormBlockProvider } from './instruction/FormBlockProvider'; import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodoBlockInitializer.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodoBlockInitializer.tsx index 60fe9f562..052542501 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodoBlockInitializer.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/WorkflowTodoBlockInitializer.tsx @@ -1,8 +1,8 @@ -import { TableOutlined } from '@ant-design/icons'; import React, { FC } from 'react'; - import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; +import { TableOutlined } from '@ant-design/icons'; + export const WorkflowTodoBlockInitializer: FC = () => { const itemConfig = useSchemaInitializerItem(); const { insert } = useSchemaInitializer(); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/createRecordForm.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/createRecordForm.test.ts index 0e153faa4..90c5b4be7 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/createRecordForm.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/createRecordForm.test.ts @@ -1,20 +1,21 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - ManualNode, apiCreateWorkflow, apiDeleteWorkflow, + apiGetDataSourceCount, apiGetRecord, apiGetWorkflow, apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, - apiGetDataSourceCount, + ManualNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('block configuration', () => {}); test.describe('field configuration', () => {}); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/customFormBlocks.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/customFormBlocks.test.ts index 962ac9bf2..061272b8c 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/customFormBlocks.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/customFormBlocks.test.ts @@ -1,18 +1,19 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - ManualNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, + ManualNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('block configuration', () => {}); test.describe('field configuration', () => {}); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/datablocks.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/datablocks.test.ts index 5b45007d8..1e6347160 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/datablocks.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/datablocks.test.ts @@ -1,11 +1,5 @@ -import { faker } from '@faker-js/faker'; import { AggregateNode, - ClculationNode, - CollectionTriggerNode, - CreateRecordNode, - ManualNode, - QueryRecordNode, apiCreateWorkflow, apiCreateWorkflowNode, apiDeleteWorkflow, @@ -15,11 +9,18 @@ import { apiGetWorkflowNode, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + CreateRecordNode, generalWithNoRelationalFields, + ManualNode, + QueryRecordNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('field data', () => { test('Collection event to add a data trigger, get a single line of text data for the trigger node', async ({ page, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/updateRecordForm.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/updateRecordForm.test.ts index 3a3731326..82b34f830 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/updateRecordForm.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/updateRecordForm.test.ts @@ -1,20 +1,21 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - ManualNode, apiCreateWorkflow, apiDeleteWorkflow, apiFilterList, + apiGetDataSourceCount, apiGetWorkflow, apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, - apiGetDataSourceCount, + ManualNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('block configuration', () => {}); test.describe('field configuration', () => {}); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/workflowTodo.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/workflowTodo.test.ts index 3983e5f7f..b0f9acc24 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/workflowTodo.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/__e2e__/workflowTodo.test.ts @@ -1,18 +1,19 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, - ManualNode, apiCreateWorkflow, apiDeleteWorkflow, + apiGetDataSourceCount, apiGetWorkflow, apiUpdateWorkflowTrigger, appendJsonCollectionName, + CollectionTriggerNode, generalWithNoRelationalFields, - apiGetDataSourceCount, + ManualNode, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test('filter task node', async ({ page, mockPage, mockCollections, mockRecords }) => { //数据表后缀标识 const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/index.ts index d9be73d87..cf876e188 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/index.ts @@ -1,18 +1,17 @@ import { Plugin } from '@tachybase/client'; + import WorkflowPlugin from '../..'; - -import Manual from './instruction'; - import { NAMESPACE } from '../../locale'; -import { WorkflowTodo } from './WorkflowTodo'; -import { WorkflowTodoBlockInitializer } from './WorkflowTodoBlockInitializer'; +import Manual from './instruction'; +import { addCustomFormField, addCustomFormField_deprecated } from './instruction/forms/custom'; import { addActionButton, addActionButton_deprecated, addBlockButton, addBlockButton_deprecated, } from './instruction/SchemaConfig'; -import { addCustomFormField, addCustomFormField_deprecated } from './instruction/forms/custom'; +import { WorkflowTodo } from './WorkflowTodo'; +import { WorkflowTodoBlockInitializer } from './WorkflowTodoBlockInitializer'; export class PluginManual extends Plugin { async load() { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/AssigneesSelect.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/AssigneesSelect.tsx index b67825d84..5ab2bc38d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/AssigneesSelect.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/AssigneesSelect.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { RemoteSelect, Variable } from '@tachybase/client'; + import { useWorkflowVariableOptions } from '../../..'; function isUserKeyField(field) { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockInitializer.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockInitializer.tsx index b42054f24..9cef23c9e 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockInitializer.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockInitializer.tsx @@ -1,5 +1,4 @@ import React from 'react'; - import { CollectionProvider_deprecated, SchemaInitializerItem, @@ -11,7 +10,6 @@ import { } from '@tachybase/client'; import { JOB_STATUS, traverseSchema } from '../../..'; - import { NAMESPACE } from '../../../locale'; import { createManualFormBlockUISchema } from './createManualFormBlockUISchema'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockProvider.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockProvider.tsx index c67952f2f..42cb0e547 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockProvider.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/FormBlockProvider.tsx @@ -1,5 +1,4 @@ -import { createForm } from '@tachybase/schema'; -import { RecursionField, useField, useFieldSchema } from '@tachybase/schema'; +import React, { useMemo, useRef } from 'react'; import { BlockRequestContext_deprecated, CollectionManagerProvider, @@ -16,7 +15,7 @@ import { useDesignable, useRecord, } from '@tachybase/client'; -import React, { useMemo, useRef } from 'react'; +import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; export function FormBlockProvider(props) { const userJob = useRecord(); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/ModeConfig.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/ModeConfig.tsx index d7a708f0b..a8036247d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/ModeConfig.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/ModeConfig.tsx @@ -1,9 +1,10 @@ -import { QuestionCircleOutlined } from '@ant-design/icons'; -import { FormLayout } from '@tachybase/components'; -import { Form, Radio, Tooltip } from 'antd'; import React from 'react'; - import { css, FormItem } from '@tachybase/client'; +import { FormLayout } from '@tachybase/components'; + +import { QuestionCircleOutlined } from '@ant-design/icons'; +import { Form, Radio, Tooltip } from 'antd'; + import { lang } from '../../../locale'; function parseMode(v) { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/create.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/create.tsx index c9fec4b10..9f2acd527 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/create.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/create.tsx @@ -1,5 +1,4 @@ import React, { useMemo, useState } from 'react'; - import { GeneralSchemaDesigner, SchemaSettingsBlockTitleItem, @@ -13,6 +12,7 @@ import { } from '@tachybase/client'; import _ from 'lodash'; + import { NAMESPACE } from '../../../../locale'; import { FormBlockInitializer } from '../FormBlockInitializer'; import { ManualFormType } from '../SchemaConfig'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/custom.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/custom.tsx index 5775a9711..9060bf2c0 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/custom.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/custom.tsx @@ -1,31 +1,29 @@ import React, { useContext, useMemo, useState } from 'react'; - -import { ArrayTable } from '@tachybase/components'; -import { Field, createForm } from '@tachybase/schema'; -import { useField, useFieldSchema, useForm } from '@tachybase/schema'; -import { cloneDeep, pick, set } from 'lodash'; - import { ActionContextProvider, CollectionProvider_deprecated, CompatibleSchemaInitializer, FormBlockContext, + gridRowColWrap, RecordProvider, SchemaComponent, SchemaInitializerItem, - SchemaInitializerItemType, SchemaInitializerItems, - gridRowColWrap, - useCollectionManager_deprecated, + SchemaInitializerItemType, useCollection_deprecated, + useCollectionManager_deprecated, useRecord, useSchemaInitializer, useSchemaInitializerItem, } from '@tachybase/client'; -import { JOB_STATUS } from '../../../..'; +import { ArrayTable } from '@tachybase/components'; +import { createForm, Field, useField, useFieldSchema, useForm } from '@tachybase/schema'; import { merge, uid } from '@tachybase/utils/client'; -import { NAMESPACE, lang } from '../../../../locale'; +import { cloneDeep, pick, set } from 'lodash'; + +import { JOB_STATUS } from '../../../..'; +import { lang, NAMESPACE } from '../../../../locale'; import { ManualFormType } from '../SchemaConfig'; import { findSchema } from '../utils'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/update.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/update.tsx index 31369e438..05f503215 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/update.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/manual/instruction/forms/update.tsx @@ -1,8 +1,4 @@ -import { useFieldSchema } from '@tachybase/schema'; import React, { useMemo, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import _ from 'lodash'; - import { GeneralSchemaDesigner, SchemaSettingsActionModalItem, @@ -15,12 +11,16 @@ import { useDesignable, useMenuSearch, } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; +import _ from 'lodash'; +import { useTranslation } from 'react-i18next'; + +import { FilterDynamicComponent } from '../../../../components'; import { NAMESPACE } from '../../../../locale'; import { FormBlockInitializer } from '../FormBlockInitializer'; import { ManualFormType } from '../SchemaConfig'; import { findSchema } from '../utils'; -import { FilterDynamicComponent } from '../../../../components'; function UpdateFormDesigner() { const { name, title } = useCollection_deprecated(); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/__e2e__/parallelBranch.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/__e2e__/parallelBranch.test.ts index 455404ce4..78b14dbd2 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/__e2e__/parallelBranch.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/__e2e__/parallelBranch.test.ts @@ -1,20 +1,21 @@ -import { faker } from '@faker-js/faker'; import { - CollectionTriggerNode, apiCreateWorkflow, apiDeleteWorkflow, apiGetWorkflow, + apiGetWorkflowNodeExecutions, apiUpdateWorkflowTrigger, appendJsonCollectionName, + ClculationNode, + CollectionTriggerNode, + ConditionYesNode, generalWithNoRelationalFields, ParallelBranchNode, - ConditionYesNode, - ClculationNode, - apiGetWorkflowNodeExecutions, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('All succeeded', () => { test('All 3 branches were successful', async ({ page, mockCollections, mockRecords }) => { //数据表后缀标识 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/index.ts index ab89c0d28..92e0e365e 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/parallel/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import ParallelInstruction from './ParallelInstruction'; export class PluginParallel extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/request/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/request/index.ts index 16bd33be5..8158aea22 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/request/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/request/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import RequestInstruction from './RequestInstruction'; export class PluginRequest extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/__e2e__/dataCURD.test.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/__e2e__/dataCURD.test.ts index 984883436..f4ee6e84a 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/__e2e__/dataCURD.test.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/__e2e__/dataCURD.test.ts @@ -1,24 +1,25 @@ -import { faker } from '@faker-js/faker'; import { + apiCreateWorkflow, + apiDeleteWorkflow, + apiGetRecord, + apiGetWorkflow, + apiGetWorkflowNodeExecutions, + apiUpdateRecord, + apiUpdateWorkflowTrigger, + appendJsonCollectionName, CollectionTriggerNode, CreateWorkFlow, EditWorkFlow, - WorkflowListRecords, - apiCreateWorkflow, - apiDeleteWorkflow, - apiGetWorkflow, - apiUpdateRecord, - apiGetWorkflowNodeExecutions, - apiUpdateWorkflowTrigger, - appendJsonCollectionName, generalWithNoRelationalFields, QueryRecordNode, SQLNode, - apiGetRecord, + WorkflowListRecords, } from '@tachybase/plugin-workflow-test/e2e'; import { expect, test } from '@tachybase/test/e2e'; import { dayjs } from '@tachybase/utils'; +import { faker } from '@faker-js/faker'; + test.describe('select data', () => { test('No variable SQL, select 1 record', async ({ page, mockCollections, mockRecords }) => { //数据表后缀标识 diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/index.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/index.ts index 329cfb53d..68b8bf0ee 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/index.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/sql/index.ts @@ -1,6 +1,6 @@ import { Plugin } from '@tachybase/client'; -import WorkflowPlugin from '../..'; +import WorkflowPlugin from '../..'; import SQLInstruction from './SQLInstruction'; export class PluginSql extends Plugin { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/VariableTargetSelect.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/VariableTargetSelect.tsx new file mode 100644 index 000000000..3cb02a31e --- /dev/null +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/variables/VariableTargetSelect.tsx @@ -0,0 +1,56 @@ +import React, { useCallback } from 'react'; +import { Space } from '@tachybase/client'; + +import { Radio, Select } from 'antd'; + +import { lang } from '../../locale'; +import { useAvailableUpstreams, useNodeContext } from '../../nodes'; +import { useStyles } from './useStyles'; + +export function VariableTargetSelect({ value, onChange }) { + const isNull = value == null; + const node = useNodeContext(); + const nodes = useAvailableUpstreams(node, (n) => n.type === 'variable' && !n.config.target); + const { styles } = useStyles(); + const onTargetChange = useCallback( + ({ target }) => { + if (target.value) return onChange(null); + nodes.length && onChange(nodes[0].key); + }, + [onChange, nodes], + ); + const filterOption = useCallback( + (t, v) => v.label.toLowerCase().indexOf(t.toLowerCase()) >= 0 || `#${v.data.id}`.indexOf(t) >= 0, + [], + ); + return ( +
+ + + {lang('Declare a new variable')} + + + {lang('Assign value to an existing variable')} + + {!isNull && ( +