@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/lib/client/AddButton.d.ts +1 -1
- package/lib/client/AddButton.js +7 -2
- package/lib/client/Branch.d.ts +1 -1
- package/lib/client/ExecutionCanvas.js +5 -10
- package/lib/client/WorkflowCanvas.js +11 -40
- package/lib/client/WorkflowProvider.js +10 -1
- package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
- package/lib/client/components/CollectionBlockInitializer.js +81 -0
- package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
- package/lib/client/components/CollectionFieldInitializers.js +89 -0
- package/lib/client/components/CollectionFieldset.js +21 -25
- package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
- package/lib/client/components/FilterDynamicComponent.js +43 -0
- package/lib/client/components/NullRender.d.ts +1 -0
- package/lib/client/components/NullRender.js +10 -0
- package/lib/client/components/RadioWithTooltip.d.ts +7 -0
- package/lib/client/components/RadioWithTooltip.js +94 -0
- package/lib/client/constants.d.ts +10 -8
- package/lib/client/constants.js +52 -14
- package/lib/client/index.d.ts +0 -1
- package/lib/client/index.js +1 -10
- package/lib/client/locale/en-US.d.ts +18 -18
- package/lib/client/locale/en-US.js +19 -19
- package/lib/client/locale/zh-CN.d.ts +47 -20
- package/lib/client/locale/zh-CN.js +48 -21
- package/lib/client/nodes/calculation.d.ts +40 -6
- package/lib/client/nodes/calculation.js +171 -19
- package/lib/client/nodes/condition.d.ts +67 -0
- package/lib/client/nodes/condition.js +287 -27
- package/lib/client/nodes/create.d.ts +8 -6
- package/lib/client/nodes/create.js +27 -33
- package/lib/client/nodes/delay.d.ts +2 -0
- package/lib/client/nodes/delay.js +8 -4
- package/lib/client/nodes/destroy.d.ts +2 -2
- package/lib/client/nodes/destroy.js +2 -2
- package/lib/client/nodes/index.d.ts +10 -2
- package/lib/client/nodes/index.js +73 -27
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +64 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
- package/lib/client/nodes/manual/ModeConfig.js +160 -0
- package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
- package/lib/client/nodes/manual/SchemaConfig.js +715 -0
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
- package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
- package/lib/client/nodes/manual/index.d.ts +64 -0
- package/lib/client/nodes/manual/index.js +146 -0
- package/lib/client/nodes/parallel.d.ts +11 -5
- package/lib/client/nodes/parallel.js +22 -34
- package/lib/client/nodes/query.d.ts +9 -14
- package/lib/client/nodes/query.js +38 -44
- package/lib/client/nodes/request.d.ts +75 -33
- package/lib/client/nodes/request.js +124 -63
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +2 -2
- package/lib/client/schemas/collection.js +1 -1
- package/lib/client/schemas/executions.js +1 -1
- package/lib/client/schemas/workflows.js +1 -1
- package/lib/client/style.js +0 -4
- package/lib/client/triggers/collection.d.ts +7 -3
- package/lib/client/triggers/collection.js +39 -48
- package/lib/client/triggers/index.d.ts +5 -2
- package/lib/client/triggers/index.js +34 -12
- package/lib/client/triggers/schedule/index.d.ts +7 -5
- package/lib/client/triggers/schedule/index.js +38 -79
- package/lib/client/utils.d.ts +1 -0
- package/lib/client/utils.js +38 -0
- package/lib/client/variable.d.ts +21 -0
- package/lib/client/variable.js +147 -0
- package/lib/server/Plugin.d.ts +3 -3
- package/lib/server/Plugin.js +12 -21
- package/lib/server/Processor.d.ts +9 -2
- package/lib/server/Processor.js +33 -33
- package/lib/server/actions/index.js +2 -4
- package/lib/server/actions/workflows.d.ts +1 -0
- package/lib/server/actions/workflows.js +80 -23
- package/lib/server/collections/executions.js +5 -7
- package/lib/server/collections/flow_nodes.js +6 -18
- package/lib/server/collections/jobs.js +3 -1
- package/lib/server/collections/workflows.js +8 -4
- package/lib/server/constants.d.ts +9 -3
- package/lib/server/constants.js +11 -5
- package/lib/server/functions/index.d.ts +4 -0
- package/lib/server/functions/index.js +38 -0
- package/lib/server/index.d.ts +0 -1
- package/lib/server/index.js +0 -14
- package/lib/server/instructions/calculation.d.ts +2 -7
- package/lib/server/instructions/calculation.js +32 -37
- package/lib/server/instructions/condition.d.ts +4 -4
- package/lib/server/instructions/condition.js +126 -54
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/manual/actions.js +101 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
- package/lib/server/instructions/manual/index.d.ts +25 -0
- package/lib/server/instructions/manual/index.js +200 -0
- package/lib/server/instructions/parallel.js +11 -7
- package/lib/server/instructions/request.d.ts +5 -4
- package/lib/server/instructions/request.js +60 -79
- package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
- package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
- package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
- package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
- package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
- package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
- package/lib/server/triggers/schedule.js +11 -3
- package/package.json +10 -10
- package/lib/client/calculators.d.ts +0 -89
- package/lib/client/calculators.js +0 -668
- package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
- package/lib/client/components/CollectionFieldSelect.js +0 -106
- package/lib/client/components/EjsTextArea.d.ts +0 -2
- package/lib/client/components/EjsTextArea.js +0 -232
- package/lib/server/actions/jobs.d.ts +0 -2
- package/lib/server/actions/jobs.js +0 -39
- package/lib/server/calculators/index.d.ts +0 -40
- package/lib/server/calculators/index.js +0 -187
- package/lib/server/extensions/assignees/actions.js +0 -75
- package/lib/server/extensions/assignees/index.d.ts +0 -2
- package/lib/server/extensions/assignees/index.js +0 -273
- package/lib/server/extensions/index.d.ts +0 -3
- package/lib/server/extensions/index.js +0 -13
- package/lib/server/instructions/prompt.d.ts +0 -19
- package/lib/server/instructions/prompt.js +0 -131
- /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WorkflowTodo = WorkflowTodo;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _core() {
|
|
19
|
+
const data = require("@formily/core");
|
|
20
|
+
|
|
21
|
+
_core = function _core() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _react2() {
|
|
29
|
+
const data = require("@formily/react");
|
|
30
|
+
|
|
31
|
+
_react2 = function _react2() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _antd() {
|
|
39
|
+
const data = require("antd");
|
|
40
|
+
|
|
41
|
+
_antd = function _antd() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _jsonTemplates() {
|
|
49
|
+
const data = _interopRequireDefault(require("json-templates"));
|
|
50
|
+
|
|
51
|
+
_jsonTemplates = function _jsonTemplates() {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _css() {
|
|
59
|
+
const data = require("@emotion/css");
|
|
60
|
+
|
|
61
|
+
_css = function _css() {
|
|
62
|
+
return data;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _moment() {
|
|
69
|
+
const data = _interopRequireDefault(require("moment"));
|
|
70
|
+
|
|
71
|
+
_moment = function _moment() {
|
|
72
|
+
return data;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _client() {
|
|
79
|
+
const data = require("@nocobase/client");
|
|
80
|
+
|
|
81
|
+
_client = function _client() {
|
|
82
|
+
return data;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _client2() {
|
|
89
|
+
const data = require("@nocobase/utils/client");
|
|
90
|
+
|
|
91
|
+
_client2 = function _client2() {
|
|
92
|
+
return data;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var _constants = require("../../constants");
|
|
99
|
+
|
|
100
|
+
var _locale = require("../../locale");
|
|
101
|
+
|
|
102
|
+
var _FlowContext = require("../../FlowContext");
|
|
103
|
+
|
|
104
|
+
var _ = require("..");
|
|
105
|
+
|
|
106
|
+
var _utils = require("../../utils");
|
|
107
|
+
|
|
108
|
+
const _excluded = ["nodes"],
|
|
109
|
+
_excluded2 = ["workflow"],
|
|
110
|
+
_excluded3 = ["collections"];
|
|
111
|
+
|
|
112
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
113
|
+
|
|
114
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
115
|
+
|
|
116
|
+
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; }
|
|
117
|
+
|
|
118
|
+
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; }
|
|
119
|
+
|
|
120
|
+
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; }
|
|
121
|
+
|
|
122
|
+
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; }
|
|
123
|
+
|
|
124
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
125
|
+
|
|
126
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
127
|
+
|
|
128
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
129
|
+
|
|
130
|
+
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."); }
|
|
131
|
+
|
|
132
|
+
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); }
|
|
133
|
+
|
|
134
|
+
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; }
|
|
135
|
+
|
|
136
|
+
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; }
|
|
137
|
+
|
|
138
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
139
|
+
|
|
140
|
+
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); } }
|
|
141
|
+
|
|
142
|
+
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); }); }; }
|
|
143
|
+
|
|
144
|
+
const nodeCollection = {
|
|
145
|
+
title: `{{t("Task", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
146
|
+
name: 'flow_nodes',
|
|
147
|
+
fields: [{
|
|
148
|
+
type: 'bigInt',
|
|
149
|
+
name: 'id',
|
|
150
|
+
interface: 'm2o',
|
|
151
|
+
uiSchema: {
|
|
152
|
+
type: 'number',
|
|
153
|
+
title: 'ID',
|
|
154
|
+
'x-component': 'RemoteSelect',
|
|
155
|
+
'x-component-props': {
|
|
156
|
+
fieldNames: {
|
|
157
|
+
label: 'title',
|
|
158
|
+
value: 'id'
|
|
159
|
+
},
|
|
160
|
+
service: {
|
|
161
|
+
resource: 'flow_nodes',
|
|
162
|
+
params: {
|
|
163
|
+
filter: {
|
|
164
|
+
type: 'manual'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
type: 'string',
|
|
172
|
+
name: 'title',
|
|
173
|
+
interface: 'input',
|
|
174
|
+
uiSchema: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
title: '{{t("Title")}}',
|
|
177
|
+
'x-component': 'Input'
|
|
178
|
+
}
|
|
179
|
+
}]
|
|
180
|
+
};
|
|
181
|
+
const workflowCollection = {
|
|
182
|
+
title: `{{t("Workflow", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
183
|
+
name: 'workflows',
|
|
184
|
+
fields: [{
|
|
185
|
+
type: 'string',
|
|
186
|
+
name: 'title',
|
|
187
|
+
interface: 'input',
|
|
188
|
+
uiSchema: {
|
|
189
|
+
title: '{{t("Name")}}',
|
|
190
|
+
type: 'string',
|
|
191
|
+
'x-component': 'Input',
|
|
192
|
+
required: true
|
|
193
|
+
}
|
|
194
|
+
}]
|
|
195
|
+
};
|
|
196
|
+
const todoCollection = {
|
|
197
|
+
title: `{{t("Workflow todos", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
198
|
+
name: 'users_jobs',
|
|
199
|
+
fields: [{
|
|
200
|
+
type: 'belongsTo',
|
|
201
|
+
name: 'user',
|
|
202
|
+
target: 'users',
|
|
203
|
+
foreignKey: 'userId',
|
|
204
|
+
interface: 'm2o',
|
|
205
|
+
uiSchema: {
|
|
206
|
+
type: 'number',
|
|
207
|
+
title: '{{t("User")}}',
|
|
208
|
+
'x-component': 'RemoteSelect',
|
|
209
|
+
'x-component-props': {
|
|
210
|
+
fieldNames: {
|
|
211
|
+
label: 'nickname',
|
|
212
|
+
value: 'id'
|
|
213
|
+
},
|
|
214
|
+
service: {
|
|
215
|
+
resource: 'users'
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
type: 'belongsTo',
|
|
221
|
+
name: 'node',
|
|
222
|
+
target: 'flow_nodes',
|
|
223
|
+
foreignKey: 'nodeId',
|
|
224
|
+
interface: 'm2o',
|
|
225
|
+
isAssociation: true,
|
|
226
|
+
uiSchema: {
|
|
227
|
+
type: 'number',
|
|
228
|
+
title: `{{t("Task", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
229
|
+
'x-component': 'RemoteSelect',
|
|
230
|
+
'x-component-props': {
|
|
231
|
+
fieldNames: {
|
|
232
|
+
label: 'title',
|
|
233
|
+
value: 'id'
|
|
234
|
+
},
|
|
235
|
+
service: {
|
|
236
|
+
resource: 'flow_nodes'
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
type: 'belongsTo',
|
|
242
|
+
name: 'workflow',
|
|
243
|
+
target: 'workflows',
|
|
244
|
+
foreignKey: 'workflowId',
|
|
245
|
+
interface: 'm2o',
|
|
246
|
+
uiSchema: {
|
|
247
|
+
type: 'number',
|
|
248
|
+
title: `{{t("Workflow", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
249
|
+
'x-component': 'RemoteSelect',
|
|
250
|
+
'x-component-props': {
|
|
251
|
+
fieldNames: {
|
|
252
|
+
label: 'title',
|
|
253
|
+
value: 'id'
|
|
254
|
+
},
|
|
255
|
+
service: {
|
|
256
|
+
resource: 'workflows'
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
type: 'integer',
|
|
262
|
+
name: 'status',
|
|
263
|
+
interface: 'select',
|
|
264
|
+
uiSchema: {
|
|
265
|
+
type: 'number',
|
|
266
|
+
title: `{{t("Status", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
267
|
+
'x-component': 'Select',
|
|
268
|
+
enum: _constants.JobStatusOptions
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
name: 'createdAt',
|
|
272
|
+
type: 'date',
|
|
273
|
+
interface: 'createdAt',
|
|
274
|
+
uiSchema: {
|
|
275
|
+
type: 'datetime',
|
|
276
|
+
title: '{{t("Created at")}}',
|
|
277
|
+
'x-component': 'DatePicker',
|
|
278
|
+
'x-component-props': {
|
|
279
|
+
showTime: true
|
|
280
|
+
},
|
|
281
|
+
'x-read-pretty': true
|
|
282
|
+
}
|
|
283
|
+
}]
|
|
284
|
+
};
|
|
285
|
+
const NodeColumn = (0, _react2().observer)(() => {
|
|
286
|
+
var _field$value$title, _field$value, _field$value2;
|
|
287
|
+
|
|
288
|
+
const field = (0, _react2().useField)();
|
|
289
|
+
return (_field$value$title = field === null || field === void 0 ? void 0 : (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.title) !== null && _field$value$title !== void 0 ? _field$value$title : `#${(_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : _field$value2.id}`;
|
|
290
|
+
});
|
|
291
|
+
const WorkflowColumn = (0, _react2().observer)(() => {
|
|
292
|
+
var _field$value$title2, _field$value3, _field$value4;
|
|
293
|
+
|
|
294
|
+
const field = (0, _react2().useField)();
|
|
295
|
+
return (_field$value$title2 = field === null || field === void 0 ? void 0 : (_field$value3 = field.value) === null || _field$value3 === void 0 ? void 0 : _field$value3.title) !== null && _field$value$title2 !== void 0 ? _field$value$title2 : `#${(_field$value4 = field.value) === null || _field$value4 === void 0 ? void 0 : _field$value4.id}`;
|
|
296
|
+
});
|
|
297
|
+
const UserColumn = (0, _react2().observer)(() => {
|
|
298
|
+
var _field$value$nickname, _field$value5, _field$value6;
|
|
299
|
+
|
|
300
|
+
const field = (0, _react2().useField)();
|
|
301
|
+
return (_field$value$nickname = field === null || field === void 0 ? void 0 : (_field$value5 = field.value) === null || _field$value5 === void 0 ? void 0 : _field$value5.nickname) !== null && _field$value$nickname !== void 0 ? _field$value$nickname : (_field$value6 = field.value) === null || _field$value6 === void 0 ? void 0 : _field$value6.id;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
function WorkflowTodo() {
|
|
305
|
+
return _react().default.createElement(_client().SchemaComponent, {
|
|
306
|
+
components: {
|
|
307
|
+
NodeColumn,
|
|
308
|
+
WorkflowColumn,
|
|
309
|
+
UserColumn
|
|
310
|
+
},
|
|
311
|
+
schema: {
|
|
312
|
+
type: 'void',
|
|
313
|
+
name: (0, _client2().uid)(),
|
|
314
|
+
'x-component': 'div',
|
|
315
|
+
properties: {
|
|
316
|
+
actions: {
|
|
317
|
+
type: 'void',
|
|
318
|
+
'x-component': 'ActionBar',
|
|
319
|
+
'x-component-props': {
|
|
320
|
+
style: {
|
|
321
|
+
marginBottom: 16
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
properties: {
|
|
325
|
+
filter: {
|
|
326
|
+
type: 'void',
|
|
327
|
+
title: '{{ t("Filter") }}',
|
|
328
|
+
'x-action': 'filter',
|
|
329
|
+
'x-designer': 'Filter.Action.Designer',
|
|
330
|
+
'x-component': 'Filter.Action',
|
|
331
|
+
'x-component-props': {
|
|
332
|
+
icon: 'FilterOutlined',
|
|
333
|
+
useProps: '{{ useFilterActionProps }}'
|
|
334
|
+
},
|
|
335
|
+
'x-align': 'left'
|
|
336
|
+
},
|
|
337
|
+
refresher: {
|
|
338
|
+
type: 'void',
|
|
339
|
+
title: '{{ t("Refresh") }}',
|
|
340
|
+
'x-action': 'refresh',
|
|
341
|
+
'x-component': 'Action',
|
|
342
|
+
'x-designer': 'Action.Designer',
|
|
343
|
+
'x-component-props': {
|
|
344
|
+
icon: 'ReloadOutlined',
|
|
345
|
+
useProps: '{{ useRefreshActionProps }}'
|
|
346
|
+
},
|
|
347
|
+
'x-align': 'right'
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
table: {
|
|
352
|
+
type: 'array',
|
|
353
|
+
'x-component': 'TableV2',
|
|
354
|
+
'x-component-props': {
|
|
355
|
+
rowKey: 'id',
|
|
356
|
+
useProps: '{{ useTableBlockProps }}'
|
|
357
|
+
},
|
|
358
|
+
properties: {
|
|
359
|
+
node: {
|
|
360
|
+
type: 'void',
|
|
361
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
362
|
+
'x-component': 'TableV2.Column',
|
|
363
|
+
title: `{{t("Task", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
364
|
+
properties: {
|
|
365
|
+
node: {
|
|
366
|
+
'x-component': 'NodeColumn',
|
|
367
|
+
'x-read-pretty': true
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
workflow: {
|
|
372
|
+
type: 'void',
|
|
373
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
374
|
+
'x-component': 'TableV2.Column',
|
|
375
|
+
title: `{{t("Workflow", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
376
|
+
properties: {
|
|
377
|
+
workflow: {
|
|
378
|
+
'x-component': 'WorkflowColumn',
|
|
379
|
+
'x-read-pretty': true
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
createdAt: {
|
|
384
|
+
type: 'void',
|
|
385
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
386
|
+
'x-component': 'TableV2.Column',
|
|
387
|
+
properties: {
|
|
388
|
+
createdAt: {
|
|
389
|
+
type: 'number',
|
|
390
|
+
'x-component': 'CollectionField',
|
|
391
|
+
'x-read-pretty': true
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
user: {
|
|
396
|
+
type: 'void',
|
|
397
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
398
|
+
'x-component': 'TableV2.Column',
|
|
399
|
+
title: `{{t("Assignee", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
400
|
+
properties: {
|
|
401
|
+
user: {
|
|
402
|
+
'x-component': 'UserColumn',
|
|
403
|
+
'x-read-pretty': true
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
status: {
|
|
408
|
+
type: 'void',
|
|
409
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
410
|
+
'x-component': 'TableV2.Column',
|
|
411
|
+
properties: {
|
|
412
|
+
status: {
|
|
413
|
+
type: 'number',
|
|
414
|
+
'x-component': 'CollectionField',
|
|
415
|
+
'x-read-pretty': true
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
actions: {
|
|
420
|
+
type: 'void',
|
|
421
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
422
|
+
'x-component': 'TableV2.Column',
|
|
423
|
+
title: '{{t("Actions")}}',
|
|
424
|
+
properties: {
|
|
425
|
+
view: {
|
|
426
|
+
type: 'void',
|
|
427
|
+
'x-component': 'Action.Link',
|
|
428
|
+
title: '{{t("View")}}',
|
|
429
|
+
properties: {
|
|
430
|
+
drawer: {
|
|
431
|
+
'x-component': 'WorkflowTodo.Drawer'
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const ManualActionStatusContext = (0, _react().createContext)(null);
|
|
445
|
+
|
|
446
|
+
function useManualActionStatusContext() {
|
|
447
|
+
return (0, _react().useContext)(ManualActionStatusContext);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function ManualActionStatusProvider({
|
|
451
|
+
value,
|
|
452
|
+
children
|
|
453
|
+
}) {
|
|
454
|
+
return _react().default.createElement(ManualActionStatusContext.Provider, {
|
|
455
|
+
value: value
|
|
456
|
+
}, children);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function useSubmit() {
|
|
460
|
+
const api = (0, _client().useAPIClient)();
|
|
461
|
+
|
|
462
|
+
const _useActionContext = (0, _client().useActionContext)(),
|
|
463
|
+
setVisible = _useActionContext.setVisible;
|
|
464
|
+
|
|
465
|
+
const _useForm = (0, _react2().useForm)(),
|
|
466
|
+
values = _useForm.values,
|
|
467
|
+
submit = _useForm.submit;
|
|
468
|
+
|
|
469
|
+
const nextStatus = useManualActionStatusContext();
|
|
470
|
+
|
|
471
|
+
const _useTableBlockContext = (0, _client().useTableBlockContext)(),
|
|
472
|
+
service = _useTableBlockContext.service;
|
|
473
|
+
|
|
474
|
+
const _useRecord = (0, _client().useRecord)(),
|
|
475
|
+
id = _useRecord.id;
|
|
476
|
+
|
|
477
|
+
return {
|
|
478
|
+
run() {
|
|
479
|
+
return _asyncToGenerator(function* () {
|
|
480
|
+
yield submit();
|
|
481
|
+
yield api.resource('users_jobs').submit({
|
|
482
|
+
filterByTk: id,
|
|
483
|
+
values: {
|
|
484
|
+
status: nextStatus,
|
|
485
|
+
result: values
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
setVisible(false);
|
|
489
|
+
service.refresh();
|
|
490
|
+
})();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function useFlowRecordFromBlock(opts) {
|
|
497
|
+
var _execution$jobs;
|
|
498
|
+
|
|
499
|
+
const _useFieldSchema = (0, _react2().useFieldSchema)(),
|
|
500
|
+
dataSource = _useFieldSchema['x-context-datasource'];
|
|
501
|
+
|
|
502
|
+
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
503
|
+
execution = _useFlowContext.execution;
|
|
504
|
+
|
|
505
|
+
let result = (0, _jsonTemplates().default)(dataSource)({
|
|
506
|
+
$context: execution === null || execution === void 0 ? void 0 : execution.context,
|
|
507
|
+
$jobsMapByNodeId: ((_execution$jobs = execution === null || execution === void 0 ? void 0 : execution.jobs) !== null && _execution$jobs !== void 0 ? _execution$jobs : []).reduce((map, job) => Object.assign(map, {
|
|
508
|
+
[job.nodeId]: job.result
|
|
509
|
+
}), {})
|
|
510
|
+
});
|
|
511
|
+
return (0, _client().useRequest)(() => {
|
|
512
|
+
return Promise.resolve({
|
|
513
|
+
data: result
|
|
514
|
+
});
|
|
515
|
+
}, opts);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function FlowContextProvider(props) {
|
|
519
|
+
const api = (0, _client().useAPIClient)();
|
|
520
|
+
|
|
521
|
+
const _useRecord2 = (0, _client().useRecord)(),
|
|
522
|
+
node = _useRecord2.node,
|
|
523
|
+
executionId = _useRecord2.executionId;
|
|
524
|
+
|
|
525
|
+
const _useState = (0, _react().useState)(null),
|
|
526
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
527
|
+
flowContext = _useState2[0],
|
|
528
|
+
setFlowContext = _useState2[1];
|
|
529
|
+
|
|
530
|
+
(0, _react().useEffect)(() => {
|
|
531
|
+
var _api$resource$get, _api$resource;
|
|
532
|
+
|
|
533
|
+
if (!executionId) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
(_api$resource$get = (_api$resource = api.resource('executions')).get) === null || _api$resource$get === void 0 ? void 0 : _api$resource$get.call(_api$resource, {
|
|
538
|
+
filterByTk: executionId,
|
|
539
|
+
appends: ['workflow', 'workflow.nodes', 'jobs']
|
|
540
|
+
}).then(({
|
|
541
|
+
data
|
|
542
|
+
}) => {
|
|
543
|
+
var _data$data;
|
|
544
|
+
|
|
545
|
+
const _ref = (_data$data = data === null || data === void 0 ? void 0 : data.data) !== null && _data$data !== void 0 ? _data$data : {},
|
|
546
|
+
_ref$workflow = _ref.workflow,
|
|
547
|
+
_ref$workflow2 = _ref$workflow === void 0 ? {} : _ref$workflow,
|
|
548
|
+
_ref$workflow2$nodes = _ref$workflow2.nodes,
|
|
549
|
+
nodes = _ref$workflow2$nodes === void 0 ? [] : _ref$workflow2$nodes,
|
|
550
|
+
workflow = _objectWithoutProperties(_ref$workflow2, _excluded),
|
|
551
|
+
execution = _objectWithoutProperties(_ref, _excluded2);
|
|
552
|
+
|
|
553
|
+
(0, _utils.linkNodes)(nodes);
|
|
554
|
+
setFlowContext({
|
|
555
|
+
workflow,
|
|
556
|
+
nodes,
|
|
557
|
+
execution
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
}, [executionId]);
|
|
561
|
+
|
|
562
|
+
if (!flowContext) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const nodes = (0, _.useAvailableUpstreams)(flowContext.nodes.find(item => item.id === node.id));
|
|
567
|
+
const nodeComponents = nodes.reduce((components, {
|
|
568
|
+
type
|
|
569
|
+
}) => Object.assign(components, _.instructions.get(type).components), {});
|
|
570
|
+
return _react().default.createElement(_FlowContext.FlowContext.Provider, {
|
|
571
|
+
value: flowContext
|
|
572
|
+
}, _react().default.createElement(_client().SchemaComponentOptions, {
|
|
573
|
+
components: _objectSpread({}, nodeComponents)
|
|
574
|
+
}, props.children));
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
WorkflowTodo.Drawer = function () {
|
|
578
|
+
var _node$config$schema, _node$title;
|
|
579
|
+
|
|
580
|
+
const ctx = (0, _react().useContext)(_client().SchemaComponentContext);
|
|
581
|
+
|
|
582
|
+
const _useRecord3 = (0, _client().useRecord)(),
|
|
583
|
+
id = _useRecord3.id,
|
|
584
|
+
node = _useRecord3.node,
|
|
585
|
+
workflow = _useRecord3.workflow,
|
|
586
|
+
status = _useRecord3.status,
|
|
587
|
+
result = _useRecord3.result,
|
|
588
|
+
updatedAt = _useRecord3.updatedAt;
|
|
589
|
+
|
|
590
|
+
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
591
|
+
readPretty: Boolean(status),
|
|
592
|
+
initialValues: result
|
|
593
|
+
}), [result]);
|
|
594
|
+
|
|
595
|
+
const _ref2 = (_node$config$schema = node.config.schema) !== null && _node$config$schema !== void 0 ? _node$config$schema : {},
|
|
596
|
+
blocks = _ref2.blocks,
|
|
597
|
+
collection = _ref2.collection,
|
|
598
|
+
actions = _ref2.actions;
|
|
599
|
+
|
|
600
|
+
const statusOption = _constants.JobStatusOptionsMap[status];
|
|
601
|
+
const actionSchema = status ? {
|
|
602
|
+
date: {
|
|
603
|
+
type: 'void',
|
|
604
|
+
'x-component': 'time',
|
|
605
|
+
'x-component-props': {
|
|
606
|
+
className: (0, _css().css)`
|
|
607
|
+
margin-right: .5em;
|
|
608
|
+
`
|
|
609
|
+
},
|
|
610
|
+
'x-content': (0, _moment().default)(updatedAt).format('YYYY-MM-DD HH:mm:ss')
|
|
611
|
+
},
|
|
612
|
+
status: {
|
|
613
|
+
type: 'void',
|
|
614
|
+
'x-component': 'Tag',
|
|
615
|
+
'x-component-props': {
|
|
616
|
+
icon: statusOption.icon,
|
|
617
|
+
color: statusOption.color
|
|
618
|
+
},
|
|
619
|
+
'x-content': statusOption.label
|
|
620
|
+
}
|
|
621
|
+
} : actions;
|
|
622
|
+
return _react().default.createElement(_client().SchemaComponentContext.Provider, {
|
|
623
|
+
value: _objectSpread(_objectSpread({}, ctx), {}, {
|
|
624
|
+
designable: false
|
|
625
|
+
})
|
|
626
|
+
}, _react().default.createElement(_client().CollectionProvider, {
|
|
627
|
+
collection: collection
|
|
628
|
+
}, _react().default.createElement(_client().SchemaComponent, {
|
|
629
|
+
components: {
|
|
630
|
+
Tag: _antd().Tag,
|
|
631
|
+
ManualActionStatusProvider,
|
|
632
|
+
FlowContextProvider
|
|
633
|
+
},
|
|
634
|
+
schema: {
|
|
635
|
+
type: 'void',
|
|
636
|
+
name: `drawer-${id}-${status}`,
|
|
637
|
+
'x-decorator': 'Form',
|
|
638
|
+
'x-decorator-props': {
|
|
639
|
+
form
|
|
640
|
+
},
|
|
641
|
+
'x-component': 'Action.Drawer',
|
|
642
|
+
'x-component-props': {
|
|
643
|
+
className: 'nb-action-popup'
|
|
644
|
+
},
|
|
645
|
+
title: `${workflow.title} - ${(_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`}`,
|
|
646
|
+
properties: {
|
|
647
|
+
tabs: {
|
|
648
|
+
type: 'void',
|
|
649
|
+
'x-decorator': 'FlowContextProvider',
|
|
650
|
+
'x-component': 'Tabs',
|
|
651
|
+
properties: blocks
|
|
652
|
+
},
|
|
653
|
+
footer: {
|
|
654
|
+
type: 'void',
|
|
655
|
+
'x-component': 'Action.Drawer.Footer',
|
|
656
|
+
properties: actionSchema
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
scope: {
|
|
661
|
+
useSubmit,
|
|
662
|
+
useFlowRecordFromBlock
|
|
663
|
+
}
|
|
664
|
+
})));
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
WorkflowTodo.Decorator = function ({
|
|
668
|
+
children
|
|
669
|
+
}) {
|
|
670
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
671
|
+
collections = _useCollectionManager.collections,
|
|
672
|
+
cm = _objectWithoutProperties(_useCollectionManager, _excluded3);
|
|
673
|
+
|
|
674
|
+
const blockProps = {
|
|
675
|
+
collection: 'users_jobs',
|
|
676
|
+
resource: 'users_jobs',
|
|
677
|
+
action: 'list',
|
|
678
|
+
params: {
|
|
679
|
+
pageSize: 20,
|
|
680
|
+
sort: ['-createdAt'],
|
|
681
|
+
appends: ['user', 'node', 'workflow'],
|
|
682
|
+
except: ['workflow.config']
|
|
683
|
+
},
|
|
684
|
+
rowKey: 'id',
|
|
685
|
+
showIndex: true,
|
|
686
|
+
dragSort: false
|
|
687
|
+
};
|
|
688
|
+
return _react().default.createElement(_client().CollectionManagerProvider, _objectSpread(_objectSpread({}, cm), {}, {
|
|
689
|
+
collections: [...collections, nodeCollection, workflowCollection, todoCollection]
|
|
690
|
+
}), _react().default.createElement(_client().TableBlockProvider, _objectSpread({}, blockProps), children));
|
|
691
|
+
};
|