@nocobase/plugin-workflow 0.10.0-alpha.5 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +1 -8
- package/lib/client/Branch.js +8 -8
- package/lib/client/CanvasContent.js +8 -8
- package/lib/client/ExecutionCanvas.js +20 -27
- package/lib/client/ExecutionPage.js +1 -8
- package/lib/client/WorkflowCanvas.js +3 -10
- package/lib/client/WorkflowPage.js +1 -8
- package/lib/client/WorkflowProvider.js +3 -42
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +8 -15
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/DynamicExpression.js +14 -4
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +6 -6
- package/lib/client/components/NodeDescription.js +11 -11
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/nodes/aggregate.d.ts +10 -4
- package/lib/client/nodes/aggregate.js +12 -9
- package/lib/client/nodes/calculation.d.ts +11 -16
- package/lib/client/nodes/calculation.js +72 -52
- package/lib/client/nodes/condition.d.ts +2 -6
- package/lib/client/nodes/condition.js +20 -24
- package/lib/client/nodes/create.d.ts +8 -5
- package/lib/client/nodes/create.js +34 -7
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +4 -4
- package/lib/client/nodes/index.js +79 -86
- package/lib/client/nodes/loop.d.ts +3 -1
- package/lib/client/nodes/loop.js +48 -35
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +3 -3
- package/lib/client/nodes/manual/SchemaConfig.js +18 -17
- package/lib/client/nodes/manual/WorkflowTodo.js +66 -72
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/custom.js +11 -18
- package/lib/client/nodes/manual/index.d.ts +11 -5
- package/lib/client/nodes/manual/index.js +21 -10
- package/lib/client/nodes/parallel.js +20 -20
- package/lib/client/nodes/query.d.ts +7 -4
- package/lib/client/nodes/query.js +34 -7
- package/lib/client/nodes/request.d.ts +10 -6
- package/lib/client/nodes/request.js +37 -9
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +1 -1
- package/lib/client/schemas/collection.js +3 -10
- package/lib/client/style.js +18 -18
- package/lib/client/triggers/collection.d.ts +4 -3
- package/lib/client/triggers/collection.js +21 -7
- package/lib/client/triggers/index.d.ts +2 -2
- package/lib/client/triggers/index.js +46 -52
- package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -1
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +11 -11
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +17 -24
- package/lib/client/triggers/schedule/index.d.ts +3 -4
- package/lib/client/triggers/schedule/index.js +21 -11
- package/lib/client/variable.d.ts +3 -4
- package/lib/client/variable.js +110 -45
- package/lib/server/Plugin.d.ts +2 -3
- package/lib/server/Plugin.js +8 -9
- package/lib/server/Processor.d.ts +2 -4
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +1 -1
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +1 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/request.d.ts +2 -2
- package/lib/server/instructions/request.js +1 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +2 -2
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/package.json +40 -20
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +99 -0
- package/src/client/Branch.tsx +35 -0
- package/src/client/CanvasContent.tsx +23 -0
- package/src/client/ExecutionCanvas.tsx +168 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +44 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +220 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +51 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +158 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +28 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +44 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +242 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +217 -0
- package/src/client/nodes/condition.tsx +490 -0
- package/src/client/nodes/create.tsx +86 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +489 -0
- package/src/client/nodes/loop.tsx +159 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +68 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +365 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +611 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +88 -0
- package/src/client/nodes/manual/forms/custom.tsx +388 -0
- package/src/client/nodes/manual/forms/update.tsx +130 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +137 -0
- package/src/client/nodes/query.tsx +89 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +312 -0
- package/src/client/triggers/collection.tsx +186 -0
- package/src/client/triggers/index.tsx +307 -0
- package/src/client/triggers/schedule/DateFieldsSelect.tsx +28 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +50 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +225 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +72 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +296 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +351 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +23 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +854 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +217 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +298 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +37 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +63 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +79 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +22 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +22 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +31 -0
- package/src/server/instructions/request.ts +87 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/triggers/collection.ts +142 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useForm } from '@formily/react';
|
|
2
|
+
import { css, useCollectionFilterOptions } from '@nocobase/client';
|
|
3
|
+
import { NAMESPACE } from '../locale';
|
|
4
|
+
|
|
5
|
+
export const collection = {
|
|
6
|
+
type: 'string',
|
|
7
|
+
title: '{{t("Collection")}}',
|
|
8
|
+
required: true,
|
|
9
|
+
'x-reactions': [],
|
|
10
|
+
'x-decorator': 'FormItem',
|
|
11
|
+
'x-component': 'CollectionSelect',
|
|
12
|
+
'x-component-props': {
|
|
13
|
+
popupMatchSelectWidth: false,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const values = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
title: '{{t("Fields values")}}',
|
|
20
|
+
'x-decorator': 'FormItem',
|
|
21
|
+
'x-decorator-props': {
|
|
22
|
+
labelAlign: 'left',
|
|
23
|
+
className: css`
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
`,
|
|
26
|
+
},
|
|
27
|
+
'x-component': 'CollectionFieldset',
|
|
28
|
+
description: `{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${NAMESPACE}" })}}`,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const filter = {
|
|
32
|
+
type: 'object',
|
|
33
|
+
title: '{{t("Filter")}}',
|
|
34
|
+
'x-decorator': 'FormItem',
|
|
35
|
+
'x-component': 'Filter',
|
|
36
|
+
'x-component-props': {
|
|
37
|
+
useProps() {
|
|
38
|
+
const { values } = useForm();
|
|
39
|
+
const options = useCollectionFilterOptions(values?.collection);
|
|
40
|
+
return {
|
|
41
|
+
options,
|
|
42
|
+
className: css`
|
|
43
|
+
position: relative;
|
|
44
|
+
width: 100%;
|
|
45
|
+
`,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
dynamicComponent: 'FilterDynamicComponent',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const appends = {
|
|
53
|
+
type: 'array',
|
|
54
|
+
title: `{{t("Preload associations", { ns: "${NAMESPACE}" })}}`,
|
|
55
|
+
description: `{{t("Please select the associated fields that need to be accessed in subsequent nodes", { ns: "${NAMESPACE}" })}}`,
|
|
56
|
+
'x-decorator': 'FormItem',
|
|
57
|
+
'x-component': 'FieldsSelect',
|
|
58
|
+
'x-component-props': {
|
|
59
|
+
mode: 'multiple',
|
|
60
|
+
placeholder: '{{t("Select field")}}',
|
|
61
|
+
filter(field) {
|
|
62
|
+
return ['linkTo', 'belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
'x-reactions': [
|
|
66
|
+
{
|
|
67
|
+
dependencies: ['collection'],
|
|
68
|
+
fulfill: {
|
|
69
|
+
state: {
|
|
70
|
+
visible: '{{!!$deps[0]}}',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ISchema } from '@formily/react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { useActionContext } from '@nocobase/client';
|
|
5
|
+
import { ExecutionStatusOptions } from '../constants';
|
|
6
|
+
import { NAMESPACE } from '../locale';
|
|
7
|
+
|
|
8
|
+
export const executionCollection = {
|
|
9
|
+
name: 'executions',
|
|
10
|
+
fields: [
|
|
11
|
+
{
|
|
12
|
+
interface: 'createdAt',
|
|
13
|
+
type: 'datetime',
|
|
14
|
+
// field: 'createdAt',
|
|
15
|
+
name: 'createdAt',
|
|
16
|
+
uiSchema: {
|
|
17
|
+
type: 'datetime',
|
|
18
|
+
title: `{{t("Triggered at", { ns: "${NAMESPACE}" })}}`,
|
|
19
|
+
'x-component': 'DatePicker',
|
|
20
|
+
'x-component-props': {},
|
|
21
|
+
'x-read-pretty': true,
|
|
22
|
+
} as ISchema,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
interface: 'm2o',
|
|
26
|
+
type: 'belongsTo',
|
|
27
|
+
name: 'workflowId',
|
|
28
|
+
uiSchema: {
|
|
29
|
+
type: 'number',
|
|
30
|
+
title: `{{t("Version", { ns: "${NAMESPACE}" })}}`,
|
|
31
|
+
['x-component']({ value }) {
|
|
32
|
+
const { setVisible } = useActionContext();
|
|
33
|
+
return (
|
|
34
|
+
<Link
|
|
35
|
+
to={`/admin/settings/workflow/workflows/${value}`}
|
|
36
|
+
onClick={() => setVisible(false)}
|
|
37
|
+
>{`#${value}`}</Link>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
} as ISchema,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'number',
|
|
44
|
+
name: 'status',
|
|
45
|
+
interface: 'select',
|
|
46
|
+
uiSchema: {
|
|
47
|
+
title: `{{t("Status", { ns: "${NAMESPACE}" })}}`,
|
|
48
|
+
type: 'string',
|
|
49
|
+
'x-component': 'Select',
|
|
50
|
+
'x-decorator': 'FormItem',
|
|
51
|
+
enum: ExecutionStatusOptions,
|
|
52
|
+
} as ISchema,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const executionSchema = {
|
|
58
|
+
type: 'void',
|
|
59
|
+
name: 'executionHistoryDrawer',
|
|
60
|
+
title: `{{t("Execution history", { ns: "${NAMESPACE}" })}}`,
|
|
61
|
+
'x-component': 'Action.Drawer',
|
|
62
|
+
properties: {
|
|
63
|
+
content: {
|
|
64
|
+
type: 'void',
|
|
65
|
+
'x-decorator': 'ExecutionResourceProvider',
|
|
66
|
+
'x-decorator-props': {
|
|
67
|
+
collection: executionCollection,
|
|
68
|
+
resourceName: 'executions',
|
|
69
|
+
request: {
|
|
70
|
+
resource: 'executions',
|
|
71
|
+
action: 'list',
|
|
72
|
+
params: {
|
|
73
|
+
appends: ['workflow.id', 'workflow.title'],
|
|
74
|
+
pageSize: 20,
|
|
75
|
+
sort: ['-createdAt'],
|
|
76
|
+
filter: {},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
properties: {
|
|
81
|
+
actions: {
|
|
82
|
+
type: 'void',
|
|
83
|
+
'x-component': 'ActionBar',
|
|
84
|
+
'x-component-props': {
|
|
85
|
+
style: {
|
|
86
|
+
marginBottom: 16,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
properties: {
|
|
90
|
+
// filter: {
|
|
91
|
+
// type: 'object',
|
|
92
|
+
// 'x-component': 'Filter',
|
|
93
|
+
// }
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
table: {
|
|
97
|
+
type: 'void',
|
|
98
|
+
'x-component': 'Table.Void',
|
|
99
|
+
'x-component-props': {
|
|
100
|
+
rowKey: 'id',
|
|
101
|
+
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
|
102
|
+
},
|
|
103
|
+
properties: {
|
|
104
|
+
createdAt: {
|
|
105
|
+
type: 'void',
|
|
106
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
107
|
+
'x-component': 'Table.Column',
|
|
108
|
+
properties: {
|
|
109
|
+
createdAt: {
|
|
110
|
+
type: 'datetime',
|
|
111
|
+
'x-component': 'CollectionField',
|
|
112
|
+
'x-component-props': {
|
|
113
|
+
showTime: true,
|
|
114
|
+
},
|
|
115
|
+
'x-read-pretty': true,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
workflowId: {
|
|
120
|
+
type: 'void',
|
|
121
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
122
|
+
'x-component': 'Table.Column',
|
|
123
|
+
properties: {
|
|
124
|
+
workflowId: {
|
|
125
|
+
type: 'number',
|
|
126
|
+
'x-component': 'CollectionField',
|
|
127
|
+
'x-read-pretty': true,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
status: {
|
|
132
|
+
type: 'void',
|
|
133
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
134
|
+
'x-component': 'Table.Column',
|
|
135
|
+
properties: {
|
|
136
|
+
status: {
|
|
137
|
+
type: 'number',
|
|
138
|
+
'x-component': 'CollectionField',
|
|
139
|
+
'x-read-pretty': true,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
actions: {
|
|
144
|
+
type: 'void',
|
|
145
|
+
title: '{{ t("Actions") }}',
|
|
146
|
+
'x-component': 'Table.Column',
|
|
147
|
+
properties: {
|
|
148
|
+
actions: {
|
|
149
|
+
type: 'void',
|
|
150
|
+
'x-component': 'Space',
|
|
151
|
+
'x-component-props': {
|
|
152
|
+
split: '|',
|
|
153
|
+
},
|
|
154
|
+
properties: {
|
|
155
|
+
config: {
|
|
156
|
+
type: 'void',
|
|
157
|
+
title: `{{t("Details", { ns: "${NAMESPACE}" })}}`,
|
|
158
|
+
'x-component': 'ExecutionLink',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { ISchema } from '@formily/react';
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useRecord, useResourceActionContext, useResourceContext } from '@nocobase/client';
|
|
5
|
+
import { NAMESPACE } from '../locale';
|
|
6
|
+
import { triggers } from '../triggers';
|
|
7
|
+
import { executionSchema } from './executions';
|
|
8
|
+
|
|
9
|
+
const collection = {
|
|
10
|
+
name: 'workflows',
|
|
11
|
+
fields: [
|
|
12
|
+
{
|
|
13
|
+
type: 'string',
|
|
14
|
+
name: 'title',
|
|
15
|
+
interface: 'input',
|
|
16
|
+
uiSchema: {
|
|
17
|
+
title: '{{t("Name")}}',
|
|
18
|
+
type: 'string',
|
|
19
|
+
'x-component': 'Input',
|
|
20
|
+
required: true,
|
|
21
|
+
} as ISchema,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'string',
|
|
25
|
+
name: 'type',
|
|
26
|
+
interface: 'select',
|
|
27
|
+
uiSchema: {
|
|
28
|
+
title: `{{t("Trigger type", { ns: "${NAMESPACE}" })}}`,
|
|
29
|
+
type: 'string',
|
|
30
|
+
'x-component': 'Select',
|
|
31
|
+
'x-decorator': 'FormItem',
|
|
32
|
+
enum: Array.from(triggers.getEntities()).map(([value, { title }]) => ({
|
|
33
|
+
value,
|
|
34
|
+
label: title,
|
|
35
|
+
color: 'gold',
|
|
36
|
+
})),
|
|
37
|
+
required: true,
|
|
38
|
+
} as ISchema,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'string',
|
|
42
|
+
name: 'description',
|
|
43
|
+
interface: 'textarea',
|
|
44
|
+
uiSchema: {
|
|
45
|
+
title: '{{t("Description")}}',
|
|
46
|
+
type: 'string',
|
|
47
|
+
'x-component': 'Input.TextArea',
|
|
48
|
+
} as ISchema,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
name: 'enabled',
|
|
53
|
+
interface: 'radio',
|
|
54
|
+
uiSchema: {
|
|
55
|
+
title: `{{t("Status", { ns: "${NAMESPACE}" })}}`,
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: [
|
|
58
|
+
{ label: `{{t("On", { ns: "${NAMESPACE}" })}}`, value: true, color: '#52c41a' },
|
|
59
|
+
{ label: `{{t("Off", { ns: "${NAMESPACE}" })}}`, value: false },
|
|
60
|
+
],
|
|
61
|
+
'x-component': 'Radio.Group',
|
|
62
|
+
'x-decorator': 'FormItem',
|
|
63
|
+
default: false,
|
|
64
|
+
} as ISchema,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'number',
|
|
68
|
+
name: 'allExecuted',
|
|
69
|
+
interface: 'integer',
|
|
70
|
+
uiSchema: {
|
|
71
|
+
title: `{{t("Executed", { ns: "${NAMESPACE}" })}}`,
|
|
72
|
+
type: 'number',
|
|
73
|
+
'x-component': 'InputNumber',
|
|
74
|
+
'x-decorator': 'FormItem',
|
|
75
|
+
} as ISchema,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const workflowSchema: ISchema = {
|
|
81
|
+
type: 'void',
|
|
82
|
+
properties: {
|
|
83
|
+
provider: {
|
|
84
|
+
type: 'void',
|
|
85
|
+
'x-decorator': 'ResourceActionProvider',
|
|
86
|
+
'x-decorator-props': {
|
|
87
|
+
collection,
|
|
88
|
+
resourceName: 'workflows',
|
|
89
|
+
request: {
|
|
90
|
+
resource: 'workflows',
|
|
91
|
+
action: 'list',
|
|
92
|
+
params: {
|
|
93
|
+
pageSize: 20,
|
|
94
|
+
filter: {
|
|
95
|
+
current: true,
|
|
96
|
+
},
|
|
97
|
+
sort: ['-createdAt'],
|
|
98
|
+
except: ['config'],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
'x-component': 'CollectionProvider',
|
|
103
|
+
'x-component-props': {
|
|
104
|
+
collection,
|
|
105
|
+
},
|
|
106
|
+
properties: {
|
|
107
|
+
actions: {
|
|
108
|
+
type: 'void',
|
|
109
|
+
'x-component': 'ActionBar',
|
|
110
|
+
'x-component-props': {
|
|
111
|
+
style: {
|
|
112
|
+
marginBottom: 16,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
properties: {
|
|
116
|
+
delete: {
|
|
117
|
+
type: 'void',
|
|
118
|
+
title: '{{t("Delete")}}',
|
|
119
|
+
'x-component': 'Action',
|
|
120
|
+
'x-component-props': {
|
|
121
|
+
useAction: '{{ cm.useBulkDestroyAction }}',
|
|
122
|
+
confirm: {
|
|
123
|
+
title: "{{t('Delete record')}}",
|
|
124
|
+
content: "{{t('Are you sure you want to delete it?')}}",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
create: {
|
|
129
|
+
type: 'void',
|
|
130
|
+
title: '{{t("Add new")}}',
|
|
131
|
+
'x-component': 'Action',
|
|
132
|
+
'x-component-props': {
|
|
133
|
+
type: 'primary',
|
|
134
|
+
},
|
|
135
|
+
properties: {
|
|
136
|
+
drawer: {
|
|
137
|
+
type: 'void',
|
|
138
|
+
'x-component': 'Action.Drawer',
|
|
139
|
+
'x-decorator': 'Form',
|
|
140
|
+
'x-decorator-props': {
|
|
141
|
+
initialValue: {
|
|
142
|
+
current: true,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
title: '{{t("Add new")}}',
|
|
146
|
+
properties: {
|
|
147
|
+
title: {
|
|
148
|
+
'x-component': 'CollectionField',
|
|
149
|
+
'x-decorator': 'FormItem',
|
|
150
|
+
},
|
|
151
|
+
type: {
|
|
152
|
+
'x-component': 'CollectionField',
|
|
153
|
+
'x-decorator': 'FormItem',
|
|
154
|
+
},
|
|
155
|
+
description: {
|
|
156
|
+
'x-component': 'CollectionField',
|
|
157
|
+
'x-decorator': 'FormItem',
|
|
158
|
+
},
|
|
159
|
+
footer: {
|
|
160
|
+
type: 'void',
|
|
161
|
+
'x-component': 'Action.Drawer.Footer',
|
|
162
|
+
properties: {
|
|
163
|
+
cancel: {
|
|
164
|
+
title: '{{ t("Cancel") }}',
|
|
165
|
+
'x-component': 'Action',
|
|
166
|
+
'x-component-props': {
|
|
167
|
+
useAction: '{{ cm.useCancelAction }}',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
submit: {
|
|
171
|
+
title: '{{ t("Submit") }}',
|
|
172
|
+
'x-component': 'Action',
|
|
173
|
+
'x-component-props': {
|
|
174
|
+
type: 'primary',
|
|
175
|
+
useAction: '{{ cm.useCreateAction }}',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
table: {
|
|
187
|
+
type: 'void',
|
|
188
|
+
'x-component': 'Table.Void',
|
|
189
|
+
'x-component-props': {
|
|
190
|
+
rowKey: 'id',
|
|
191
|
+
rowSelection: {
|
|
192
|
+
type: 'checkbox',
|
|
193
|
+
},
|
|
194
|
+
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
|
195
|
+
},
|
|
196
|
+
properties: {
|
|
197
|
+
title: {
|
|
198
|
+
type: 'void',
|
|
199
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
200
|
+
'x-component': 'Table.Column',
|
|
201
|
+
properties: {
|
|
202
|
+
title: {
|
|
203
|
+
type: 'string',
|
|
204
|
+
'x-component': 'CollectionField',
|
|
205
|
+
'x-read-pretty': true,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
type: {
|
|
210
|
+
type: 'void',
|
|
211
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
212
|
+
'x-component': 'Table.Column',
|
|
213
|
+
properties: {
|
|
214
|
+
type: {
|
|
215
|
+
type: 'string',
|
|
216
|
+
'x-component': 'CollectionField',
|
|
217
|
+
'x-read-pretty': true,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
enabled: {
|
|
222
|
+
type: 'void',
|
|
223
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
224
|
+
'x-component': 'Table.Column',
|
|
225
|
+
properties: {
|
|
226
|
+
enabled: {
|
|
227
|
+
type: 'boolean',
|
|
228
|
+
'x-component': 'CollectionField',
|
|
229
|
+
'x-read-pretty': true,
|
|
230
|
+
default: false,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
allExecuted: {
|
|
235
|
+
type: 'void',
|
|
236
|
+
'x-decorator': 'Table.Column.Decorator',
|
|
237
|
+
'x-component': 'Table.Column',
|
|
238
|
+
properties: {
|
|
239
|
+
allExecuted: {
|
|
240
|
+
type: 'number',
|
|
241
|
+
'x-decorator': 'OpenDrawer',
|
|
242
|
+
'x-decorator-props': {
|
|
243
|
+
component: 'a',
|
|
244
|
+
},
|
|
245
|
+
'x-component': 'CollectionField',
|
|
246
|
+
'x-read-pretty': true,
|
|
247
|
+
properties: {
|
|
248
|
+
drawer: executionSchema,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
actions: {
|
|
254
|
+
type: 'void',
|
|
255
|
+
title: '{{ t("Actions") }}',
|
|
256
|
+
'x-component': 'Table.Column',
|
|
257
|
+
properties: {
|
|
258
|
+
actions: {
|
|
259
|
+
type: 'void',
|
|
260
|
+
'x-component': 'Space',
|
|
261
|
+
'x-component-props': {
|
|
262
|
+
split: '|',
|
|
263
|
+
},
|
|
264
|
+
properties: {
|
|
265
|
+
config: {
|
|
266
|
+
type: 'void',
|
|
267
|
+
'x-component': 'WorkflowLink',
|
|
268
|
+
},
|
|
269
|
+
update: {
|
|
270
|
+
type: 'void',
|
|
271
|
+
title: '{{ t("Edit") }}',
|
|
272
|
+
'x-component': 'Action.Link',
|
|
273
|
+
'x-component-props': {
|
|
274
|
+
type: 'primary',
|
|
275
|
+
},
|
|
276
|
+
properties: {
|
|
277
|
+
drawer: {
|
|
278
|
+
type: 'void',
|
|
279
|
+
'x-component': 'Action.Drawer',
|
|
280
|
+
'x-decorator': 'Form',
|
|
281
|
+
'x-decorator-props': {
|
|
282
|
+
useValues: '{{ cm.useValuesFromRecord }}',
|
|
283
|
+
},
|
|
284
|
+
title: '{{ t("Edit") }}',
|
|
285
|
+
properties: {
|
|
286
|
+
title: {
|
|
287
|
+
'x-component': 'CollectionField',
|
|
288
|
+
'x-decorator': 'FormItem',
|
|
289
|
+
},
|
|
290
|
+
enabled: {
|
|
291
|
+
'x-component': 'CollectionField',
|
|
292
|
+
'x-decorator': 'FormItem',
|
|
293
|
+
},
|
|
294
|
+
description: {
|
|
295
|
+
'x-component': 'CollectionField',
|
|
296
|
+
'x-decorator': 'FormItem',
|
|
297
|
+
},
|
|
298
|
+
footer: {
|
|
299
|
+
type: 'void',
|
|
300
|
+
'x-component': 'Action.Drawer.Footer',
|
|
301
|
+
properties: {
|
|
302
|
+
cancel: {
|
|
303
|
+
title: '{{ t("Cancel") }}',
|
|
304
|
+
'x-component': 'Action',
|
|
305
|
+
'x-component-props': {
|
|
306
|
+
useAction: '{{ cm.useCancelAction }}',
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
submit: {
|
|
310
|
+
title: '{{ t("Submit") }}',
|
|
311
|
+
'x-component': 'Action',
|
|
312
|
+
'x-component-props': {
|
|
313
|
+
type: 'primary',
|
|
314
|
+
useAction: '{{ cm.useUpdateAction }}',
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
revision: {
|
|
324
|
+
type: 'void',
|
|
325
|
+
title: `{{t("Duplicate", { ns: "${NAMESPACE}" })}}`,
|
|
326
|
+
'x-component': 'Action.Link',
|
|
327
|
+
'x-component-props': {
|
|
328
|
+
useAction() {
|
|
329
|
+
const { t } = useTranslation();
|
|
330
|
+
const { refresh } = useResourceActionContext();
|
|
331
|
+
const { resource, targetKey } = useResourceContext();
|
|
332
|
+
const { [targetKey]: filterByTk } = useRecord();
|
|
333
|
+
return {
|
|
334
|
+
async run() {
|
|
335
|
+
await resource.revision({ filterByTk });
|
|
336
|
+
message.success(t('Operation succeeded'));
|
|
337
|
+
refresh();
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
// delete: {
|
|
344
|
+
// type: 'void',
|
|
345
|
+
// title: '{{ t("Delete") }}',
|
|
346
|
+
// 'x-component': 'Action.Link',
|
|
347
|
+
// 'x-component-props': {
|
|
348
|
+
// confirm: {
|
|
349
|
+
// title: "{{t('Delete record')}}",
|
|
350
|
+
// content: "{{t('Are you sure you want to delete it?')}}",
|
|
351
|
+
// },
|
|
352
|
+
// useAction: '{{ cm.useDestroyActionAndRefreshCM }}',
|
|
353
|
+
// },
|
|
354
|
+
// },
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
};
|