@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-alpha.2

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 (138) hide show
  1. package/README.md +9 -0
  2. package/README.zh-CN.md +9 -0
  3. package/lib/client/AddButton.d.ts +1 -1
  4. package/lib/client/AddButton.js +43 -27
  5. package/lib/client/Branch.d.ts +1 -1
  6. package/lib/client/ExecutionCanvas.js +5 -10
  7. package/lib/client/WorkflowCanvas.js +12 -42
  8. package/lib/client/WorkflowProvider.js +10 -1
  9. package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
  10. package/lib/client/components/CollectionBlockInitializer.js +81 -0
  11. package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
  12. package/lib/client/components/CollectionFieldInitializers.js +89 -0
  13. package/lib/client/components/CollectionFieldset.js +25 -33
  14. package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
  15. package/lib/client/components/FilterDynamicComponent.js +43 -0
  16. package/lib/client/components/NullRender.d.ts +1 -0
  17. package/lib/client/components/NullRender.js +10 -0
  18. package/lib/client/components/RadioWithTooltip.d.ts +7 -0
  19. package/lib/client/components/RadioWithTooltip.js +94 -0
  20. package/lib/client/constants.d.ts +10 -8
  21. package/lib/client/constants.js +52 -14
  22. package/lib/client/index.d.ts +0 -1
  23. package/lib/client/index.js +1 -10
  24. package/lib/client/locale/en-US.d.ts +18 -18
  25. package/lib/client/locale/en-US.js +19 -19
  26. package/lib/client/locale/zh-CN.d.ts +47 -20
  27. package/lib/client/locale/zh-CN.js +48 -21
  28. package/lib/client/nodes/calculation.d.ts +39 -7
  29. package/lib/client/nodes/calculation.js +165 -19
  30. package/lib/client/nodes/condition.d.ts +67 -4
  31. package/lib/client/nodes/condition.js +283 -31
  32. package/lib/client/nodes/create.d.ts +10 -10
  33. package/lib/client/nodes/create.js +28 -42
  34. package/lib/client/nodes/delay.d.ts +4 -4
  35. package/lib/client/nodes/delay.js +10 -8
  36. package/lib/client/nodes/destroy.d.ts +4 -7
  37. package/lib/client/nodes/destroy.js +4 -5
  38. package/lib/client/nodes/index.d.ts +10 -2
  39. package/lib/client/nodes/index.js +217 -110
  40. package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
  41. package/lib/client/nodes/manual/AssigneesSelect.js +65 -0
  42. package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
  43. package/lib/client/nodes/manual/ModeConfig.js +160 -0
  44. package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
  45. package/lib/client/nodes/manual/SchemaConfig.js +715 -0
  46. package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
  47. package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
  48. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
  49. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
  50. package/lib/client/nodes/manual/index.d.ts +62 -0
  51. package/lib/client/nodes/manual/index.js +137 -0
  52. package/lib/client/nodes/parallel.d.ts +12 -7
  53. package/lib/client/nodes/parallel.js +32 -39
  54. package/lib/client/nodes/query.d.ts +11 -19
  55. package/lib/client/nodes/query.js +40 -47
  56. package/lib/client/nodes/request.d.ts +77 -42
  57. package/lib/client/nodes/request.js +123 -69
  58. package/lib/client/nodes/update.d.ts +33 -29
  59. package/lib/client/nodes/update.js +14 -7
  60. package/lib/client/schemas/collection.d.ts +0 -3
  61. package/lib/client/schemas/collection.js +2 -7
  62. package/lib/client/schemas/executions.js +1 -1
  63. package/lib/client/schemas/workflows.js +1 -1
  64. package/lib/client/style.js +51 -9
  65. package/lib/client/triggers/collection.d.ts +44 -15
  66. package/lib/client/triggers/collection.js +104 -82
  67. package/lib/client/triggers/index.d.ts +6 -3
  68. package/lib/client/triggers/index.js +167 -74
  69. package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -3
  70. package/lib/client/triggers/schedule/ScheduleConfig.js +15 -17
  71. package/lib/client/triggers/schedule/index.d.ts +7 -6
  72. package/lib/client/triggers/schedule/index.js +39 -81
  73. package/lib/client/utils.d.ts +1 -0
  74. package/lib/client/utils.js +38 -0
  75. package/lib/client/variable.d.ts +21 -0
  76. package/lib/client/variable.js +147 -0
  77. package/lib/server/Plugin.d.ts +3 -3
  78. package/lib/server/Plugin.js +12 -21
  79. package/lib/server/Processor.d.ts +9 -2
  80. package/lib/server/Processor.js +33 -33
  81. package/lib/server/actions/index.js +2 -4
  82. package/lib/server/actions/workflows.d.ts +1 -0
  83. package/lib/server/actions/workflows.js +80 -23
  84. package/lib/server/collections/executions.js +5 -7
  85. package/lib/server/collections/flow_nodes.js +6 -18
  86. package/lib/server/collections/jobs.js +3 -1
  87. package/lib/server/collections/workflows.js +8 -4
  88. package/lib/server/constants.d.ts +9 -3
  89. package/lib/server/constants.js +11 -5
  90. package/lib/server/functions/index.d.ts +4 -0
  91. package/lib/server/functions/index.js +38 -0
  92. package/lib/server/index.d.ts +0 -1
  93. package/lib/server/index.js +0 -14
  94. package/lib/server/instructions/calculation.d.ts +2 -7
  95. package/lib/server/instructions/calculation.js +32 -37
  96. package/lib/server/instructions/condition.d.ts +4 -4
  97. package/lib/server/instructions/condition.js +126 -54
  98. package/lib/server/instructions/index.js +1 -1
  99. package/lib/server/instructions/manual/actions.js +101 -0
  100. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
  101. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
  102. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
  103. package/lib/server/instructions/manual/index.d.ts +25 -0
  104. package/lib/server/instructions/manual/index.js +200 -0
  105. package/lib/server/instructions/parallel.js +11 -7
  106. package/lib/server/instructions/request.d.ts +5 -4
  107. package/lib/server/instructions/request.js +60 -79
  108. package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
  109. package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
  110. package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
  111. package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
  112. package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
  113. package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
  114. package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
  115. package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
  116. package/lib/server/triggers/schedule.js +11 -3
  117. package/package.json +10 -10
  118. package/lib/client/calculators.d.ts +0 -89
  119. package/lib/client/calculators.js +0 -668
  120. package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
  121. package/lib/client/components/CollectionFieldSelect.js +0 -106
  122. package/lib/client/components/EjsTextArea.d.ts +0 -2
  123. package/lib/client/components/EjsTextArea.js +0 -232
  124. package/lib/server/actions/jobs.d.ts +0 -2
  125. package/lib/server/actions/jobs.js +0 -39
  126. package/lib/server/calculators/index.d.ts +0 -40
  127. package/lib/server/calculators/index.js +0 -187
  128. package/lib/server/extensions/assignees/actions.js +0 -75
  129. package/lib/server/extensions/assignees/index.d.ts +0 -2
  130. package/lib/server/extensions/assignees/index.js +0 -273
  131. package/lib/server/extensions/index.d.ts +0 -3
  132. package/lib/server/extensions/index.js +0 -13
  133. package/lib/server/instructions/prompt.d.ts +0 -19
  134. package/lib/server/instructions/prompt.js +0 -131
  135. /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
  136. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
  137. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
  138. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _Duration = _interopRequireDefault(require("../components/Duration"));
9
9
 
10
+ var _constants = require("../constants");
11
+
10
12
  var _locale = require("../locale");
11
13
 
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -16,17 +18,16 @@ var _default = {
16
18
  type: 'delay',
17
19
  group: 'control',
18
20
  fieldset: {
19
- 'config.duration': {
21
+ duration: {
20
22
  type: 'number',
21
- name: 'config.duration',
22
23
  title: `{{t("Duration", { ns: "${_locale.NAMESPACE}" })}}`,
23
24
  'x-decorator': 'FormItem',
24
25
  'x-component': 'Duration',
25
- default: 60000
26
+ default: 60000,
27
+ required: true
26
28
  },
27
- 'config.endStatus': {
29
+ endStatus: {
28
30
  type: 'number',
29
- name: 'config.endStatus',
30
31
  title: `{{t("End Status", { ns: "${_locale.NAMESPACE}" })}}`,
31
32
  'x-decorator': 'FormItem',
32
33
  'x-component': 'Select',
@@ -35,11 +36,12 @@ var _default = {
35
36
  },
36
37
  enum: [{
37
38
  label: `{{t("Succeed and continue", { ns: "${_locale.NAMESPACE}" })}}`,
38
- value: 1
39
+ value: _constants.JOB_STATUS.RESOLVED
39
40
  }, {
40
41
  label: `{{t("Fail and exit", { ns: "${_locale.NAMESPACE}" })}}`,
41
- value: -1
42
- }]
42
+ value: _constants.JOB_STATUS.FAILED
43
+ }],
44
+ required: true
43
45
  }
44
46
  },
45
47
  view: {},
@@ -1,14 +1,13 @@
1
1
  import { useCollectionDataSource } from '@nocobase/client';
2
- import { VariableComponent } from '../calculators';
2
+ import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  type: string;
6
6
  group: string;
7
7
  fieldset: {
8
- 'config.collection': {
8
+ collection: {
9
9
  type: string;
10
10
  title: string;
11
- name: string;
12
11
  required: boolean;
13
12
  'x-reactions': string[];
14
13
  'x-decorator': string;
@@ -17,16 +16,14 @@ declare const _default: {
17
16
  placeholder: string;
18
17
  };
19
18
  };
20
- 'config.params': {
19
+ params: {
21
20
  type: string;
22
- name: string;
23
21
  title: string;
24
22
  'x-decorator': string;
25
23
  properties: {
26
24
  filter: {
27
25
  type: string;
28
26
  title: string;
29
- name: string;
30
27
  'x-decorator': string;
31
28
  'x-decorator-props': {
32
29
  labelAlign: string;
@@ -49,7 +46,7 @@ declare const _default: {
49
46
  useCollectionDataSource: typeof useCollectionDataSource;
50
47
  };
51
48
  components: {
52
- VariableComponent: typeof VariableComponent;
49
+ FilterDynamicComponent: typeof FilterDynamicComponent;
53
50
  };
54
51
  };
55
52
  export default _default;
@@ -15,7 +15,7 @@ function _client() {
15
15
  return data;
16
16
  }
17
17
 
18
- var _calculators = require("../calculators");
18
+ var _FilterDynamicComponent = require("../components/FilterDynamicComponent");
19
19
 
20
20
  var _collection = require("../schemas/collection");
21
21
 
@@ -24,10 +24,9 @@ var _default = {
24
24
  type: 'destroy',
25
25
  group: 'collection',
26
26
  fieldset: {
27
- 'config.collection': _collection.collection,
28
- 'config.params': {
27
+ collection: _collection.collection,
28
+ params: {
29
29
  type: 'object',
30
- name: 'config.params',
31
30
  title: '',
32
31
  'x-decorator': 'FormItem',
33
32
  properties: {
@@ -40,7 +39,7 @@ var _default = {
40
39
  useCollectionDataSource: _client().useCollectionDataSource
41
40
  },
42
41
  components: {
43
- VariableComponent: _calculators.VariableComponent
42
+ FilterDynamicComponent: _FilterDynamicComponent.FilterDynamicComponent
44
43
  }
45
44
  };
46
45
  exports.default = _default;
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ISchema } from '@formily/react';
3
3
  import { Registry } from '@nocobase/utils/client';
4
+ import { SchemaInitializerItemOptions } from '@nocobase/client';
5
+ import { VariableOption } from '../variable';
4
6
  export interface Instruction {
5
7
  title: string;
6
8
  type: string;
@@ -20,12 +22,18 @@ export interface Instruction {
20
22
  components?: {
21
23
  [key: string]: any;
22
24
  };
23
- render?(props: any): React.ReactElement;
25
+ render?(props: any): React.ReactNode;
24
26
  endding?: boolean;
25
- getter?(node: any): React.ReactElement;
27
+ getOptions?(config: any, types?: any): VariableOption[] | null;
28
+ useInitializers?(node: any): SchemaInitializerItemOptions | null;
29
+ initializers?: {
30
+ [key: string]: any;
31
+ };
26
32
  }
27
33
  export declare const instructions: Registry<Instruction>;
34
+ export declare const NodeContext: React.Context<any>;
28
35
  export declare function useNodeContext(): any;
36
+ export declare function useAvailableUpstreams(node: any): any[];
29
37
  export declare function Node({ data }: {
30
38
  data: any;
31
39
  }): JSX.Element;
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.JobButton = JobButton;
7
7
  exports.Node = Node;
8
+ exports.NodeContext = void 0;
8
9
  exports.NodeDefaultView = NodeDefaultView;
9
10
  exports.RemoveButton = RemoveButton;
10
11
  exports.instructions = void 0;
12
+ exports.useAvailableUpstreams = useAvailableUpstreams;
11
13
  exports.useNodeContext = useNodeContext;
12
14
 
13
15
  function _react() {
@@ -114,6 +116,8 @@ var _parallel = _interopRequireDefault(require("./parallel"));
114
116
 
115
117
  var _delay = _interopRequireDefault(require("./delay"));
116
118
 
119
+ var _manual = _interopRequireDefault(require("./manual"));
120
+
117
121
  var _query = _interopRequireDefault(require("./query"));
118
122
 
119
123
  var _create = _interopRequireDefault(require("./create"));
@@ -134,6 +138,24 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
134
138
 
135
139
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
136
140
 
141
+ 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; }
142
+
143
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
144
+
145
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
146
+
147
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
148
+
149
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
150
+
151
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
152
+
153
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
154
+
155
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
156
+
157
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
158
+
137
159
  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); } }
138
160
 
139
161
  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); }); }; }
@@ -145,6 +167,7 @@ instructions.register('condition', _condition.default);
145
167
  instructions.register('parallel', _parallel.default);
146
168
  instructions.register('calculation', _calculation.default);
147
169
  instructions.register('delay', _delay.default);
170
+ instructions.register('manual', _manual.default);
148
171
  instructions.register('query', _query.default);
149
172
  instructions.register('create', _create.default);
150
173
  instructions.register('update', _update.default);
@@ -167,19 +190,19 @@ function useUpdateAction() {
167
190
  return {
168
191
  run() {
169
192
  return _asyncToGenerator(function* () {
193
+ var _api$resource$update, _api$resource;
194
+
170
195
  if (workflow.executed) {
171
196
  _antd().message.error((0, _locale.lang)('Node in executed workflow cannot be modified'));
172
197
 
173
198
  return;
174
- } // TODO: how to do validation separately for each field? especially disabled for dynamic fields?
175
- // await form.submit();
176
-
199
+ }
177
200
 
178
- yield api.resource('flow_nodes', data.id).update({
201
+ yield form.submit();
202
+ yield (_api$resource$update = (_api$resource = api.resource('flow_nodes', data.id)).update) === null || _api$resource$update === void 0 ? void 0 : _api$resource$update.call(_api$resource, {
179
203
  filterByTk: data.id,
180
204
  values: {
181
- title: form.values.title,
182
- config: form.values.config
205
+ config: form.values
183
206
  }
184
207
  });
185
208
  ctx.setVisible(false);
@@ -192,12 +215,24 @@ function useUpdateAction() {
192
215
 
193
216
  ;
194
217
 
195
- const NodeContext = _react().default.createContext(null);
218
+ const NodeContext = _react().default.createContext({});
219
+
220
+ exports.NodeContext = NodeContext;
196
221
 
197
222
  function useNodeContext() {
198
223
  return (0, _react().useContext)(NodeContext);
199
224
  }
200
225
 
226
+ function useAvailableUpstreams(node) {
227
+ const stack = [];
228
+
229
+ for (let current = node.upstream; current; current = current.upstream) {
230
+ stack.push(current);
231
+ }
232
+
233
+ return stack;
234
+ }
235
+
201
236
  function Node({
202
237
  data
203
238
  }) {
@@ -241,7 +276,7 @@ function RemoveButton() {
241
276
  const _ref = (_useFlowContext2 = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext2 !== void 0 ? _useFlowContext2 : {},
242
277
  workflow = _ref.workflow,
243
278
  nodes = _ref.nodes,
244
- onNodeRemoved = _ref.onNodeRemoved;
279
+ refresh = _ref.refresh;
245
280
 
246
281
  const current = useNodeContext();
247
282
 
@@ -263,12 +298,12 @@ function RemoveButton() {
263
298
 
264
299
  function _onOk() {
265
300
  _onOk = _asyncToGenerator(function* () {
266
- const _yield$resource$destr = yield resource.destroy({
267
- filterByTk: current.id
268
- }),
269
- node = _yield$resource$destr.data.data;
301
+ var _resource$destroy;
270
302
 
271
- onNodeRemoved(node);
303
+ yield (_resource$destroy = resource.destroy) === null || _resource$destroy === void 0 ? void 0 : _resource$destroy.call(resource, {
304
+ filterByTk: current.id
305
+ });
306
+ refresh();
272
307
  });
273
308
  return _onOk.apply(this, arguments);
274
309
  }
@@ -340,6 +375,7 @@ function JobButton() {
340
375
  className: (0, _css().cx)('workflow-node-job-button', (0, _css().css)`
341
376
  border: 2px solid #d9d9d9;
342
377
  border-radius: 50%;
378
+ cursor: not-allowed;
343
379
  `)
344
380
  });
345
381
  }
@@ -353,21 +389,26 @@ function JobButton() {
353
389
  schema: {
354
390
  type: 'void',
355
391
  properties: {
356
- job: {
392
+ [`${job.id}-button`]: {
357
393
  type: 'void',
358
394
  'x-component': 'Action',
359
395
  'x-component-props': {
360
- title: icon,
396
+ title: _react().default.createElement(_antd().Tag, {
397
+ color: color
398
+ }, icon),
361
399
  shape: 'circle',
362
400
  className: ['workflow-node-job-button', (0, _css().css)`
363
- background-color: ${color};
364
- &:hover,&:focus{
365
- background-color: ${color}
401
+ .ant-tag{
402
+ padding: 0;
403
+ width: 100%;
404
+ line-height: 18px;
405
+ margin-right: 0;
406
+ border-radius: 50%;
366
407
  }
367
408
  `]
368
409
  },
369
410
  properties: {
370
- [job.id]: {
411
+ [`${job.id}-modal`]: {
371
412
  type: 'void',
372
413
  'x-decorator': 'Form',
373
414
  'x-decorator-props': {
@@ -421,125 +462,191 @@ function JobButton() {
421
462
  }
422
463
 
423
464
  function NodeDefaultView(props) {
424
- var _useFlowContext4;
465
+ var _useFlowContext4, _data$title;
425
466
 
467
+ const data = props.data,
468
+ children = props.children;
426
469
  const compile = (0, _client2().useCompile)();
470
+ const api = (0, _client2().useAPIClient)();
427
471
 
428
472
  const _ref3 = (_useFlowContext4 = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext4 !== void 0 ? _useFlowContext4 : {},
429
- workflow = _ref3.workflow;
430
-
431
- if (!workflow) {
432
- return null;
433
- }
473
+ workflow = _ref3.workflow,
474
+ refresh = _ref3.refresh;
434
475
 
435
- const data = props.data,
436
- children = props.children;
437
476
  const instruction = instructions.get(data.type);
438
477
  const detailText = workflow.executed ? '{{t("View")}}' : '{{t("Configure")}}';
478
+ const typeTitle = compile(instruction.title);
479
+
480
+ const _useState = (0, _react().useState)((_data$title = data.title) !== null && _data$title !== void 0 ? _data$title : typeTitle),
481
+ _useState2 = _slicedToArray(_useState, 2),
482
+ editingTitle = _useState2[0],
483
+ setEditingTitle = _useState2[1];
484
+
485
+ const _useState3 = (0, _react().useState)(false),
486
+ _useState4 = _slicedToArray(_useState3, 2),
487
+ editingConfig = _useState4[0],
488
+ setEditingConfig = _useState4[1];
489
+
490
+ function onChangeTitle(_x) {
491
+ return _onChangeTitle.apply(this, arguments);
492
+ }
493
+
494
+ function _onChangeTitle() {
495
+ _onChangeTitle = _asyncToGenerator(function* (next) {
496
+ var _api$resource$update2, _api$resource2;
497
+
498
+ const title = next || typeTitle;
499
+ setEditingTitle(title);
500
+
501
+ if (title === data.title) {
502
+ return;
503
+ }
504
+
505
+ yield (_api$resource$update2 = (_api$resource2 = api.resource('flow_nodes')).update) === null || _api$resource$update2 === void 0 ? void 0 : _api$resource$update2.call(_api$resource2, {
506
+ filterByTk: data.id,
507
+ values: {
508
+ title
509
+ }
510
+ });
511
+ refresh();
512
+ });
513
+ return _onChangeTitle.apply(this, arguments);
514
+ }
515
+
516
+ function onOpenDrawer(ev) {
517
+ if (ev.target === ev.currentTarget) {
518
+ setEditingConfig(true);
519
+ return;
520
+ }
521
+
522
+ const whiteSet = new Set(['workflow-node-meta', 'workflow-node-config-button', 'ant-input-disabled']);
523
+
524
+ for (let el = ev.target; el && el !== ev.currentTarget; el = el.parentNode) {
525
+ if (Array.from(el.classList).some(name => whiteSet.has(name))) {
526
+ setEditingConfig(true);
527
+ ev.stopPropagation();
528
+ return;
529
+ }
530
+ }
531
+ }
532
+
439
533
  return _react().default.createElement("div", {
440
534
  className: (0, _css().cx)(_style.nodeClass, `workflow-node-type-${data.type}`)
441
535
  }, _react().default.createElement("div", {
442
- className: (0, _css().cx)(_style.nodeCardClass)
443
- }, _react().default.createElement("div", {
444
- className: (0, _css().cx)(_style.nodeHeaderClass)
536
+ className: (0, _css().cx)(_style.nodeCardClass, {
537
+ configuring: editingConfig
538
+ }),
539
+ onClick: onOpenDrawer
445
540
  }, _react().default.createElement("div", {
446
- className: (0, _css().cx)(_style.nodeMetaClass)
447
- }, _react().default.createElement(_antd().Tag, null, compile(instruction.title))), _react().default.createElement("h4", {
448
- className: (0, _css().cx)(_style.nodeTitleClass)
449
- }, _react().default.createElement("strong", null, data.title), _react().default.createElement("span", {
541
+ className: (0, _css().cx)(_style.nodeMetaClass, 'workflow-node-meta')
542
+ }, _react().default.createElement(_antd().Tag, null, typeTitle), _react().default.createElement("span", {
450
543
  className: "workflow-node-id"
451
- }, "#", data.id)), _react().default.createElement(RemoveButton, null), _react().default.createElement(JobButton, null)), _react().default.createElement(_client2().SchemaComponent, {
544
+ }, data.id)), _react().default.createElement("div", null, _react().default.createElement(_antd().Input.TextArea, {
545
+ disabled: workflow.executed,
546
+ value: editingTitle,
547
+ onChange: ev => setEditingTitle(ev.target.value),
548
+ onBlur: ev => onChangeTitle(ev.target.value),
549
+ autoSize: true
550
+ })), _react().default.createElement(RemoveButton, null), _react().default.createElement(JobButton, null), _react().default.createElement(_client2().ActionContext.Provider, {
551
+ value: {
552
+ visible: editingConfig,
553
+ setVisible: setEditingConfig
554
+ }
555
+ }, _react().default.createElement(_client2().SchemaComponent, {
452
556
  scope: instruction.scope,
453
557
  components: instruction.components,
454
558
  schema: {
455
559
  type: 'void',
456
- properties: {
457
- view: instruction.view,
458
- config: {
560
+ properties: _objectSpread(_objectSpread({}, instruction.view ? {
561
+ view: instruction.view
562
+ } : {}), {}, {
563
+ button: {
459
564
  type: 'void',
460
- title: detailText,
461
- 'x-component': 'Action.Link',
565
+ 'x-content': detailText,
566
+ 'x-component': _antd().Button,
462
567
  'x-component-props': {
463
- type: 'primary'
568
+ type: 'link',
569
+ className: 'workflow-node-config-button'
570
+ }
571
+ },
572
+ [`${instruction.type}_${data.id}`]: {
573
+ type: 'void',
574
+ title: instruction.title,
575
+ 'x-component': 'Action.Drawer',
576
+ 'x-decorator': 'Form',
577
+ 'x-decorator-props': {
578
+ disabled: workflow.executed,
579
+
580
+ useValues(options) {
581
+ const _useNodeContext2 = useNodeContext(),
582
+ config = _useNodeContext2.config;
583
+
584
+ return (0, _client2().useRequest)(() => {
585
+ return Promise.resolve({
586
+ data: config
587
+ });
588
+ }, options);
589
+ }
590
+
464
591
  },
465
- properties: {
466
- [instruction.type]: {
592
+ properties: _objectSpread(_objectSpread({}, workflow.executed ? {
593
+ alert: {
467
594
  type: 'void',
468
- title: instruction.title,
469
- 'x-component': 'Action.Drawer',
470
- 'x-decorator': 'Form',
471
- 'x-decorator-props': {
472
- useValues(options) {
473
- const d = useNodeContext();
474
- return (0, _client2().useRequest)(() => {
475
- return Promise.resolve({
476
- data: d
477
- });
478
- }, options);
479
- }
480
-
595
+ 'x-component': _antd().Alert,
596
+ 'x-component-props': {
597
+ type: 'warning',
598
+ showIcon: true,
599
+ message: `{{t("Node in executed workflow cannot be modified", { ns: "${_locale.NAMESPACE}" })}}`,
600
+ className: (0, _css().css)`
601
+ width: 100%;
602
+ font-size: 85%;
603
+ margin-bottom: 2em;
604
+ `
605
+ }
606
+ }
607
+ } : {}), {}, {
608
+ fieldset: {
609
+ type: 'void',
610
+ 'x-component': 'fieldset',
611
+ 'x-component-props': {
612
+ className: (0, _css().css)`
613
+ .ant-input,
614
+ .ant-select,
615
+ .ant-cascader-picker,
616
+ .ant-picker,
617
+ .ant-input-number,
618
+ .ant-input-affix-wrapper{
619
+ width: auto;
620
+ min-width: 6em;
621
+ }
622
+ `
481
623
  },
624
+ properties: instruction.fieldset
625
+ },
626
+ actions: workflow.executed ? null : {
627
+ type: 'void',
628
+ 'x-component': 'Action.Drawer.Footer',
482
629
  properties: {
483
- title: {
484
- type: 'string',
485
- name: 'title',
486
- title: '{{t("Name")}}',
487
- 'x-decorator': 'FormItem',
488
- 'x-component': 'Input'
489
- },
490
- config: {
491
- type: 'void',
492
- name: 'config',
493
- 'x-component': 'fieldset',
630
+ cancel: {
631
+ title: '{{t("Cancel")}}',
632
+ 'x-component': 'Action',
494
633
  'x-component-props': {
495
- disabled: workflow.executed,
496
- className: (0, _css().css)`
497
- .ant-select,
498
- .ant-cascader-picker,
499
- .ant-picker,
500
- .ant-input-number,
501
- .ant-input-affix-wrapper{
502
- width: auto;
503
- min-width: 6em;
504
- }
505
- `
506
- },
507
- properties: instruction.fieldset
634
+ useAction: '{{ cm.useCancelAction }}'
635
+ }
508
636
  },
509
- actions: {
510
- type: 'void',
511
- 'x-component': 'Action.Drawer.Footer',
512
- properties: workflow.executed ? {
513
- close: {
514
- title: '{{t("Close")}}',
515
- 'x-component': 'Action',
516
- 'x-component-props': {
517
- useAction: '{{ cm.useCancelAction }}'
518
- }
519
- }
520
- } : {
521
- cancel: {
522
- title: '{{t("Cancel")}}',
523
- 'x-component': 'Action',
524
- 'x-component-props': {
525
- useAction: '{{ cm.useCancelAction }}'
526
- }
527
- },
528
- submit: {
529
- title: '{{t("Submit")}}',
530
- 'x-component': 'Action',
531
- 'x-component-props': {
532
- type: 'primary',
533
- useAction: useUpdateAction
534
- }
535
- }
637
+ submit: {
638
+ title: '{{t("Submit")}}',
639
+ 'x-component': 'Action',
640
+ 'x-component-props': {
641
+ type: 'primary',
642
+ useAction: useUpdateAction
536
643
  }
537
644
  }
538
645
  }
539
646
  }
540
- }
647
+ })
541
648
  }
542
- }
649
+ })
543
650
  }
544
- })), children);
651
+ }))), children);
545
652
  }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare function AssigneesSelect({ multiple, value, onChange }: {
3
+ multiple?: boolean;
4
+ value?: any[];
5
+ onChange: any;
6
+ }): JSX.Element;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AssigneesSelect = AssigneesSelect;
7
+
8
+ function _client() {
9
+ const data = require("@nocobase/client");
10
+
11
+ _client = function _client() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _react() {
19
+ const data = _interopRequireDefault(require("react"));
20
+
21
+ _react = function _react() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ var _variable = require("../../variable");
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ function AssigneesSelect({
33
+ multiple = false,
34
+ value = [],
35
+ onChange: _onChange
36
+ }) {
37
+ const scope = (0, _variable.useWorkflowVariableOptions)();
38
+ console.log(value);
39
+ return _react().default.createElement(_client().Variable.Input, {
40
+ scope: scope,
41
+ types: [{
42
+ type: 'reference',
43
+ options: {
44
+ collection: 'users'
45
+ }
46
+ }],
47
+ value: value[0],
48
+ onChange: next => {
49
+ _onChange([next]);
50
+ }
51
+ }, _react().default.createElement(_client().RemoteSelect, {
52
+ fieldNames: {
53
+ label: 'nickname',
54
+ value: 'id'
55
+ },
56
+ service: {
57
+ resource: 'users'
58
+ },
59
+ manual: false,
60
+ value: value[0],
61
+ onChange: v => {
62
+ _onChange(v != null ? [v] : []);
63
+ }
64
+ }));
65
+ }