@nocobase/plugin-workflow 2.0.0-alpha.44 → 2.0.0-alpha.46
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/dist/client/16ee3f25c89840fb.js +10 -0
- package/dist/client/7f42af110b1baadd.js +10 -0
- package/dist/client/{f68fbc145c3ddec3.js → 80d4cd8911e03c27.js} +1 -1
- package/dist/client/Branch.d.ts +2 -0
- package/dist/client/index.js +1 -1
- package/dist/client/nodes/multi-conditions.d.ts +57 -0
- package/dist/common/collections/jobs.js +4 -0
- package/dist/externalVersion.js +11 -11
- package/dist/locale/zh-CN.json +15 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/server/Plugin.js +3 -0
- package/dist/server/Processor.js +4 -0
- package/dist/server/actions/index.js +1 -0
- package/dist/server/actions/nodes.d.ts +1 -0
- package/dist/server/actions/nodes.js +77 -0
- package/dist/server/instructions/MultiConditionsInstruction.d.ts +18 -0
- package/dist/server/instructions/MultiConditionsInstruction.js +118 -0
- package/dist/server/types/Job.d.ts +1 -0
- package/package.json +2 -2
- package/dist/client/248e211bb2d99aee.js +0 -10
- package/dist/client/e7c028a099537ab1.js +0 -10
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Instruction } from '.';
|
|
11
|
+
import { RadioWithTooltip } from '../components/RadioWithTooltip';
|
|
12
|
+
import { useWorkflowVariableOptions, WorkflowVariableTextArea } from '../variable';
|
|
13
|
+
declare function NodeComponent({ data }: {
|
|
14
|
+
data: any;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
export default class extends Instruction {
|
|
17
|
+
title: string;
|
|
18
|
+
type: string;
|
|
19
|
+
group: string;
|
|
20
|
+
description: string;
|
|
21
|
+
icon: React.JSX.Element;
|
|
22
|
+
fieldset: {
|
|
23
|
+
continueOnNoMatch: {
|
|
24
|
+
type: string;
|
|
25
|
+
title: string;
|
|
26
|
+
'x-decorator': string;
|
|
27
|
+
'x-component': string;
|
|
28
|
+
'x-component-props': {
|
|
29
|
+
options: {
|
|
30
|
+
label: string;
|
|
31
|
+
value: boolean;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
branching: {
|
|
38
|
+
label: string;
|
|
39
|
+
value: number;
|
|
40
|
+
}[];
|
|
41
|
+
scope: {
|
|
42
|
+
renderEngineReference: (key: string) => React.JSX.Element;
|
|
43
|
+
useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
|
|
44
|
+
};
|
|
45
|
+
components: {
|
|
46
|
+
WorkflowVariableTextArea: typeof WorkflowVariableTextArea;
|
|
47
|
+
RadioWithTooltip: typeof RadioWithTooltip;
|
|
48
|
+
};
|
|
49
|
+
Component: typeof NodeComponent;
|
|
50
|
+
createDefaultConfig(): {
|
|
51
|
+
conditions: {
|
|
52
|
+
uid: any;
|
|
53
|
+
}[];
|
|
54
|
+
continueOnNoMatch: boolean;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {};
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,8 +11,8 @@ module.exports = {
|
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@formily/core": "2.3.7",
|
|
13
13
|
"@formily/react": "2.3.7",
|
|
14
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
15
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
14
|
+
"@nocobase/client": "2.0.0-alpha.46",
|
|
15
|
+
"@nocobase/utils": "2.0.0-alpha.46",
|
|
16
16
|
"antd": "5.24.2",
|
|
17
17
|
"@ant-design/icons": "5.6.1",
|
|
18
18
|
"react-router-dom": "6.30.1",
|
|
@@ -20,17 +20,17 @@ module.exports = {
|
|
|
20
20
|
"lodash": "4.17.21",
|
|
21
21
|
"@dnd-kit/core": "6.1.0",
|
|
22
22
|
"@formily/shared": "2.3.7",
|
|
23
|
-
"@nocobase/plugin-mobile": "2.0.0-alpha.
|
|
23
|
+
"@nocobase/plugin-mobile": "2.0.0-alpha.46",
|
|
24
24
|
"sequelize": "6.35.2",
|
|
25
|
-
"@nocobase/database": "2.0.0-alpha.
|
|
26
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
27
|
-
"@nocobase/data-source-manager": "2.0.0-alpha.
|
|
28
|
-
"@nocobase/logger": "2.0.0-alpha.
|
|
29
|
-
"@nocobase/evaluators": "2.0.0-alpha.
|
|
25
|
+
"@nocobase/database": "2.0.0-alpha.46",
|
|
26
|
+
"@nocobase/server": "2.0.0-alpha.46",
|
|
27
|
+
"@nocobase/data-source-manager": "2.0.0-alpha.46",
|
|
28
|
+
"@nocobase/logger": "2.0.0-alpha.46",
|
|
29
|
+
"@nocobase/evaluators": "2.0.0-alpha.46",
|
|
30
30
|
"@formily/antd-v5": "1.2.3",
|
|
31
31
|
"@formily/reactive": "2.3.7",
|
|
32
|
-
"@nocobase/actions": "2.0.0-alpha.
|
|
32
|
+
"@nocobase/actions": "2.0.0-alpha.46",
|
|
33
33
|
"dayjs": "1.11.13",
|
|
34
|
-
"@nocobase/plugin-workflow-test": "2.0.0-alpha.
|
|
35
|
-
"@nocobase/test": "2.0.0-alpha.
|
|
34
|
+
"@nocobase/plugin-workflow-test": "2.0.0-alpha.46",
|
|
35
|
+
"@nocobase/test": "2.0.0-alpha.46"
|
|
36
36
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -192,6 +192,21 @@
|
|
|
192
192
|
"Inside of \"{{branchName}}\" branch": "“{{branchName}}”分支内",
|
|
193
193
|
"\"{{branchName}}\" branch": "“{{branchName}}”分支",
|
|
194
194
|
"Branch {{index}}": "分支 {{index}}",
|
|
195
|
+
|
|
196
|
+
"Multi conditions": "多条件分支",
|
|
197
|
+
"From left to right, attempt each branch sequentially based on the configured conditions. Only branches that meet the conditions will be executed. Otherwise, the next branch will be attempted. If none of the branches meet the conditions, it can either exit the process or continue to the next node based on configuration.":
|
|
198
|
+
"从左到右,基于配置的条件,依次尝试每个分支。只有满足条件的分支才会被执行,否则尝试下一个分支。如果没有任何分支满足条件,可以根据配置选择退出流程或继续下一个节点。",
|
|
199
|
+
"When no condition matches": "未满足任何条件时",
|
|
200
|
+
"Continue the workflow": "继续执行工作流",
|
|
201
|
+
"End as failed": "以失败结束",
|
|
202
|
+
"First condition": "第一个条件",
|
|
203
|
+
"Otherwise": "否则",
|
|
204
|
+
"Add branch": "添加分支",
|
|
205
|
+
"Delete branch": "删除分支",
|
|
206
|
+
"Condition {{index}}": "条件 {{index}}",
|
|
207
|
+
"Configure condition": "配置条件",
|
|
208
|
+
"Condition label": "条件名称",
|
|
209
|
+
|
|
195
210
|
"Create record": "新增数据",
|
|
196
211
|
"Add new record to a collection. You can use variables from upstream nodes to assign values to fields.":
|
|
197
212
|
"向一个数据表中添加新的数据。可以使用上游节点里的变量为字段赋值。",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2025-11-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2025-11-24T08:21:43.440Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2025-11-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2025-11-24T08:21:43.069Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2025-11-
|
|
1
|
+
{"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2025-11-24T08:21:42.853Z"}
|
package/dist/server/Plugin.js
CHANGED
|
@@ -59,6 +59,7 @@ var import_CreateInstruction = __toESM(require("./instructions/CreateInstruction
|
|
|
59
59
|
var import_DestroyInstruction = __toESM(require("./instructions/DestroyInstruction"));
|
|
60
60
|
var import_QueryInstruction = __toESM(require("./instructions/QueryInstruction"));
|
|
61
61
|
var import_UpdateInstruction = __toESM(require("./instructions/UpdateInstruction"));
|
|
62
|
+
var import_MultiConditionsInstruction = __toESM(require("./instructions/MultiConditionsInstruction"));
|
|
62
63
|
var import_WorkflowRepository = __toESM(require("./repositories/WorkflowRepository"));
|
|
63
64
|
const WORKER_JOB_WORKFLOW_PROCESS = "workflow:process";
|
|
64
65
|
class PluginWorkflowServer extends import_server.Plugin {
|
|
@@ -268,6 +269,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
268
269
|
initInstructions(more = {}) {
|
|
269
270
|
this.registerInstruction("calculation", import_CalculationInstruction.default);
|
|
270
271
|
this.registerInstruction("condition", import_ConditionInstruction.default);
|
|
272
|
+
this.registerInstruction("multi-conditions", import_MultiConditionsInstruction.default);
|
|
271
273
|
this.registerInstruction("end", import_EndInstruction.default);
|
|
272
274
|
this.registerInstruction("create", import_CreateInstruction.default);
|
|
273
275
|
this.registerInstruction("destroy", import_DestroyInstruction.default);
|
|
@@ -330,6 +332,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
330
332
|
"executions:destroy",
|
|
331
333
|
"flow_nodes:update",
|
|
332
334
|
"flow_nodes:destroy",
|
|
335
|
+
"flow_nodes:destroyBranch",
|
|
333
336
|
"flow_nodes:test",
|
|
334
337
|
"jobs:get",
|
|
335
338
|
"workflowCategories:*"
|
package/dist/server/Processor.js
CHANGED
|
@@ -274,6 +274,10 @@ class Processor {
|
|
|
274
274
|
changes.push([`status`, job.status]);
|
|
275
275
|
job.changed("status", false);
|
|
276
276
|
}
|
|
277
|
+
if (job.changed("meta")) {
|
|
278
|
+
changes.push([`meta`, JSON.stringify(job.meta ?? null)]);
|
|
279
|
+
job.changed("meta", false);
|
|
280
|
+
}
|
|
277
281
|
if (job.changed("result")) {
|
|
278
282
|
changes.push([`result`, JSON.stringify(job.result ?? null)]);
|
|
279
283
|
job.changed("result", false);
|
|
@@ -9,5 +9,6 @@
|
|
|
9
9
|
import { Context } from '@nocobase/actions';
|
|
10
10
|
export declare function create(context: Context, next: any): Promise<void>;
|
|
11
11
|
export declare function destroy(context: Context, next: any): Promise<void>;
|
|
12
|
+
export declare function destroyBranch(context: Context, next: any): Promise<void>;
|
|
12
13
|
export declare function update(context: Context, next: any): Promise<void>;
|
|
13
14
|
export declare function test(context: Context, next: any): Promise<void>;
|
|
@@ -38,6 +38,7 @@ var nodes_exports = {};
|
|
|
38
38
|
__export(nodes_exports, {
|
|
39
39
|
create: () => create,
|
|
40
40
|
destroy: () => destroy,
|
|
41
|
+
destroyBranch: () => destroyBranch,
|
|
41
42
|
test: () => test,
|
|
42
43
|
update: () => update
|
|
43
44
|
});
|
|
@@ -260,6 +261,81 @@ async function destroy(context, next) {
|
|
|
260
261
|
context.body = instance;
|
|
261
262
|
await next();
|
|
262
263
|
}
|
|
264
|
+
async function destroyBranch(context, next) {
|
|
265
|
+
const { db } = context;
|
|
266
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
267
|
+
const { filterByTk, branchIndex: branchIndexParam, shift: shiftParam } = context.action.params;
|
|
268
|
+
if (branchIndexParam == null || branchIndexParam === "") {
|
|
269
|
+
context.throw(400, "branchIndex is required");
|
|
270
|
+
}
|
|
271
|
+
const branchIndex = Number.parseInt(branchIndexParam, 10);
|
|
272
|
+
if (Number.isNaN(branchIndex)) {
|
|
273
|
+
context.throw(400, "branchIndex must be a number");
|
|
274
|
+
}
|
|
275
|
+
const shift = !(shiftParam == null || shiftParam === "") && Number.parseInt(String(shiftParam), 10) === 1;
|
|
276
|
+
const fields = ["id", "upstreamId", "downstreamId", "branchIndex", "key"];
|
|
277
|
+
const instance = await repository.findOne({
|
|
278
|
+
filterByTk,
|
|
279
|
+
fields: [...fields, "workflowId"],
|
|
280
|
+
appends: ["workflow.versionStats.executed"]
|
|
281
|
+
});
|
|
282
|
+
if (!instance) {
|
|
283
|
+
context.throw(404, "Node not found");
|
|
284
|
+
}
|
|
285
|
+
if (instance.workflow.versionStats.executed > 0) {
|
|
286
|
+
context.throw(400, "Branches in executed workflow could not be deleted");
|
|
287
|
+
}
|
|
288
|
+
let deletedBranchHead = null;
|
|
289
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
290
|
+
const nodes = await repository.find({
|
|
291
|
+
filter: {
|
|
292
|
+
workflowId: instance.workflowId
|
|
293
|
+
},
|
|
294
|
+
fields,
|
|
295
|
+
transaction
|
|
296
|
+
});
|
|
297
|
+
const nodesMap = /* @__PURE__ */ new Map();
|
|
298
|
+
nodes.forEach((item) => {
|
|
299
|
+
nodesMap.set(item.id, item);
|
|
300
|
+
});
|
|
301
|
+
nodes.forEach((item) => {
|
|
302
|
+
if (item.upstreamId) {
|
|
303
|
+
item.upstream = nodesMap.get(item.upstreamId);
|
|
304
|
+
}
|
|
305
|
+
if (item.downstreamId) {
|
|
306
|
+
item.downstream = nodesMap.get(item.downstreamId);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
const branchHeads = nodes.filter((item) => item.upstreamId === instance.id && item.branchIndex != null).sort((a, b) => a.branchIndex - b.branchIndex);
|
|
310
|
+
const branchHead = branchHeads.find((item) => item.branchIndex === branchIndex);
|
|
311
|
+
deletedBranchHead = branchHead || null;
|
|
312
|
+
if (branchHead) {
|
|
313
|
+
const nodesToDelete = searchBranchDownstreams(nodes, branchHead);
|
|
314
|
+
const idsToDelete = nodesToDelete.map((item) => item.id);
|
|
315
|
+
if (idsToDelete.length) {
|
|
316
|
+
await repository.destroy({
|
|
317
|
+
filterByTk: idsToDelete,
|
|
318
|
+
transaction
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (shift) {
|
|
323
|
+
const headsToShift = branchHeads.filter((item) => item.branchIndex > branchIndex);
|
|
324
|
+
await Promise.all(
|
|
325
|
+
headsToShift.map(
|
|
326
|
+
(item) => item.update(
|
|
327
|
+
{
|
|
328
|
+
branchIndex: item.branchIndex - 1
|
|
329
|
+
},
|
|
330
|
+
{ transaction }
|
|
331
|
+
)
|
|
332
|
+
)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
context.body = deletedBranchHead;
|
|
337
|
+
await next();
|
|
338
|
+
}
|
|
263
339
|
async function update(context, next) {
|
|
264
340
|
const { db } = context;
|
|
265
341
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
@@ -308,6 +384,7 @@ async function test(context, next) {
|
|
|
308
384
|
0 && (module.exports = {
|
|
309
385
|
create,
|
|
310
386
|
destroy,
|
|
387
|
+
destroyBranch,
|
|
311
388
|
test,
|
|
312
389
|
update
|
|
313
390
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Instruction } from '.';
|
|
10
|
+
import type Processor from '../Processor';
|
|
11
|
+
import type { FlowNodeModel, JobModel } from '../types';
|
|
12
|
+
export declare class MultiConditionsInstruction extends Instruction {
|
|
13
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<JobModel>;
|
|
14
|
+
resume(node: FlowNodeModel, branchJob: JobModel, processor: Processor): Promise<any>;
|
|
15
|
+
private evaluateCondition;
|
|
16
|
+
private getBranchNode;
|
|
17
|
+
}
|
|
18
|
+
export default MultiConditionsInstruction;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var MultiConditionsInstruction_exports = {};
|
|
28
|
+
__export(MultiConditionsInstruction_exports, {
|
|
29
|
+
MultiConditionsInstruction: () => MultiConditionsInstruction,
|
|
30
|
+
default: () => MultiConditionsInstruction_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(MultiConditionsInstruction_exports);
|
|
33
|
+
var import_evaluators = require("@nocobase/evaluators");
|
|
34
|
+
var import__ = require(".");
|
|
35
|
+
var import_constants = require("../constants");
|
|
36
|
+
var import_logicCalculate = require("../logicCalculate");
|
|
37
|
+
class MultiConditionsInstruction extends import__.Instruction {
|
|
38
|
+
async run(node, prevJob, processor) {
|
|
39
|
+
const { conditions = [], continueOnNoMatch = false } = node.config || {};
|
|
40
|
+
const meta = { conditions: [] };
|
|
41
|
+
const job = processor.saveJob({
|
|
42
|
+
status: import_constants.JOB_STATUS.PENDING,
|
|
43
|
+
result: null,
|
|
44
|
+
meta,
|
|
45
|
+
nodeId: node.id,
|
|
46
|
+
nodeKey: node.key,
|
|
47
|
+
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
48
|
+
});
|
|
49
|
+
for (let cursor = 0; cursor < conditions.length; cursor++) {
|
|
50
|
+
const branchIndex = cursor + 1;
|
|
51
|
+
const condition = conditions[cursor];
|
|
52
|
+
let conditionResult;
|
|
53
|
+
try {
|
|
54
|
+
conditionResult = this.evaluateCondition(condition, node, processor);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
conditionResult = error instanceof Error ? error.message : String(error);
|
|
57
|
+
processor.logger.error(`[multi-conditions] evaluate condition[${cursor}] error:`, { error });
|
|
58
|
+
} finally {
|
|
59
|
+
meta.conditions.push(conditionResult);
|
|
60
|
+
job.set("result", conditionResult);
|
|
61
|
+
}
|
|
62
|
+
if (typeof conditionResult === "string") {
|
|
63
|
+
job.set("status", import_constants.JOB_STATUS.ERROR);
|
|
64
|
+
return job;
|
|
65
|
+
}
|
|
66
|
+
if (conditionResult === true) {
|
|
67
|
+
const branchNode = this.getBranchNode(node, processor, branchIndex);
|
|
68
|
+
job.set("status", import_constants.JOB_STATUS.RESOLVED);
|
|
69
|
+
if (branchNode) {
|
|
70
|
+
await processor.run(branchNode, job);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return job;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
job.set("status", continueOnNoMatch ? import_constants.JOB_STATUS.RESOLVED : import_constants.JOB_STATUS.FAILED);
|
|
77
|
+
const defaultBranch = this.getBranchNode(node, processor, 0);
|
|
78
|
+
if (defaultBranch) {
|
|
79
|
+
await processor.run(defaultBranch, job);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
return job;
|
|
83
|
+
}
|
|
84
|
+
async resume(node, branchJob, processor) {
|
|
85
|
+
const job = processor.findBranchParentJob(branchJob, node);
|
|
86
|
+
if (!job) {
|
|
87
|
+
throw new Error("Parent job not found");
|
|
88
|
+
}
|
|
89
|
+
const { continueOnNoMatch = false } = node.config || {};
|
|
90
|
+
const jobNode = processor.nodesMap.get(branchJob.nodeId);
|
|
91
|
+
const branchStartNode = processor.findBranchStartNode(jobNode, node);
|
|
92
|
+
const branchIndex = branchStartNode.branchIndex;
|
|
93
|
+
if (branchJob.status === import_constants.JOB_STATUS.RESOLVED) {
|
|
94
|
+
if (branchIndex > 0) {
|
|
95
|
+
job.set({
|
|
96
|
+
status: import_constants.JOB_STATUS.RESOLVED
|
|
97
|
+
});
|
|
98
|
+
return job;
|
|
99
|
+
}
|
|
100
|
+
job.set({ status: continueOnNoMatch ? import_constants.JOB_STATUS.RESOLVED : import_constants.JOB_STATUS.FAILED });
|
|
101
|
+
return job;
|
|
102
|
+
}
|
|
103
|
+
return processor.exit(branchJob.status);
|
|
104
|
+
}
|
|
105
|
+
evaluateCondition(condition, node, processor) {
|
|
106
|
+
const { engine = "basic", calculation, expression } = condition ?? {};
|
|
107
|
+
const evaluator = import_evaluators.evaluators.get(engine);
|
|
108
|
+
return evaluator ? evaluator(expression, processor.getScope(node.id)) : (0, import_logicCalculate.logicCalculate)(processor.getParsedValue(calculation, node.id));
|
|
109
|
+
}
|
|
110
|
+
getBranchNode(node, processor, branchIndex) {
|
|
111
|
+
return processor.getBranches(node).find((item) => Number(item.branchIndex) === Number(branchIndex));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var MultiConditionsInstruction_default = MultiConditionsInstruction;
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
MultiConditionsInstruction
|
|
118
|
+
});
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
7
7
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
8
8
|
"description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
|
|
9
|
-
"version": "2.0.0-alpha.
|
|
9
|
+
"version": "2.0.0-alpha.46",
|
|
10
10
|
"license": "AGPL-3.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@nocobase/test": "2.x",
|
|
49
49
|
"@nocobase/utils": "2.x"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "ebf3cbeea4957a914e3157f3c6b570dba685c46f",
|
|
52
52
|
"keywords": [
|
|
53
53
|
"Workflow"
|
|
54
54
|
]
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["771"],{144:function(e,t,r){r.d(t,{g:function(){return w}});var n=r(2721),o=r(8156),a=r.n(o);let l=(0,o.createContext)(null),i={didCatch:!1,error:null};class c extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=i}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,r,n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];null==(t=(r=this.props).onReset)||t.call(r,{args:o,reason:"imperative-api"}),this.setState(i)}}componentDidCatch(e,t){var r,n;null==(r=(n=this.props).onError)||r.call(n,e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;if(r&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)){var o,a;null==(o=(a=this.props).onReset)||o.call(a,{next:n,prev:e.resetKeys,reason:"keys"}),this.setState(i)}}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:a,error:i}=this.state,c=e;if(a){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(n))c=n;else if("function"==typeof t)c=t(e);else if(r)c=(0,o.createElement)(r,e);else throw i}return(0,o.createElement)(l.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}var s=r(3772),u=r(2415),d=r(8551),m=r(5329),f=r(4477),p=r(8562);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(){var e=v(["\n margin-top: 0 !important;\n "]);return b=function(){return e},e}function h(){var e=v(["\n margin-bottom: 1em;\n "]);return h=function(){return e},e}function E(){var e=v(["\n margin-top: 0 !important;\n "]);return E=function(){return e},e}function w(e){var t,r=e.entry,o=(0,m.Z)().styles,l=(0,p.RY)(),i=(t=a().useState(100),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return y(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),v=i[0],w=i[1];return a().createElement("div",{className:"workflow-canvas-wrapper"},a().createElement(c,{FallbackComponent:s.ErrorFallback,onError:console.error},a().createElement("div",{className:"workflow-canvas",style:{zoom:v/100}},a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(b()))},a().createElement("div",{className:o.branchClass},l?a().createElement(n.Alert,{type:"warning",message:(0,d.KQ)("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:(0,s.css)(h())}):null,a().createElement(f.Gk,null),a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(E()))},a().createElement(u.I,{entry:r})),a().createElement("div",{className:o.terminalClass},(0,d.KQ)("End")))))),a().createElement("div",{className:"workflow-canvas-zoomer"},a().createElement(n.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:v,onChange:w})))}},2378:function(e,t,r){r.r(t),r.d(t,{ExecutionPage:function(){return N}});var n=r(3772),o=r(8156),a=r.n(o),l=r(6128),i=r(2721),c=r(7584),s=r(482),u=r(3238),d=r(9130),m=r(144),f=r(118),p=r(1682),y=r(8398),v=r(8551),b=r(5329),h=r(9315),E=r(467);function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(e,t)||S(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return w(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return w(e,t)}}function j(e){var t,r,o=(0,y.G2)().viewJob,l=(0,n.useRequest)({resource:"jobs",action:"get",params:{filterByTk:o.id}}),c=l.data;if(l.loading)return a().createElement(i.Spin,null);var s=(0,E.get)(c,"data.result");return a().createElement(n.Input.JSON,(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){g(e,t,r[t])})}return e}({},e),r=r={value:s,disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))}function C(){var e=(0,n.usePlugin)(d.default).instructions,t=(0,n.useCompile)(),r=(0,y.G2)(),o=r.viewJob,l=r.setViewJob,c=(0,b.Z)().styles,s=(null!=o?o:{}).node,u=void 0===s?{}:s,m=e.get(u.type);return a().createElement(n.ActionContextProvider,{value:{visible:!!o,setVisible:l}},a().createElement(n.SchemaComponent,{components:{JobResult:j},schema:{type:"void",properties:g({},"".concat(null==o?void 0:o.id,"-").concat(null==o?void 0:o.updatedAt,"-modal"),{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:a().createElement("div",{className:c.nodeTitleClass},a().createElement(i.Tag,null,t(null==m?void 0:m.title)),a().createElement("strong",null,u.title),a().createElement("span",{className:"workflow-node-id"},"#",u.id)),properties:{status:{type:"number",title:'{{t("Status", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"Select",enum:p.Vh,"x-read-pretty":!0},updatedAt:{type:"string",title:'{{t("Executed at", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:'{{t("Node result", { ns: "'.concat(v.A7,'" })}}'),"x-decorator":"FormItem","x-component":"JobResult","x-component-props":{className:c.nodeJobResultClass,autoSize:{minRows:4,maxRows:32}}}}})}}))}function A(e){var t=(0,y.G2)().execution,r=(0,n.useAPIClient)(),u=(0,l.useNavigate)(),d=(0,b.Z)().styles,m=x((0,o.useState)([]),2),v=m[0],E=m[1],w=x((0,o.useState)([]),2),g=w[0],k=w[1];(0,o.useEffect)(function(){t&&r.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){E(e.data.data)}).catch(function(){})},[t.id]),(0,o.useEffect)(function(){t&&r.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){k(e.data.data.reverse())}).catch(function(){})},[t.id]);var S=(0,o.useCallback)(function(e){var r=e.key;r!=t.id&&u((0,h.s_)(r))},[t.id]);return t?a().createElement(i.Dropdown,{menu:{onClick:S,defaultSelectedKeys:["".concat(t.id)],className:(0,n.cx)(d.dropdownClass,d.executionsDropdownRowClass),items:O(g).concat([t],O(v)).map(function(e){return{key:e.id,label:a().createElement(a().Fragment,null,a().createElement("span",{className:"id"},"#".concat(e.id)),a().createElement("time",null,(0,c.str2moment)(e.createdAt).format("YYYY-MM-DD HH:mm:ss"))),icon:a().createElement("span",null,a().createElement(f.Y,{statusMap:p.uy,status:e.status}))}})}},a().createElement(i.Space,null,a().createElement("strong",null,"#".concat(t.id)),a().createElement(s.DownOutlined,null))):null}function P(){var e,t=(0,u.useTranslation)().t,r=(0,n.useCompile)(),d=(0,n.useResourceActionContext)(),f=d.data,b=d.loading,E=d.refresh,w=(0,n.useDocumentTitle)().setTitle,g=x((0,o.useState)(null),2),O=g[0],S=g[1],j=(0,n.useApp)(),P=(0,n.useAPIClient)();(0,o.useEffect)(function(){var e,t=(null!=(e=null==f?void 0:f.data)?e:{}).workflow;null==w||w("".concat((null==t?void 0:t.title)?"".concat(t.title," - "):"").concat((0,v.KQ)("Execution history")))},[null==f?void 0:f.data,w]);var N=(0,o.useCallback)(function(){i.Modal.confirm({title:(0,v.KQ)("Cancel the execution"),icon:a().createElement(s.ExclamationCircleFilled,null),content:(0,v.KQ)("Are you sure you want to cancel the execution?"),onOk:function(){P.resource("executions").cancel({filterByTk:null==f?void 0:f.data.id}).then(function(){i.message.success(t("Operation succeeded")),E()}).catch(function(e){console.error(e.data.error)})}})},[null==f?void 0:f.data]);if(!(null==f?void 0:f.data))return b?a().createElement(i.Spin,null):a().createElement(i.Result,{status:"404",title:"Not found"});var I=null!=(e=null==f?void 0:f.data)?e:{},D=I.jobs,T=I.workflow,R=void 0===T?{}:T,B=R.nodes,K=void 0===B?[]:B,M=(R.revisions,k(I.workflow,["nodes","revisions"])),Y=k(I,["jobs","workflow"]);(0,h.Yc)(K),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=new Map;e.forEach(function(e){e.jobs=[],r.set(e.id,e)}),t.forEach(function(e){var t=r.get(e.nodeId);t.jobs.push(e),e.node={id:t.id,key:t.key,title:t.title,type:t.type}}),e.forEach(function(e){e.jobs=e.jobs.sort(function(e,t){return e.id-t.id})})}(K,void 0===D?[]:D);var F=K.find(function(e){return!e.upstream}),J=p.uy[Y.status];return a().createElement(y.iT.Provider,{value:{workflow:M.type?M:null,nodes:K,execution:Y,viewJob:O,setViewJob:S}},a().createElement("div",{className:"workflow-toolbar"},a().createElement("header",null,a().createElement(i.Breadcrumb,{items:[{title:a().createElement(l.Link,{to:j.pluginSettingsManager.getRoutePath("workflow")},(0,v.KQ)("Workflow"))},{title:a().createElement(i.Tooltip,{title:"Key: ".concat(M.key)},a().createElement(l.Link,{to:(0,h.SI)(M.id)},M.title))},{title:a().createElement(A,null)}]})),a().createElement("aside",null,a().createElement(i.Tag,{color:J.color},r(J.label)),Y.status?null:a().createElement(i.Tooltip,{title:(0,v.KQ)("Cancel the execution")},a().createElement(i.Button,{type:"link",danger:!0,onClick:N,shape:"circle",size:"small",icon:a().createElement(s.StopOutlined,null)})),a().createElement("time",null,(0,c.str2moment)(Y.updatedAt).format("YYYY-MM-DD HH:mm:ss")))),a().createElement(m.g,{entry:F}),a().createElement(C,null))}var N=function(){var e,t,r,o=(0,l.useParams)(),i=(0,b.Z)().styles;return a().createElement("div",{className:(0,n.cx)(i.workflowPageClass)},a().createElement(n.SchemaComponent,{schema:{type:"void",properties:(e={},t="execution_".concat(o.id),r={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:o,appends:["jobs","workflow","workflow.nodes","workflow.versionStats","workflow.stats"],except:["jobs.result","workflow.options"]}}},"x-component":"ExecutionCanvas"},t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e)},components:{ExecutionCanvas:P}}))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["626"],{144:function(e,t,r){r.d(t,{g:function(){return g}});var n=r(2721),o=r(8156),a=r.n(o);let l=(0,o.createContext)(null),i={didCatch:!1,error:null};class c extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=i}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,r,n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];null==(t=(r=this.props).onReset)||t.call(r,{args:o,reason:"imperative-api"}),this.setState(i)}}componentDidCatch(e,t){var r,n;null==(r=(n=this.props).onError)||r.call(n,e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;if(r&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)){var o,a;null==(o=(a=this.props).onReset)||o.call(a,{next:n,prev:e.resetKeys,reason:"keys"}),this.setState(i)}}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:a,error:i}=this.state,c=e;if(a){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(n))c=n;else if("function"==typeof t)c=t(e);else if(r)c=(0,o.createElement)(r,e);else throw i}return(0,o.createElement)(l.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}var s=r(3772),u=r(2415),d=r(8551),f=r(5329),p=r(4477),m=r(8562);function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(){var e=y(["\n margin-top: 0 !important;\n "]);return b=function(){return e},e}function h(){var e=y(["\n margin-bottom: 1em;\n "]);return h=function(){return e},e}function w(){var e=y(["\n margin-top: 0 !important;\n "]);return w=function(){return e},e}function g(e){var t,r=e.entry,o=(0,f.Z)().styles,l=(0,m.RY)(),i=(t=a().useState(100),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return v(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),y=i[0],g=i[1];return a().createElement("div",{className:"workflow-canvas-wrapper"},a().createElement(c,{FallbackComponent:s.ErrorFallback,onError:console.error},a().createElement("div",{className:"workflow-canvas",style:{zoom:y/100}},a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(b()))},a().createElement("div",{className:o.branchClass},l?a().createElement(n.Alert,{type:"warning",message:(0,d.KQ)("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:(0,s.css)(h())}):null,a().createElement(p.Gk,null),a().createElement("div",{className:(0,s.cx)(o.branchBlockClass,(0,s.css)(w()))},a().createElement(u.I,{entry:r})),a().createElement("div",{className:o.terminalClass},(0,d.KQ)("End")))))),a().createElement("div",{className:"workflow-canvas-zoomer"},a().createElement(n.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:y,onChange:g})))}},6443:function(e,t,r){r.r(t),r.d(t,{WorkflowPage:function(){return W}});var n=r(3772),o=r(8156),a=r.n(o),l=r(6128),i=r(5329),c=r(3238),s=r(2721),u=r(482),d=r(3505),f=r(7584),p=r(144),m=r(4665),v=r(1113),y=r(8398),b=r(8551),h=r(1685),w=r(9315),g=r(8303),k=r(1600),E=r(4477),x=r(1682),A=r(7032),C=r(8562),O=r(2495),S=r(2743);function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t,r,n,o,a,l){try{var i=e[a](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function T(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){j(a,n,o,l,i,"next",e)}function i(e){j(a,n,o,l,i,"throw",e)}l(void 0)})}}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function K(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function N(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){var r,n,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var c=[a,i];if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function Q(){var e,t,r=(e=["\n margin-bottom: 1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return Q=function(){return r},r}function I(e){var t,r=e.request,o=(e.filter,N(e,["request","filter"])),l=(0,y.G2)().workflow,i=K(R({},o),{request:K(R({},r),{params:K(R({},null==r?void 0:r.params),{filter:K(R({},null==r||null==(t=r.params)?void 0:t.filter),{key:l.key})})})});return a().createElement(n.ResourceActionProvider,i)}function D(e){var t=e.data,r=e.option,o=(0,n.useCompile)()(r.label);return a().createElement(c.Trans,{ns:b.A7,values:{statusText:o}},"Workflow executed, the result status is ",a().createElement(s.Tag,{color:r.color},"{{statusText}}"),a().createElement(l.Link,{to:"/admin/workflow/executions/".concat(t.id)},"View the execution"))}function V(){var e=(0,y.G2)().workflow,t=(0,d.useForm)(),r=(0,n.useResourceContext)().resource,o=(0,n.useActionContext)(),l=(0,n.useNavigateNoUpdate)(),i=s.App.useApp().message,c=(0,C.RY)();return{run:function(){return T(function(){var n,s,u,d;return F(this,function(f){switch(f.label){case 0:return s=(n=t.values).autoRevision,u=N(n,["autoRevision"]),[4,t.submit()];case 1:return f.sent(),[4,r.execute(R({filterByTk:e.id,values:u},!c&&s?{autoRevision:1}:{}))];case 2:var p,m,v,y;return d=f.sent().data.data,t.reset(),o.setFormValueChanged(!1),o.setVisible(!1),null==i||i.open((m=(p=d.execution).id,v=p.status,(y=x.uy[v])?{type:"info",content:a().createElement(D,{data:{id:m},option:y})}:null)),d.newVersionId&&l("/admin/workflow/workflows/".concat(d.newVersionId)),[2]}})})()}}}function z(e){var t=e.children,r=(0,d.useField)(),n=(0,y.G2)().workflow,o=(0,E.cC)(),l=o.validate(n.config),i="";switch(!0){case!l:i=(0,b.KQ)("The trigger is not configured correctly, please check the trigger configuration.");break;case!o.triggerFieldset:i=(0,b.KQ)("This type of trigger has not been supported to be executed manually.")}return r.setPattern(i?"disabled":"editable"),i?a().createElement(s.Tooltip,{title:i},t):t}function G(){var e,t=(0,y.G2)().workflow,r=(0,C.RY)(),o=(0,E.cC)();return a().createElement(y.zQ.Provider,{value:t},a().createElement(A.XA.Provider,{value:!0},a().createElement(n.SchemaComponent,{components:R({Alert:s.Alert,Fieldset:g.p,ActionDisabledProvider:z},o.components),scope:R({useCancelAction:n.useCancelAction,useExecuteConfirmAction:V},o.scope),schema:{name:"trigger-modal-".concat(t.type,"-").concat(t.id),type:"void","x-decorator":"ActionDisabledProvider","x-component":"Action","x-component-props":{openSize:"small"},title:"{{t('Execute manually', { ns: \"".concat(b.A7,'" })}}'),properties:{drawer:{type:"void","x-decorator":"FormV2","x-component":"Action.Modal",title:"{{t('Execute manually', { ns: \"".concat(b.A7,'" })}}'),properties:K(R(K(R({},Object.keys(null!=(e=o.triggerFieldset)?e:{}).length?{alert:{type:"void","x-component":"Alert","x-component-props":{message:"{{t('Trigger variables need to be filled for executing.', { ns: \"".concat(b.A7,'" })}}'),className:(0,n.css)(Q())}}}:{description:{type:"void","x-component":"p","x-content":"{{t('This will perform all the actions configured in the workflow. Are you sure you want to continue?', { ns: \"".concat(b.A7,'" })}}')}}),{fieldset:{type:"void","x-decorator":"FormItem","x-component":"Fieldset",title:"{{t('Trigger variables', { ns: \"".concat(b.A7,'" })}}'),properties:o.triggerFieldset}}),r?{}:{autoRevision:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"{{t('Automatically create a new version after execution', { ns: \"".concat(b.A7,'" })}}'),default:!0}}),{footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{type:"void",title:"{{t('Cancel')}}","x-component":"Action","x-component-props":{useAction:"{{useCancelAction}}"}},submit:{type:"void",title:"{{t('Confirm')}}","x-component":"Action","x-component-props":{type:"primary",useAction:"{{useExecuteConfirmAction}}"}}}}})}}}})))}function M(){var e=(0,y.G2)(),t=e.workflow,r=e.revisions,i=B((0,o.useState)(!1),2),d=i[0],f=i[1],p=(0,l.useNavigate)(),g=(0,c.useTranslation)().t,E=s.App.useApp().modal,A=(0,n.useApp)(),O=(0,n.useResourceContext)().resource,S=s.App.useApp().message;(0,C.RY)();var P=(0,C.U3)(),j=(0,o.useCallback)(T(function(){var e;return F(this,function(r){switch(r.label){case 0:return[4,O.revision({filterByTk:t.id,filter:{key:t.key}})];case 1:return e=r.sent().data.data,S.success(g("Operation succeeded")),p("/admin/workflow/workflows/".concat(e.id)),[2]}})}),[O,t.id,t.key,S,g,p]),R=(0,o.useCallback)(T(function(){var e;return F(this,function(n){return e=t.current?(0,b.KQ)("This is a main version, delete it will cause the whole workflow to be deleted (including all other revisions)."):(0,b.KQ)("Current version will be deleted (without affecting other versions)."),E.confirm({title:g("Are you sure you want to delete it?"),content:e,onOk:function(){return T(function(){var e;return F(this,function(n){switch(n.label){case 0:return[4,O.destroy({filterByTk:t.id})];case 1:return n.sent(),S.success(g("Operation succeeded")),p(t.current?A.pluginSettingsManager.getRoutePath("workflow"):(0,w.SI)(null==(e=r.find(function(e){return e.current}))?void 0:e.id)),[2]}})})()}}),[2]})}),[t,E,g,O,S,p,A.pluginSettingsManager,r]),K=(0,o.useCallback)(function(e){switch(e.key){case"history":f(!0);return;case"revision":return j();case"delete":return R()}},[R,j]);return a().createElement(a().Fragment,null,a().createElement(s.Dropdown,{menu:{items:[{key:"key",label:"Key: ".concat(t.key),disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:(0,b.KQ)("Execution history"),disabled:!P},{role:"button","aria-label":"revision",key:"revision",label:(0,b.KQ)("Copy to new version")},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:g("Delete")}],onClick:K}},a().createElement(s.Button,{"aria-label":"more",type:"text",icon:a().createElement(u.EllipsisOutlined,null)})),a().createElement(n.ActionContextProvider,{value:{visible:d,setVisible:f}},a().createElement(n.SchemaComponent,{schema:h.V,components:{ExecutionResourceProvider:I,ExecutionLink:v.a,ExecutionStatusColumn:m.rV},scope:{useRefreshActionProps:k.X,ExecutionStatusOptions:x.C6}})))}function _(){var e,t,r,c,d=(0,l.useNavigate)(),m=(0,n.useApp)(),v=(0,n.useResourceActionContext)(),h=v.data,g=v.refresh,k=v.loading,E=(0,n.useResourceContext)().resource,x=(0,n.useDocumentTitle)().setTitle,A=(0,i.Z)().styles,C=B((0,o.useState)(null!=(r=null==h||null==(t=h.data)?void 0:t.enabled)&&r),2),P=C[0],j=C[1],R=B((0,o.useState)(!1),2),K=R[0],Q=R[1],I=null!=(c=null==h?void 0:h.data)?c:{},D=I.nodes,V=void 0===D?[]:D,z=I.revisions,_=void 0===z?[]:z,W=N(I,["nodes","revisions"]);(0,w.Yc)(V),(0,o.useEffect)(function(){var e,t=null!=(e=null==h?void 0:h.data)?e:{},r=t.title,n=t.enabled;null==x||x("".concat((0,b.KQ)("Workflow")).concat(r?": ".concat(r):"")),j(n)},[null==h?void 0:h.data,x]);var U=(0,o.useCallback)(function(e){var t=e.key;t!=W.id&&d((0,w.SI)(t))},[W.id,d]),Y=(0,o.useCallback)((e=T(function(e){return F(this,function(t){switch(t.label){case 0:return Q(!0),[4,E.update({filterByTk:W.id,values:{enabled:e}})];case 1:return t.sent(),Q(!1),j(e),[2]}})}),function(t){return e.apply(this,arguments)}),[E,W.id]);if(!(null==h?void 0:h.data))return k?a().createElement(s.Spin,null):a().createElement(s.Result,{status:"404",title:"Not found",extra:a().createElement(s.Button,{onClick:function(){return d(-1)}},(0,b.KQ)("Go back"))});var q=V.find(function(e){return!e.upstream});return a().createElement(y.iT.Provider,{value:{workflow:W,revisions:_,nodes:V,refresh:g}},a().createElement("div",{className:"workflow-toolbar"},a().createElement("header",null,a().createElement(s.Breadcrumb,{items:[{title:a().createElement(l.Link,{to:m.pluginSettingsManager.getRoutePath("workflow")},(0,b.KQ)("Workflow"))},{title:a().createElement(s.Tooltip,{title:"Key: ".concat(W.key)},a().createElement("strong",null,W.title))}]}),W.sync?a().createElement(s.Tag,{color:"orange"},(0,b.KQ)("Synchronously")):a().createElement(s.Tag,{color:"cyan"},(0,b.KQ)("Asynchronously"))),a().createElement("aside",null,a().createElement(G,null),a().createElement(s.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:U,defaultSelectedKeys:["".concat(W.id)],className:(0,n.cx)(A.dropdownClass,A.workflowVersionDropdownClass),items:_.sort(function(e,t){return t.id-e.id}).map(function(e,t){return{role:"button","aria-label":"version-".concat(t),key:"".concat(e.id),icon:e.current?a().createElement(u.RightOutlined,null):null,className:(0,n.cx)({executed:e.versionStats.executed>0,unexecuted:0==e.versionStats.executed,enabled:e.enabled}),label:a().createElement(a().Fragment,null,a().createElement("strong",null,"#".concat(e.id)),a().createElement("time",null,(0,f.dayjs)(e.createdAt).fromNow()))}})}},a().createElement(s.Button,{type:"text","aria-label":"version"},a().createElement("label",null,(0,b.KQ)("Version")),a().createElement("span",null,(null==W?void 0:W.id)?"#".concat(W.id):null),a().createElement(u.DownOutlined,null))),a().createElement(s.Switch,{checked:P,onChange:Y,checkedChildren:(0,b.KQ)("On"),unCheckedChildren:(0,b.KQ)("Off"),loading:K}),a().createElement(M,null))),a().createElement(O.E1,null,a().createElement(S.I,null,a().createElement(p.g,{entry:q}))))}var W=function(){var e,t,r,o=(0,l.useParams)(),c=(0,i.Z)().styles;return a().createElement("div",{className:(0,n.cx)(c.workflowPageClass)},a().createElement(n.SchemaComponent,{schema:{type:"void",properties:(e={},t="provider_".concat(o.id),r={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:o.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.stats.executed","revisions.versionStats.executed","revisions.enabled","stats.executed","versionStats.executed"]}}},"x-component":"WorkflowCanvas"},t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e)},components:{WorkflowCanvas:_}}))}}}]);
|