@nocobase/plugin-workflow-action-trigger 0.20.0-alpha.6
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/LICENSE +661 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/ActionTrigger.d.ts +54 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +1 -0
- package/dist/externalVersion.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +9 -0
- package/dist/locale/index.d.ts +3 -0
- package/dist/locale/index.js +39 -0
- package/dist/locale/ko_KR.json +9 -0
- package/dist/locale/zh-CN.json +10 -0
- package/dist/server/ActionTrigger.d.ts +9 -0
- package/dist/server/ActionTrigger.js +130 -0
- package/dist/server/Plugin.d.ts +4 -0
- package/dist/server/Plugin.js +41 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/migrations/20240227172623-change-name.d.ts +6 -0
- package/dist/server/migrations/20240227172623-change-name.js +42 -0
- package/package.json +28 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/ActionTrigger.tsx +132 -0
- package/src/client/__e2e__/configuration.test.ts +661 -0
- package/src/client/__e2e__/workflowCRUD.test.ts +178 -0
- package/src/client/index.ts +100 -0
- package/src/index.ts +2 -0
- package/src/locale/en-US.json +9 -0
- package/src/locale/index.ts +12 -0
- package/src/locale/ko_KR.json +9 -0
- package/src/locale/zh-CN.json +10 -0
- package/src/server/ActionTrigger.ts +132 -0
- package/src/server/Plugin.ts +11 -0
- package/src/server/__tests__/trigger.test.ts +503 -0
- package/src/server/index.ts +1 -0
- package/src/server/migrations/20240227172623-change-name.ts +22 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useForm } from '@formily/react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
SchemaInitializerItemType,
|
|
5
|
+
useCollectionDataSource,
|
|
6
|
+
useCollectionManager_deprecated,
|
|
7
|
+
useCompile,
|
|
8
|
+
} from '@nocobase/client';
|
|
9
|
+
import { Trigger, CollectionBlockInitializer, getCollectionFieldOptions } from '@nocobase/plugin-workflow/client';
|
|
10
|
+
import { NAMESPACE, useLang } from '../locale';
|
|
11
|
+
|
|
12
|
+
export default class extends Trigger {
|
|
13
|
+
title = `{{t("Action event", { ns: "${NAMESPACE}" })}}`;
|
|
14
|
+
description = `{{t("Triggers after specific operations on data are submitted, such as create, update, delete, etc., or directly submitting a record to the workflow.", { ns: "${NAMESPACE}" })}}`;
|
|
15
|
+
fieldset = {
|
|
16
|
+
collection: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true,
|
|
19
|
+
'x-decorator': 'FormItem',
|
|
20
|
+
'x-component': 'CollectionSelect',
|
|
21
|
+
'x-component-props': {
|
|
22
|
+
className: 'auto-width',
|
|
23
|
+
},
|
|
24
|
+
title: `{{t("Collection", { ns: "${NAMESPACE}" })}}`,
|
|
25
|
+
description: `{{t("Which collection record belongs to.", { ns: "${NAMESPACE}" })}}`,
|
|
26
|
+
'x-reactions': [
|
|
27
|
+
{
|
|
28
|
+
target: 'appends',
|
|
29
|
+
effects: ['onFieldValueChange'],
|
|
30
|
+
fulfill: {
|
|
31
|
+
state: {
|
|
32
|
+
value: [],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
appends: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
title: `{{t("Associations to use", { ns: "${NAMESPACE}" })}}`,
|
|
41
|
+
description: `{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "workflow" })}}`,
|
|
42
|
+
'x-decorator': 'FormItem',
|
|
43
|
+
'x-component': 'AppendsTreeSelect',
|
|
44
|
+
'x-component-props': {
|
|
45
|
+
title: 'Preload associations',
|
|
46
|
+
multiple: true,
|
|
47
|
+
useCollection() {
|
|
48
|
+
const { values } = useForm();
|
|
49
|
+
return values?.collection;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
'x-reactions': [
|
|
53
|
+
{
|
|
54
|
+
dependencies: ['collection'],
|
|
55
|
+
fulfill: {
|
|
56
|
+
state: {
|
|
57
|
+
visible: '{{!!$deps[0]}}',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
scope = {
|
|
65
|
+
useCollectionDataSource,
|
|
66
|
+
};
|
|
67
|
+
isActionTriggerable = (config, context) => {
|
|
68
|
+
return ['create', 'update', 'customize:update', 'customize:triggerWorkflows'].includes(context.action);
|
|
69
|
+
};
|
|
70
|
+
useVariables(config, options) {
|
|
71
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
72
|
+
const compile = useCompile();
|
|
73
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
74
|
+
const { getCollectionFields } = useCollectionManager_deprecated();
|
|
75
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
76
|
+
const langTriggerData = useLang('Trigger data');
|
|
77
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
78
|
+
const langUserSubmittedForm = useLang('User submitted action');
|
|
79
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
80
|
+
const langRoleSubmittedForm = useLang('Role of user submitted action');
|
|
81
|
+
const rootFields = [
|
|
82
|
+
{
|
|
83
|
+
collectionName: config.collection,
|
|
84
|
+
name: 'data',
|
|
85
|
+
type: 'hasOne',
|
|
86
|
+
target: config.collection,
|
|
87
|
+
uiSchema: {
|
|
88
|
+
title: langTriggerData,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
collectionName: 'users',
|
|
93
|
+
name: 'user',
|
|
94
|
+
type: 'hasOne',
|
|
95
|
+
target: 'users',
|
|
96
|
+
uiSchema: {
|
|
97
|
+
title: langUserSubmittedForm,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'roleName',
|
|
102
|
+
uiSchema: {
|
|
103
|
+
title: langRoleSubmittedForm,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
const result = getCollectionFieldOptions({
|
|
108
|
+
// depth,
|
|
109
|
+
appends: ['data', 'user', ...(config.appends?.map((item) => `data.${item}`) || [])],
|
|
110
|
+
...options,
|
|
111
|
+
fields: rootFields,
|
|
112
|
+
compile,
|
|
113
|
+
getCollectionFields,
|
|
114
|
+
});
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
useInitializers(config): SchemaInitializerItemType | null {
|
|
118
|
+
if (!config.collection) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
name: 'triggerData',
|
|
124
|
+
type: 'item',
|
|
125
|
+
key: 'triggerData',
|
|
126
|
+
title: `{{t("Trigger data", { ns: "${NAMESPACE}" })}}`,
|
|
127
|
+
Component: CollectionBlockInitializer,
|
|
128
|
+
collection: config.collection,
|
|
129
|
+
dataSource: '{{$context.data}}',
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|