@nocobase/plugin-workflow 0.10.1-alpha.1 → 0.11.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/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +13 -11
- package/lib/client/Branch.js +10 -8
- package/lib/client/CanvasContent.js +12 -10
- package/lib/client/ExecutionCanvas.js +37 -33
- package/lib/client/ExecutionPage.js +4 -9
- package/lib/client/WorkflowCanvas.js +18 -15
- package/lib/client/WorkflowPage.js +4 -9
- package/lib/client/WorkflowProvider.js +1 -40
- package/lib/client/components/CollectionBlockInitializer.js +3 -3
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +15 -16
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +10 -7
- package/lib/client/components/NodeDescription.js +45 -31
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/locale/zh-CN.d.ts +5 -1
- package/lib/client/locale/zh-CN.js +6 -2
- package/lib/client/nodes/aggregate.d.ts +8 -3
- package/lib/client/nodes/aggregate.js +5 -4
- package/lib/client/nodes/calculation.d.ts +6 -4
- package/lib/client/nodes/calculation.js +22 -28
- package/lib/client/nodes/condition.d.ts +2 -10
- package/lib/client/nodes/condition.js +19 -37
- package/lib/client/nodes/create.d.ts +5 -6
- package/lib/client/nodes/create.js +1 -3
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +2 -3
- package/lib/client/nodes/index.js +95 -102
- package/lib/client/nodes/loop.d.ts +1 -1
- package/lib/client/nodes/loop.js +46 -54
- package/lib/client/nodes/manual/FormBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +4 -5
- package/lib/client/nodes/manual/SchemaConfig.js +180 -25
- package/lib/client/nodes/manual/WorkflowTodo.js +95 -110
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/create.js +8 -1
- package/lib/client/nodes/manual/forms/custom.js +22 -22
- package/lib/client/nodes/manual/forms/update.js +8 -1
- package/lib/client/nodes/manual/index.d.ts +6 -1
- package/lib/client/nodes/manual/index.js +5 -4
- package/lib/client/nodes/parallel.js +23 -20
- package/lib/client/nodes/query.d.ts +3 -5
- package/lib/client/nodes/query.js +1 -3
- package/lib/client/nodes/request.d.ts +2 -2
- package/lib/client/nodes/request.js +7 -7
- package/lib/client/nodes/sql.d.ts +26 -0
- package/lib/client/{triggers/schedule/DateFieldsSelect.js → nodes/sql.js} +37 -46
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +3 -4
- package/lib/client/schemas/collection.js +11 -17
- package/lib/client/style.d.ts +18 -13
- package/lib/client/style.js +315 -292
- package/lib/client/triggers/collection.d.ts +13 -13
- package/lib/client/triggers/collection.js +5 -1
- package/lib/client/triggers/index.d.ts +3 -4
- package/lib/client/triggers/index.js +51 -53
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +45 -33
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +24 -31
- package/lib/client/triggers/schedule/index.d.ts +1 -1
- package/lib/client/triggers/schedule/index.js +32 -20
- package/lib/client/variable.d.ts +31 -13
- package/lib/client/variable.js +44 -29
- package/lib/server/Plugin.d.ts +3 -6
- package/lib/server/Plugin.js +15 -12
- package/lib/server/Processor.d.ts +3 -5
- package/lib/server/Processor.js +2 -2
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +2 -2
- package/lib/server/instructions/create.js +13 -13
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +19 -7
- package/lib/server/instructions/manual/forms/create.js +7 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/forms/update.js +7 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/query.js +8 -1
- package/lib/server/instructions/request.d.ts +3 -3
- package/lib/server/instructions/request.js +5 -2
- package/lib/server/instructions/sql.d.ts +12 -0
- package/lib/server/instructions/sql.js +34 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/migrations/20230710115902-manual-action-values.d.ts +4 -0
- package/lib/server/migrations/20230710115902-manual-action-values.js +97 -0
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +15 -13
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/lib/server/utils.d.ts +2 -0
- package/lib/server/utils.js +21 -0
- package/package.json +39 -18
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +111 -0
- package/src/client/Branch.tsx +37 -0
- package/src/client/CanvasContent.tsx +25 -0
- package/src/client/ExecutionCanvas.tsx +166 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +45 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +221 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +52 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +160 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +32 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +51 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +248 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +216 -0
- package/src/client/nodes/condition.tsx +463 -0
- package/src/client/nodes/create.tsx +85 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +485 -0
- package/src/client/nodes/loop.tsx +144 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +69 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +509 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +607 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +92 -0
- package/src/client/nodes/manual/forms/custom.tsx +392 -0
- package/src/client/nodes/manual/forms/update.tsx +134 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +138 -0
- package/src/client/nodes/query.tsx +88 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/sql.tsx +37 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +347 -0
- package/src/client/triggers/collection.tsx +190 -0
- package/src/client/triggers/index.tsx +311 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +64 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +227 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +78 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +318 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +355 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +27 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +1173 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +247 -0
- package/src/server/__tests__/instructions/sql.test.ts +162 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +333 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +39 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +64 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +91 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +23 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +23 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +42 -0
- package/src/server/instructions/request.ts +88 -0
- package/src/server/instructions/sql.ts +25 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/migrations/20230710115902-manual-action-values.ts +78 -0
- package/src/server/triggers/collection.ts +146 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- package/src/server/utils.ts +17 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +0 -2
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function _lodash() {
|
|
8
|
-
const data = require("lodash");
|
|
9
|
-
_lodash = function _lodash() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _server() {
|
|
15
8
|
const data = require("@nocobase/server");
|
|
16
9
|
_server = function _server() {
|
|
@@ -287,7 +280,7 @@ class _default extends _server().Migration {
|
|
|
287
280
|
yield usedNodes.reduce((promise, node) => promise.then( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
288
281
|
var _node$config2;
|
|
289
282
|
yield node.update({
|
|
290
|
-
config: migrateUsedConfig((
|
|
283
|
+
config: migrateUsedConfig(_utils().lodash.cloneDeep((_node$config2 = node.config) !== null && _node$config2 !== void 0 ? _node$config2 : {}), nodeForms)
|
|
291
284
|
}, {
|
|
292
285
|
silent: true,
|
|
293
286
|
transaction
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _server() {
|
|
8
|
+
const data = require("@nocobase/server");
|
|
9
|
+
_server = function _server() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
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); } }
|
|
20
|
+
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); }); }; }
|
|
21
|
+
function findSchema(root, filter, onlyLeaf = false) {
|
|
22
|
+
const result = [];
|
|
23
|
+
if (!root) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
if (filter(root) && (!onlyLeaf || !root.properties)) {
|
|
27
|
+
result.push(root);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
if (root.properties) {
|
|
31
|
+
Object.keys(root.properties).forEach(key => {
|
|
32
|
+
result.push(...findSchema(root.properties[key], filter));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function migrateConfig(config) {
|
|
38
|
+
const _config$forms = config.forms,
|
|
39
|
+
forms = _config$forms === void 0 ? {} : _config$forms,
|
|
40
|
+
_config$schema = config.schema,
|
|
41
|
+
schema = _config$schema === void 0 ? {} : _config$schema;
|
|
42
|
+
const root = {
|
|
43
|
+
properties: schema
|
|
44
|
+
};
|
|
45
|
+
Object.keys(forms).forEach(key => {
|
|
46
|
+
const form = forms[key];
|
|
47
|
+
const formSchema = findSchema(root, item => item.name === key);
|
|
48
|
+
const actions = findSchema(formSchema[0], item => item['x-component'] === 'Action');
|
|
49
|
+
form.actions = actions.map(action => {
|
|
50
|
+
action['x-designer'] = 'ManualActionDesigner';
|
|
51
|
+
action['x-action-settings'] = {};
|
|
52
|
+
delete action['x-action'];
|
|
53
|
+
return {
|
|
54
|
+
status: action['x-decorator-props'].value,
|
|
55
|
+
values: {},
|
|
56
|
+
key: action.name
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
class _default extends _server().Migration {
|
|
63
|
+
up() {
|
|
64
|
+
var _this = this;
|
|
65
|
+
return _asyncToGenerator(function* () {
|
|
66
|
+
const match = yield _this.app.version.satisfies('<0.11.0-alpha.2');
|
|
67
|
+
if (!match) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const db = _this.context.db;
|
|
71
|
+
const NodeRepo = db.getRepository('flow_nodes');
|
|
72
|
+
yield db.sequelize.transaction( /*#__PURE__*/function () {
|
|
73
|
+
var _ref = _asyncToGenerator(function* (transaction) {
|
|
74
|
+
const nodes = yield NodeRepo.find({
|
|
75
|
+
filter: {
|
|
76
|
+
type: 'manual'
|
|
77
|
+
},
|
|
78
|
+
transaction
|
|
79
|
+
});
|
|
80
|
+
console.log('%d nodes need to be migrated.', nodes.length);
|
|
81
|
+
yield nodes.reduce((promise, node) => promise.then(() => {
|
|
82
|
+
node.set('config', _objectSpread({}, migrateConfig(node.config)));
|
|
83
|
+
node.changed('config', true);
|
|
84
|
+
return node.save({
|
|
85
|
+
silent: true,
|
|
86
|
+
transaction
|
|
87
|
+
});
|
|
88
|
+
}), Promise.resolve());
|
|
89
|
+
});
|
|
90
|
+
return function (_x) {
|
|
91
|
+
return _ref.apply(this, arguments);
|
|
92
|
+
};
|
|
93
|
+
}());
|
|
94
|
+
})();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.default = _default;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ = require("..");
|
|
8
|
+
var _utils = require("../utils");
|
|
8
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
10
|
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."); }
|
|
10
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
@@ -56,7 +57,7 @@ function _handler() {
|
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
// NOTE: if no configured condition match, do not trigger
|
|
59
|
-
if (condition && (
|
|
60
|
+
if (condition && (_condition$$and = condition.$and) !== null && _condition$$and !== void 0 && _condition$$and.length) {
|
|
60
61
|
// TODO: change to map filter format to calculation format
|
|
61
62
|
// const calculation = toCalculation(condition);
|
|
62
63
|
const count = yield repository.count({
|
|
@@ -72,22 +73,23 @@ function _handler() {
|
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
let result = data;
|
|
77
|
+
if (appends !== null && appends !== void 0 && appends.length && !(mode & MODE_BITMAP.DESTROY)) {
|
|
78
|
+
const includeFields = appends.reduce((set, field) => {
|
|
79
|
+
set.add(field.split('.')[0]);
|
|
80
|
+
set.add(field);
|
|
81
|
+
return set;
|
|
82
|
+
}, new Set());
|
|
83
|
+
result = yield repository.findOne({
|
|
84
|
+
filterByTk: data[model.primaryKeyAttribute],
|
|
85
|
+
appends: Array.from(includeFields),
|
|
80
86
|
transaction
|
|
81
87
|
});
|
|
82
|
-
includeFields.forEach(field => {
|
|
83
|
-
const value = included.get(field);
|
|
84
|
-
data.set(field, Array.isArray(value) ? value.map(item => item.toJSON()) : value ? value.toJSON() : null, {
|
|
85
|
-
raw: true
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
88
|
}
|
|
89
|
+
// TODO: `result.toJSON()` throws error
|
|
90
|
+
const json = (0, _utils.toJSON)(result);
|
|
89
91
|
this.plugin.trigger(workflow, {
|
|
90
|
-
data:
|
|
92
|
+
data: json
|
|
91
93
|
}, {
|
|
92
94
|
context
|
|
93
95
|
});
|
|
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.SCHEDULE_MODE = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data =
|
|
9
|
-
|
|
7
|
+
function _database() {
|
|
8
|
+
const data = require("@nocobase/database");
|
|
9
|
+
_database = function _database() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data = require("
|
|
16
|
-
|
|
14
|
+
function _cronParser() {
|
|
15
|
+
const data = _interopRequireDefault(require("cron-parser"));
|
|
16
|
+
_cronParser = function _cronParser() {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
@@ -233,7 +233,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
233
233
|
}
|
|
234
234
|
const conditions = [{
|
|
235
235
|
[startsOn.field]: {
|
|
236
|
-
[
|
|
236
|
+
[_database().Op.lt]: new Date(startTimestamp + _this2.cacheCycle)
|
|
237
237
|
}
|
|
238
238
|
}];
|
|
239
239
|
// when repeat is number, means repeat after startsOn
|
|
@@ -241,8 +241,8 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
241
241
|
if (repeat) {
|
|
242
242
|
const tsFn = DialectTimestampFnMap[db.options.dialect];
|
|
243
243
|
if (typeof repeat === 'number' && repeat > _this2.cacheCycle && tsFn) {
|
|
244
|
-
conditions.push((0,
|
|
245
|
-
[
|
|
244
|
+
conditions.push((0, _database().where)((0, _database().fn)('MOD', (0, _database().literal)(`${Math.round(timestamp / 1000)} - ${tsFn(startsOn.field)}`), Math.round(repeat / 1000)), {
|
|
245
|
+
[_database().Op.lt]: Math.round(_this2.cacheCycle / 1000)
|
|
246
246
|
}));
|
|
247
247
|
// conditions.push(literal(`mod(${timestamp} - ${tsFn(startsOn.field)} * 1000, ${repeat}) < ${this.cacheCycle}`));
|
|
248
248
|
}
|
|
@@ -259,7 +259,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
259
259
|
} else {
|
|
260
260
|
conditions.push({
|
|
261
261
|
[endsOn.field]: {
|
|
262
|
-
[
|
|
262
|
+
[_database().Op.gte]: new Date(endTimestamp + _this2.interval)
|
|
263
263
|
}
|
|
264
264
|
});
|
|
265
265
|
}
|
|
@@ -267,7 +267,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
267
267
|
} else {
|
|
268
268
|
conditions.push({
|
|
269
269
|
[startsOn.field]: {
|
|
270
|
-
[
|
|
270
|
+
[_database().Op.gte]: new Date(startTimestamp)
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
}
|
|
@@ -275,7 +275,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
275
275
|
model = _db$getCollection.model;
|
|
276
276
|
const count = yield model.count({
|
|
277
277
|
where: {
|
|
278
|
-
[
|
|
278
|
+
[_database().Op.and]: conditions
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
281
|
return Boolean(count);
|
|
@@ -297,20 +297,20 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
297
297
|
}
|
|
298
298
|
const conditions = [{
|
|
299
299
|
[startsOn.field]: {
|
|
300
|
-
[
|
|
300
|
+
[_database().Op.lt]: new Date(startTimestamp + _this3.interval)
|
|
301
301
|
}
|
|
302
302
|
}];
|
|
303
303
|
if (repeat) {
|
|
304
304
|
// startsOn not after now
|
|
305
305
|
conditions.push({
|
|
306
306
|
[startsOn.field]: {
|
|
307
|
-
[
|
|
307
|
+
[_database().Op.lt]: new Date(startTimestamp)
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
const tsFn = DialectTimestampFnMap[_this3.plugin.app.db.options.dialect];
|
|
311
311
|
if (typeof repeat === 'number' && tsFn) {
|
|
312
|
-
conditions.push((0,
|
|
313
|
-
[
|
|
312
|
+
conditions.push((0, _database().where)((0, _database().fn)('MOD', (0, _database().literal)(`${Math.round(timestamp / 1000)} - ${tsFn(startsOn.field)}`), Math.round(repeat / 1000)), {
|
|
313
|
+
[_database().Op.eq]: 0
|
|
314
314
|
}));
|
|
315
315
|
// conditions.push(literal(`MOD(CAST(${timestamp} AS BIGINT) - CAST((FLOOR(${tsFn(startsOn.field)}) AS BIGINT) * 1000), ${repeat}) = 0`));
|
|
316
316
|
}
|
|
@@ -327,7 +327,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
327
327
|
} else {
|
|
328
328
|
conditions.push({
|
|
329
329
|
[endsOn.field]: {
|
|
330
|
-
[
|
|
330
|
+
[_database().Op.gte]: new Date(endTimestamp + _this3.interval)
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
}
|
|
@@ -336,7 +336,7 @@ ScheduleModes.set(SCHEDULE_MODE.COLLECTION_FIELD, {
|
|
|
336
336
|
// startsOn exactly equal to now in 1s
|
|
337
337
|
conditions.push({
|
|
338
338
|
[startsOn.field]: {
|
|
339
|
-
[
|
|
339
|
+
[_database().Op.gte]: new Date(startTimestamp)
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
342
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Database, Model } from '@nocobase/database';
|
|
2
|
-
import { BelongsToGetAssociationMixin, HasManyGetAssociationsMixin } from 'sequelize';
|
|
3
|
-
import WorkflowModel from './Workflow';
|
|
1
|
+
import { BelongsToGetAssociationMixin, Database, HasManyGetAssociationsMixin, Model } from '@nocobase/database';
|
|
4
2
|
import JobModel from './Job';
|
|
3
|
+
import WorkflowModel from './Workflow';
|
|
5
4
|
export default class ExecutionModel extends Model {
|
|
6
5
|
static readonly database: Database;
|
|
7
6
|
id: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Database, Model } from '@nocobase/database';
|
|
2
|
-
import { BelongsToGetAssociationMixin } from 'sequelize';
|
|
1
|
+
import { BelongsToGetAssociationMixin, Database, Model } from '@nocobase/database';
|
|
3
2
|
import WorkflowModel from './Workflow';
|
|
4
3
|
export default class FlowNodeModel extends Model {
|
|
5
4
|
static readonly database: Database;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Model } from '@nocobase/database';
|
|
2
|
-
import { BelongsToGetAssociationMixin } from 'sequelize';
|
|
1
|
+
import { BelongsToGetAssociationMixin, Model } from '@nocobase/database';
|
|
3
2
|
import FlowNodeModel from './FlowNode';
|
|
4
3
|
export default class JobModel extends Model {
|
|
5
4
|
id: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Database, Model } from '@nocobase/database';
|
|
2
|
-
import { HasManyCountAssociationsMixin, HasManyCreateAssociationMixin, HasManyGetAssociationsMixin } from 'sequelize';
|
|
1
|
+
import { Database, HasManyCountAssociationsMixin, HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, Model } from '@nocobase/database';
|
|
3
2
|
import ExecutionModel from './Execution';
|
|
4
3
|
import FlowNodeModel from './FlowNode';
|
|
5
4
|
export default class WorkflowModel extends Model {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toJSON = toJSON;
|
|
7
|
+
function toJSON(data) {
|
|
8
|
+
if (typeof data !== 'object' || !data) {
|
|
9
|
+
return data;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(data)) {
|
|
12
|
+
return data.map(toJSON);
|
|
13
|
+
}
|
|
14
|
+
const result = data.get();
|
|
15
|
+
Object.keys(data.constructor.associations).forEach(key => {
|
|
16
|
+
if (result[key] != null) {
|
|
17
|
+
result[key] = toJSON(result[key]);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow",
|
|
3
|
-
"displayName": "
|
|
3
|
+
"displayName": "Workflow",
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A powerful workflow plugin designed to support business process management and automation.",
|
|
6
6
|
"description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.11.1-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
|
-
"main": "./lib/index.js",
|
|
10
|
-
"
|
|
9
|
+
"main": "./lib/server/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"src",
|
|
13
|
+
"README.md",
|
|
14
|
+
"README.zh-CN.md",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"server.js",
|
|
17
|
+
"server.d.ts",
|
|
18
|
+
"client.js",
|
|
19
|
+
"client.d.ts"
|
|
20
|
+
],
|
|
11
21
|
"dependencies": {
|
|
12
|
-
"@nocobase/actions": "0.10.1-alpha.1",
|
|
13
|
-
"@nocobase/client": "0.10.1-alpha.1",
|
|
14
|
-
"@nocobase/database": "0.10.1-alpha.1",
|
|
15
|
-
"@nocobase/evaluators": "0.10.1-alpha.1",
|
|
16
|
-
"@nocobase/logger": "0.10.1-alpha.1",
|
|
17
|
-
"@nocobase/resourcer": "0.10.1-alpha.1",
|
|
18
|
-
"@nocobase/server": "0.10.1-alpha.1",
|
|
19
|
-
"@nocobase/utils": "0.10.1-alpha.1",
|
|
20
|
-
"antd": "^4.24.8",
|
|
21
22
|
"axios": "^0.27.2",
|
|
22
23
|
"classnames": "^2.3.1",
|
|
23
24
|
"cron-parser": "4.4.0",
|
|
24
25
|
"lru-cache": "8.0.5",
|
|
25
|
-
"moment": "^2.29.2",
|
|
26
26
|
"react-js-cron": "^3.1.0"
|
|
27
27
|
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@ant-design/icons": "^5.1.4",
|
|
30
|
+
"@formily/antd-v5": "1.1.0-beta.4",
|
|
31
|
+
"@formily/core": "2.2.26",
|
|
32
|
+
"@formily/react": "2.2.26",
|
|
33
|
+
"@nocobase/actions": "0.11.0-alpha.1",
|
|
34
|
+
"@nocobase/client": "0.11.0-alpha.1",
|
|
35
|
+
"@nocobase/database": "0.11.0-alpha.1",
|
|
36
|
+
"@nocobase/evaluators": "0.11.0-alpha.1",
|
|
37
|
+
"@nocobase/logger": "0.11.0-alpha.1",
|
|
38
|
+
"@nocobase/plugin-users": "0.11.0-alpha.1",
|
|
39
|
+
"@nocobase/resourcer": "0.11.0-alpha.1",
|
|
40
|
+
"@nocobase/server": "0.11.0-alpha.1",
|
|
41
|
+
"@nocobase/utils": "0.11.0-alpha.1",
|
|
42
|
+
"antd": "^5.6.4",
|
|
43
|
+
"dayjs": "^1.11.8",
|
|
44
|
+
"react": "18.x",
|
|
45
|
+
"react-i18next": "^11.15.1",
|
|
46
|
+
"react-router-dom": "^6.11.2",
|
|
47
|
+
"sequelize": "^6.26.0",
|
|
48
|
+
"winston": "^3.8.2"
|
|
49
|
+
},
|
|
28
50
|
"devDependencies": {
|
|
29
|
-
"@nocobase/
|
|
30
|
-
"@nocobase/test": "0.10.1-alpha.1",
|
|
51
|
+
"@nocobase/test": "0.11.1-alpha.1",
|
|
31
52
|
"@types/ejs": "^3.1.1"
|
|
32
53
|
},
|
|
33
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9ed1dba520bc5f3a7cb1255ea8d92ccbefc11bc8"
|
|
34
55
|
}
|
package/server.d.ts
CHANGED
package/server.js
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
var _index = _interopRequireWildcard(require("./lib/server"));
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
var _exportNames = {};
|
|
13
|
-
Object.defineProperty(exports, "default", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _index.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Object.keys(_index).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _index[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _index[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
1
|
+
module.exports = require('./lib/server/index.js');
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
2
|
+
import { cx, css, useAPIClient, useCompile } from '@nocobase/client';
|
|
3
|
+
import { Button, Dropdown, MenuProps } from 'antd';
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
import { useFlowContext } from './FlowContext';
|
|
6
|
+
import { NAMESPACE } from './locale';
|
|
7
|
+
import { Instruction, instructions } from './nodes';
|
|
8
|
+
import useStyles from './style';
|
|
9
|
+
|
|
10
|
+
interface AddButtonProps {
|
|
11
|
+
upstream;
|
|
12
|
+
branchIndex?: number | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
|
|
16
|
+
const compile = useCompile();
|
|
17
|
+
const api = useAPIClient();
|
|
18
|
+
const { workflow, refresh } = useFlowContext() ?? {};
|
|
19
|
+
const instructionList = Array.from(instructions.getValues()) as Instruction[];
|
|
20
|
+
const { styles } = useStyles();
|
|
21
|
+
|
|
22
|
+
const groups = useMemo(() => {
|
|
23
|
+
return [
|
|
24
|
+
{ key: 'control', label: `{{t("Control", { ns: "${NAMESPACE}" })}}` },
|
|
25
|
+
{ key: 'collection', label: `{{t("Collection operations", { ns: "${NAMESPACE}" })}}` },
|
|
26
|
+
{ key: 'manual', label: `{{t("Manual", { ns: "${NAMESPACE}" })}}` },
|
|
27
|
+
{ key: 'extended', label: `{{t("Extended types", { ns: "${NAMESPACE}" })}}` },
|
|
28
|
+
]
|
|
29
|
+
.filter((group) => instructionList.filter((item) => item.group === group.key).length)
|
|
30
|
+
.map((group) => {
|
|
31
|
+
const groupInstructions = instructionList.filter((item) => item.group === group.key);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
...group,
|
|
35
|
+
type: 'group',
|
|
36
|
+
children: groupInstructions.map((item) => ({
|
|
37
|
+
key: item.type,
|
|
38
|
+
label: item.title,
|
|
39
|
+
type: item.options ? 'subMenu' : null,
|
|
40
|
+
children: item.options
|
|
41
|
+
? item.options.map((option) => ({
|
|
42
|
+
key: option.key,
|
|
43
|
+
label: option.label,
|
|
44
|
+
}))
|
|
45
|
+
: null,
|
|
46
|
+
})),
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}, [instructionList]);
|
|
50
|
+
const resource = useMemo(() => {
|
|
51
|
+
if (!workflow) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return api.resource('workflows.nodes', workflow.id);
|
|
55
|
+
}, [workflow?.id]);
|
|
56
|
+
const onCreate = useCallback(
|
|
57
|
+
async ({ keyPath }) => {
|
|
58
|
+
const type = keyPath.pop();
|
|
59
|
+
const config = {};
|
|
60
|
+
const [optionKey] = keyPath;
|
|
61
|
+
const instruction = instructions.get(type);
|
|
62
|
+
if (optionKey) {
|
|
63
|
+
const { value } = instruction.options?.find((item) => item.key === optionKey) ?? {};
|
|
64
|
+
Object.assign(config, value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (resource) {
|
|
68
|
+
await resource.create({
|
|
69
|
+
values: {
|
|
70
|
+
type,
|
|
71
|
+
upstreamId: upstream?.id ?? null,
|
|
72
|
+
branchIndex,
|
|
73
|
+
title: compile(instruction.title),
|
|
74
|
+
config,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
refresh();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[branchIndex, resource?.create, upstream?.id],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const menu = useMemo<MenuProps>(() => {
|
|
84
|
+
return {
|
|
85
|
+
onClick: onCreate,
|
|
86
|
+
items: compile(groups),
|
|
87
|
+
};
|
|
88
|
+
}, [groups, onCreate]);
|
|
89
|
+
|
|
90
|
+
if (!workflow) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className={styles.addButtonClass}>
|
|
96
|
+
<Dropdown
|
|
97
|
+
trigger={['click']}
|
|
98
|
+
menu={menu}
|
|
99
|
+
disabled={workflow.executed}
|
|
100
|
+
overlayClassName={css`
|
|
101
|
+
.ant-dropdown-menu-root{
|
|
102
|
+
max-height: 30em;
|
|
103
|
+
overflow-y: auto;
|
|
104
|
+
}
|
|
105
|
+
`}
|
|
106
|
+
>
|
|
107
|
+
<Button shape="circle" icon={<PlusOutlined />} />
|
|
108
|
+
</Dropdown>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cx } from '@nocobase/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AddButton } from './AddButton';
|
|
4
|
+
import { Node } from './nodes';
|
|
5
|
+
import useStyles from './style';
|
|
6
|
+
|
|
7
|
+
export function Branch({
|
|
8
|
+
from = null,
|
|
9
|
+
entry = null,
|
|
10
|
+
branchIndex = null,
|
|
11
|
+
controller = null,
|
|
12
|
+
}: {
|
|
13
|
+
from?: any;
|
|
14
|
+
entry?: any;
|
|
15
|
+
branchIndex?: number | null;
|
|
16
|
+
controller?: any;
|
|
17
|
+
}) {
|
|
18
|
+
const { styles } = useStyles();
|
|
19
|
+
|
|
20
|
+
const list: any[] = [];
|
|
21
|
+
for (let node = entry; node; node = node.downstream) {
|
|
22
|
+
list.push(node);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={cx(styles.branchClass)}>
|
|
27
|
+
<div className="workflow-branch-lines" />
|
|
28
|
+
{controller}
|
|
29
|
+
<AddButton upstream={from} branchIndex={branchIndex} />
|
|
30
|
+
<div className="workflow-node-list">
|
|
31
|
+
{list.map((item) => (
|
|
32
|
+
<Node data={item} key={item.id} />
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|