@nocobase/plugin-workflow 0.8.0-alpha.9 → 0.8.1-alpha.4

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.
Files changed (95) hide show
  1. package/lib/client/AddButton.js +21 -13
  2. package/lib/client/ExecutionCanvas.js +9 -21
  3. package/lib/client/ExecutionResourceProvider.d.ts +2 -1
  4. package/lib/client/ExecutionResourceProvider.js +4 -3
  5. package/lib/client/FlowContext.js +1 -1
  6. package/lib/client/WorkflowCanvas.js +135 -36
  7. package/lib/client/WorkflowProvider.d.ts +3 -0
  8. package/lib/client/WorkflowProvider.js +71 -16
  9. package/lib/client/WorkflowShortcut.d.ts +0 -1
  10. package/lib/client/WorkflowShortcut.js +4 -47
  11. package/lib/client/calculators.d.ts +27 -37
  12. package/lib/client/calculators.js +168 -150
  13. package/lib/client/components/CollectionFieldset.js +10 -20
  14. package/lib/client/components/Duration.js +3 -14
  15. package/lib/client/components/EjsTextArea.d.ts +2 -0
  16. package/lib/client/components/EjsTextArea.js +232 -0
  17. package/lib/client/components/OpenDrawer.d.ts +6 -0
  18. package/lib/client/components/OpenDrawer.js +93 -0
  19. package/lib/client/constants.js +11 -9
  20. package/lib/client/index.d.ts +1 -0
  21. package/lib/client/index.js +14 -0
  22. package/lib/client/locale/en-US.d.ts +105 -0
  23. package/lib/client/locale/en-US.js +111 -0
  24. package/lib/client/locale/index.d.ts +3 -0
  25. package/lib/client/locale/index.js +69 -0
  26. package/lib/client/locale/ja-JP.d.ts +88 -0
  27. package/lib/client/locale/ja-JP.js +94 -0
  28. package/lib/client/locale/ru-RU.d.ts +88 -0
  29. package/lib/client/locale/ru-RU.js +94 -0
  30. package/lib/client/locale/tr-TR.d.ts +88 -0
  31. package/lib/client/locale/tr-TR.js +94 -0
  32. package/lib/client/locale/zh-CN.d.ts +130 -0
  33. package/lib/client/locale/zh-CN.js +136 -0
  34. package/lib/client/nodes/calculation.d.ts +0 -1
  35. package/lib/client/nodes/calculation.js +9 -17
  36. package/lib/client/nodes/condition.js +16 -22
  37. package/lib/client/nodes/create.d.ts +3 -1
  38. package/lib/client/nodes/create.js +11 -11
  39. package/lib/client/nodes/delay.js +8 -6
  40. package/lib/client/nodes/index.js +46 -14
  41. package/lib/client/nodes/parallel.d.ts +0 -1
  42. package/lib/client/nodes/parallel.js +11 -32
  43. package/lib/client/nodes/query.js +9 -17
  44. package/lib/client/nodes/request.d.ts +138 -0
  45. package/lib/client/nodes/request.js +167 -0
  46. package/lib/client/nodes/update.js +4 -2
  47. package/lib/client/schemas/collection.js +3 -1
  48. package/lib/client/schemas/executions.d.ts +211 -207
  49. package/lib/client/schemas/executions.js +102 -96
  50. package/lib/client/schemas/workflows.js +112 -22
  51. package/lib/client/style.js +7 -7
  52. package/lib/client/triggers/collection.d.ts +2 -1
  53. package/lib/client/triggers/collection.js +49 -34
  54. package/lib/client/triggers/index.d.ts +3 -3
  55. package/lib/client/triggers/index.js +46 -46
  56. package/lib/client/triggers/schedule/EndsByField.js +13 -39
  57. package/lib/client/triggers/schedule/OnField.js +10 -5
  58. package/lib/client/triggers/schedule/RepeatField.js +6 -14
  59. package/lib/client/triggers/schedule/ScheduleConfig.js +25 -20
  60. package/lib/client/triggers/schedule/constants.d.ts +4 -0
  61. package/lib/client/triggers/schedule/constants.js +11 -0
  62. package/lib/client/triggers/schedule/index.d.ts +2 -3
  63. package/lib/client/triggers/schedule/index.js +55 -40
  64. package/lib/server/Plugin.d.ts +15 -5
  65. package/lib/server/Plugin.js +176 -61
  66. package/lib/server/Processor.d.ts +1 -2
  67. package/lib/server/Processor.js +3 -19
  68. package/lib/server/actions/jobs.js +2 -3
  69. package/lib/server/actions/workflows.js +13 -5
  70. package/lib/server/calculators/index.d.ts +4 -2
  71. package/lib/server/calculators/index.js +6 -4
  72. package/lib/server/collections/executions.js +2 -1
  73. package/lib/server/constants.d.ts +1 -0
  74. package/lib/server/constants.js +1 -0
  75. package/lib/server/extensions/assignees/actions.js +2 -3
  76. package/lib/server/extensions/assignees/collections/users_jobs.js +9 -1
  77. package/lib/server/index.d.ts +3 -4
  78. package/lib/server/index.js +21 -44
  79. package/lib/server/instructions/condition.js +1 -1
  80. package/lib/server/instructions/create.js +3 -1
  81. package/lib/server/instructions/delay.js +2 -3
  82. package/lib/server/instructions/destroy.js +3 -1
  83. package/lib/server/instructions/index.d.ts +3 -2
  84. package/lib/server/instructions/index.js +1 -1
  85. package/lib/server/instructions/prompt.js +2 -1
  86. package/lib/server/instructions/query.js +3 -1
  87. package/lib/server/instructions/request.d.ts +14 -0
  88. package/lib/server/instructions/request.js +154 -0
  89. package/lib/server/instructions/update.d.ts +1 -1
  90. package/lib/server/instructions/update.js +3 -1
  91. package/lib/server/migrations/20221129153547-calculation-variables.d.ts +5 -0
  92. package/lib/server/migrations/20221129153547-calculation-variables.js +116 -0
  93. package/lib/server/triggers/collection.js +5 -7
  94. package/lib/server/triggers/schedule.js +17 -6
  95. package/package.json +13 -8
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.executionSchema = void 0;
6
+ exports.executionSchema = exports.executionCollection = void 0;
7
7
 
8
8
  function _react() {
9
9
  const data = _interopRequireDefault(require("react"));
@@ -37,9 +37,11 @@ function _client() {
37
37
 
38
38
  var _constants = require("../constants");
39
39
 
40
+ var _locale = require("../locale");
41
+
40
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
43
 
42
- const collection = {
44
+ const executionCollection = {
43
45
  name: 'executions',
44
46
  fields: [{
45
47
  interface: 'createdAt',
@@ -48,7 +50,7 @@ const collection = {
48
50
  name: 'createdAt',
49
51
  uiSchema: {
50
52
  type: 'datetime',
51
- title: '{{t("Triggered at")}}',
53
+ title: `{{t("Triggered at", { ns: "${_locale.NAMESPACE}" })}}`,
52
54
  'x-component': 'DatePicker',
53
55
  'x-component-props': {},
54
56
  'x-read-pretty': true
@@ -59,7 +61,7 @@ const collection = {
59
61
  name: 'workflowId',
60
62
  uiSchema: {
61
63
  type: 'number',
62
- title: '{{t("Version")}}',
64
+ title: `{{t("Version", { ns: "${_locale.NAMESPACE}" })}}`,
63
65
 
64
66
  ['x-component']({
65
67
  value
@@ -79,7 +81,7 @@ const collection = {
79
81
  name: 'status',
80
82
  interface: 'select',
81
83
  uiSchema: {
82
- title: '{{t("Status")}}',
84
+ title: `{{t("Status", { ns: "${_locale.NAMESPACE}" })}}`,
83
85
  type: 'string',
84
86
  'x-component': 'Select',
85
87
  'x-decorator': 'FormItem',
@@ -87,105 +89,109 @@ const collection = {
87
89
  }
88
90
  }]
89
91
  };
92
+ exports.executionCollection = executionCollection;
90
93
  const executionSchema = {
91
- provider: {
92
- type: 'void',
93
- 'x-decorator': 'ExecutionResourceProvider',
94
- 'x-decorator-props': {
95
- collection,
96
- resourceName: 'executions',
97
- request: {
98
- resource: 'executions',
99
- action: 'list',
100
- params: {
101
- appends: ['workflow.id', 'workflow.title'],
102
- pageSize: 50,
103
- sort: ['-createdAt']
104
- }
105
- }
106
- },
107
- 'x-component': 'CollectionProvider',
108
- 'x-component-props': {
109
- collection
110
- },
111
- properties: {
112
- actions: {
113
- type: 'void',
114
- 'x-component': 'ActionBar',
115
- 'x-component-props': {
116
- style: {
117
- marginBottom: 16
94
+ type: 'void',
95
+ name: 'executionHistoryDrawer',
96
+ title: `{{t("Execution history", { ns: "${_locale.NAMESPACE}" })}}`,
97
+ 'x-component': 'Action.Drawer',
98
+ properties: {
99
+ content: {
100
+ type: 'void',
101
+ 'x-decorator': 'ExecutionResourceProvider',
102
+ 'x-decorator-props': {
103
+ collection: executionCollection,
104
+ resourceName: 'executions',
105
+ request: {
106
+ resource: 'executions',
107
+ action: 'list',
108
+ params: {
109
+ appends: ['workflow.id', 'workflow.title'],
110
+ pageSize: 20,
111
+ sort: ['-createdAt'],
112
+ filter: {}
118
113
  }
119
- },
120
- properties: {// filter: {
121
- // type: 'object',
122
- // 'x-component': 'Filter',
123
- // }
124
114
  }
125
115
  },
126
- table: {
127
- type: 'void',
128
- 'x-component': 'Table.Void',
129
- 'x-component-props': {
130
- rowKey: 'id',
131
- useDataSource: '{{ cm.useDataSourceFromRAC }}'
132
- },
133
- properties: {
134
- createdAt: {
135
- type: 'void',
136
- 'x-decorator': 'Table.Column.Decorator',
137
- 'x-component': 'Table.Column',
138
- properties: {
139
- createdAt: {
140
- type: 'datetime',
141
- 'x-component': 'CollectionField',
142
- 'x-component-props': {
143
- showTime: true
144
- },
145
- 'x-read-pretty': true
146
- }
116
+ properties: {
117
+ actions: {
118
+ type: 'void',
119
+ 'x-component': 'ActionBar',
120
+ 'x-component-props': {
121
+ style: {
122
+ marginBottom: 16
147
123
  }
148
124
  },
149
- workflowId: {
150
- type: 'void',
151
- 'x-decorator': 'Table.Column.Decorator',
152
- 'x-component': 'Table.Column',
153
- properties: {
154
- workflowId: {
155
- type: 'number',
156
- 'x-component': 'CollectionField',
157
- 'x-read-pretty': true
158
- }
159
- }
125
+ properties: {// filter: {
126
+ // type: 'object',
127
+ // 'x-component': 'Filter',
128
+ // }
129
+ }
130
+ },
131
+ table: {
132
+ type: 'void',
133
+ 'x-component': 'Table.Void',
134
+ 'x-component-props': {
135
+ rowKey: 'id',
136
+ useDataSource: '{{ cm.useDataSourceFromRAC }}'
160
137
  },
161
- status: {
162
- type: 'void',
163
- 'x-decorator': 'Table.Column.Decorator',
164
- 'x-component': 'Table.Column',
165
- properties: {
166
- status: {
167
- type: 'number',
168
- 'x-component': 'CollectionField',
169
- 'x-read-pretty': true
138
+ properties: {
139
+ createdAt: {
140
+ type: 'void',
141
+ 'x-decorator': 'Table.Column.Decorator',
142
+ 'x-component': 'Table.Column',
143
+ properties: {
144
+ createdAt: {
145
+ type: 'datetime',
146
+ 'x-component': 'CollectionField',
147
+ 'x-component-props': {
148
+ showTime: true
149
+ },
150
+ 'x-read-pretty': true
151
+ }
170
152
  }
171
- }
172
- },
173
- actions: {
174
- type: 'void',
175
- title: '{{ t("Actions") }}',
176
- 'x-component': 'Table.Column',
177
- properties: {
178
- actions: {
179
- type: 'void',
180
- 'x-component': 'Space',
181
- 'x-component-props': {
182
- split: '|'
183
- },
184
- properties: {
185
- config: {
186
- type: 'void',
187
- title: '{{t("Details")}}',
188
- 'x-component': 'ExecutionLink'
153
+ },
154
+ workflowId: {
155
+ type: 'void',
156
+ 'x-decorator': 'Table.Column.Decorator',
157
+ 'x-component': 'Table.Column',
158
+ properties: {
159
+ workflowId: {
160
+ type: 'number',
161
+ 'x-component': 'CollectionField',
162
+ 'x-read-pretty': true
163
+ }
164
+ }
165
+ },
166
+ status: {
167
+ type: 'void',
168
+ 'x-decorator': 'Table.Column.Decorator',
169
+ 'x-component': 'Table.Column',
170
+ properties: {
171
+ status: {
172
+ type: 'number',
173
+ 'x-component': 'CollectionField',
174
+ 'x-read-pretty': true
175
+ }
176
+ }
177
+ },
178
+ actions: {
179
+ type: 'void',
180
+ title: '{{ t("Actions") }}',
181
+ 'x-component': 'Table.Column',
182
+ properties: {
183
+ actions: {
184
+ type: 'void',
185
+ 'x-component': 'Space',
186
+ 'x-component-props': {
187
+ split: '|'
188
+ },
189
+ properties: {
190
+ config: {
191
+ type: 'void',
192
+ title: `{{t("Details", { ns: "${_locale.NAMESPACE}" })}}`,
193
+ 'x-component': 'ExecutionLink'
194
+ }
189
195
  }
190
196
  }
191
197
  }
@@ -5,10 +5,46 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.workflowSchema = void 0;
7
7
 
8
+ function _antd() {
9
+ const data = require("antd");
10
+
11
+ _antd = function _antd() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _reactI18next() {
19
+ const data = require("react-i18next");
20
+
21
+ _reactI18next = function _reactI18next() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _client() {
29
+ const data = require("@nocobase/client");
30
+
31
+ _client = function _client() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ var _locale = require("../locale");
39
+
8
40
  var _triggers = require("../triggers");
9
41
 
10
42
  var _executions = require("./executions");
11
43
 
44
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
45
+
46
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
47
+
12
48
  const collection = {
13
49
  name: 'workflows',
14
50
  fields: [{
@@ -26,7 +62,7 @@ const collection = {
26
62
  name: 'type',
27
63
  interface: 'select',
28
64
  uiSchema: {
29
- title: '{{t("Trigger type")}}',
65
+ title: `{{t("Trigger type", { ns: "${_locale.NAMESPACE}" })}}`,
30
66
  type: 'string',
31
67
  'x-component': 'Select',
32
68
  'x-decorator': 'FormItem',
@@ -53,20 +89,30 @@ const collection = {
53
89
  name: 'enabled',
54
90
  interface: 'radio',
55
91
  uiSchema: {
56
- title: '{{t("Status")}}',
92
+ title: `{{t("Status", { ns: "${_locale.NAMESPACE}" })}}`,
57
93
  type: 'string',
58
94
  enum: [{
59
- label: '{{t("On")}}',
95
+ label: `{{t("On", { ns: "${_locale.NAMESPACE}" })}}`,
60
96
  value: true,
61
97
  color: '#52c41a'
62
98
  }, {
63
- label: '{{t("Off")}}',
99
+ label: `{{t("Off", { ns: "${_locale.NAMESPACE}" })}}`,
64
100
  value: false
65
101
  }],
66
102
  'x-component': 'Radio.Group',
67
103
  'x-decorator': 'FormItem',
68
104
  default: false
69
105
  }
106
+ }, {
107
+ type: 'number',
108
+ name: 'allExecuted',
109
+ interface: 'integer',
110
+ uiSchema: {
111
+ title: `{{t("Executed", { ns: "${_locale.NAMESPACE}" })}}`,
112
+ type: 'number',
113
+ 'x-component': 'InputNumber',
114
+ 'x-decorator': 'FormItem'
115
+ }
70
116
  }]
71
117
  };
72
118
  const workflowSchema = {
@@ -82,11 +128,11 @@ const workflowSchema = {
82
128
  resource: 'workflows',
83
129
  action: 'list',
84
130
  params: {
85
- pageSize: 50,
131
+ pageSize: 20,
86
132
  filter: {
87
133
  current: true
88
134
  },
89
- sort: ['createdAt'],
135
+ sort: ['-enabled', '-createdAt'],
90
136
  except: ['config']
91
137
  }
92
138
  }
@@ -223,6 +269,25 @@ const workflowSchema = {
223
269
  }
224
270
  }
225
271
  },
272
+ allExecuted: {
273
+ type: 'void',
274
+ 'x-decorator': 'Table.Column.Decorator',
275
+ 'x-component': 'Table.Column',
276
+ properties: {
277
+ allExecuted: {
278
+ type: 'number',
279
+ 'x-decorator': 'OpenDrawer',
280
+ 'x-decorator-props': {
281
+ component: 'a'
282
+ },
283
+ 'x-component': 'CollectionField',
284
+ 'x-read-pretty': true,
285
+ properties: {
286
+ drawer: _executions.executionSchema
287
+ }
288
+ }
289
+ }
290
+ },
226
291
  actions: {
227
292
  type: 'void',
228
293
  title: '{{ t("Actions") }}',
@@ -239,22 +304,6 @@ const workflowSchema = {
239
304
  type: 'void',
240
305
  'x-component': 'WorkflowLink'
241
306
  },
242
- executions: {
243
- type: 'void',
244
- title: '{{t("Execution history")}}',
245
- 'x-component': 'Action.Link',
246
- 'x-component-props': {
247
- type: 'primary'
248
- },
249
- properties: {
250
- drawer: {
251
- type: 'void',
252
- title: '{{t("Execution history")}}',
253
- 'x-component': 'Action.Drawer',
254
- properties: _executions.executionSchema
255
- }
256
- }
257
- },
258
307
  update: {
259
308
  type: 'void',
260
309
  title: '{{ t("Edit") }}',
@@ -280,6 +329,10 @@ const workflowSchema = {
280
329
  'x-component': 'CollectionField',
281
330
  'x-decorator': 'FormItem'
282
331
  },
332
+ description: {
333
+ 'x-component': 'CollectionField',
334
+ 'x-decorator': 'FormItem'
335
+ },
283
336
  footer: {
284
337
  type: 'void',
285
338
  'x-component': 'Action.Modal.Footer',
@@ -304,6 +357,43 @@ const workflowSchema = {
304
357
  }
305
358
  }
306
359
  }
360
+ },
361
+ revision: {
362
+ type: 'void',
363
+ title: `{{t("Duplicate", { ns: "${_locale.NAMESPACE}" })}}`,
364
+ 'x-component': 'Action.Link',
365
+ 'x-component-props': {
366
+ useAction() {
367
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
368
+ t = _useTranslation.t;
369
+
370
+ const _useResourceActionCon = (0, _client().useResourceActionContext)(),
371
+ refresh = _useResourceActionCon.refresh;
372
+
373
+ const _useResourceContext = (0, _client().useResourceContext)(),
374
+ resource = _useResourceContext.resource,
375
+ targetKey = _useResourceContext.targetKey;
376
+
377
+ const _useRecord = (0, _client().useRecord)(),
378
+ filterByTk = _useRecord[targetKey];
379
+
380
+ return {
381
+ run() {
382
+ return _asyncToGenerator(function* () {
383
+ yield resource.revision({
384
+ filterByTk
385
+ });
386
+
387
+ _antd().message.success(t('Operation succeeded'));
388
+
389
+ refresh();
390
+ })();
391
+ }
392
+
393
+ };
394
+ }
395
+
396
+ }
307
397
  } // delete: {
308
398
  // type: 'void',
309
399
  // title: '{{ t("Delete") }}',
@@ -30,13 +30,7 @@ const workflowPageClass = (0, _css().css)`
30
30
  header{
31
31
  display: flex;
32
32
  align-items: center;
33
-
34
- > *:not(:last-child) {
35
- &:after{
36
- content: ">";
37
- margin: 0 .5em;
38
- }
39
- }
33
+ min-height: 2rem;
40
34
  }
41
35
 
42
36
  aside{
@@ -44,6 +38,12 @@ const workflowPageClass = (0, _css().css)`
44
38
  align-items: center;
45
39
  gap: .5em;
46
40
  }
41
+
42
+ .workflow-versions{
43
+ label{
44
+ margin-right: .5em;
45
+ }
46
+ }
47
47
  }
48
48
 
49
49
  .workflow-canvas{
@@ -31,8 +31,8 @@ declare const _default: {
31
31
  'x-component': string;
32
32
  'x-component-props': {
33
33
  options: {
34
- value: number;
35
34
  label: string;
35
+ value: number;
36
36
  }[];
37
37
  placeholder: string;
38
38
  };
@@ -83,6 +83,7 @@ declare const _default: {
83
83
  components: {
84
84
  FieldsSelect: React.MemoExoticComponent<React.FunctionComponent<unknown>>;
85
85
  };
86
+ getOptions(config: any): any[];
86
87
  getter(props: any): JSX.Element;
87
88
  };
88
89
  export default _default;
@@ -71,6 +71,10 @@ function _core() {
71
71
 
72
72
  var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
73
73
 
74
+ var _locale = require("../locale");
75
+
76
+ var _calculators = require("../calculators");
77
+
74
78
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75
79
 
76
80
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -112,8 +116,27 @@ const FieldsSelect = (0, _react2().observer)(props => {
112
116
  }, compile((_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title));
113
117
  }));
114
118
  });
119
+ const COLLECTION_TRIGGER_MODE = {
120
+ CREATED: 1,
121
+ UPDATED: 2,
122
+ SAVED: 3,
123
+ DELETED: 4
124
+ };
125
+ const collectionModeOptions = [{
126
+ label: `{{t("After record added", { ns: "${_locale.NAMESPACE}" })}}`,
127
+ value: COLLECTION_TRIGGER_MODE.CREATED
128
+ }, {
129
+ label: `{{t("After record updated", { ns: "${_locale.NAMESPACE}" })}}`,
130
+ value: COLLECTION_TRIGGER_MODE.UPDATED
131
+ }, {
132
+ label: `{{t("After record added or updated", { ns: "${_locale.NAMESPACE}" })}}`,
133
+ value: COLLECTION_TRIGGER_MODE.SAVED
134
+ }, {
135
+ label: `{{t("After record deleted", { ns: "${_locale.NAMESPACE}" })}}`,
136
+ value: COLLECTION_TRIGGER_MODE.DELETED
137
+ }];
115
138
  var _default = {
116
- title: '{{t("Collection event")}}',
139
+ title: `{{t("Collection event", { ns: "${_locale.NAMESPACE}" })}}`,
117
140
  type: 'collection',
118
141
  fieldset: {
119
142
  'config.collection': _objectSpread(_objectSpread({}, _collection.collection), {}, {
@@ -142,32 +165,20 @@ var _default = {
142
165
  }),
143
166
  'config.mode': {
144
167
  type: 'number',
145
- title: '{{t("Trigger on")}}',
168
+ title: `{{t("Trigger on", { ns: "${_locale.NAMESPACE}" })}}`,
146
169
  name: 'config.mode',
147
170
  'x-decorator': 'FormItem',
148
171
  'x-component': 'Select',
149
172
  'x-component-props': {
150
- options: [{
151
- value: 1,
152
- label: '{{t("After record added")}}'
153
- }, {
154
- value: 2,
155
- label: '{{t("After record updated")}}'
156
- }, {
157
- value: 3,
158
- label: '{{t("After record added or updated")}}'
159
- }, {
160
- value: 4,
161
- label: '{{t("After record deleted")}}'
162
- }],
163
- placeholder: '{{t("Trigger on")}}'
173
+ options: collectionModeOptions,
174
+ placeholder: `{{t("Trigger on", { ns: "${_locale.NAMESPACE}" })}}`
164
175
  },
165
176
  required: true,
166
177
  'x-reactions': [{
167
178
  target: 'config.changed',
168
179
  fulfill: {
169
180
  state: {
170
- disabled: '{{!($self.value & 0b010)}}'
181
+ disabled: `{{!($self.value & ${COLLECTION_TRIGGER_MODE.UPDATED})}}`
171
182
  }
172
183
  }
173
184
  }]
@@ -175,8 +186,8 @@ var _default = {
175
186
  'config.changed': {
176
187
  type: 'array',
177
188
  name: 'changed',
178
- title: '{{t("Changed fields")}}',
179
- description: '{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.")}}',
189
+ title: `{{t("Changed fields", { ns: "${_locale.NAMESPACE}" })}}`,
190
+ description: `{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${_locale.NAMESPACE}" })}}`,
180
191
  'x-decorator': 'FormItem',
181
192
  'x-component': 'FieldsSelect',
182
193
  'x-component-props': {
@@ -186,7 +197,7 @@ var _default = {
186
197
  },
187
198
  'config.condition': _objectSpread(_objectSpread({}, _collection.filter), {}, {
188
199
  name: 'config.condition',
189
- title: '{{t("Only triggers when match conditions")}}'
200
+ title: `{{t("Only triggers when match conditions", { ns: "${_locale.NAMESPACE}" })}}`
190
201
  })
191
202
  },
192
203
  scope: {
@@ -196,27 +207,31 @@ var _default = {
196
207
  FieldsSelect
197
208
  },
198
209
 
199
- getter(props) {
200
- var _options$path;
210
+ getOptions(config) {
211
+ const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
212
+ t = _useWorkflowTranslati.t;
201
213
 
202
- const type = props.type,
203
- options = props.options,
204
- _onChange = props.onChange;
214
+ const options = [{
215
+ value: 'data',
216
+ label: t('Trigger data')
217
+ }];
218
+ return options;
219
+ },
220
+
221
+ getter(props) {
222
+ const _onChange = props.onChange;
205
223
 
206
224
  const _useFlowContext = (0, _FlowContext.useFlowContext)(),
207
225
  workflow = _useFlowContext.workflow;
208
226
 
209
- const value = options === null || options === void 0 ? void 0 : (_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.replace(/^data\./, '');
227
+ const _useOperandContext = (0, _calculators.useOperandContext)(),
228
+ options = _useOperandContext.options;
229
+
210
230
  return _react().default.createElement(_CollectionFieldSelect.default, {
211
231
  collection: workflow.config.collection,
212
- value: value,
213
- onChange: value => {
214
- _onChange({
215
- type,
216
- options: _objectSpread(_objectSpread({}, options), {}, {
217
- path: `data.${value}`
218
- })
219
- });
232
+ value: options === null || options === void 0 ? void 0 : options.path,
233
+ onChange: path => {
234
+ _onChange(`{{$context.data.${path}}}`);
220
235
  }
221
236
  });
222
237
  }
@@ -4,7 +4,7 @@ import React from "react";
4
4
  export interface Trigger {
5
5
  title: string;
6
6
  type: string;
7
- options?: {
7
+ getOptions?(config: any): {
8
8
  label: string;
9
9
  value: any;
10
10
  key: string;
@@ -19,8 +19,8 @@ export interface Trigger {
19
19
  components?: {
20
20
  [key: string]: any;
21
21
  };
22
- render?(props: any): React.ReactElement;
23
- getter?(node: any): React.ReactElement;
22
+ render?(props: any): React.ReactNode;
23
+ getter?(node: any): React.ReactNode;
24
24
  }
25
25
  export declare const triggers: Registry<Trigger>;
26
26
  export declare const TriggerConfig: () => JSX.Element;