@nocobase/plugin-workflow-parallel 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -1,3 +1,11 @@
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
+ */
1
9
  import React from 'react';
2
10
  import { RadioWithTooltip, Instruction } from '@nocobase/plugin-workflow/client';
3
11
  export default class extends Instruction {
@@ -1,3 +1,11 @@
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
+ */
1
9
  import { Plugin } from '@nocobase/client';
2
10
  export default class extends Plugin {
3
11
  afterAdd(): Promise<void>;
@@ -1,3 +1,12 @@
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
+
1
10
  (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","react","antd","@ant-design/icons","react-i18next"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-workflow-parallel"]={},e["@nocobase/client"],e["@nocobase/plugin-workflow"],e.jsxRuntime,e.react,e.antd,e["@ant-design/icons"],e["react-i18next"]))})(this,function(e,t,n,r,f,d,b,u){"use strict";var M=Object.defineProperty;var S=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var l=(e,t,n)=>(S(e,typeof t!="symbol"?t+"":t,n),n);var x=(e,t,n)=>new Promise((r,f)=>{var d=a=>{try{u(n.next(a))}catch(p){f(p)}},b=a=>{try{u(n.throw(a))}catch(p){f(p)}},u=a=>a.done?r(a.value):Promise.resolve(a.value).then(d,b);u((n=n.apply(e,t)).next())});const a="workflow-parallel";function p(h,m={}){const{t:c}=v(m);return c(h)}function v(h){return u.useTranslation(a,h)}class $ extends n.Instruction{constructor(){super(...arguments);l(this,"title",`{{t("Parallel branch", { ns: "${a}" })}}`);l(this,"type","parallel");l(this,"group","control");l(this,"description",`{{t("Run multiple branch processes in parallel.", { ns: "${a}" })}}`);l(this,"fieldset",{mode:{type:"string",title:`{{t("Mode", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${a}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${a}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${a}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${a}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${a}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${a}" })}}`}]},default:"all"}});l(this,"components",{RadioWithTooltip:n.RadioWithTooltip})}Component({data:c}){const{styles:A}=n.useStyles(),{id:B,config:{mode:L}}=c,{workflow:y,nodes:T}=n.useFlowContext(),i=T.reduce((s,o)=>o.upstreamId===B&&o.branchIndex!=null?s.concat(o):s,[]).sort((s,o)=>s.branchIndex-o.branchIndex),[g,C]=f.useState(Math.max(2,i.length)),{getAriaLabel:q}=n.useGetAriaLabelOfAddButton(c),N=p("Add branch"),j=Array(Math.max(0,g-i.length)).fill(null),I=i[i.length-1];return r.jsx(n.NodeDefaultView,{data:c,children:r.jsxs("div",{className:A.nodeSubtreeClass,children:[r.jsxs("div",{className:A.branchBlockClass,children:[i.map(s=>r.jsx(n.Branch,{from:c,entry:s,branchIndex:s.branchIndex},s.id)),j.map((s,o)=>r.jsx(n.Branch,{from:c,branchIndex:(I?I.branchIndex:0)+o+1,controller:i.length+o>1?r.jsx("div",{className:t.css`
2
11
  padding-top: 2em;
3
12
 
@@ -1,12 +1,21 @@
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
+
1
10
  module.exports = {
2
11
  "react": "18.2.0",
3
12
  "antd": "5.12.8",
4
13
  "@ant-design/icons": "5.2.6",
5
- "@nocobase/client": "1.0.0-alpha.2",
6
- "@nocobase/plugin-workflow": "1.0.0-alpha.2",
14
+ "@nocobase/client": "1.0.0-alpha.3",
15
+ "@nocobase/plugin-workflow": "1.0.0-alpha.3",
7
16
  "react-i18next": "11.18.6",
8
- "@nocobase/server": "1.0.0-alpha.2",
9
- "@nocobase/plugin-workflow-test": "1.0.0-alpha.2",
10
- "@nocobase/test": "1.0.0-alpha.2",
11
- "@nocobase/utils": "1.0.0-alpha.2"
17
+ "@nocobase/server": "1.0.0-alpha.3",
18
+ "@nocobase/plugin-workflow-test": "1.0.0-alpha.3",
19
+ "@nocobase/test": "1.0.0-alpha.3",
20
+ "@nocobase/utils": "1.0.0-alpha.3"
12
21
  };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,10 @@
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
+ */
1
9
  export * from './server';
2
10
  export { default } from './server';
package/dist/index.js CHANGED
@@ -1,3 +1,12 @@
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
+
1
10
  var __create = Object.create;
2
11
  var __defProp = Object.defineProperty;
3
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,3 +1,11 @@
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
+ */
1
9
  export declare const NAMESPACE = "workflow-parallel";
2
10
  export declare function useLang(key: string, options?: {}): string;
3
11
  export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-parallel", undefined>;
@@ -1,3 +1,12 @@
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
+
1
10
  var __defProp = Object.defineProperty;
2
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,11 @@
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
+ */
1
9
  import { Processor, Instruction, FlowNodeModel, JobModel } from '@nocobase/plugin-workflow';
2
10
  export declare const PARALLEL_MODE: {
3
11
  readonly ALL: "all";
@@ -1,3 +1,12 @@
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
+
1
10
  var __defProp = Object.defineProperty;
2
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,11 @@
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
+ */
1
9
  import { Plugin } from '@nocobase/server';
2
10
  export default class extends Plugin {
3
11
  load(): Promise<void>;
@@ -1,3 +1,12 @@
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
+
1
10
  var __create = Object.create;
2
11
  var __defProp = Object.defineProperty;
3
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1 +1,9 @@
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
+ */
1
9
  export { default } from './Plugin';
@@ -1,3 +1,12 @@
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
+
1
10
  var __create = Object.create;
2
11
  var __defProp = Object.defineProperty;
3
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:并行分支节点",
5
5
  "description": "Could be used for parallel execution of branch processes in the workflow.",
6
6
  "description.zh-CN": "用于在工作流中需要并行执行的分支流程。",
7
- "version": "1.0.0-alpha.2",
7
+ "version": "1.0.0-alpha.3",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-parallel",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "1.x",
23
23
  "@nocobase/test": "1.x"
24
24
  },
25
- "gitHead": "f89dbc9e67d58404a2e484a5e124f739f340dcf8",
25
+ "gitHead": "7ccb137c7616cba5d238f87368239640e1d9ace1",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]
@@ -1,147 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { Button, Tooltip } from 'antd';
3
- import { PlusOutlined } from '@ant-design/icons';
4
-
5
- import { css } from '@nocobase/client';
6
-
7
- import {
8
- NodeDefaultView,
9
- Branch,
10
- useFlowContext,
11
- useStyles,
12
- useGetAriaLabelOfAddButton,
13
- RadioWithTooltip,
14
- Instruction,
15
- } from '@nocobase/plugin-workflow/client';
16
-
17
- import { NAMESPACE, useLang } from '../locale';
18
-
19
- export default class extends Instruction {
20
- title = `{{t("Parallel branch", { ns: "${NAMESPACE}" })}}`;
21
- type = 'parallel';
22
- group = 'control';
23
- description = `{{t("Run multiple branch processes in parallel.", { ns: "${NAMESPACE}" })}}`;
24
- fieldset = {
25
- mode: {
26
- type: 'string',
27
- title: `{{t("Mode", { ns: "${NAMESPACE}" })}}`,
28
- 'x-decorator': 'FormItem',
29
- 'x-component': 'RadioWithTooltip',
30
- 'x-component-props': {
31
- options: [
32
- {
33
- value: 'all',
34
- label: `{{t('All succeeded', { ns: "${NAMESPACE}" })}}`,
35
- tooltip: `{{t('Continue after all branches succeeded', { ns: "${NAMESPACE}" })}}`,
36
- },
37
- {
38
- value: 'any',
39
- label: `{{t('Any succeeded', { ns: "${NAMESPACE}" })}}`,
40
- tooltip: `{{t('Continue after any branch succeeded', { ns: "${NAMESPACE}" })}}`,
41
- },
42
- {
43
- value: 'race',
44
- label: `{{t('Any succeeded or failed', { ns: "${NAMESPACE}" })}}`,
45
- tooltip: `{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${NAMESPACE}" })}}`,
46
- },
47
- ],
48
- },
49
- default: 'all',
50
- },
51
- };
52
- components = {
53
- RadioWithTooltip,
54
- };
55
- Component({ data }) {
56
- // eslint-disable-next-line react-hooks/rules-of-hooks
57
- const { styles } = useStyles();
58
- const {
59
- id,
60
- config: { mode },
61
- } = data;
62
- // eslint-disable-next-line react-hooks/rules-of-hooks
63
- const { workflow, nodes } = useFlowContext();
64
- const branches = nodes
65
- .reduce((result, node) => {
66
- if (node.upstreamId === id && node.branchIndex != null) {
67
- return result.concat(node);
68
- }
69
- return result;
70
- }, [])
71
- .sort((a, b) => a.branchIndex - b.branchIndex);
72
- // eslint-disable-next-line react-hooks/rules-of-hooks
73
- const [branchCount, setBranchCount] = useState(Math.max(2, branches.length));
74
- // eslint-disable-next-line react-hooks/rules-of-hooks
75
- const { getAriaLabel } = useGetAriaLabelOfAddButton(data);
76
- // eslint-disable-next-line react-hooks/rules-of-hooks
77
- const langAddBranch = useLang('Add branch');
78
-
79
- const tempBranches = Array(Math.max(0, branchCount - branches.length)).fill(null);
80
- const lastBranchHead = branches[branches.length - 1];
81
-
82
- return (
83
- <NodeDefaultView data={data}>
84
- <div className={styles.nodeSubtreeClass}>
85
- <div className={styles.branchBlockClass}>
86
- {branches.map((branch) => (
87
- <Branch key={branch.id} from={data} entry={branch} branchIndex={branch.branchIndex} />
88
- ))}
89
- {tempBranches.map((_, i) => (
90
- <Branch
91
- key={`temp_${branches.length + i}`}
92
- from={data}
93
- branchIndex={(lastBranchHead ? lastBranchHead.branchIndex : 0) + i + 1}
94
- controller={
95
- branches.length + i > 1 ? (
96
- <div
97
- className={css`
98
- padding-top: 2em;
99
-
100
- > button {
101
- .anticon {
102
- transform: rotate(45deg);
103
- }
104
- }
105
- `}
106
- >
107
- <Button
108
- shape="circle"
109
- icon={<PlusOutlined />}
110
- onClick={() => setBranchCount(branchCount - 1)}
111
- disabled={workflow.executed}
112
- />
113
- </div>
114
- ) : null
115
- }
116
- />
117
- ))}
118
- </div>
119
- <Tooltip
120
- title={langAddBranch}
121
- className={css`
122
- visibility: ${workflow.executed ? 'hidden' : 'visible'};
123
- `}
124
- >
125
- <Button
126
- aria-label={getAriaLabel('add-branch')}
127
- icon={<PlusOutlined />}
128
- className={css`
129
- position: relative;
130
- top: 1em;
131
- transform-origin: center;
132
- transform: rotate(45deg);
133
-
134
- .anticon {
135
- transform-origin: center;
136
- transform: rotate(-45deg);
137
- }
138
- `}
139
- onClick={() => setBranchCount(branchCount + 1)}
140
- disabled={workflow.executed}
141
- />
142
- </Tooltip>
143
- </div>
144
- </NodeDefaultView>
145
- );
146
- }
147
- }