@nocobase/plugin-workflow 1.4.0-alpha.6 → 1.4.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -5
- package/dist/client/{AddButton.d.ts → AddNodeContext.d.ts} +2 -0
- package/dist/client/index.js +156 -152
- package/dist/client/nodes/condition.d.ts +24 -6
- package/dist/client/nodes/index.d.ts +19 -8
- package/dist/externalVersion.js +12 -12
- package/dist/locale/zh-CN.json +8 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/actions/index.js +1 -1
- package/package.json +3 -3
- package/README.zh-CN.md +0 -9
package/dist/client/index.js
CHANGED
|
@@ -7,7 +7,48 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(v,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("
|
|
10
|
+
(function(v,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("lodash"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("@formily/antd-v5"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/react","@formily/shared","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","lodash","@formily/reactive","@nocobase/evaluators/client","@formily/antd-v5","dayjs"],n):(v=typeof globalThis!="undefined"?globalThis:v||self,n(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@formily/react"],v["@formily/shared"],v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v.lodash,v["@formily/reactive"],v["@nocobase/evaluators"],v["@formily/antd-v5"],v.dayjs))})(this,function(v,n,T,te,a,X,se,y,g,Y,V,fe,we,Ge,Ie,bo,en){"use strict";var Gr=Object.defineProperty,qr=Object.defineProperties;var Yr=Object.getOwnPropertyDescriptors;var go=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var zo=(v,n,T)=>n in v?Gr(v,n,{enumerable:!0,configurable:!0,writable:!0,value:T}):v[n]=T,C=(v,n)=>{for(var T in n||(n={}))Qt.call(n,T)&&zo(v,T,n[T]);if(go)for(var T of go(n))Xt.call(n,T)&&zo(v,T,n[T]);return v},A=(v,n)=>qr(v,Yr(n));var Rt=v=>typeof v=="symbol"?v:v+"",Q=(v,n)=>{var T={};for(var te in v)Qt.call(v,te)&&n.indexOf(te)<0&&(T[te]=v[te]);if(v!=null&&go)for(var te of go(v))n.indexOf(te)<0&&Xt.call(v,te)&&(T[te]=v[te]);return T};var w=(v,n,T)=>(zo(v,typeof n!="symbol"?n+"":n,T),T);var J=(v,n,T)=>new Promise((te,a)=>{var X=g=>{try{y(T.next(g))}catch(Y){a(Y)}},se=g=>{try{y(T.throw(g))}catch(Y){a(Y)}},y=g=>g.done?te(g.value):Promise.resolve(g.value).then(X,se);y((T=T.apply(v,n)).next())});const on=y.createContext(null),vo={didCatch:!1,error:null};class tn extends y.Component{constructor(o){super(o),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=vo}static getDerivedStateFromError(o){return{didCatch:!0,error:o}}resetErrorBoundary(){const{error:o}=this.state;if(o!==null){for(var t,r,s=arguments.length,l=new Array(s),i=0;i<s;i++)l[i]=arguments[i];(t=(r=this.props).onReset)===null||t===void 0||t.call(r,{args:l,reason:"imperative-api"}),this.setState(vo)}}componentDidCatch(o,t){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,o,t)}componentDidUpdate(o,t){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&t.error!==null&&nn(o.resetKeys,s)){var l,i;(l=(i=this.props).onReset)===null||l===void 0||l.call(i,{next:s,prev:o.resetKeys,reason:"keys"}),this.setState(vo)}}render(){const{children:o,fallbackRender:t,FallbackComponent:r,fallback:s}=this.props,{didCatch:l,error:i}=this.state;let c=o;if(l){const u={error:i,resetErrorBoundary:this.resetErrorBoundary};if(y.isValidElement(s))c=s;else if(typeof t=="function")c=t(u);else if(r)c=y.createElement(r,u);else throw i}return y.createElement(on.Provider,{value:{didCatch:l,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}function nn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==o.length||e.some((t,r)=>!Object.is(t,o[r]))}const Pe=y.createContext({});function H(){return y.useContext(Pe)}const p="workflow";function N(e,o={}){return a.i18n.t(e,A(C({},o),{ns:p}))}function xo(){return Y.useTranslation(p)}function wo(e){const o=new Map;e.forEach(t=>o.set(t.id,t));for(const t of o.values())t.upstreamId&&(t.upstream=o.get(t.upstreamId)),t.downstreamId&&(t.downstream=o.get(t.downstreamId))}function Co(e,o){o(e),e.properties&&Object.keys(e.properties).forEach(t=>{Co(e.properties[t],o)})}function Ce(e){return`/admin/workflow/workflows/${e}`}function qe(e){return`/admin/workflow/executions/${e}`}function rn(r){var s=r,{collection:e,dataPath:o}=s,t=Q(s,["collection","dataPath"]);const{insert:l}=a.useSchemaInitializer(),{getTemplateSchemaByMode:i}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager_deprecated(),u=a.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,x]=a.parseCollectionName(e);d=c(x,h)}else d=e;function m(x){return J(this,arguments,function*({item:h}){const b=h.template?yield i(h):null,f={type:"void",name:te.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:o},"x-component":"CardItem","x-component-props":{title:t.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:b||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};Co(f,k=>{k["x-uid"]&&delete k["x-uid"]}),l(f)})}return n.jsx(a.SchemaInitializerItem,A(C({},t),{onClick:m,items:u}))}function Me(e){var l;const o=a.useSchemaInitializerItem(),t=(l=e==null?void 0:e.collection)!=null?l:o.collection;let r,s;if(typeof t=="string"){const i=a.parseCollectionName(t);r=i[0],s=i[1]}else s=t;return n.jsx(a.CollectionProvider_deprecated,{dataSource:r,collection:s,children:n.jsx(rn,C(C({},o),e))})}function sn(e){const{execution:o,nodes:t}=H(),r=y.useMemo(()=>t.reduce((i,c)=>Object.assign(i,{[c.id]:c.key}),{}),[t]),s=y.useMemo(()=>{var i;return{$context:o==null?void 0:o.context,$jobsMapByNodeKey:((i=o==null?void 0:o.jobs)!=null?i:[]).reduce((c,u)=>Object.assign(c,{[r[u.nodeId]]:u.result}),{})}},[o==null?void 0:o.context,o==null?void 0:o.jobs,r]);return y.useMemo(()=>we.get(s,e),[s,e])}function ln({collection:e,dataPath:o,children:t}){const r=T.useField(),s=y.useRef(null),{getAssociationAppends:l}=a.useAssociationNames(),{appends:i,updateAssociationValues:c}=l(),u=sn(o);let d,m;if(typeof e=="string"){const M=a.parseCollectionName(e);d=M[0],m=M[1]}else m=e;const h=y.useMemo(()=>fe.createForm({values:u,readPretty:!0}),[u]),x={appends:i},b={loading:!1,data:{data:u}},k=a.useAPIClient().resource(m),F=a.useBlockRequestContext();return n.jsx(a.CollectionProvider_deprecated,{dataSource:d,collection:m,children:n.jsx(a.RecordProvider,{record:u,parent:null,children:n.jsx(a.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:r,service:b,resource:k,__parent:F},children:n.jsx(a.FormBlockContext.Provider,{value:{params:x,form:h,field:r,service:b,updateAssociationValues:c,formBlockRef:s},children:t})})})})}function an(){return!0}const ko=T.observer(e=>{const d=e,{filter:o=an}=d,t=Q(d,["filter"]),r=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager_deprecated(),{values:l}=T.useForm(),[i,c]=a.parseCollectionName(l==null?void 0:l.collection),u=s(c,i);return n.jsx(g.Select,A(C({popupMatchSelectWidth:!1},t),{options:u.filter(o).map(m=>{var h;return{label:r((h=m.uiSchema)==null?void 0:h.title),value:m.name}})}))},{displayName:"FieldsSelect"}),cn=a.createStyles(({css:e,token:o})=>({container:e`
|
|
11
|
+
margin-bottom: 1.5em;
|
|
12
|
+
padding: 1em;
|
|
13
|
+
background-color: ${o.colorFillAlter};
|
|
14
|
+
|
|
15
|
+
> *:last-child {
|
|
16
|
+
margin-bottom: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
dl {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: baseline;
|
|
22
|
+
|
|
23
|
+
dt {
|
|
24
|
+
color: ${o.colorText};
|
|
25
|
+
&:after {
|
|
26
|
+
content: ':';
|
|
27
|
+
margin-right: 0.5em;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
p {
|
|
33
|
+
color: ${o.colorTextDescription};
|
|
34
|
+
}
|
|
35
|
+
`}));function Jo(e){const{label:o,title:t,description:r}=e,{styles:s}=cn();return n.jsxs("div",{className:a.cx(s.container,e.className),children:[n.jsxs("dl",{children:[n.jsx("dt",{children:o}),n.jsx("dd",{children:n.jsx(g.Tag,{style:{background:"none"},children:t})})]}),r?n.jsx("p",{children:r}):null]})}function dn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Uo={exports:{}};/*!
|
|
36
|
+
Copyright (c) 2018 Jed Watson.
|
|
37
|
+
Licensed under the MIT License (MIT), see
|
|
38
|
+
http://jedwatson.github.io/classnames
|
|
39
|
+
*/(function(e){(function(){var o={}.hasOwnProperty;function t(){for(var l="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(l=s(l,r(c)))}return l}function r(l){if(typeof l=="string"||typeof l=="number")return l;if(typeof l!="object")return"";if(Array.isArray(l))return t.apply(null,l);if(l.toString!==Object.prototype.toString&&!l.toString.toString().includes("[native code]"))return l.toString();var i="";for(var c in l)o.call(l,c)&&l[c]&&(i=s(i,c));return i}function s(l,i){return i?l?l+" "+i:l+i:l}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(Uo);var un=Uo.exports;const pn=dn(un),mn=a.createStyles(({css:e,token:o})=>({statusButtonClass:e`
|
|
40
|
+
border: none;
|
|
41
|
+
.ant-tag {
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
padding: 0;
|
|
45
|
+
margin-right: 0;
|
|
46
|
+
border-radius: 50%;
|
|
47
|
+
text-align: center;
|
|
48
|
+
}
|
|
49
|
+
`,noStatusButtonClass:e`
|
|
50
|
+
border-width: 2px;
|
|
51
|
+
`}));function Be(e){const i=e,{status:o,statusMap:t}=i,r=Q(i,["status","statusMap"]),{styles:s}=mn();let l=null;if(typeof o!="undefined"&&(t!=null&&t[o])){const{icon:c,color:u}=t[o];l=n.jsx(g.Tag,{color:u,children:c})}return n.jsx(g.Button,A(C({},r),{shape:"circle",size:"small",className:pn(l?s.statusButtonClass:s.noStatusButtonClass,e.className),children:l}))}const ie={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Ye=[{value:ie.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:n.jsx(V.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ie.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],_e=Ye.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),ce={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},So=[{value:ce.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.ClockCircleOutlined,{})},{value:ce.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{})},{value:ce.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{})},{value:ce.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{})},{value:ce.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90})},{value:ce.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45})},{value:ce.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{})},{value:ce.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{})}],Ke=So.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),Ao=(e,o)=>({getAriaLabel:y.useCallback(r=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,o!=null?String(o):"",r].filter(Boolean).join("-"),[o,e==null?void 0:e.title,e==null?void 0:e.type])}),ne=a.createStyles(({css:e,token:o})=>({workflowPageClass:e`
|
|
11
52
|
flex-grow: 1;
|
|
12
53
|
overflow: hidden;
|
|
13
54
|
display: flex;
|
|
@@ -19,8 +60,8 @@
|
|
|
19
60
|
justify-content: space-between;
|
|
20
61
|
position: relative;
|
|
21
62
|
padding: 0.5rem 1rem;
|
|
22
|
-
background: ${
|
|
23
|
-
border-bottom: 1px solid ${
|
|
63
|
+
background: ${o.colorBgContainer};
|
|
64
|
+
border-bottom: 1px solid ${o.colorBorderSecondary};
|
|
24
65
|
|
|
25
66
|
header {
|
|
26
67
|
display: flex;
|
|
@@ -55,7 +96,7 @@
|
|
|
55
96
|
height: 10em;
|
|
56
97
|
padding: 1em 0;
|
|
57
98
|
border-radius: 0.5em;
|
|
58
|
-
background: ${
|
|
99
|
+
background: ${o.colorBgContainer};
|
|
59
100
|
}
|
|
60
101
|
|
|
61
102
|
.workflow-canvas {
|
|
@@ -129,7 +170,7 @@
|
|
|
129
170
|
bottom: 0;
|
|
130
171
|
left: calc(50% - 0.5px);
|
|
131
172
|
width: 1px;
|
|
132
|
-
background-color: ${
|
|
173
|
+
background-color: ${o.colorBgLayout};
|
|
133
174
|
}
|
|
134
175
|
`,branchClass:e`
|
|
135
176
|
display: flex;
|
|
@@ -148,7 +189,7 @@
|
|
|
148
189
|
top: 0;
|
|
149
190
|
bottom: 0;
|
|
150
191
|
width: 1px;
|
|
151
|
-
background-color: ${
|
|
192
|
+
background-color: ${o.colorBorder};
|
|
152
193
|
}
|
|
153
194
|
|
|
154
195
|
:before,
|
|
@@ -156,7 +197,7 @@
|
|
|
156
197
|
content: '';
|
|
157
198
|
position: absolute;
|
|
158
199
|
height: 1px;
|
|
159
|
-
background-color: ${
|
|
200
|
+
background-color: ${o.colorBorder};
|
|
160
201
|
}
|
|
161
202
|
|
|
162
203
|
:before {
|
|
@@ -199,7 +240,7 @@
|
|
|
199
240
|
justify-content: center;
|
|
200
241
|
width: 0;
|
|
201
242
|
height: 6em;
|
|
202
|
-
border-left: 1px dashed ${
|
|
243
|
+
border-left: 1px dashed ${o.colorBgLayout};
|
|
203
244
|
|
|
204
245
|
.anticon {
|
|
205
246
|
font-size: 1.5em;
|
|
@@ -221,15 +262,15 @@
|
|
|
221
262
|
`,nodeCardClass:e`
|
|
222
263
|
position: relative;
|
|
223
264
|
width: 20em;
|
|
224
|
-
background: ${
|
|
265
|
+
background: ${o.colorBgContainer};
|
|
225
266
|
padding: 1em;
|
|
226
|
-
box-shadow: ${
|
|
227
|
-
border-radius: ${
|
|
267
|
+
box-shadow: ${o.boxShadowTertiary};
|
|
268
|
+
border-radius: ${o.borderRadiusLG}px;
|
|
228
269
|
cursor: pointer;
|
|
229
270
|
transition: box-shadow 0.3s ease;
|
|
230
271
|
|
|
231
272
|
&:hover {
|
|
232
|
-
box-shadow: ${
|
|
273
|
+
box-shadow: ${o.boxShadow};
|
|
233
274
|
|
|
234
275
|
.workflow-node-remove-button {
|
|
235
276
|
display: block;
|
|
@@ -237,22 +278,22 @@
|
|
|
237
278
|
}
|
|
238
279
|
|
|
239
280
|
&.configuring {
|
|
240
|
-
box-shadow: ${
|
|
281
|
+
box-shadow: ${o.boxShadow};
|
|
241
282
|
}
|
|
242
283
|
|
|
243
284
|
.workflow-node-remove-button {
|
|
244
285
|
display: none;
|
|
245
286
|
position: absolute;
|
|
246
|
-
right: 0
|
|
247
|
-
top: 0
|
|
248
|
-
color: ${
|
|
287
|
+
right: 0;
|
|
288
|
+
top: 0;
|
|
289
|
+
color: ${o.colorText};
|
|
249
290
|
|
|
250
291
|
&[disabled] {
|
|
251
292
|
display: none;
|
|
252
293
|
}
|
|
253
294
|
|
|
254
295
|
&:hover {
|
|
255
|
-
color: ${
|
|
296
|
+
color: ${o.colorErrorHover};
|
|
256
297
|
}
|
|
257
298
|
}
|
|
258
299
|
|
|
@@ -263,15 +304,15 @@
|
|
|
263
304
|
transition:
|
|
264
305
|
background-color 0.3s ease,
|
|
265
306
|
border-color 0.3s ease;
|
|
266
|
-
border-color: ${
|
|
267
|
-
background-color: ${
|
|
307
|
+
border-color: ${o.colorBorderBg};
|
|
308
|
+
background-color: ${o.colorBgContainerDisabled};
|
|
268
309
|
|
|
269
310
|
&:not(:disabled):hover {
|
|
270
|
-
border-color: ${
|
|
311
|
+
border-color: ${o.colorPrimaryBorderHover};
|
|
271
312
|
}
|
|
272
313
|
|
|
273
314
|
&:disabled:hover {
|
|
274
|
-
border-color: ${
|
|
315
|
+
border-color: ${o.colorBorderBg};
|
|
275
316
|
}
|
|
276
317
|
}
|
|
277
318
|
}
|
|
@@ -290,18 +331,23 @@
|
|
|
290
331
|
`,nodeJobButtonClass:e`
|
|
291
332
|
display: flex;
|
|
292
333
|
position: absolute;
|
|
293
|
-
top:
|
|
294
|
-
right:
|
|
334
|
+
top: 0;
|
|
335
|
+
right: 0;
|
|
295
336
|
justify-content: center;
|
|
296
337
|
align-items: center;
|
|
297
|
-
color: ${
|
|
338
|
+
color: ${o.colorTextLightSolid};
|
|
298
339
|
`,nodeHeaderClass:e`
|
|
299
|
-
|
|
300
|
-
`,nodeMetaClass:e`
|
|
340
|
+
display: flex;
|
|
301
341
|
margin-bottom: 0.5em;
|
|
302
342
|
|
|
343
|
+
.workflow-node-actions {
|
|
344
|
+
position: relative;
|
|
345
|
+
}
|
|
346
|
+
`,nodeMetaClass:e`
|
|
347
|
+
flex-grow: 1;
|
|
348
|
+
|
|
303
349
|
.workflow-node-id {
|
|
304
|
-
color: ${
|
|
350
|
+
color: ${o.colorTextDescription};
|
|
305
351
|
|
|
306
352
|
&:before {
|
|
307
353
|
content: '#';
|
|
@@ -312,7 +358,7 @@
|
|
|
312
358
|
align-items: center;
|
|
313
359
|
font-weight: normal;
|
|
314
360
|
.workflow-node-id {
|
|
315
|
-
color: ${
|
|
361
|
+
color: ${o.colorTextDescription};
|
|
316
362
|
}
|
|
317
363
|
`,nodeSubtreeClass:e`
|
|
318
364
|
display: flex;
|
|
@@ -320,7 +366,6 @@
|
|
|
320
366
|
align-items: center;
|
|
321
367
|
margin: auto;
|
|
322
368
|
`,nodeJobResultClass:e`
|
|
323
|
-
padding: 1em;
|
|
324
369
|
background-color: #f3f3f3;
|
|
325
370
|
`,addButtonClass:e`
|
|
326
371
|
flex-shrink: 0;
|
|
@@ -339,8 +384,8 @@
|
|
|
339
384
|
position: absolute;
|
|
340
385
|
top: calc(1.5em - 1px);
|
|
341
386
|
line-height: 1em;
|
|
342
|
-
color: ${
|
|
343
|
-
background-color: ${
|
|
387
|
+
color: ${o.colorTextSecondary};
|
|
388
|
+
background-color: ${o.colorBgLayout};
|
|
344
389
|
padding: 1px;
|
|
345
390
|
}
|
|
346
391
|
`,loopLineClass:e`
|
|
@@ -360,57 +405,11 @@
|
|
|
360
405
|
width: 4em;
|
|
361
406
|
height: 4em;
|
|
362
407
|
border-radius: 50%;
|
|
363
|
-
background-color: ${
|
|
364
|
-
color: ${
|
|
365
|
-
`}));
|
|
366
|
-
.ant-dropdown-menu-root {
|
|
367
|
-
max-height: 30em;
|
|
368
|
-
overflow-y: auto;
|
|
369
|
-
}
|
|
370
|
-
`,children:n.jsx(h.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(V.PlusOutlined,{}),loading:m})})}):null}const vt=(e,t)=>({getAriaLabel:g.useCallback(r=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",r].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),tn=l.createStyles(({css:e,token:t})=>({container:e`
|
|
371
|
-
margin-bottom: 1.5em;
|
|
372
|
-
padding: 1em;
|
|
373
|
-
background-color: ${t.colorFillAlter};
|
|
374
|
-
|
|
375
|
-
> *:last-child {
|
|
376
|
-
margin-bottom: 0;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
dl {
|
|
380
|
-
display: flex;
|
|
381
|
-
align-items: baseline;
|
|
382
|
-
|
|
383
|
-
dt {
|
|
384
|
-
color: ${t.colorText};
|
|
385
|
-
&:after {
|
|
386
|
-
content: ':';
|
|
387
|
-
margin-right: 0.5em;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
p {
|
|
393
|
-
color: ${t.colorTextDescription};
|
|
394
|
-
}
|
|
395
|
-
`}));function zt(e){const{label:t,title:o,description:r}=e,{styles:s}=tn();return n.jsxs("div",{className:l.cx(s.container,e.className),children:[n.jsxs("dl",{children:[n.jsx("dt",{children:t}),n.jsx("dd",{children:n.jsx(h.Tag,{style:{background:"none"},children:o})})]}),r?n.jsx("p",{children:r}):null]})}function on(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jt={exports:{}};/*!
|
|
396
|
-
Copyright (c) 2018 Jed Watson.
|
|
397
|
-
Licensed under the MIT License (MIT), see
|
|
398
|
-
http://jedwatson.github.io/classnames
|
|
399
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=s(a,r(c)))}return a}function r(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return o.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var c in a)t.call(a,c)&&a[c]&&(i=s(i,c));return i}function s(a,i){return i?a?a+" "+i:a+i:a}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(Jt);var nn=Jt.exports;const rn=on(nn),sn=l.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
400
|
-
border: none;
|
|
401
|
-
.ant-tag {
|
|
402
|
-
width: 100%;
|
|
403
|
-
height: 100%;
|
|
404
|
-
padding: 0;
|
|
405
|
-
margin-right: 0;
|
|
406
|
-
border-radius: 50%;
|
|
407
|
-
text-align: center;
|
|
408
|
-
}
|
|
409
|
-
`,noStatusButtonClass:e`
|
|
410
|
-
border-width: 2px;
|
|
411
|
-
`}));function Me(e){const i=e,{status:t,statusMap:o}=i,r=Q(i,["status","statusMap"]),{styles:s}=sn();let a=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:u}=o[t];a=n.jsx(h.Tag,{color:u,children:c})}return n.jsx(h.Button,A(C({},r),{shape:"circle",size:"small",className:rn(a?s.statusButtonClass:s.noStatusButtonClass,e.className),children:a}))}const ae={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},qe=[{value:ae.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:n.jsx(V.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ae.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ae.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ae.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ye=qe.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ie={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},xt=[{value:ie.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.ClockCircleOutlined,{})},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{})},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{})},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{})},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90})},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45})},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{})},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{})}],Ke=xt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Fe={label:"label",value:"value",children:"children"},ln=e=>[{key:"yesterday",value:"yesterday",label:e("Yesterday")},{key:"today",value:"today",label:e("Today")},{key:"tomorrow",value:"tomorrow",label:e("Tomorrow")},{key:"lastWeek",value:"lastWeek",label:e("Last week")},{key:"thisWeek",value:"thisWeek",label:e("This week")},{key:"nextWeek",value:"nextWeek",label:e("Next week")},{key:"lastMonth",value:"lastMonth",label:e("Last month")},{key:"thisMonth",value:"thisMonth",label:e("This month")},{key:"nextMonth",value:"nextMonth",label:e("Next month")},{key:"lastQuarter",value:"lastQuarter",label:e("Last quarter")},{key:"thisQuarter",value:"thisQuarter",label:e("This quarter")},{key:"nextQuarter",value:"nextQuarter",label:e("Next quarter")},{key:"lastYear",value:"lastYear",label:e("Last year")},{key:"thisYear",value:"thisYear",label:e("This year")},{key:"nextYear",value:"nextYear",label:e("Next year")},{key:"last7Days",value:"last7Days",label:e("Last 7 days")},{key:"next7Days",value:"next7Days",label:e("Next 7 days")},{key:"last30Days",value:"last30Days",label:e("Last 30 days")},{key:"next30Days",value:"next30Days",label:e("Next 30 days")},{key:"last90Days",value:"last90Days",label:e("Last 90 days")},{key:"next90Days",value:"next90Days",label:e("Next 90 days")}],Ut={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=l.usePlugin(ue),o=ve(),r=Kt(o),s=[];return r.forEach(a=>{var u;const i=t.get(a.type),c=(u=i.useVariables)==null?void 0:u.call(i,a,e);c&&s.push(c)}),s}},Ht={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=l.usePlugin(ue),{workflow:o}=H(),r=t.get(o.type);return(a=(s=r==null?void 0:r.useVariables)==null?void 0:s.call(r,o.config,e))!=null?a:null}},Gt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Fe,current:o}=e,{instructions:r}=l.usePlugin(ue),s=ve(),a=o!=null?o:s,i=_t(a),c=[];return i.forEach(u=>{var y,x;const d=r.get(u.type),m=(y=d.useScopeVariables)==null?void 0:y.call(d,u,e);m&&c.push({key:u.key,[t.value]:u.key,[t.label]:(x=u.title)!=null?x:`#${u.id}`,[t.children]:m})}),c}},qt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Fe}){const{t:o}=q.useTranslation();return[...!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"},{key:"dateRange",[t.label]:O("Date range"),[t.value]:"dateRange",children:ln(o)}]:[]]}},_e={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Yt(e,t){var o,r,s,a,i,c;return typeof t=="string"?(o=_e[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?wt(e)?((r=t.options)==null?void 0:r.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((i=t.options)==null?void 0:i.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function wt(e){return["belongsTo","hasOne","hasMany","belongsToMany","belongsToArray"].includes(e.type)}function Ct(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(r=>r.startsWith(o)).map(r=>r.replace(o,""))}function kt({fields:e,types:t,appends:o,depth:r=1,compile:s,getCollectionFields:a}){return e.filter(i=>{const c=t!=null&&t.length?t.some(u=>Yt(i,u)):!0;if(wt(i)){if(o===null)return r?c||kt({fields:St(i.target,{compile:s,getCollectionFields:a}),types:t,depth:r-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ct(i,o),d=o.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&kt({fields:St(i.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function Ze(e,t){var a,i;const o=l.useCompile(),r=(i=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:i.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function me(e={}){var s;const t=Object.assign({},Fe,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Ze(Gt,o),Ze(Ut,o),Ze(Ht,o),Ze(qt,o)]}function St(e,{compile:t,getCollectionFields:o}){var d,m,y,x;const[r,s]=l.parseCollectionName(e),a=o(s,r),i=[],c=[];a.forEach(b=>{if(b.isForeignKey&&!b.primaryKey)i.push(b);else{const f=a.find(k=>k.name===b.foreignKey);f&&i.push(f),c.push(b)}});const u=we.uniqBy(i,"name");for(let b=c.length-1;b>=0;b--){const f=c[b];if(f.type==="belongsTo"){const k=u.findIndex(F=>F.name===f.foreignKey);if(k>-1){const F=u[k];c.splice(b,0,A(C(C({},f),F),{uiSchema:A(C({},f.uiSchema),{title:(d=F.uiSchema)!=null&&d.title?t((m=F.uiSchema)==null?void 0:m.title):F.name})})),u.splice(k,1)}else c.splice(b,0,A(C({},f),{name:f.foreignKey,type:"bigInt",isForeignKey:!0,interface:f.interface,uiSchema:A(C({},f.uiSchema),{title:(y=f.uiSchema)!=null&&y.title?`${t((x=f.uiSchema)==null?void 0:x.title)} ID`:f.name})}))}else f.type==="context"&&f.collectionName==="users"&&c.splice(b,1)}return c.push(...u),we.uniqBy(c,"name").filter(b=>b.interface&&!b.hidden)}function an(e){const t=Ct(e.field,e.appends),o=Te(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>Yt(e.field,s))||(e.disabled=!0))}function Te(e){const{fields:t,collection:o,types:r,appends:s=[],depth:a=1,compile:i,getCollectionFields:c,fieldNames:u=Fe}=e,d=t!=null?t:St(o,{compile:i,getCollectionFields:c}),m=an.bind({compile:i,getCollectionFields:c,fieldNames:u});return kt({fields:d,types:r,depth:a,appends:s,compile:i,getCollectionFields:c}).map(x=>{var F;const b=i(((F=x.uiSchema)==null?void 0:F.title)||x.name),f=Ct(x,s),k=!wt(x)||f&&!f.length&&!s.includes(x.name)||!1;return{[u.label]:b,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:m,field:x,depth:a,appends:s,types:r}})}function Be(e){const t=l.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return g.useCallback(r=>o.getCollectionAllFields(r),[o])}function At(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.Input,C({scope:s},t))}function Ft(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.TextArea,C({scope:s},t))}function cn(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.RawTextArea,C({scope:s},t))}function dn(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.JSON,C({scope:s},t))}class be{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"end");w(this,"testable")}createDefaultConfig(){return{}}}function un(){const e=T.useForm(),t=l.useAPIClient(),o=l.useActionContext(),{refresh:r}=l.useResourceActionContext(),s=ve(),{workflow:a}=H();return{run(){return J(this,null,function*(){var c,u;if(a.executed){h.message.error(O("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues(Ge.toJS(e.values)),o.setFormValueChanged(!1),o.setVisible(!1),r()})}}}const Qe=g.createContext({});function ve(){return g.useContext(Qe)}function Ve(e=[]){const t=ve();return e.some(o=>we.get(t.config,o)!=null)}function Kt(e,t){const o=[];if(!e)return[];for(let r=e.upstream;r;r=r.upstream)(typeof t!="function"||t(r))&&o.push(r);return o}function _t(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function Zt({data:e}){var i;const{styles:t}=ne(),{getAriaLabel:o}=vt(e),r=l.usePlugin(ue),{Component:s=Nt,end:a}=(i=r.instructions.get(e.type))!=null?i:{};return n.jsx(Qe.Provider,{value:e,children:n.jsxs("div",{className:l.cx(t.nodeBlockClass),children:[n.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?n.jsx(Lt,{"aria-label":o(),upstream:e}):n.jsx("div",{className:"end-sign",children:n.jsx(V.CloseOutlined,{})})]})})}function Tt(){var m;const{t:e}=q.useTranslation(),t=l.useAPIClient(),{workflow:o,nodes:r,refresh:s}=(m=H())!=null?m:{},a=ve(),{modal:i}=h.App.useApp(),c=t.resource("flow_nodes"),u=g.useCallback(()=>J(this,null,function*(){var y;yield(y=c.destroy)==null?void 0:y.call(c,{filterByTk:a.id}),s()}),[a.id,s,c]),d=g.useCallback(()=>J(this,null,function*(){const y=r.filter(f=>f===a?!1:X.parse(f.config).parameters.filter(({key:B})=>B.startsWith(`$jobsMapByNodeKey.${a.key}.`)||B===`$jobsMapByNodeKey.${a.key}`).length);if(y.length){i.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:y.map(f=>`#${f.id}`).join(", ")})});return}const b=!r.find(f=>f.upstream===a&&f.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");i.confirm({title:e("Delete"),content:b,onOk:u})}),[a,i,r,u,e]);return o?o.executed?null:n.jsx(h.Button,{type:"text",shape:"circle",icon:n.jsx(V.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"}):null}function Ot(){var a;const{execution:e,setViewJob:t}=H(),{jobs:o}=(a=ve())!=null?a:{},{styles:r}=ne();if(!e)return null;if(!o.length)return n.jsx(Me,{className:r.nodeJobButtonClass,disabled:!0});function s({key:i}){const c=o.find(u=>u.id==i);t(c)}return n.jsx(h.Tooltip,{title:O("View result"),children:o.length>1?n.jsx(h.Dropdown,{menu:{items:o.map(i=>({key:i.id,label:n.jsxs(n.Fragment,{children:[n.jsx(Me,{statusMap:Ke,status:i.status}),n.jsx("time",{children:X.str2moment(i.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:r.dropdownClass},children:n.jsx(Me,{statusMap:Ke,status:o[o.length-1].status,className:r.nodeJobButtonClass})}):n.jsx(Me,{statusMap:Ke,status:o[0].status,onClick:()=>t(o[0]),className:r.nodeJobButtonClass})})}function pn(){return{form:T.useForm()}}const mn=()=>{const{values:e,query:t}=T.useForm(),o=ve(),r=l.useAPIClient(),s=l.useActionContext(),a=T.useField();return{run(){return J(this,null,function*(){const u=X.parse(o.config)(Ge.toJS(e.config)),d=t("result").take();d.setValue(null),d.setFeedback({}),a.data=a.data||{},a.data.loading=!0;try{const{data:{data:m}}=yield r.resource("flow_nodes").test({values:{config:u,type:o.type}});d.setFeedback({type:m.status>0?"success":"error",messages:m.status>0?[O("Resolved")]:[O("Failed")]}),d.setValue(m.result)}catch(m){d.setFeedback({type:"error",messages:m.message})}a.data.loading=!1,s.setFormValueChanged(!1)})}}},Qt=g.createContext([]);function fn({name:e,value:t,onChange:o}){return n.jsxs(h.Space,{children:[n.jsx(At,{variableOptions:{},value:`{{${e}}}`,disabled:!0}),n.jsx(l.Variable.Input,{useTypedConstant:["string","number","boolean","date"],value:t,onChange:o})]})}function hn({value:e,onChange:t}){const o=g.useContext(Qt);return o.length?n.jsx(n.Fragment,{children:o.map(r=>n.jsx(fn,{name:r,value:we.get(e,r),onChange:s=>{we.set(e,r,s),t(e)}},r))}):n.jsx(h.Empty,{image:h.Empty.PRESENTED_IMAGE_SIMPLE,description:O("No variable"),style:{margin:"1em"}})}function yn(){const e=ve(),{values:t}=T.useForm(),r=X.parse(t).parameters.map(a=>a.key),s=g.useMemo(()=>ge.createForm(),[]);return n.jsx(Qe.Provider,{value:{type:e.type,config:t},children:n.jsx(Qt.Provider,{value:r,children:n.jsx(l.SchemaComponent,{components:{Alert:h.Alert},scope:{useCancelAction:l.useCancelAction,useRunAction:mn},schema:{type:"void",name:"testButton",title:'{{t("Test run")}}',"x-component":"Action","x-component-props":{icon:"CaretRightOutlined"},properties:{modal:{type:"void","x-decorator":"FormV2","x-decorator-props":{form:s},"x-component":"Action.Modal",title:'{{t("Test run", { ns: "workflow" })}}',properties:{alert:{type:"void","x-component":"Alert","x-component-props":{message:'{{t("Test run will do the actual data manipulating or API calling, please use with caution.", { ns: "workflow" })}}',type:"warning",showIcon:!0,className:l.css`
|
|
408
|
+
background-color: ${o.colorText};
|
|
409
|
+
color: ${o.colorBgContainer};
|
|
410
|
+
`}));class be{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"presetFieldset");w(this,"branching");w(this,"view");w(this,"scope");w(this,"components");w(this,"end");w(this,"testable")}createDefaultConfig(){return{}}}function fn(){const e=T.useForm(),o=a.useAPIClient(),t=a.useActionContext(),{refresh:r}=a.useResourceActionContext(),s=ve(),{workflow:l}=H();return{run(){return J(this,null,function*(){var c,u;if(l.executed){g.message.error(N("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=o.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues(Ge.toJS(e.values)),t.setFormValueChanged(!1),t.setVisible(!1),r()})}}}const Ze=y.createContext({});function ve(){return y.useContext(Ze)}function Ve(e=[]){const o=ve();return e.some(t=>we.get(o.config,t)!=null)}function Ho(e,o){const t=[];if(!e)return[];for(let r=e.upstream;r;r=r.upstream)(typeof o!="function"||o(r))&&t.push(r);return t}function Go(e){const o=[];if(!e)return[];for(let t=e;t;t=t.upstream)t.upstream&&t.branchIndex!=null&&o.push(t.upstream);return o}function qo({data:e}){var i;const{styles:o}=ne(),{getAriaLabel:t}=Ao(e),r=a.usePlugin(ae),{Component:s=No,end:l}=(i=r.instructions.get(e.type))!=null?i:{};return n.jsx(Ze.Provider,{value:e,children:n.jsxs("div",{className:a.cx(o.nodeBlockClass),children:[n.jsx(s,{data:e}),!l||typeof l=="function"&&!l(e)?n.jsx(rt,{"aria-label":t(),upstream:e}):n.jsx("div",{className:"end-sign",children:n.jsx(V.CloseOutlined,{})})]})})}function Fo(){var m;const{t:e}=Y.useTranslation(),o=a.useAPIClient(),{workflow:t,nodes:r,refresh:s}=(m=H())!=null?m:{},l=ve(),{modal:i}=g.App.useApp(),c=o.resource("flow_nodes"),u=y.useCallback(()=>J(this,null,function*(){var h;yield(h=c.destroy)==null?void 0:h.call(c,{filterByTk:l.id}),s()}),[l.id,s,c]),d=y.useCallback(()=>J(this,null,function*(){const h=r.filter(f=>f===l?!1:X.parse(f.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${l.key}.`)||M===`$jobsMapByNodeKey.${l.key}`).length);if(h.length){i.error({title:N("Can not delete"),content:N("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(f=>`#${f.id}`).join(", ")})});return}const b=!r.find(f=>f.upstream===l&&f.branchIndex!=null)?e("Are you sure you want to delete it?"):N("This node contains branches, deleting will also be preformed to them, are you sure?");i.confirm({title:e("Delete"),content:b,onOk:u})}),[l,i,r,u,e]);return t?t.executed?null:n.jsx(g.Button,{type:"text",shape:"circle",icon:n.jsx(V.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button",size:"small"}):null}function To(){var l;const{execution:e,setViewJob:o}=H(),{jobs:t}=(l=ve())!=null?l:{},{styles:r}=ne();if(!e)return null;if(!t.length)return n.jsx(Be,{className:r.nodeJobButtonClass,disabled:!0});function s({key:i}){const c=t.find(u=>u.id==i);o(c)}return n.jsx(g.Tooltip,{title:N("View result"),children:t.length>1?n.jsx(g.Dropdown,{menu:{items:t.map(i=>({key:i.id,label:n.jsxs(n.Fragment,{children:[n.jsx(Be,{statusMap:Ke,status:i.status}),n.jsx("time",{children:X.str2moment(i.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:r.dropdownClass},children:n.jsx(Be,{statusMap:Ke,status:t[t.length-1].status,className:r.nodeJobButtonClass})}):n.jsx(Be,{statusMap:Ke,status:t[0].status,onClick:()=>o(t[0]),className:r.nodeJobButtonClass})})}function hn(){return{form:T.useForm()}}const yn=()=>{const{values:e,query:o}=T.useForm(),t=ve(),r=a.useAPIClient(),s=a.useActionContext(),l=T.useField();return{run(){return J(this,null,function*(){const u=X.parse(t.config)(Ge.toJS(e.config)),d=o("result").take();d.setValue(null),d.setFeedback({}),l.data=l.data||{},l.data.loading=!0;try{const{data:{data:m}}=yield r.resource("flow_nodes").test({values:{config:u,type:t.type}});d.setFeedback({type:m.status>0?"success":"error",messages:m.status>0?[N("Resolved")]:[N("Failed")]}),d.setValue(m.result)}catch(m){d.setFeedback({type:"error",messages:m.message})}l.data.loading=!1,s.setFormValueChanged(!1)})}}},Yo=y.createContext([]);function gn({name:e,value:o,onChange:t}){return n.jsxs(g.Space,{children:[n.jsx(Io,{variableOptions:{},value:`{{${e}}}`,disabled:!0}),n.jsx(a.Variable.Input,{useTypedConstant:["string","number","boolean","date"],value:o,onChange:t})]})}function bn({value:e,onChange:o}){const t=y.useContext(Yo);return t.length?n.jsx(n.Fragment,{children:t.map(r=>n.jsx(gn,{name:r,value:we.get(e,r),onChange:s=>{we.set(e,r,s),o(e)}},r))}):n.jsx(g.Empty,{image:g.Empty.PRESENTED_IMAGE_SIMPLE,description:N("No variable"),style:{margin:"1em"}})}function vn(){const e=ve(),{values:o}=T.useForm(),r=X.parse(o).parameters.map(l=>l.key),s=y.useMemo(()=>fe.createForm(),[]);return n.jsx(Ze.Provider,{value:{type:e.type,config:o},children:n.jsx(Yo.Provider,{value:r,children:n.jsx(a.SchemaComponent,{components:{Alert:g.Alert},scope:{useCancelAction:a.useCancelAction,useRunAction:yn},schema:{type:"void",name:"testButton",title:'{{t("Test run")}}',"x-component":"Action","x-component-props":{icon:"CaretRightOutlined"},properties:{modal:{type:"void","x-decorator":"FormV2","x-decorator-props":{form:s},"x-component":"Action.Modal",title:'{{t("Test run", { ns: "workflow" })}}',properties:{alert:{type:"void","x-component":"Alert","x-component-props":{message:'{{t("Test run will do the actual data manipulating or API calling, please use with caution.", { ns: "workflow" })}}',type:"warning",showIcon:!0,className:a.css`
|
|
412
411
|
margin-bottom: 1em;
|
|
413
|
-
`}},config:{type:"object",title:'{{t("Replace variables", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":
|
|
412
|
+
`}},config:{type:"object",title:'{{t("Replace variables", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":bn},actions:{type:"void","x-component":"ActionBar",properties:{submit:{type:"void",title:'{{t("Run")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRunAction }}"}}}},result:{type:"string",title:'{{t("Result", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{autoSize:{minRows:5,maxRows:20},style:{whiteSpace:"pre",cursor:"text"}},"x-pattern":"disabled"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{type:"void",title:'{{t("Close")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}}}}}}}}})})})}function No(e){var I;const{data:o,children:t}=e,r=a.useCompile(),s=a.useAPIClient(),{workflow:l,refresh:i}=(I=H())!=null?I:{},{styles:c}=ne(),d=a.usePlugin(ae).instructions.get(o.type),m=l.executed?'{{t("View")}}':'{{t("Configure")}}',[h,x]=y.useState(o.title),[b,f]=y.useState(!1),[k,F]=y.useState(!1),M=y.useMemo(()=>{const $=we.cloneDeep(o.config);return fe.createForm({initialValues:$,disabled:l.executed})},[o,l]),S=y.useCallback($=>{f($),$||M.reset()},[M]),E=y.useCallback(function($){return J(this,null,function*(){var B,G;const O=$||r(d==null?void 0:d.title);x(O),O!==o.title&&(yield(G=(B=s.resource("flow_nodes")).update)==null?void 0:G.call(B,{filterByTk:o.id,values:{title:O}}),i())})},[o,d]),L=y.useCallback(function($){if($.target===$.currentTarget){f(!0);return}const O=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let B=$.target;B&&B!==$.currentTarget&&B!==document.documentElement;B=B.parentNode)if(Array.from(B.classList).some(G=>O.has(G))){f(!0),$.stopPropagation();return}},[]);if(!d)return n.jsx("div",{className:a.cx(c.nodeClass,`workflow-node-type-${o.type}`),children:n.jsx(g.Tooltip,{title:N("Node with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`_untyped-${h}`,className:a.cx(c.nodeCardClass,"invalid"),children:[n.jsxs("div",{className:c.nodeHeaderClass,children:[n.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(g.Tag,{color:"error",children:N("Unknown node")}),n.jsx("span",{className:"workflow-node-id",children:o.id})]}),n.jsxs("div",{className:"workflow-node-actions",children:[n.jsx(Fo,{}),n.jsx(To,{})]})]}),n.jsx(g.Input.TextArea,{value:h,disabled:!0,autoSize:!0})]})})});const D=r(d.title);return n.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${o.type}`),children:[n.jsxs("div",{role:"button","aria-label":`${D}-${h}`,className:a.cx(c.nodeCardClass,{configuring:b}),onClick:L,children:[n.jsxs("div",{className:c.nodeHeaderClass,children:[n.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(g.Tag,{children:D}),n.jsx("span",{className:"workflow-node-id",children:o.id})]}),n.jsxs("div",{className:"workflow-node-actions",children:[n.jsx(Fo,{}),n.jsx(To,{})]})]}),n.jsx(g.Input.TextArea,{disabled:l.executed,value:h,onChange:$=>x($.target.value),onBlur:$=>E($.target.value),autoSize:!0}),n.jsx(a.ActionContextProvider,{value:{visible:b,setVisible:S,formValueChanged:k,setFormValueChanged:F},children:n.jsx(a.FormProvider,{form:M,children:n.jsx(a.SchemaComponent,{distributed:!1,scope:A(C({},d.scope),{useFormProviderProps:hn,useUpdateAction:fn}),components:d.components,schema:{type:"void",properties:A(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":m,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:n.jsxs("div",{className:a.css`
|
|
414
413
|
display: flex;
|
|
415
414
|
justify-content: space-between;
|
|
416
415
|
|
|
@@ -425,7 +424,7 @@
|
|
|
425
424
|
code {
|
|
426
425
|
font-weight: normal;
|
|
427
426
|
}
|
|
428
|
-
`,children:[n.jsx("strong",{children:
|
|
427
|
+
`,children:[n.jsx("strong",{children:o.title}),n.jsx(g.Tooltip,{title:N("Variable key of node"),children:n.jsx(g.Tag,{children:n.jsx("code",{children:o.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:A(C({},d.description?{description:{type:"void","x-component":Jo,"x-component-props":{label:N("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
|
|
429
428
|
.ant-input,
|
|
430
429
|
.ant-select,
|
|
431
430
|
.ant-cascader-picker,
|
|
@@ -437,34 +436,91 @@
|
|
|
437
436
|
min-width: 6em;
|
|
438
437
|
}
|
|
439
438
|
}
|
|
440
|
-
`},properties:d.fieldset},footer:
|
|
439
|
+
`},properties:d.fieldset},footer:l.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{flexGrow:1}},properties:A(C({},d.testable?{test:{type:"void","x-component":T.observer(vn),"x-align":"left"}}:{}),{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}})}}}})}})}})})})]}),t]})}const Te={label:"label",value:"value",children:"children"},xn=e=>[{key:"yesterday",value:"yesterday",label:e("Yesterday")},{key:"today",value:"today",label:e("Today")},{key:"tomorrow",value:"tomorrow",label:e("Tomorrow")},{key:"lastWeek",value:"lastWeek",label:e("Last week")},{key:"thisWeek",value:"thisWeek",label:e("This week")},{key:"nextWeek",value:"nextWeek",label:e("Next week")},{key:"lastMonth",value:"lastMonth",label:e("Last month")},{key:"thisMonth",value:"thisMonth",label:e("This month")},{key:"nextMonth",value:"nextMonth",label:e("Next month")},{key:"lastQuarter",value:"lastQuarter",label:e("Last quarter")},{key:"thisQuarter",value:"thisQuarter",label:e("This quarter")},{key:"nextQuarter",value:"nextQuarter",label:e("Next quarter")},{key:"lastYear",value:"lastYear",label:e("Last year")},{key:"thisYear",value:"thisYear",label:e("This year")},{key:"nextYear",value:"nextYear",label:e("Next year")},{key:"last7Days",value:"last7Days",label:e("Last 7 days")},{key:"next7Days",value:"next7Days",label:e("Next 7 days")},{key:"last30Days",value:"last30Days",label:e("Last 30 days")},{key:"next30Days",value:"next30Days",label:e("Next 30 days")},{key:"last90Days",value:"last90Days",label:e("Last 90 days")},{key:"next90Days",value:"next90Days",label:e("Next 90 days")}],_o={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:o}=a.usePlugin(ae),t=ve(),r=Ho(t),s=[];return r.forEach(l=>{var u;const i=o.get(l.type),c=(u=i.useVariables)==null?void 0:u.call(i,l,e);c&&s.push(c)}),s}},Ko={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,l;const{triggers:o}=a.usePlugin(ae),{workflow:t}=H(),r=o.get(t.type);return(l=(s=r==null?void 0:r.useVariables)==null?void 0:s.call(r,t.config,e))!=null?l:null}},Zo={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:o=Te,current:t}=e,{instructions:r}=a.usePlugin(ae),s=ve(),l=t!=null?t:s,i=Go(l),c=[];return i.forEach(u=>{var h,x;const d=r.get(u.type),m=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);m&&c.push({key:u.key,[o.value]:u.key,[o.label]:(x=u.title)!=null?x:`#${u.id}`,[o.children]:m})}),c}},Qo={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:o=Te}){const{t}=Y.useTranslation();return[...!e||e.includes("date")?[{key:"now",[o.label]:N("System time"),[o.value]:"now"},{key:"dateRange",[o.label]:N("Date range"),[o.value]:"dateRange",children:xn(t)}]:[]]}},Qe={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Xo(e,o){var t,r,s,l,i,c;return typeof o=="string"?(t=Qe[o])==null?void 0:t.has(e.interface):typeof o=="object"&&o.type==="reference"?Oo(e)?((r=o.options)==null?void 0:r.entity)&&(e.collectionName===((s=o.options)==null?void 0:s.collection)||((l=o.options)==null?void 0:l.collection)==="*"):e.isForeignKey?e.collectionName===((i=o.options)==null?void 0:i.collection)&&e.name==="id"||e.target===((c=o.options)==null?void 0:c.collection):!1:typeof o=="function"?o(e):!1}function Oo(e){return["belongsTo","hasOne","hasMany","belongsToMany","belongsToArray"].includes(e.type)}function Do(e,o){if(o==null)return null;const t=`${e.name}.`;return o.filter(r=>r.startsWith(t)).map(r=>r.replace(t,""))}function Eo({fields:e,types:o,appends:t,depth:r=1,compile:s,getCollectionFields:l}){return e.filter(i=>{const c=o!=null&&o.length?o.some(u=>Xo(i,u)):!0;if(Oo(i)){if(t===null)return r?c||Eo({fields:$o(i.target,{compile:s,getCollectionFields:l}),types:o,depth:r-1,appends:t,compile:s,getCollectionFields:l}):!1;const u=Do(i,t),d=t.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&Eo({fields:$o(i.target,{compile:s,getCollectionFields:l}),types:o,appends:u,compile:s,getCollectionFields:l}).length}else return c})}function Xe(e,o){var l,i;const t=a.useCompile(),r=(i=(l=e.useOptions)==null?void 0:l.call(e,o))==null?void 0:i.filter(Boolean),{fieldNames:s}=o;return{[s.label]:t(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function me(e={}){var s;const o=Object.assign({},Te,(s=e.fieldNames)!=null?s:{}),t=Object.assign(e,{fieldNames:o});return[Xe(Zo,t),Xe(_o,t),Xe(Ko,t),Xe(Qo,t)]}function $o(e,{compile:o,getCollectionFields:t}){var d,m,h,x;const[r,s]=a.parseCollectionName(e),l=t(s,r),i=[],c=[];l.forEach(b=>{if(b.isForeignKey&&!b.primaryKey)i.push(b);else{const f=l.find(k=>k.name===b.foreignKey);f&&i.push(f),c.push(b)}});const u=we.uniqBy(i,"name");for(let b=c.length-1;b>=0;b--){const f=c[b];if(f.type==="belongsTo"){const k=u.findIndex(F=>F.name===f.foreignKey);if(k>-1){const F=u[k];c.splice(b,0,A(C(C({},f),F),{uiSchema:A(C({},f.uiSchema),{title:(d=F.uiSchema)!=null&&d.title?o((m=F.uiSchema)==null?void 0:m.title):F.name})})),u.splice(k,1)}else c.splice(b,0,A(C({},f),{name:f.foreignKey,type:"bigInt",isForeignKey:!0,interface:f.interface,uiSchema:A(C({},f.uiSchema),{title:(h=f.uiSchema)!=null&&h.title?`${o((x=f.uiSchema)==null?void 0:x.title)} ID`:f.name})}))}else f.type==="context"&&f.collectionName==="users"&&c.splice(b,1)}return c.push(...u),we.uniqBy(c,"name").filter(b=>b.interface&&!b.hidden)}function wn(e){const o=Do(e.field,e.appends),t=Ne(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:o,depth:e.depth-1},this));e.loadChildren=null,t.length?e.children=t:(e.isLeaf=!0,!e.types||e.types.some(s=>Xo(e.field,s))||(e.disabled=!0))}function Ne(e){const{fields:o,collection:t,types:r,appends:s=[],depth:l=1,compile:i,getCollectionFields:c,fieldNames:u=Te}=e,d=o!=null?o:$o(t,{compile:i,getCollectionFields:c}),m=wn.bind({compile:i,getCollectionFields:c,fieldNames:u});return Eo({fields:d,types:r,depth:l,appends:s,compile:i,getCollectionFields:c}).map(x=>{var F;const b=i(((F=x.uiSchema)==null?void 0:F.title)||x.name),f=Do(x,s),k=!Oo(x)||f&&!f.length&&!s.includes(x.name)||!1;return{[u.label]:b,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:m,field:x,depth:l,appends:s,types:r}})}function je(e){const o=a.useApp(),{collectionManager:t}=o.dataSourceManager.getDataSource(e);return y.useCallback(r=>t.getCollectionAllFields(r),[t])}function Io(t){var r=t,{variableOptions:e}=r,o=Q(r,["variableOptions"]);const s=me(e);return n.jsx(a.Variable.Input,C({scope:s},o))}function Po(t){var r=t,{variableOptions:e}=r,o=Q(r,["variableOptions"]);const s=me(e);return n.jsx(a.Variable.TextArea,C({scope:s},o))}function Cn(t){var r=t,{variableOptions:e}=r,o=Q(r,["variableOptions"]);const s=me(e);return n.jsx(a.Variable.RawTextArea,C({scope:s},o))}function kn(t){var r=t,{variableOptions:e}=r,o=Q(r,["variableOptions"]);const s=me(e);return n.jsx(a.Variable.JSON,C({scope:s},o))}function Re({value:e,onChange:o,renderSchemaComponent:t}){const r=me();return n.jsx(a.Variable.Input,{value:e,onChange:o,scope:r,children:t()})}function ke(e){const l=e,{options:o=[],direction:t}=l,r=Q(l,["options","direction"]),s=a.useCompile();return n.jsx(g.Radio.Group,A(C({},r),{children:n.jsx(g.Space,{direction:t,children:o.map(i=>n.jsxs(g.Radio,{value:i.value,children:[n.jsx("span",{className:a.css`
|
|
440
|
+
& + .anticon {
|
|
441
|
+
margin-left: 0.25em;
|
|
442
|
+
}
|
|
443
|
+
`,children:s(i.label)}),i.tooltip&&n.jsx(g.Tooltip,{title:s(i.tooltip),children:n.jsx(V.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))})}))}function Sn(e){const l=e,{options:o=[],direction:t}=l,r=Q(l,["options","direction"]),s=a.useCompile();return n.jsx(g.Checkbox.Group,A(C({},r),{children:n.jsx(g.Space,{direction:t,children:o.map(i=>n.jsxs(g.Checkbox,{value:i.value,children:[n.jsx("span",{className:a.css`
|
|
444
|
+
& + .anticon {
|
|
445
|
+
margin-left: 0.25em;
|
|
446
|
+
}
|
|
447
|
+
`,children:s(i.label)}),i.tooltip&&n.jsx(g.Tooltip,{title:s(i.tooltip),children:n.jsx(V.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))})}))}function Ro(){const e=T.useFieldSchema(),o=a.useCompile();return n.jsxs(a.GeneralSchemaDesigner,{title:o(e.title),children:[n.jsx(a.SchemaSettingsBlockTitleItem,{}),n.jsx(a.SchemaSettingsDivider,{}),n.jsx(a.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Oe=()=>null;function An(){const l=a.useSchemaInitializerItem(),{node:o,resultTitle:t}=l,r=Q(l,["node","resultTitle"]),{insert:s}=a.useSchemaInitializer();return n.jsx(a.SchemaInitializerItem,A(C({},r),{onClick:()=>{var i;s({type:"void",name:o.id,title:o.title,"x-component":"CardItem","x-component-props":{title:(i=o.title)!=null?i:`#${o.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:t,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}})}}))}function Fn({dataSource:e}){var s;const o=T.useFieldSchema(),{execution:t}=H();if(!t)return o.title;const r=X.parse(e)({$jobsMapByNodeKey:((s=t.jobs)!=null?s:[]).reduce((l,i)=>Object.assign(l,{[i.nodeKey]:i.result}),{})});return n.jsx("pre",{className:a.css`
|
|
448
|
+
margin: 0;
|
|
449
|
+
`,children:JSON.stringify(r,null,2)})}Oe.Initializer=An,Oe.Result=Fn,Oe.Designer=Ro;const Mo=e=>{const o=Ie.evaluators.get(e);return o&&o.link?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:a.css`
|
|
450
|
+
&:after {
|
|
451
|
+
content: ':';
|
|
452
|
+
}
|
|
453
|
+
& + a {
|
|
454
|
+
margin-left: 0.25em;
|
|
455
|
+
}
|
|
456
|
+
`,children:a.i18n.t("Syntax references")}),n.jsx("a",{href:o.link,target:"_blank",rel:"noreferrer",children:o.label})]}):null},_=new X.Registry;_.register("equal",{name:"=",type:"boolean",group:"boolean"}),_.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),_.register("gt",{name:">",type:"boolean",group:"boolean"}),_.register("gte",{name:"≥",type:"boolean",group:"boolean"}),_.register("lt",{name:"<",type:"boolean",group:"boolean"}),_.register("lte",{name:"≤",type:"boolean",group:"boolean"}),_.register("add",{name:"+",type:"number",group:"number"}),_.register("minus",{name:"-",type:"number",group:"number"}),_.register("multiple",{name:"*",type:"number",group:"number"}),_.register("divide",{name:"/",type:"number",group:"number"}),_.register("mod",{name:"%",type:"number",group:"number"}),_.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),_.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),_.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),_.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),_.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),_.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),_.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const Tn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function et(e){return Array.from(_.getEntities()).filter(([o,t])=>t.group===e)}function Nn({calculator:e,operands:o=[],onChange:t}){const r=a.useCompile(),s=y.useContext(tt),l=s(),i=s(),c=y.useCallback(m=>t({calculator:e,operands:[m,o[1]]}),[e,t,o]),u=y.useCallback(m=>t({calculator:e,operands:[o[0],m]}),[e,t,o]),d=y.useCallback(m=>t({operands:o,calculator:m}),[t,o]);return n.jsxs("fieldset",{className:a.css`
|
|
457
|
+
display: flex;
|
|
458
|
+
gap: 0.5em;
|
|
459
|
+
align-items: center;
|
|
460
|
+
flex-wrap: wrap;
|
|
461
|
+
`,children:[n.jsx(a.Variable.Input,{changeOnSelect:!0,value:o[0],onChange:c,scope:l,useTypedConstant:!0}),n.jsx(g.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Tn.filter(m=>!!et(m.value).length).map(m=>n.jsx(g.Select.OptGroup,{label:r(m.title),children:et(m.value).map(([h,{name:x}])=>n.jsx(g.Select.Option,{value:h,children:r(x)},h))},m.value))}),n.jsx(a.Variable.Input,{changeOnSelect:!0,value:o[1],onChange:u,scope:i,useTypedConstant:!0})]})}function On({value:e,onChange:o,onRemove:t}){if(!e)return null;const{calculator:r,operands:s=[]}=e;return n.jsxs("div",{className:a.css`
|
|
462
|
+
display: flex;
|
|
463
|
+
position: relative;
|
|
464
|
+
margin: 0.5em 0;
|
|
465
|
+
`,children:[e.group?n.jsx(ot,{value:e.group,onChange:l=>o(A(C({},e),{group:l}))}):n.jsx(Nn,{operands:s,calculator:r,onChange:o}),n.jsx(g.Button,{"aria-label":"icon-close",onClick:t,type:"link",icon:n.jsx(V.CloseCircleOutlined,{})})]})}function ot({value:e,onChange:o}){const{t}=Y.useTranslation(),{type:r="and",calculations:s=[]}=e,l=y.useCallback(()=>{o(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))},[e,s,o]),i=y.useCallback(()=>{o(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))},[e,s,o]),c=y.useCallback(d=>{s.splice(d,1),o(A(C({},e),{calculations:[...s]}))},[e,s,o]),u=y.useCallback((d,m)=>{s.splice(d,1,m),o(A(C({},e),{calculations:[...s]}))},[e,s,o]);return n.jsxs("div",{className:a.cx("node-type-condition-group",a.css`
|
|
466
|
+
position: relative;
|
|
467
|
+
width: 100%;
|
|
468
|
+
.node-type-condition-group {
|
|
469
|
+
padding: 0.5em 1em;
|
|
470
|
+
border: 1px dashed #ddd;
|
|
471
|
+
}
|
|
472
|
+
+ button {
|
|
473
|
+
position: absolute;
|
|
474
|
+
right: 0;
|
|
475
|
+
}
|
|
476
|
+
`),children:[n.jsx("div",{className:a.css`
|
|
477
|
+
display: flex;
|
|
478
|
+
align-items: center;
|
|
479
|
+
gap: 0.5em;
|
|
480
|
+
.ant-select {
|
|
481
|
+
width: auto;
|
|
482
|
+
min-width: 6em;
|
|
483
|
+
}
|
|
484
|
+
`,children:n.jsxs(Y.Trans,{children:["Meet ",n.jsxs(g.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:d=>o(A(C({},e),{type:d})),children:[n.jsx(g.Select.Option,{value:"and",children:"All"}),n.jsx(g.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((d,m)=>n.jsx(On,{value:d,onChange:u.bind(this,m),onRemove:()=>c(m)},`${d.calculator}_${m}`))}),n.jsxs("div",{className:a.css`
|
|
485
|
+
button {
|
|
486
|
+
padding: 0;
|
|
487
|
+
&:not(:last-child) {
|
|
488
|
+
margin-right: 1em;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
`,children:[n.jsx(g.Button,{type:"link",onClick:l,children:t("Add condition")}),n.jsx(g.Button,{type:"link",onClick:i,children:t("Add condition group")})]})]})}const tt=y.createContext(me);function nt({value:e,onChange:o,useVariableHook:t=me}){const r=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(tt.Provider,{value:t,children:n.jsx(ot,{value:r.group,onChange:s=>o(A(C({},r),{group:s}))})})}function Dn(e){return n.jsx(g.Card,{children:n.jsx(bo.FormLayout,{layout:e.layout||"vertical",children:e.children})})}function rt(e){var x;const{upstream:o,branchIndex:t=null}=e,r=a.usePlugin(ae),s=a.useCompile(),{workflow:l}=(x=H())!=null?x:{},i=Array.from(r.instructions.getValues()),{styles:c}=ne(),{onCreate:u,creating:d}=eo(),m=y.useMemo(()=>{const b=[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"calculation",label:`{{t("Calculation", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(f=>{const k=i.filter(F=>F.group===f.key&&(F.isAvailable?F.isAvailable({engine:r,workflow:l,upstream:o,branchIndex:t}):!0));return A(C({},f),{type:"group",children:k.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title}))})}).filter(f=>f.children.length);return s(b)},[t,s,r,i,o,l]),h=y.useCallback(f=>J(this,[f],function*({keyPath:b}){const[k]=b;u({type:k,upstream:o,branchIndex:t})}),[t,u,o]);return l?n.jsx("div",{className:c.addButtonClass,children:n.jsx(g.Dropdown,{menu:{items:m,onClick:h},disabled:l.executed,overlayClassName:a.css`
|
|
492
|
+
.ant-dropdown-menu-root {
|
|
493
|
+
max-height: 30em;
|
|
494
|
+
overflow-y: auto;
|
|
495
|
+
}
|
|
496
|
+
`,children:n.jsx(g.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(V.PlusOutlined,{}),loading:(d==null?void 0:d.upstreamId)==(o==null?void 0:o.id)&&(d==null?void 0:d.branchIndex)===t,size:"small"})})}):null}function En(){const e=T.useForm(),o=a.useAPIClient(),{workflow:t,refresh:r}=H(),{presetting:s,setPresetting:l,setCreating:i}=eo(),c=a.useActionContext();return{run(){return J(this,null,function*(){if(s){yield e.submit(),i(s.data);try{const{data:{data:d}}=yield o.resource("workflows.nodes",t.id).create({values:A(C({},s.data),{config:C(C({},s.data.config),e.values.config)})});e.values.downstreamBranchIndex!==!1&&d.downstreamId&&(yield o.resource("flow_nodes").update({filterByTk:d.downstreamId,values:{branchIndex:e.values.downstreamBranchIndex,upstream:{id:d.id,downstreamId:null}},updateAssociationValues:["upstream"]})),c.setVisible(!1),l(null),r()}catch(d){console.error(d)}finally{i(null)}}})}}}const st=y.createContext(null);function eo(){return y.useContext(st)}const $n=[{label:`{{t('After end of branches', { ns: "${p}" })}}`,value:!1},{label:`{{t('Inside of branch', { ns: "${p}" })}}`,value:0}],In=T.observer(e=>{var i,c;const{presetting:o}=eo(),{nodes:t}=H(),{values:r}=T.useForm(),s=y.useMemo(()=>{var x;if(!(o!=null&&o.instruction))return[];const{instruction:u,data:d}=o;if(!(d.upstreamId?t.find(b=>b.upstreamId===d.upstreamId&&b.branchIndex===d.branchIndex):t.find(b=>b.upstreamId===null)))return[];const h=typeof u.branching=="function"?u.branching((x=r.config)!=null?x:{}):u.branching;return h?h===!0?$n:h:[]},[o,t,r.config]);if(!s.length)return null;const{data:l}=o;return n.jsx(a.SchemaComponent,{components:{RadioWithTooltip:ke},schema:{name:`${(i=l.type)!=null?i:"unknown"}-${(c=l.upstreamId)!=null?c:"root"}-${l.branchIndex}`,type:"void",properties:{downstreamBranchIndex:{type:"number",title:N("Move all downstream nodes to",{ns:p}),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:s,direction:"vertical"},default:!1,required:!0}}}})});function Pn(){const{presetting:e}=eo();return e!=null&&e.instruction.presetFieldset?n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{config:{type:"object",properties:e.instruction.presetFieldset}}}}):null}function Mn(e){var M;const o=a.useAPIClient(),t=a.useCompile(),r=a.usePlugin(ae),[s,l]=y.useState(null),[i,c]=y.useState(null),[u,d]=y.useState(!1),{workflow:m,nodes:h,refresh:x}=(M=H())!=null?M:{},b=y.useMemo(()=>fe.createForm(),[]),f=y.useCallback(S=>{S||(b.reset(),b.clearFormGraph("*"),c(null))},[b]),k=y.useCallback(S=>J(this,null,function*(){l(S);try{yield o.resource("workflows.nodes",m.id).create({values:S}),x()}catch(E){console.error(E)}finally{l(null)}}),[o,x,m.id]),F=y.useCallback(({type:S,upstream:E,branchIndex:L})=>{var O,B,G;const D=r.instructions.get(S);if(!D){console.error(`Instruction "${S}" not found`);return}const I={key:X.uid(),type:S,upstreamId:(O=E==null?void 0:E.id)!=null?O:null,branchIndex:L,title:t(D.title),config:(G=(B=D.createDefaultConfig)==null?void 0:B.call(D))!=null?G:{}},$=E!=null&&E.id?h.find(U=>U.upstreamId===I.upstreamId&&U.branchIndex===I.branchIndex):h.find(U=>U.upstreamId===null);if(D.presetFieldset||(typeof D.branching=="function"?D.branching(I.config):D.branching)&&$){c({data:I,instruction:D});return}k(I)},[t,k,r.instructions]);return n.jsxs(st.Provider,{value:{presetting:i,setPresetting:c,onCreate:F,creating:s,setCreating:l},children:[e.children,n.jsx(a.ActionContextProvider,{value:{visible:!!i,setVisible:f,formValueChanged:u,setFormValueChanged:d,openSize:"small"},children:n.jsx(a.SchemaComponent,{components:{DownstreamBranchIndex:In,PresetFieldset:Pn},scope:{useCancelAction:a.useCancelAction,useAddNodeSubmitAction:En},schema:{name:"modal",type:"void","x-decorator":"FormV2","x-decorator-props":{form:b},"x-component":"Action.Modal",title:`{{ t("Add node", { ns: "${p}" }) }}`,properties:{config:{type:"void","x-component":"PresetFieldset"},downstreamBranchIndex:{type:"void","x-component":"DownstreamBranchIndex"},footer:{"x-component":"Action.Modal.Footer",properties:{actions:{type:"void","x-component":"ActionBar",properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{type:"void",title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useAddNodeSubmitAction }}"}}}}}}}}})})]})}function oo({from:e=null,entry:o=null,branchIndex:t=null,controller:r=null,className:s,end:l}){const{styles:i}=ne(),{getAriaLabel:c}=Ao(e,t),u=[];for(let d=o;d;d=d.downstream)u.push(d);return n.jsxs("div",{className:a.cx("workflow-branch",i.branchClass,s),children:[n.jsx("div",{className:"workflow-branch-lines"}),r,n.jsx(rt,{"aria-label":c(),upstream:e,branchIndex:t}),n.jsx("div",{className:"workflow-node-list",children:u.map(d=>n.jsx(qo,{data:d},d.id))}),l?n.jsx("div",{className:"end-sign",children:n.jsx(V.CloseOutlined,{})}):null]})}function Bn(){var l;const e=T.useForm(),o=a.useAPIClient(),{workflow:t}=(l=H())!=null?l:{},r=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return J(this,null,function*(){if(t.executed){g.message.error(N("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield o.resource("workflows").update({filterByTk:t.id,values:{config:e.values}}),r.setFormValueChanged(!1),r.setVisible(!1),s()})}}}class Bo{constructor(){w(this,"sync");w(this,"title");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"isActionTriggerable")}}function Vn(){const e=a.useCompile(),{workflow:o,execution:t}=H(),{styles:r}=ne(),s=Vo();return t?n.jsx(a.SchemaComponent,{components:{Tooltip:g.Tooltip},schema:{type:"void",name:"execution","x-decorator":"Tooltip","x-decorator-props":{title:N("View result")},"x-component":"Action","x-component-props":{title:n.jsx(V.InfoOutlined,{}),shape:"circle",size:"small",className:r.nodeJobButtonClass,type:"primary"},properties:{[t.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:n.jsxs("div",{className:a.cx(r.nodeTitleClass),children:[n.jsx(g.Tag,{children:e(s.title)}),n.jsx("strong",{children:o.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",t.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:a.css`
|
|
441
497
|
padding: 1em;
|
|
442
498
|
background-color: #f3f3f3;
|
|
443
|
-
`},"x-read-pretty":!0}}}}}}):null}function
|
|
499
|
+
`},"x-read-pretty":!0}}}}}}):null}function jn(){return{form:T.useForm()}}const Wn=()=>{const e=a.useAPIClient(),{workflow:o,refresh:t}=H(),[r,s]=y.useState(""),[l,i]=y.useState(!1),[c,u]=y.useState(!1),{styles:d}=ne(),m=a.useCompile(),h=Vo();y.useEffect(()=>{var D,I;o&&s((I=(D=o.triggerTitle)!=null?D:o.title)!=null?I:m(h==null?void 0:h.title))},[o,h]);const x=y.useMemo(()=>{const D=we.cloneDeep(o.config);return fe.createForm({initialValues:D,disabled:o.executed})},[o]),b=y.useCallback(D=>{i(D),D||x.reset()},[x]),f=y.useCallback(function(D){return J(this,null,function*(){const I=D||m(h==null?void 0:h.title);s(I),I!==o.triggerTitle&&(yield e.resource("workflows").update({filterByTk:o.id,values:{triggerTitle:I}}),t())})},[o,h]),k=y.useCallback(function(D){var $;if(D.target===D.currentTarget){i(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let O=D.target;O&&O!==D.currentTarget;O=O.parentNode)if(Array.from(($=O.classList)!=null?$:[]).some(B=>I.has(B))){i(!0),D.stopPropagation();return}},[]),F=o.executed?'{{t("View")}}':'{{t("Configure")}}',M=N("Trigger");if(!h)return n.jsx(g.Tooltip,{title:N("Workflow with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`${M}-${r}`,className:a.cx(d.nodeCardClass,"invalid"),onClick:k,children:[n.jsx("div",{className:d.nodeHeaderClass,children:n.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsx(g.Tag,{color:"error",children:N("Unknown trigger")})})}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(g.Input.TextArea,{value:r,disabled:!0,autoSize:!0})})]})});const{fieldset:S,scope:E,components:L}=h;return n.jsxs("div",{role:"button","aria-label":`${M}-${r}`,className:a.cx(d.nodeCardClass),onClick:k,children:[n.jsxs("div",{className:d.nodeHeaderClass,children:[n.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsxs(g.Tag,{color:"gold",children:[n.jsx(V.ThunderboltOutlined,{}),n.jsx("span",{className:"type",children:m(h.title)})]})}),n.jsx("div",{className:"workflow-node-actions",children:n.jsx(Vn,{})})]}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(g.Input.TextArea,{value:r,onChange:D=>s(D.target.value),onBlur:D=>f(D.target.value),autoSize:!0,disabled:o.executed})}),n.jsx(a.ActionContextProvider,{value:{visible:l,setVisible:b,formValueChanged:c,setFormValueChanged:u},children:n.jsx(a.FormProvider,{form:x,children:n.jsx(a.SchemaComponent,{scope:A(C({},E),{useFormProviderProps:jn}),components:L,schema:{name:`workflow-trigger-${o.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:A(C({},h.description?{description:{type:"void","x-component":Jo,"x-component-props":{label:N("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
|
|
444
500
|
.ant-select.auto-width {
|
|
445
501
|
width: auto;
|
|
446
502
|
min-width: 6em;
|
|
447
503
|
}
|
|
448
|
-
`},properties:S},actions:C({},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
`),children:n.jsx(Xe,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(h.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function $t(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function It(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{It(e.properties[o],t)})}function Ce(e){return`/admin/workflow/workflows/${e}`}function Re(e){return`/admin/workflow/executions/${e}`}function wn(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Cn(){const{instructions:e}=l.usePlugin(ue),t=l.useCompile(),{viewJob:o,setViewJob:r}=H(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},i=e.get(a.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:r},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(h.Tag,{children:t(i==null?void 0:i.title)}),n.jsx("strong",{children:a.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:xt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function kn(e){const{execution:t}=H(),o=l.useAPIClient(),r=se.useNavigate(),{styles:s}=ne(),[a,i]=g.useState([]),[c,u]=g.useState([]);g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{i(m.data)}).catch(()=>{})},[t]),g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const d=g.useCallback(({key:m})=>{m!=t.id&&r(Re(m))},[t]);return t?n.jsx(h.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${m.id}`}),n.jsx("time",{children:X.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Me,{statusMap:Ye,status:m.status})})}))},children:n.jsxs(h.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(V.DownOutlined,{})]})}):null}function Sn(){var S;const{t:e}=q.useTranslation(),t=l.useCompile(),{data:o,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:a}=l.useDocumentTitle(),[i,c]=g.useState(null),u=l.useApp(),d=l.useAPIClient();g.useEffect(()=>{var D;const{workflow:M}=(D=o==null?void 0:o.data)!=null?D:{};a==null||a(`${M!=null&&M.title?`${M.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const m=g.useCallback(()=>{h.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{h.message.success(e("Operation succeeded")),s()}).catch(M=>{console.error(M.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return r?n.jsx(h.Spin,{}):n.jsx(h.Result,{status:"404",title:"Not found"});const E=(S=o==null?void 0:o.data)!=null?S:{},{jobs:y=[],workflow:L={}}=E,$=L,{nodes:x=[],revisions:b=[]}=$,f=Q($,["nodes","revisions"]),k=Q(E,["jobs","workflow"]);$t(x),wn(x,y);const F=x.find(M=>!M.upstream),B=Ye[k.status];return n.jsxs(Pe.Provider,{value:{workflow:f.type?f:null,nodes:x,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(h.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(h.Tooltip,{title:`Key: ${f.key}`,children:n.jsx(se.Link,{to:Ce(f.id),children:f.title})})},{title:n.jsx(kn,{})}]})}),n.jsxs("aside",{children:[n.jsx(h.Tag,{color:B.color,children:t(B.label)}),k.status?null:n.jsx(h.Tooltip,{title:O("Cancel the execution"),children:n.jsx(h.Button,{type:"link",danger:!0,onClick:m,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})}),n.jsx("time",{children:X.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(Xt,{entry:F}),n.jsx(Cn,{})]})}const Rt=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Sn}})})},eo=()=>{const{t:e}=q.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return n.jsx(se.Link,{to:Re(t),onClick:()=>o(!1),children:e("View")})},An={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return n.jsx(se.Link,{to:Ce(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:qe}}]},to={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:An,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=q.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return J(this,null,function*(){var i;yield r.destroy({filter:(i=o.params)==null?void 0:i.filter}),h.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:`{{ $deps[0] !== ${ae.STARTED} }}`}}}]}}}}}}}}}}};function oo(e){var a;const o=l.useCompile()(e.label),r=g.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(a=Ye[e.value])!=null?a:{};return n.jsx(h.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Fn(e){const t=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(oo,C({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Tn(t){var e=Q(t,[]);const o=e.multiple?"multiple":null;return n.jsx(h.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:oo,children:qe.filter(r=>!!r.value&&r.value!==ae.ABORTED).map(r=>n.jsx(h.Select.Option,A(C({},r),{children:n.jsx(Fn,C({},r))}),r.value))}))}function no(e){const{t}=q.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),a=g.useCallback(()=>{h.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{h.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
504
|
+
`},properties:S},actions:C({},o.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Bn}}}})})}}}})})})]})};function Vo(){const e=a.usePlugin(ae),{workflow:o}=H();return e.triggers.get(o.type)}function lt({entry:e}){const{styles:o}=ne(),{workflow:t}=H(),[r,s]=y.useState(100);return n.jsxs("div",{className:"workflow-canvas-wrapper",children:[n.jsx(tn,{FallbackComponent:a.ErrorFallback,onError:console.error,children:n.jsx(Mn,{children:n.jsx("div",{className:"workflow-canvas",style:{zoom:r/100},children:n.jsx("div",{className:a.cx(o.branchBlockClass,a.css`
|
|
505
|
+
margin-top: 0 !important;
|
|
506
|
+
`),children:n.jsxs("div",{className:o.branchClass,children:[t!=null&&t.executed?n.jsx(g.Alert,{type:"warning",message:N("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:a.css`
|
|
507
|
+
margin-bottom: 1em;
|
|
508
|
+
`}):null,n.jsx(Wn,{}),n.jsx("div",{className:a.cx(o.branchBlockClass,a.css`
|
|
509
|
+
margin-top: 0 !important;
|
|
510
|
+
`),children:n.jsx(oo,{entry:e})}),n.jsx("div",{className:o.terminalClass,children:N("End")})]})})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(g.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function Ln(e,o=[]){const t=new Map;e.forEach(r=>{r.jobs=[],t.set(r.id,r)}),o.forEach(r=>{const s=t.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,l)=>s.id-l.id)})}function zn(){const{instructions:e}=a.usePlugin(ae),o=a.useCompile(),{viewJob:t,setViewJob:r}=H(),{styles:s}=ne(),{node:l={}}=t!=null?t:{},i=e.get(l.type);return n.jsx(a.ActionContextProvider,{value:{visible:!!t,setVisible:r},children:n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-${t==null?void 0:t.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(g.Tag,{children:o(i==null?void 0:i.title)}),n.jsx("strong",{children:l.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",l.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:So,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function Jn(e){const{execution:o}=H(),t=a.useAPIClient(),r=se.useNavigate(),{styles:s}=ne(),[l,i]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{o&&t.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{i(m.data)}).catch(()=>{})},[o]),y.useEffect(()=>{o&&t.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[o]);const d=y.useCallback(({key:m})=>{m!=o.id&&r(qe(m))},[o]);return o?n.jsx(g.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${o.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...l].map(m=>({key:m.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${m.id}`}),n.jsx("time",{children:X.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Be,{statusMap:_e,status:m.status})})}))},children:n.jsxs(g.Space,{children:[n.jsx("strong",{children:`#${o.id}`}),n.jsx(V.DownOutlined,{})]})}):null}function Un(){var S;const{t:e}=Y.useTranslation(),o=a.useCompile(),{data:t,loading:r,refresh:s}=a.useResourceActionContext(),{setTitle:l}=a.useDocumentTitle(),[i,c]=y.useState(null),u=a.useApp(),d=a.useAPIClient();y.useEffect(()=>{var $;const{workflow:I}=($=t==null?void 0:t.data)!=null?$:{};l==null||l(`${I!=null&&I.title?`${I.title} - `:""}${N("Execution history")}`)},[t==null?void 0:t.data]);const m=y.useCallback(()=>{g.Modal.confirm({title:N("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:t==null?void 0:t.data.id}).then(()=>{g.message.success(e("Operation succeeded")),s()}).catch(I=>{console.error(I.data.error)})}})},[t==null?void 0:t.data]);if(!(t!=null&&t.data))return r?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found"});const E=(S=t==null?void 0:t.data)!=null?S:{},{jobs:h=[],workflow:L={}}=E,D=L,{nodes:x=[],revisions:b=[]}=D,f=Q(D,["nodes","revisions"]),k=Q(E,["jobs","workflow"]);wo(x),Ln(x,h);const F=x.find(I=>!I.upstream),M=_e[k.status];return n.jsxs(Pe.Provider,{value:{workflow:f.type?f:null,nodes:x,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx(se.Link,{to:Ce(f.id),children:f.title})})},{title:n.jsx(Jn,{})}]})}),n.jsxs("aside",{children:[n.jsx(g.Tag,{color:M.color,children:o(M.label)}),k.status?null:n.jsx(g.Tooltip,{title:N("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:m,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})}),n.jsx("time",{children:X.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(lt,{entry:F}),n.jsx(zn,{})]})}const at=()=>{const e=se.useParams(),{styles:o}=ne();return n.jsx("div",{className:a.cx(o.workflowPageClass),children:n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Un}})})},it=()=>{const{t:e}=Y.useTranslation(),{id:o}=a.useRecord(),{setVisible:t}=a.useActionContext();return n.jsx(se.Link,{to:qe(o),onClick:()=>t(!1),children:e("View")})},Hn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:o}=a.useActionContext();return n.jsx(se.Link,{to:Ce(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Ye}}]},ct={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Hn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Y.useTranslation(),{refresh:o,defaultRequest:t}=a.useResourceActionContext(),{resource:r}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return J(this,null,function*(){var i;yield r.destroy({filter:(i=t.params)==null?void 0:i.filter}),g.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:`{{ $deps[0] !== ${ie.STARTED} }}`}}}]}}}}}}}}}}};function dt(e){var l;const t=a.useCompile()(e.label),r=y.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(l=_e[e.value])!=null?l:{};return n.jsx(g.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:t})}function Gn(e){const o=a.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(dt,C({},e)),e.description?n.jsx("span",{children:o(e.description)}):null]})}function qn(o){var e=Q(o,[]);const t=e.multiple?"multiple":null;return n.jsx(g.Select,A(C({role:"button","data-testid":`select-${t||"single"}`},e),{mode:t,optionLabelProp:"label",tagRender:dt,children:Ye.filter(r=>!!r.value&&r.value!==ie.ABORTED).map(r=>n.jsx(g.Select.Option,A(C({},r),{children:n.jsx(Gn,C({},r))}),r.value))}))}function ut(e){const{t:o}=Y.useTranslation(),{refresh:t}=a.useResourceActionContext(),{resource:r}=a.useResourceContext(),s=a.useRecord(),l=y.useCallback(()=>{g.Modal.confirm({title:N("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{g.message.success(o("Operation succeeded")),t()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:a.css`
|
|
455
511
|
display: flex;
|
|
456
|
-
`,children:[e.children,s.status?null:n.jsx(h.Tooltip,{title:O("Cancel the execution"),children:n.jsx(h.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function ro(){const e=l.useResourceActionContext();return{onClick(){return J(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function On(r){var s=r,{request:e,filter:t={}}=s,o=Q(s,["request","filter"]);var c;const{workflow:a}=H(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function Nn(){var M;const e=se.useNavigate(),{t}=q.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[u,d]=g.useState(!1),{styles:m}=ne(),{modal:y}=h.App.useApp();if(g.useEffect(()=>{var I;const{title:N}=(I=r==null?void 0:r.data)!=null?I:{};c==null||c(`${O("Workflow")}${N?`: ${N}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(h.Spin,{}):n.jsx(h.Result,{status:"404",title:"Not found",extra:n.jsx(h.Button,{onClick:()=>e(-1),children:O("Go back")})});const D=(M=r==null?void 0:r.data)!=null?M:{},{nodes:x=[],revisions:b=[]}=D,f=Q(D,["nodes","revisions"]);$t(x);const k=x.find(N=>!N.upstream);function F({key:N}){N!=f.id&&e(Ce(N))}function B(N){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:N}}),s()})}function S(){return J(this,null,function*(){const{data:{data:N}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});h.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function E(){return J(this,null,function*(){const N=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";y.confirm({title:t("Are you sure you want to delete it?"),content:N,onOk(){return J(this,null,function*(){var U;yield i.destroy({filterByTk:f.id}),h.message.success(t("Operation succeeded")),e(f.current?o.pluginSettingsManager.getRoutePath("workflow"):Ce((U=b.find(K=>K.current))==null?void 0:U.id))})}})})}function L(I){return J(this,arguments,function*({key:N}){switch(N){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const $=f.executed&&!b.find(N=>!N.executed&&new Date(N.createdAt)>new Date(f.createdAt));return n.jsxs(Pe.Provider,{value:{workflow:f,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(h.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(h.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(h.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(h.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(h.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:l.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((N,I)=>I.id-N.id).map((N,I)=>({role:"button","aria-label":`version-${I}`,key:`${N.id}`,icon:N.current?n.jsx(V.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${N.id}`}),n.jsx("time",{children:X.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(h.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(h.Switch,{checked:f.enabled,onChange:B,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(h.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!$},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:L},children:n.jsx(h.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:u,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:to,components:{ExecutionResourceProvider:On,ExecutionLink:eo,ExecutionStatusColumn:no},scope:{useRefreshActionProps:ro}})})]})]}),n.jsx(Xt,{entry:k})]})}const so=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Nn}})})},Dn=r=>{var s=r,{request:e,filter:t={}}=s,o=Q(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},En=()=>{const{t:e}=q.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(t),onClick:()=>o(!1),children:e("Configure")})};function $n(r){var s=r,{component:e="div",children:t}=s,o=Q(s,["component","children"]);const[a,i]=g.useState(!1),c=T.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[g.createElement(e,A(C({},o),{onClick(){i(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function In({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(h.Space,{direction:"vertical",children:[n.jsx(h.Tag,{color:o,children:s(t)}),n.jsx(h.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const lo={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:In,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"select",uiSchema:{title:`{{t("Mode", { ns: "${p}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Select",enum:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Pn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:lo,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:lo},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=q.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return J(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),h.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return g.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:to}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=q.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:i}),h.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Mn(e){const t=T.useField(),o=l.useRecord(),r=l.usePlugin(ue);return T.useFormEffects(s=>{ge.onFieldChange("type",a=>{let i=o.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),g.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(Ne,C({},e))}function Bn(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function Vn(){const e=g.useContext(l.SchemaComponentContext),{useTriggersOptions:t}=l.usePlugin(ue);return n.jsx(h.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:Pn,components:{WorkflowLink:En,ExecutionResourceProvider:Dn,ExecutionLink:eo,OpenDrawer:$n,ExecutionStatusSelect:Tn,SyncOptionSelect:Mn,ExecutionStatusColumn:no,Tooltip:h.Tooltip},scope:{useTriggersOptions:t,useWorkflowSyncAction:Bn,useRefreshActionProps:ro}})})})}function jn(r){var s=r,{collection:e,dataPath:t}=s,o=Q(s,["collection","dataPath"]);const{insert:a}=l.useSchemaInitializer(),{getTemplateSchemaByMode:i}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager_deprecated(),u=l.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[y,x]=l.parseCollectionName(e);d=c(x,y)}else d=e;function m(x){return J(this,arguments,function*({item:y}){const b=y.template?yield i(y):null,f={type:"void",name:oe.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:b||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};It(f,k=>{k["x-uid"]&&delete k["x-uid"]}),a(f)})}return n.jsx(l.SchemaInitializerItem,A(C({},o),{onClick:m,items:u}))}function je(e){var a;const t=l.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let r,s;if(typeof o=="string"){const i=l.parseCollectionName(o);r=i[0],s=i[1]}else s=o;return n.jsx(l.CollectionProvider_deprecated,{dataSource:r,collection:s,children:n.jsx(jn,C(C({},t),e))})}function Wn(){return!0}const Pt=T.observer(e=>{const d=e,{filter:t=Wn}=d,o=Q(d,["filter"]),r=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager_deprecated(),{values:a}=T.useForm(),[i,c]=l.parseCollectionName(a==null?void 0:a.collection),u=s(c,i);return n.jsx(h.Select,A(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(m=>{var y;return{label:r((y=m.uiSchema)==null?void 0:y.title),value:m.name}})}))},{displayName:"FieldsSelect"}),ce={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ao={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
512
|
+
`,children:[e.children,s.status?null:n.jsx(g.Tooltip,{title:N("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:l,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function pt(){const e=a.useResourceActionContext();return{onClick(){return J(this,null,function*(){var t;(t=e==null?void 0:e.refresh)==null||t.call(e)})}}}function Yn(r){var s=r,{request:e,filter:o={}}=s,t=Q(s,["request","filter"]);var c;const{workflow:l}=H(),i=A(C({},t),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return n.jsx(a.ResourceActionProvider,C({},i))}function _n(){var I;const e=se.useNavigate(),{t:o}=Y.useTranslation(),t=a.useApp(),{data:r,refresh:s,loading:l}=a.useResourceActionContext(),{resource:i}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=y.useState(!1),{styles:m}=ne(),{modal:h}=g.App.useApp();if(y.useEffect(()=>{var B;const{title:O}=(B=r==null?void 0:r.data)!=null?B:{};c==null||c(`${N("Workflow")}${O?`: ${O}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return l?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found",extra:n.jsx(g.Button,{onClick:()=>e(-1),children:N("Go back")})});const $=(I=r==null?void 0:r.data)!=null?I:{},{nodes:x=[],revisions:b=[]}=$,f=Q($,["nodes","revisions"]);wo(x);const k=x.find(O=>!O.upstream);function F({key:O}){O!=f.id&&e(Ce(O))}function M(O){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:O}}),s()})}function S(){return J(this,null,function*(){const{data:{data:O}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});g.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${O.id}`)})}function E(){return J(this,null,function*(){const O=f.current?N("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:o("Are you sure you want to delete it?"),content:O,onOk(){return J(this,null,function*(){var G;yield i.destroy({filterByTk:f.id}),g.message.success(o("Operation succeeded")),e(f.current?t.pluginSettingsManager.getRoutePath("workflow"):Ce((G=b.find(U=>U.current))==null?void 0:G.id))})}})})}function L(B){return J(this,arguments,function*({key:O}){switch(O){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const D=f.executed&&!b.find(O=>!O.executed&&new Date(O.createdAt)>new Date(f.createdAt));return n.jsxs(Pe.Provider,{value:{workflow:f,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:t.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(g.Tag,{color:"orange",children:N("Synchronously")}):n.jsx(g.Tag,{color:"cyan",children:N("Asynchronously")}),n.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:a.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((O,B)=>B.id-O.id).map((O,B)=>({role:"button","aria-label":`version-${B}`,key:`${O.id}`,icon:O.current?n.jsx(V.RightOutlined,{}):null,className:a.cx({executed:O.executed,unexecuted:!O.executed,enabled:O.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${O.id}`}),n.jsx("time",{children:X.str2moment(O.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(g.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:N("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(g.Switch,{checked:f.enabled,onChange:M,checkedChildren:N("On"),unCheckedChildren:N("Off")}),n.jsx(g.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!D},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:o("Delete")}],onClick:L},children:n.jsx(g.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:n.jsx(a.SchemaComponent,{schema:ct,components:{ExecutionResourceProvider:Yn,ExecutionLink:it,ExecutionStatusColumn:ut},scope:{useRefreshActionProps:pt}})})]})]}),n.jsx(lt,{entry:k})]})}const mt=()=>{const e=se.useParams(),{styles:o}=ne();return n.jsx("div",{className:a.cx(o.workflowPageClass),children:n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:_n}})})},Kn=r=>{var s=r,{request:e,filter:o={}}=s,t=Q(s,["request","filter"]);var c;const l=a.useRecord(),i=A(C({},t),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return n.jsx(a.ResourceActionProvider,C({},i))},Zn=()=>{const{t:e}=Y.useTranslation(),{id:o}=a.useRecord(),{setVisible:t}=a.useActionContext(),{getAriaLabel:r}=a.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(o),onClick:()=>t(!1),children:e("Configure")})};function Qn(r){var s=r,{component:e="div",children:o}=s,t=Q(s,["component","children"]);const[l,i]=y.useState(!1),c=T.useFieldSchema();return n.jsxs(a.ActionContextProvider,{value:{visible:l,setVisible:i,fieldSchema:c},children:[y.createElement(e,A(C({},t),{onClick(){i(!0)}}),o),n.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Xn({data:e}){const{label:o,color:t,options:r}=e,s=a.useCompile();return n.jsxs(g.Space,{direction:"vertical",children:[n.jsx(g.Tag,{color:t,children:s(o)}),n.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const ft={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:Xn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"select",uiSchema:{title:`{{t("Mode", { ns: "${p}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Select",enum:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Rn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:ft,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:ft},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Y.useTranslation(),{resource:o}=a.useResourceContext(),t=a.useResourceActionContext();return{run(){return J(this,null,function*(){yield o.sync(),yield t==null?void 0:t.refresh(),g.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:he.title,type:he.type,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(o){const t=a.useRecord();return y.createElement("a",C({"aria-label":`executed-${t.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:ct}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:he.title,enabled:he.enabled,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Y.useTranslation(),{refresh:o}=a.useResourceActionContext(),{resource:t,targetKey:r}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[r]:l}=a.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield t.revision({filterByTk:l,values:i}),g.message.success(e("Operation succeeded")),o(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function er(e){const o=T.useField(),t=a.useRecord(),r=a.usePlugin(ae);return T.useFormEffects(s=>{fe.onFieldChange("type",l=>{let i=t.id||!l.value;if(l.value){const c=r.triggers.get(l.value);c.sync!=null?(i=!0,o.setValue(c.sync)):o.setInitialValue(!1)}o.setPattern(i?"disabled":"editable")})}),y.useEffect(()=>{if(t.id){o.setPattern("disabled");const s=r.triggers.get(t.type);s.sync!=null?o.setValue(s.sync):o.setInitialValue(!1)}},[t.id,o,r.triggers]),n.jsx(ke,C({},e))}function or(e){const o=a.useApp();e.visible=!!(a.usePlugin("multi-app-share-collection")||o.name!=="main")}function tr(){const e=y.useContext(a.SchemaComponentContext),{useTriggersOptions:o}=a.usePlugin(ae);return n.jsx(g.Card,{bordered:!1,children:n.jsx(a.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(a.SchemaComponent,{schema:Rn,components:{WorkflowLink:Zn,ExecutionResourceProvider:Kn,ExecutionLink:it,OpenDrawer:Qn,ExecutionStatusSelect:qn,SyncOptionSelect:er,ExecutionStatusColumn:ut,Tooltip:g.Tooltip},scope:{useTriggersOptions:o,useWorkflowSyncAction:or,useRefreshActionProps:pt}})})})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ht={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
|
|
457
513
|
flex-direction: column;
|
|
458
|
-
`},"x-component":"CollectionFieldset"},
|
|
514
|
+
`},"x-component":"CollectionFieldset"},to={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=T.useForm(),[o,t]=a.parseCollectionName(e==null?void 0:e.collection);return{options:a.useCollectionFilterOptions(t,o),className:a.css`
|
|
459
515
|
position: relative;
|
|
460
516
|
width: 100%;
|
|
461
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},
|
|
517
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},nr={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},rr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1},default:20}}}}}}},We={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=T.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};function sr(){const e=a.useAPIClient(),o=T.useForm(),{field:t,__parent:r}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),l=se.useNavigate(),i=T.useFieldSchema(),c=T.useField(),u=a.useCompile(),{modal:d}=g.App.useApp(),m=a.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var M,S,E;const{onSuccess:b,skipValidator:f,triggerWorkflows:k}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};f||(yield o.submit());const F=yield m();c.data=t.data||{},c.data.loading=!0;try{const L=yield e.resource("workflows").trigger({values:F,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(D=>[D.workflowKey,D.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=L,(E=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||E.call(S),s==null||s(!1),!(b!=null&&b.successMessage))return;b!=null&&b.manualClose?d.success({title:u(b==null?void 0:b.successMessage),onOk:()=>J(this,null,function*(){yield o.reset(),b!=null&&b.redirecting&&(b!=null&&b.redirectTo)&&(X.isURL(b.redirectTo)?window.location.href=b.redirectTo:l(b.redirectTo))})}):g.message.success(u(b==null?void 0:b.successMessage))}catch(L){c.data.loading=!1}})}}}function lr(){var b;const e=a.useCompile(),o=a.useAPIClient(),t=a.useRecord(),r=T.useField(),s=T.useFieldSchema(),{field:l,__parent:i}=a.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=a.useActionContext(),{modal:d}=g.App.useApp(),m=se.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(b=s==null?void 0:s["x-action-settings"])!=null?b:{};return{onClick(k,F){return J(this,null,function*(){r.data=l.data||{},r.data.loading=!0;try{if(yield o.resource("workflows").trigger({values:t,triggerWorkflows:x!=null&&x.length?x.map(M=>[M.workflowKey,M.context].filter(Boolean).join("!")).join(","):void 0}),F&&F(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let M;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return J(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(X.isURL(h.redirectTo)?window.location.href=h.redirectTo:m(h.redirectTo))})}})}else g.message.success(e(h==null?void 0:h.successMessage))}catch(M){console.error(M)}finally{r.data.loading=!1}})}}}function ar(){const{workflow:e}=H();return!!(e!=null&&e.executed)}function yt(){const{workflow:e}=H();return!!(e!=null&&e.allExecuted)}const Se={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ir=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Se.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Se.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Se.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Se.DELETED}];function cr(e,o){var u;const[t,r]=a.parseCollectionName(e.collection),s=a.useCompile(),l=je(t),i=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:N("Trigger data")}}];return Ne(A(C({appends:["data",...((u=e.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},o),{fields:i,compile:s,getCollectionFields:l}))}class dr extends Bo{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:ir,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Se.UPDATED})}}`}}}]},condition:A(C({},to),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && !($deps[1] & ${Se.DELETED})}}`}}}]}),appends:A(C({},We),{"x-reactions":[...We["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Se.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useWorkflowAnyExecuted:yt});w(this,"components",{FieldsSelect:ko});w(this,"useVariables",cr)}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:t.collection,dataPath:"$context.data"}:null}}const Ae={STATIC:0,DATE_FIELD:1};function ur(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function gt({value:e,onChange:o}){const t=e!=null?e:{},{t:r}=Y.useTranslation(),[s,l]=y.useState(t.offset?t.offset/Math.abs(t.offset):0);return n.jsxs("fieldset",{className:a.css`
|
|
462
518
|
display: flex;
|
|
463
519
|
gap: 0.5em;
|
|
464
|
-
`,children:[n.jsx(
|
|
520
|
+
`,children:[n.jsx(ko,{value:t.field,onChange:i=>o(A(C({},t),{field:i})),filter:ur,placeholder:r("Select field"),className:"auto-width"}),t.field?n.jsx(g.Select,{value:s,onChange:i=>{l(i),o(A(C({},t),{offset:Math.abs(t.offset)*i}))},options:[{value:0,label:N("Exactly at")},{value:-1,label:r("Before")},{value:1,label:r("After")}],className:"auto-width"}):null,s?n.jsxs(n.Fragment,{children:[n.jsx(g.InputNumber,{value:Math.abs(t.offset),onChange:i=>o(A(C({},t),{offset:(i!=null?i:0)*s}))}),n.jsx(g.Select,{value:t.unit||864e5,onChange:i=>o(A(C({},t),{unit:i})),options:[{value:864e5,label:N("Days")},{value:36e5,label:N("Hours")},{value:6e4,label:N("Minutes")},{value:1e3,label:N("Seconds")}],className:"auto-width"})]}):null]})}function pr({value:e,onChange:o}){const{t}=xo(),r=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return n.jsxs("fieldset",{className:a.css`
|
|
465
521
|
display: flex;
|
|
466
522
|
gap: 0.5em;
|
|
467
|
-
`,children:[n.jsxs(h.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(h.Select.Option,{value:null,children:o("No end")}),n.jsx(h.Select.Option,{value:"field",children:o("By field")}),n.jsx(h.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(co,{value:e,onChange:t}):null,r==="date"?n.jsx(h.DatePicker,{showTime:!0,value:Qo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function uo(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function tt(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var Zn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ae=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],j={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function po(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function ot(e){return e.sort(function(t,o){return t-o}),e}function mo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function de(e){return Object.entries(e).filter(function(t){var o=t[0],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function fo(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||j.errorInvalidCron})}function nt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function ho(e,t,o,r,s,a,i,c,u,d,m,y,x,b){o&&o(void 0),t(!1);var f=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;f=!0}if(!f){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void b("reboot");var k=Zn.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var E=S.replace(/\s+/g," ").trim().split(" ");if(E.length===5)return E.map(function(L,$){return function(M,D){if(M==="*"||M==="*/1")return[];var N=ot(mo(vo(function(U,K,pe){if(pe){U=U.toUpperCase();for(var P=0;P<pe.length;P++)U=U.replace(pe[P],"".concat(P+K))}return U}(M,D.min,D.alt).split(",").map(function(U){var K,pe=U.split("/");if(pe.length>2)throw new Error('Invalid value "'.concat(M,' for "').concat(D.type,'"'));var P=pe[0],W=pe[1];K=P==="*"?po(D.min,D.max):function(G,_,R){var ee=G.split("-");if(ee.length===1){var ze=nt(ee[0]);if(isNaN(ze))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[ze]}if(ee.length===2){var he=nt(ee[0]),Ee=nt(ee[1]);if(isNaN(he)||isNaN(Ee))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if(Ee<he)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return po(he,Ee)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}(P,M,D);var z=function(G,_){if(G!==void 0){var R=nt(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(_.type));return R}}(W,D),le=function(G,_){if(_){var R=G[0];G=G.filter(function(ee){return ee%_==R%_||ee===R})}return G}(K,z);return le}).flat(),D))),I=xo(N,D);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(D.type));return N.length===D.total?[]:N}(L,Ae[$])});throw new Error("Invalid cron string format")}(e),B=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);b(B),u(F[0]),d(F[1]),m(F[2]),y(F[3]),x(F[4])}catch(S){f=!0}}f&&(s.current=e,t(!0),fo(o,i))}function yo(e,t,o,r,s,a,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(m,y){var x=Ae[y];return go(bo(m,x),x,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!r?[]:r],i);return c.join(" ")}function go(e,t,o,r,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=i&&function(c,u){for(var d=1;d<c.length;d++){var m=c[d-1];if(c[d]-m!==u)return!1}return!0}(e,i)?function(c,u,d){var m=wo(c),y=Co(c),x=c.length===(y-m)/d+1;return!!(m===u.min&&y+d>u.max&&x)}(e,t,i)?"*/".concat(i):"".concat(Oe(wo(e),t,o,r,s),"-").concat(Oe(Co(e),t,o,r,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(m,y,x){m!==x[y+1]-1?d!==null?(u.push([d,m]),d=null):u.push(m):d===null&&(d=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,r,s),"-").concat(Oe(c[1],t,o,r,s)):Oe(c,t,o,r,s)}).join(",")}return a}function Oe(e,t,o,r,s){var a=e.toString(),i=t.type,c=t.alt,u=t.min,d=r&&(r===!0||r.includes(i)),m=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?a=c[e-u]:e<10&&(d||m)&&(a=a.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var y=e>=12?"PM":"AM",x=e%12||12;x<10&&d&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(y)}return a}function bo(e,t){var o=ot(mo(vo(e,t)));if(o.length===0)return o;var r=xo(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function vo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function xo(e,t){var o=e[0],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function wo(e){return e[0]}function Co(e){return e[e.length-1]}function Le(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,m=e.readOnly,y=e.leadingZero,x=e.clockFormat,b=e.period,f=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,B=uo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=g.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(P){return P.toString()})},[t]),E=g.useMemo(function(){return s?s.map(function(P,W){return{value:(f.min===0?W:W+1).toString(),label:P}}):tt([],Array(f.total),!0).map(function(P,W){var z=f.min===0?W:W+1;return{value:z.toString(),label:Oe(z,f,u,y,x)}})},[s,y,u,x]),L=JSON.stringify(i),$=g.useCallback(function(P){var W=P.value;if(!t||t[0]!==Number(W))return n.jsx(n.Fragment,{});var z=go(bo(t,f),f,u,y,x),le=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:le[1]?"".concat(i.everyText||j.everyText," ").concat(le[1]):z})},[t,L,u,y,x]),M=g.useCallback(function(P){var W=Array.isArray(P)?ot(P):[P],z=W;t&&(z=F==="single"?[]:tt([],t,!0),W.forEach(function(le){var G=Number(le);z=t.some(function(_){return _===G})?z.filter(function(_){return _!==G}):ot(tt(tt([],z,!0),[G],!1))})),z.length===f.total?a([]):a(z)},[a,t]),D=g.useCallback(function(P){if(P!==0&&P!==1){for(var W=f.total+f.min,z=[],le=f.min;le<W;le++)le%P==0&&z.push(le);var G=t&&z&&t.length===z.length&&t.every(function(R,ee){return R===z[ee]}),_=z.length===E.length;a(_||G?[]:z)}else a([])},[t,E,a]),N=g.useRef([]),I=g.useCallback(function(P){if(!m){var W=N.current;W.push({time:new Date().getTime(),value:Number(P)});var z=window.setTimeout(function(){k&&W.length>1&&W[W.length-1].time-W[W.length-2].time<300?W[W.length-1].value===W[W.length-2].value?D(Number(P)):M([W[W.length-2].value,W[W.length-1].value]):M(Number(P)),N.current=[]},300);return function(){window.clearTimeout(z)}}},[N,M,D,m,k]),U=g.useCallback(function(){m||a([])},[a,m]),K=g.useMemo(function(){var P;return de(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),pe=g.useMemo(function(){var P;return de(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=f.type==="minutes"&&b!=="hour"&&b!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=f.type==="minutes"&&(b==="day"||b==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=f.type==="hours"&&x==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(f.type)]=!!c,P))},[c,r,x,b]);return n.jsx(h.Select,re({mode:F!=="single"||k?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:U,tagRender:$,className:K,popupClassName:pe,options:E,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:f.type!=="minutes"&&f.type!=="hours"||b==="day"||b==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(f.type)},B))}function Qn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,y=e.mode,x=g.useMemo(function(){var b;return de(((b={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-hours")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||j.prefixHours}),n.jsx(Le,{placeholder:r.emptyHours||j.emptyHours,value:t,unit:Ae[1],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:y})]}))}function Xn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,y=e.mode,x=g.useMemo(function(){var b;return de(((b={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-minutes")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||j.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||j.prefixMinutes}),n.jsx(Le,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||j.emptyMinutesForHourPeriod:r.emptyMinutes||j.emptyMinutes,value:t,unit:Ae[0],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:y}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||j.suffixMinutesForHourPeriod})]}))}function Rn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,m=e.periodicityOnDoubleClick,y=e.mode,x=!a||a.length===0,b=g.useMemo(function(){var F;return de(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,x]),f=JSON.stringify(r),k=g.useMemo(function(){return x?r.emptyMonthDays||j.emptyMonthDays:r.emptyMonthDaysShort||j.emptyMonthDaysShort},[x,f]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",re({className:b},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||j.prefixMonthDays}),n.jsx(Le,{placeholder:k,value:t,setValue:o,unit:Ae[2],locale:r,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:m,mode:y})]})):null}function er(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,m=e.mode,y=r.months||j.months,x=g.useMemo(function(){var b;return de(((b={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-months")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||j.prefixMonths}),n.jsx(Le,{placeholder:r.emptyMonths||j.emptyMonths,optionsList:y,grid:!1,value:t,unit:re(re({},Ae[3]),{alt:r.altMonths||j.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:m})]}))}function tr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:r.yearOption||j.yearOption}),u.includes("month")&&d.push({value:"month",label:r.monthOption||j.monthOption}),u.includes("week")&&d.push({value:"week",label:r.weekOption||j.weekOption}),u.includes("day")&&d.push({value:"day",label:r.dayOption||j.dayOption}),u.includes("hour")&&d.push({value:"hour",label:r.hourOption||j.hourOption}),u.includes("minute")&&d.push({value:"minute",label:r.minuteOption||j.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||j.rebootOption});var m=g.useCallback(function(f){i||o(f)},[o,i]),y=g.useMemo(function(){var f;return de(((f={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-period")]=!!s,f))},[s]),x=g.useMemo(function(){var f;return de(((f={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,f))},[s,r.prefixPeriod]),b=g.useMemo(function(){var f;return de(((f={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,f["".concat(s,"-select-dropdown-period")]=!!s,f))},[s]);return n.jsxs("div",re({className:y},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||j.prefixPeriod}),n.jsx(h.Select,{defaultValue:t,value:t,onChange:m,options:d,className:x,popupClassName:b,disabled:a,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function or(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,m=e.periodicityOnDoubleClick,y=e.mode,x=r.weekDays||j.weekDays,b=d==="week"||!i||i.length===0,f=g.useMemo(function(){var E;return de(((E={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!b})["".concat(s,"-field")]=!!s,E["".concat(s,"-week-days")]=!!s,E))},[s,b]),k=JSON.stringify(r),F=g.useMemo(function(){return b?r.emptyWeekDays||j.emptyWeekDays:r.emptyWeekDaysShort||j.emptyWeekDaysShort},[b,k]),B=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),S=!u||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return B?n.jsxs("div",re({className:f},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||j.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||j.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(Le,{placeholder:F,optionsList:x,grid:!1,value:t,unit:re(re({},Ae[4]),{alt:r.altWeekDays||j.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:m,mode:y})]})):null}function nr(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,i=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?j:c,d=e.value,m=d===void 0?"":d,y=e.setValue,x=e.displayError,b=x===void 0||x,f=e.onError,k=e.className,F=e.defaultPeriod,B=F===void 0?"day":F,S=e.allowEmpty,E=S===void 0?"for-default-value":S,L=e.humanizeLabels,$=L===void 0||L,M=e.humanizeValue,D=M!==void 0&&M,N=e.disabled,I=N!==void 0&&N,U=e.readOnly,K=U!==void 0&&U,pe=e.leadingZero,P=pe!==void 0&&pe,W=e.shortcuts,z=W===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:W,le=e.clockFormat,G=e.periodicityOnDoubleClick,_=G===void 0||G,R=e.mode,ee=R===void 0?"multiple":R,ze=e.allowedDropdowns,he=ze===void 0?["period","months","month-days","week-days","hours","minutes"]:ze,Ee=e.allowedPeriods,Ir=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,$e=g.useRef(m),Bt=g.useRef(B),Po=g.useState(),xe=Po[0],st=Po[1],Mo=g.useState(),Je=Mo[0],lt=Mo[1],Bo=g.useState(),at=Bo[0],it=Bo[1],Vo=g.useState(),Ue=Vo[0],ct=Vo[1],jo=g.useState(),dt=jo[0],ut=jo[1],Wo=g.useState(),pt=Wo[0],mt=Wo[1],Lo=g.useState(!1),Vt=Lo[0],He=Lo[1],zo=g.useState(!1),ft=zo[0],Jo=zo[1],Pr=function(Z){var ye=g.useRef(Z);return g.useEffect(function(){ye.current=Z},[Z]),ye.current}(ft),Uo=JSON.stringify(u);g.useEffect(function(){ho(m,He,f,E,$e,!0,u,z,mt,ut,lt,it,ct,st)},[]),g.useEffect(function(){m!==$e.current&&ho(m,He,f,E,$e,!1,u,z,mt,ut,lt,it,ct,st)},[m,$e,Uo,E,z]),g.useEffect(function(){if(!(xe||pt||at||Je||Ue||dt)||ft||Pr)ft&&Jo(!1);else{var Z=xe||Bt.current,ye=yo(Z,at,Je,Ue,dt,pt,D);y(ye,{selectedPeriod:Z}),$e.current=ye,f&&f(void 0),He(!1)}},[xe,Je,at,Ue,dt,pt,D,ft]);var Ho=g.useCallback(function(){lt(void 0),it(void 0),ct(void 0),ut(void 0),mt(void 0);var Z="",ye=xe!=="reboot"&&xe?xe:Bt.current;ye!==xe&&st(ye),i==="fill-with-every"&&(Z=yo(ye,void 0,void 0,void 0,void 0,void 0)),y(Z,{selectedPeriod:ye}),$e.current=Z,Jo(!0),E==="never"&&i==="empty"?(He(!0),fo(f,u)):(f&&f(void 0),He(!1))},[xe,y,f,i]),Mr=g.useMemo(function(){var Z;return de(((Z={"react-js-cron":!0,"react-js-cron-error":Vt&&b,"react-js-cron-disabled":I,"react-js-cron-read-only":K})["".concat(k)]=!!k,Z["".concat(k,"-error")]=Vt&&b&&!!k,Z["".concat(k,"-disabled")]=I&&!!k,Z["".concat(k,"-read-only")]=K&&!!k,Z))},[k,Vt,b,I,K]),jt=s.className,Go=uo(s,["className"]),qo=g.useMemo(function(){var Z;return de(((Z={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,Z["".concat(jt)]=!!jt,Z))},[k,jt]),Br=JSON.stringify(Go),Yo=g.useMemo(function(){return o&&!K?n.jsx(h.Button,re({className:qo,danger:!0,type:"primary",disabled:I},Go,{onClick:Ho},{children:u.clearButtonText||j.clearButtonText})):null},[o,K,Uo,qo,I,Br,Ho]),te=xe||Bt.current;return n.jsxs("div",re({className:Mr},{children:[he.includes("period")&&n.jsx(tr,{value:te,setValue:st,locale:u,className:k,disabled:I,readOnly:K,shortcuts:z,allowedPeriods:Ir}),te==="reboot"?Yo:n.jsxs(n.Fragment,{children:[te==="year"&&he.includes("months")&&n.jsx(er,{value:at,setValue:it,locale:u,className:k,humanizeLabels:$,disabled:I,readOnly:K,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month")&&he.includes("month-days")&&n.jsx(Rn,{value:Je,setValue:lt,locale:u,className:k,weekDays:Ue,disabled:I,readOnly:K,leadingZero:P,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month"||te==="week")&&he.includes("week-days")&&n.jsx(or,{value:Ue,setValue:ct,locale:u,className:k,humanizeLabels:$,monthDays:Je,disabled:I,readOnly:K,period:te,periodicityOnDoubleClick:_,mode:ee}),n.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&he.includes("hours")&&n.jsx(Qn,{value:dt,setValue:ut,locale:u,className:k,disabled:I,readOnly:K,leadingZero:P,clockFormat:le,period:te,periodicityOnDoubleClick:_,mode:ee}),te!=="minute"&&he.includes("minutes")&&n.jsx(Xn,{value:pt,setValue:mt,locale:u,period:te,className:k,disabled:I,readOnly:K,leadingZero:P,clockFormat:le,periodicityOnDoubleClick:_,mode:ee}),Yo]})]})]}))}const ko=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function So(e){return ko.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function rr(e){let t;switch(typeof e){case"number":return t=So(e),t?t.value:"none";case"string":return"cron"}return"none"}function sr({value:e,onChange:t}){const{t:o}=bt(),r=So(e);return n.jsx(h.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function lr({value:e=null,onChange:t}){const{t:o}=bt(),r=rr(e),s=g.useCallback(a=>{if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)},[t]);return n.jsxs("fieldset",{className:l.css`
|
|
523
|
+
`,children:[n.jsxs(g.Select,{value:r,onChange:s=>{o(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(g.Select.Option,{value:null,children:t("No end")}),n.jsx(g.Select.Option,{value:"field",children:t("By field")}),n.jsx(g.Select.Option,{value:"date",children:t("By custom date")})]}),r==="field"?n.jsx(gt,{value:e,onChange:o}):null,r==="date"?n.jsx(g.DatePicker,{showTime:!0,value:en(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var o,t=1,r=arguments.length;t<r;t++)for(var s in o=arguments[t])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},re.apply(this,arguments)};function bt(e,o){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)o.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(t[r[s]]=e[r[s]])}return t}function no(e,o,t){if(t||arguments.length===2)for(var r,s=0,l=o.length;s<l;s++)!r&&s in o||(r||(r=Array.prototype.slice.call(o,0,s)),r[s]=o[s]);return e.concat(r||Array.prototype.slice.call(o))}var mr=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Fe=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],j={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function vt(e,o){for(var t=[],r=e;r<=o;r++)t.push(r);return t}function ro(e){return e.sort(function(o,t){return o-t}),e}function xt(e){var o=[];return e.forEach(function(t){o.indexOf(t)<0&&o.push(t)}),o}function ue(e){return Object.entries(e).filter(function(o){var t=o[0],r=o[1];return t&&r}).map(function(o){return o[0]}).join(" ")}function wt(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||j.errorInvalidCron})}function so(e){var o=parseInt(e,10),t=Number(e);return o===t?t:NaN}function Ct(e,o,t,r,s,l,i,c,u,d,m,h,x,b){t&&t(void 0),o(!1);var f=!1;if(!e){if(r==="always"||l&&r==="for-default-value")return;f=!0}if(!f){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void b("reboot");var k=mr.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var E=S.replace(/\s+/g," ").trim().split(" ");if(E.length===5)return E.map(function(L,D){return function(I,$){if(I==="*"||I==="*/1")return[];var O=ro(xt(Ft(function(G,U,pe){if(pe){G=G.toUpperCase();for(var P=0;P<pe.length;P++)G=G.replace(pe[P],"".concat(P+U))}return G}(I,$.min,$.alt).split(",").map(function(G){var U,pe=G.split("/");if(pe.length>2)throw new Error('Invalid value "'.concat(I,' for "').concat($.type,'"'));var P=pe[0],W=pe[1];U=P==="*"?vt($.min,$.max):function(q,K,R){var ee=q.split("-");if(ee.length===1){var ze=so(ee[0]);if(isNaN(ze))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));return[ze]}if(ee.length===2){var ye=so(ee[0]),Ee=so(ee[1]);if(isNaN(ye)||isNaN(Ee))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));if(Ee<ye)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return vt(ye,Ee)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(P,I,$);var z=function(q,K){if(q!==void 0){var R=so(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(K.type));return R}}(W,$),le=function(q,K){if(K){var R=q[0];q=q.filter(function(ee){return ee%K==R%K||ee===R})}return q}(U,z);return le}).flat(),$))),B=Tt(O,$);if(B!==void 0)throw new Error('Value "'.concat(B,'" out of range for ').concat($.type));return O.length===$.total?[]:O}(L,Fe[D])});throw new Error("Invalid cron string format")}(e),M=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);b(M),u(F[0]),d(F[1]),m(F[2]),h(F[3]),x(F[4])}catch(S){f=!0}}f&&(s.current=e,o(!0),wt(t,i))}function kt(e,o,t,r,s,l,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(m,h){var x=Fe[h];return St(At(m,x),x,d)})}([e!=="minute"&&l?l:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!t?[]:t,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!r?[]:r],i);return c.join(" ")}function St(e,o,t,r,s){var l="";if(function(c,u){return c.length===u.max-u.min+1}(e,o)||e.length===0)l="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);l=i&&function(c,u){for(var d=1;d<c.length;d++){var m=c[d-1];if(c[d]-m!==u)return!1}return!0}(e,i)?function(c,u,d){var m=Nt(c),h=Ot(c),x=c.length===(h-m)/d+1;return!!(m===u.min&&h+d>u.max&&x)}(e,o,i)?"*/".concat(i):"".concat(De(Nt(e),o,t,r,s),"-").concat(De(Ot(e),o,t,r,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(m,h,x){m!==x[h+1]-1?d!==null?(u.push([d,m]),d=null):u.push(m):d===null&&(d=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(De(c[0],o,t,r,s),"-").concat(De(c[1],o,t,r,s)):De(c,o,t,r,s)}).join(",")}return l}function De(e,o,t,r,s){var l=e.toString(),i=o.type,c=o.alt,u=o.min,d=r&&(r===!0||r.includes(i)),m=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(t&&i==="week-days"||t&&i==="months"?l=c[e-u]:e<10&&(d||m)&&(l=l.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&d&&(x=x.toString().padStart(2,"0")),l="".concat(x).concat(h)}return l}function At(e,o){var t=ro(xt(Ft(e,o)));if(t.length===0)return t;var r=Tt(t,o);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(o.type));return t}function Ft(e,o){return o.type==="week-days"&&(e=e.map(function(t){return t===7?0:t})),e}function Tt(e,o){var t=e[0],r=e[e.length-1];return t<o.min?t:r>o.max?r:void 0}function Nt(e){return e[0]}function Ot(e){return e[e.length-1]}function Le(e){var o=e.value,t=e.grid,r=t===void 0||t,s=e.optionsList,l=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,m=e.readOnly,h=e.leadingZero,x=e.clockFormat,b=e.period,f=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,M=bt(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=y.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(P){return P.toString()})},[o]),E=y.useMemo(function(){return s?s.map(function(P,W){return{value:(f.min===0?W:W+1).toString(),label:P}}):no([],Array(f.total),!0).map(function(P,W){var z=f.min===0?W:W+1;return{value:z.toString(),label:De(z,f,u,h,x)}})},[s,h,u,x]),L=JSON.stringify(i),D=y.useCallback(function(P){var W=P.value;if(!o||o[0]!==Number(W))return n.jsx(n.Fragment,{});var z=St(At(o,f),f,u,h,x),le=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:le[1]?"".concat(i.everyText||j.everyText," ").concat(le[1]):z})},[o,L,u,h,x]),I=y.useCallback(function(P){var W=Array.isArray(P)?ro(P):[P],z=W;o&&(z=F==="single"?[]:no([],o,!0),W.forEach(function(le){var q=Number(le);z=o.some(function(K){return K===q})?z.filter(function(K){return K!==q}):ro(no(no([],z,!0),[q],!1))})),z.length===f.total?l([]):l(z)},[l,o]),$=y.useCallback(function(P){if(P!==0&&P!==1){for(var W=f.total+f.min,z=[],le=f.min;le<W;le++)le%P==0&&z.push(le);var q=o&&z&&o.length===z.length&&o.every(function(R,ee){return R===z[ee]}),K=z.length===E.length;l(K||q?[]:z)}else l([])},[o,E,l]),O=y.useRef([]),B=y.useCallback(function(P){if(!m){var W=O.current;W.push({time:new Date().getTime(),value:Number(P)});var z=window.setTimeout(function(){k&&W.length>1&&W[W.length-1].time-W[W.length-2].time<300?W[W.length-1].value===W[W.length-2].value?$(Number(P)):I([W[W.length-2].value,W[W.length-1].value]):I(Number(P)),O.current=[]},300);return function(){window.clearTimeout(z)}}},[O,I,$,m,k]),G=y.useCallback(function(){m||l([])},[l,m]),U=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),pe=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=f.type==="minutes"&&b!=="hour"&&b!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=f.type==="minutes"&&(b==="day"||b==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=f.type==="hours"&&x==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(f.type)]=!!c,P))},[c,r,x,b]);return n.jsx(g.Select,re({mode:F!=="single"||k?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:G,tagRender:D,className:U,popupClassName:pe,options:E,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:B,onDeselect:B,disabled:d,dropdownAlign:f.type!=="minutes"&&f.type!=="hours"||b==="day"||b==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(f.type)},M))}function fr(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-hours")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||j.prefixHours}),n.jsx(Le,{placeholder:r.emptyHours||j.emptyHours,value:o,unit:Fe[1],setValue:t,locale:r,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:h})]}))}function hr(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-minutes")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||j.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||j.prefixMinutes}),n.jsx(Le,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||j.emptyMinutesForHourPeriod:r.emptyMinutes||j.emptyMinutes,value:o,unit:Fe[0],setValue:t,locale:r,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:h}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||j.suffixMinutesForHourPeriod})]}))}function yr(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,x=!l||l.length===0,b=y.useMemo(function(){var F;return ue(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,x]),f=JSON.stringify(r),k=y.useMemo(function(){return x?r.emptyMonthDays||j.emptyMonthDays:r.emptyMonthDaysShort||j.emptyMonthDaysShort},[x,f]);return!c||o&&o.length>0||(!o||o.length===0)&&(!l||l.length===0)?n.jsxs("div",re({className:b},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||j.prefixMonthDays}),n.jsx(Le,{placeholder:k,value:o,setValue:t,unit:Fe[2],locale:r,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function gr(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,m=e.mode,h=r.months||j.months,x=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-months")]=!!s,b))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||j.prefixMonths}),n.jsx(Le,{placeholder:r.emptyMonths||j.emptyMonths,optionsList:h,grid:!1,value:o,unit:re(re({},Fe[3]),{alt:r.altMonths||j.altMonths}),setValue:t,locale:r,className:s,humanizeLabels:l,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:m})]}))}function br(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:r.yearOption||j.yearOption}),u.includes("month")&&d.push({value:"month",label:r.monthOption||j.monthOption}),u.includes("week")&&d.push({value:"week",label:r.weekOption||j.weekOption}),u.includes("day")&&d.push({value:"day",label:r.dayOption||j.dayOption}),u.includes("hour")&&d.push({value:"hour",label:r.hourOption||j.hourOption}),u.includes("minute")&&d.push({value:"minute",label:r.minuteOption||j.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||j.rebootOption});var m=y.useCallback(function(f){i||t(f)},[t,i]),h=y.useMemo(function(){var f;return ue(((f={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-period")]=!!s,f))},[s]),x=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,f))},[s,r.prefixPeriod]),b=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,f["".concat(s,"-select-dropdown-period")]=!!s,f))},[s]);return n.jsxs("div",re({className:h},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||j.prefixPeriod}),n.jsx(g.Select,{defaultValue:o,value:o,onChange:m,options:d,className:x,popupClassName:b,disabled:l,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function vr(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,l=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,x=r.weekDays||j.weekDays,b=d==="week"||!i||i.length===0,f=y.useMemo(function(){var E;return ue(((E={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!b})["".concat(s,"-field")]=!!s,E["".concat(s,"-week-days")]=!!s,E))},[s,b]),k=JSON.stringify(r),F=y.useMemo(function(){return b?r.emptyWeekDays||j.emptyWeekDays:r.emptyWeekDaysShort||j.emptyWeekDaysShort},[b,k]),M=d==="week"||!u||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0),S=!u||i&&i.length>0||(!i||i.length===0)&&(!o||o.length===0);return M?n.jsxs("div",re({className:f},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||j.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||j.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(Le,{placeholder:F,optionsList:x,grid:!1,value:o,unit:re(re({},Fe[4]),{alt:r.altWeekDays||j.altWeekDays}),setValue:t,locale:r,className:s,humanizeLabels:l,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function xr(e){var o=e.clearButton,t=o===void 0||o,r=e.clearButtonProps,s=r===void 0?{}:r,l=e.clearButtonAction,i=l===void 0?"fill-with-every":l,c=e.locale,u=c===void 0?j:c,d=e.value,m=d===void 0?"":d,h=e.setValue,x=e.displayError,b=x===void 0||x,f=e.onError,k=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,S=e.allowEmpty,E=S===void 0?"for-default-value":S,L=e.humanizeLabels,D=L===void 0||L,I=e.humanizeValue,$=I!==void 0&&I,O=e.disabled,B=O!==void 0&&O,G=e.readOnly,U=G!==void 0&&G,pe=e.leadingZero,P=pe!==void 0&&pe,W=e.shortcuts,z=W===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:W,le=e.clockFormat,q=e.periodicityOnDoubleClick,K=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,ze=e.allowedDropdowns,ye=ze===void 0?["period","months","month-days","week-days","hours","minutes"]:ze,Ee=e.allowedPeriods,zr=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,$e=y.useRef(m),jo=y.useRef(M),Vt=y.useState(),xe=Vt[0],lo=Vt[1],jt=y.useState(),Je=jt[0],ao=jt[1],Wt=y.useState(),io=Wt[0],co=Wt[1],Lt=y.useState(),Ue=Lt[0],uo=Lt[1],zt=y.useState(),po=zt[0],mo=zt[1],Jt=y.useState(),fo=Jt[0],ho=Jt[1],Ut=y.useState(!1),Wo=Ut[0],He=Ut[1],Ht=y.useState(!1),yo=Ht[0],Gt=Ht[1],Jr=function(Z){var ge=y.useRef(Z);return y.useEffect(function(){ge.current=Z},[Z]),ge.current}(yo),qt=JSON.stringify(u);y.useEffect(function(){Ct(m,He,f,E,$e,!0,u,z,ho,mo,ao,co,uo,lo)},[]),y.useEffect(function(){m!==$e.current&&Ct(m,He,f,E,$e,!1,u,z,ho,mo,ao,co,uo,lo)},[m,$e,qt,E,z]),y.useEffect(function(){if(!(xe||fo||io||Je||Ue||po)||yo||Jr)yo&&Gt(!1);else{var Z=xe||jo.current,ge=kt(Z,io,Je,Ue,po,fo,$);h(ge,{selectedPeriod:Z}),$e.current=ge,f&&f(void 0),He(!1)}},[xe,Je,io,Ue,po,fo,$,yo]);var Yt=y.useCallback(function(){ao(void 0),co(void 0),uo(void 0),mo(void 0),ho(void 0);var Z="",ge=xe!=="reboot"&&xe?xe:jo.current;ge!==xe&&lo(ge),i==="fill-with-every"&&(Z=kt(ge,void 0,void 0,void 0,void 0,void 0)),h(Z,{selectedPeriod:ge}),$e.current=Z,Gt(!0),E==="never"&&i==="empty"?(He(!0),wt(f,u)):(f&&f(void 0),He(!1))},[xe,h,f,i]),Ur=y.useMemo(function(){var Z;return ue(((Z={"react-js-cron":!0,"react-js-cron-error":Wo&&b,"react-js-cron-disabled":B,"react-js-cron-read-only":U})["".concat(k)]=!!k,Z["".concat(k,"-error")]=Wo&&b&&!!k,Z["".concat(k,"-disabled")]=B&&!!k,Z["".concat(k,"-read-only")]=U&&!!k,Z))},[k,Wo,b,B,U]),Lo=s.className,_t=bt(s,["className"]),Kt=y.useMemo(function(){var Z;return ue(((Z={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,Z["".concat(Lo)]=!!Lo,Z))},[k,Lo]),Hr=JSON.stringify(_t),Zt=y.useMemo(function(){return t&&!U?n.jsx(g.Button,re({className:Kt,danger:!0,type:"primary",disabled:B},_t,{onClick:Yt},{children:u.clearButtonText||j.clearButtonText})):null},[t,U,qt,Kt,B,Hr,Yt]),oe=xe||jo.current;return n.jsxs("div",re({className:Ur},{children:[ye.includes("period")&&n.jsx(br,{value:oe,setValue:lo,locale:u,className:k,disabled:B,readOnly:U,shortcuts:z,allowedPeriods:zr}),oe==="reboot"?Zt:n.jsxs(n.Fragment,{children:[oe==="year"&&ye.includes("months")&&n.jsx(gr,{value:io,setValue:co,locale:u,className:k,humanizeLabels:D,disabled:B,readOnly:U,period:oe,periodicityOnDoubleClick:K,mode:ee}),(oe==="year"||oe==="month")&&ye.includes("month-days")&&n.jsx(yr,{value:Je,setValue:ao,locale:u,className:k,weekDays:Ue,disabled:B,readOnly:U,leadingZero:P,period:oe,periodicityOnDoubleClick:K,mode:ee}),(oe==="year"||oe==="month"||oe==="week")&&ye.includes("week-days")&&n.jsx(vr,{value:Ue,setValue:uo,locale:u,className:k,humanizeLabels:D,monthDays:Je,disabled:B,readOnly:U,period:oe,periodicityOnDoubleClick:K,mode:ee}),n.jsxs("div",{children:[oe!=="minute"&&oe!=="hour"&&ye.includes("hours")&&n.jsx(fr,{value:po,setValue:mo,locale:u,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:le,period:oe,periodicityOnDoubleClick:K,mode:ee}),oe!=="minute"&&ye.includes("minutes")&&n.jsx(hr,{value:fo,setValue:ho,locale:u,period:oe,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:le,periodicityOnDoubleClick:K,mode:ee}),Zt]})]})]}))}const Dt=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function Et(e){return Dt.filter(t=>typeof t.value=="number").reverse().find(t=>!(e%t.value))}function wr(e){let o;switch(typeof e){case"number":return o=Et(e),o?o.value:"none";case"string":return"cron"}return"none"}function Cr({value:e,onChange:o}){const{t}=xo(),r=Et(e);return n.jsx(g.InputNumber,{value:e/r.value,onChange:s=>o(s*r.value),min:1,addonBefore:t("Every"),addonAfter:t(r.unitText),className:"auto-width"})}function kr({value:e=null,onChange:o}){const{t}=xo(),r=wr(e),s=y.useCallback(l=>{if(l==="none"){o(null);return}if(l==="cron"){o("0 * * * * *");return}o(l)},[o]);return n.jsxs("fieldset",{className:a.css`
|
|
468
524
|
display: flex;
|
|
469
525
|
flex-direction: ${r==="cron"?"column":"row"};
|
|
470
526
|
align-items: flex-start;
|
|
@@ -493,7 +549,7 @@
|
|
|
493
549
|
}
|
|
494
550
|
}
|
|
495
551
|
}
|
|
496
|
-
`,children:[n.jsx(
|
|
552
|
+
`,children:[n.jsx(g.Select,{value:r,onChange:s,className:"auto-width",children:Dt.map(l=>n.jsx(g.Select.Option,{value:l.value,children:t(l.text)},l.value))}),typeof r=="number"?n.jsx(Cr,{value:e,onChange:o}):null,r==="cron"?n.jsx(xr,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>o(`0 ${l}`),clearButton:!1,locale:window.cronLocale}):null]})}const Sr={[Ae.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[Ae.DATE_FIELD]:{collection:A(C({},de),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(C({},We),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Ae.DATE_FIELD} && $deps[1]}}`}}}]})}},Ar=[{value:Ae.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:Ae.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Fr=()=>{const{values:e={},clearFormGraph:o}=T.useForm(),[t,r]=y.useState(e.mode);return T.useFormEffects(()=>{fe.onFieldValueChange("mode",s=>{r(s.value),o("collection"),o("startsOn"),o("repeat"),o("endsOn"),o("limit")})}),n.jsxs(n.Fragment,{children:[n.jsx(a.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Ar},required:!0,default:Ae.STATIC}}),n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`mode-${t}`]:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
|
|
497
553
|
.ant-input-number {
|
|
498
554
|
width: auto;
|
|
499
555
|
min-width: 6em;
|
|
@@ -502,59 +558,7 @@
|
|
|
502
558
|
.ant-picker {
|
|
503
559
|
width: auto;
|
|
504
560
|
}
|
|
505
|
-
`},properties:ar[o]}}},components:{OnField:co,RepeatField:lr,EndsByField:_n}})]})};function dr(e,t){var c;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=Be(o),i=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),e.mode===Se.DATE_FIELD){const[u]=Te(A(C({appends:["data",...((c=e.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}],compile:s,getCollectionFields:a}));u&&i.push(u)}return i}class ur extends Dt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{ScheduleConfig:cr});w(this,"useVariables",dr)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:je,collection:o.collection,dataPath:"$context.data"}:null}}function Ne(e){const a=e,{options:t=[],direction:o}=a,r=Q(a,["options","direction"]),s=l.useCompile();return n.jsx(h.Radio.Group,A(C({},r),{children:n.jsx(h.Space,{direction:o,children:t.map(i=>n.jsxs(h.Radio,{value:i.value,children:[n.jsx("span",{className:l.css`
|
|
506
|
-
& + .anticon {
|
|
507
|
-
margin-left: 0.25em;
|
|
508
|
-
}
|
|
509
|
-
`,children:s(i.label)}),i.tooltip&&n.jsx(h.Tooltip,{title:s(i.tooltip),children:n.jsx(V.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))})}))}function Ao(){const e=T.useFieldSchema(),t=l.useCompile();return n.jsxs(l.GeneralSchemaDesigner,{title:t(e.title),children:[n.jsx(l.SchemaSettingsBlockTitleItem,{}),n.jsx(l.SchemaSettingsDivider,{}),n.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const De=()=>null;function pr(){const a=l.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,r=Q(a,["node","resultTitle"]),{insert:s}=l.useSchemaInitializer();return n.jsx(l.SchemaInitializerItem,A(C({},r),{onClick:()=>{var i;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(i=t.title)!=null?i:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function mr({dataSource:e}){var s;const t=T.useFieldSchema(),{execution:o}=H();if(!o)return t.title;const r=X.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,i)=>Object.assign(a,{[i.nodeKey]:i.result}),{})});return n.jsx("pre",{className:l.css`
|
|
510
|
-
margin: 0;
|
|
511
|
-
`,children:JSON.stringify(r,null,2)})}De.Initializer=pr,De.Result=mr,De.Designer=Ao;const Mt=e=>{const t=Ie.evaluators.get(e);return t&&t.link?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:l.css`
|
|
512
|
-
&:after {
|
|
513
|
-
content: ':';
|
|
514
|
-
}
|
|
515
|
-
& + a {
|
|
516
|
-
margin-left: 0.25em;
|
|
517
|
-
}
|
|
518
|
-
`,children:l.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class fr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","calculation");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ie.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:Mt});w(this,"components",{WorkflowVariableTextArea:Ft,RadioWithTooltip:Ne,ValueBlock:De})}useVariables({key:o,title:r},{types:s,fieldNames:a=Fe}){return s&&!s.some(i=>i in _e||Object.values(_e).some(c=>c.has(i)))?null:{value:o,label:r}}useInitializers(o){var r,s;return{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:De.Initializer,node:o,resultTitle:O("Calculation result")}}}const Y=new X.Registry;Y.register("equal",{name:"=",type:"boolean",group:"boolean"}),Y.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Y.register("gt",{name:">",type:"boolean",group:"boolean"}),Y.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Y.register("lt",{name:"<",type:"boolean",group:"boolean"}),Y.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Y.register("add",{name:"+",type:"number",group:"number"}),Y.register("minus",{name:"-",type:"number",group:"number"}),Y.register("multiple",{name:"*",type:"number",group:"number"}),Y.register("divide",{name:"/",type:"number",group:"number"}),Y.register("mod",{name:"%",type:"number",group:"number"}),Y.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Y.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Y.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Y.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Y.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Y.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Y.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const hr=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function Fo(e){return Array.from(Y.getEntities()).filter(([t,o])=>o.group===e)}function yr({calculator:e,operands:t=[],onChange:o}){const r=l.useCompile(),s=g.useContext(Oo),a=s(),i=s(),c=g.useCallback(m=>o({calculator:e,operands:[m,t[1]]}),[e,o,t]),u=g.useCallback(m=>o({calculator:e,operands:[t[0],m]}),[e,o,t]),d=g.useCallback(m=>o({operands:t,calculator:m}),[o,t]);return n.jsxs("fieldset",{className:l.css`
|
|
519
|
-
display: flex;
|
|
520
|
-
gap: 0.5em;
|
|
521
|
-
align-items: center;
|
|
522
|
-
flex-wrap: wrap;
|
|
523
|
-
`,children:[n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:c,scope:a,useTypedConstant:!0}),n.jsx(h.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:hr.filter(m=>!!Fo(m.value).length).map(m=>n.jsx(h.Select.OptGroup,{label:r(m.title),children:Fo(m.value).map(([y,{name:x}])=>n.jsx(h.Select.Option,{value:y,children:r(x)},y))},m.value))}),n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:u,scope:i,useTypedConstant:!0})]})}function gr({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:r,operands:s=[]}=e;return n.jsxs("div",{className:l.css`
|
|
524
|
-
display: flex;
|
|
525
|
-
position: relative;
|
|
526
|
-
margin: 0.5em 0;
|
|
527
|
-
`,children:[e.group?n.jsx(To,{value:e.group,onChange:a=>t(A(C({},e),{group:a}))}):n.jsx(yr,{operands:s,calculator:r,onChange:t}),n.jsx(h.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:n.jsx(V.CloseCircleOutlined,{})})]})}function To({value:e,onChange:t}){const{t:o}=q.useTranslation(),{type:r="and",calculations:s=[]}=e,a=g.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))},[e,s,t]),i=g.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))},[e,s,t]),c=g.useCallback(d=>{s.splice(d,1),t(A(C({},e),{calculations:[...s]}))},[e,s,t]),u=g.useCallback((d,m)=>{s.splice(d,1,m),t(A(C({},e),{calculations:[...s]}))},[e,s,t]);return n.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
528
|
-
position: relative;
|
|
529
|
-
width: 100%;
|
|
530
|
-
.node-type-condition-group {
|
|
531
|
-
padding: 0.5em 1em;
|
|
532
|
-
border: 1px dashed #ddd;
|
|
533
|
-
}
|
|
534
|
-
+ button {
|
|
535
|
-
position: absolute;
|
|
536
|
-
right: 0;
|
|
537
|
-
}
|
|
538
|
-
`),children:[n.jsx("div",{className:l.css`
|
|
539
|
-
display: flex;
|
|
540
|
-
align-items: center;
|
|
541
|
-
gap: 0.5em;
|
|
542
|
-
.ant-select {
|
|
543
|
-
width: auto;
|
|
544
|
-
min-width: 6em;
|
|
545
|
-
}
|
|
546
|
-
`,children:n.jsxs(q.Trans,{children:["Meet ",n.jsxs(h.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:d=>t(A(C({},e),{type:d})),children:[n.jsx(h.Select.Option,{value:"and",children:"All"}),n.jsx(h.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((d,m)=>n.jsx(gr,{value:d,onChange:u.bind(this,m),onRemove:()=>c(m)},`${d.calculator}_${m}`))}),n.jsxs("div",{className:l.css`
|
|
547
|
-
button {
|
|
548
|
-
padding: 0;
|
|
549
|
-
&:not(:last-child) {
|
|
550
|
-
margin-right: 1em;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
`,children:[n.jsx(h.Button,{type:"link",onClick:a,children:o("Add condition")}),n.jsx(h.Button,{type:"link",onClick:i,children:o("Add condition group")})]})]})}const Oo=g.createContext(me);function No({value:e,onChange:t,useVariableHook:o=me}){const r=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(Oo.Provider,{value:o,children:n.jsx(To,{value:r.group,onChange:s=>t(A(C({},r),{group:s}))})})}class br extends be{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from(Ie.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[r,s])=>o.concat(C({value:r},s)),[])},required:!0,default:"basic"},calculation:{type:"object",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:Mt,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:No,WorkflowVariableTextArea:Ft,RadioWithTooltip:Ne})}Component({data:o}){const{t:r}=q.useTranslation(),{nodes:s}=H(),{styles:a}=ne(),{id:i,config:{rejectOnFalse:c}}=o,u=s.find(m=>m.upstreamId===i&&m.branchIndex===1),d=s.find(m=>m.upstreamId===i&&m.branchIndex===0);return n.jsx(Nt,{data:o,children:c?null:n.jsxs("div",{className:a.nodeSubtreeClass,children:[n.jsxs("div",{className:a.branchBlockClass,children:[n.jsx(Xe,{from:o,entry:d,branchIndex:0}),n.jsx(Xe,{from:o,entry:u,branchIndex:1})]}),n.jsxs("div",{className:a.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:r("No")}),n.jsx("span",{style:{left:"4em"},children:r("Yes")})]})]})})}}class vr extends be{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${p}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:ie.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ie.FAILED}],required:!0,default:ie.RESOLVED}});w(this,"end",!0)}}function rt({value:e,onChange:t,renderSchemaComponent:o}){const r=me();return n.jsx(l.Variable.Input,{value:e,onChange:t,scope:r,children:o()})}function xr(e){const{execution:t,nodes:o}=H(),r=g.useMemo(()=>o.reduce((i,c)=>Object.assign(i,{[c.id]:c.key}),{}),[o]),s=g.useMemo(()=>{var i;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((i=t==null?void 0:t.jobs)!=null?i:[]).reduce((c,u)=>Object.assign(c,{[r[u.nodeId]]:u.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,r]);return g.useMemo(()=>we.get(s,e),[s,e])}function wr({collection:e,dataPath:t,children:o}){const r=T.useField(),s=g.useRef(null),{getAssociationAppends:a}=l.useAssociationNames(),{appends:i,updateAssociationValues:c}=a(),u=xr(t);let d,m;if(typeof e=="string"){const B=l.parseCollectionName(e);d=B[0],m=B[1]}else m=e;const y=g.useMemo(()=>ge.createForm({values:u,readPretty:!0}),[u]),x={appends:i},b={loading:!1,data:{data:u}},k=l.useAPIClient().resource(m),F=l.useBlockRequestContext();return n.jsx(l.CollectionProvider_deprecated,{dataSource:d,collection:m,children:n.jsx(l.RecordProvider,{record:u,parent:null,children:n.jsx(l.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:r,service:b,resource:k,__parent:F},children:n.jsx(l.FormBlockContext.Provider,{value:{params:x,form:y,field:r,service:b,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function Cr(e){const a=e,{options:t=[],direction:o}=a,r=Q(a,["options","direction"]),s=l.useCompile();return n.jsx(h.Checkbox.Group,A(C({},r),{children:n.jsx(h.Space,{direction:o,children:t.map(i=>n.jsxs(h.Checkbox,{value:i.value,children:[n.jsx("span",{className:l.css`
|
|
554
|
-
& + .anticon {
|
|
555
|
-
margin-left: 0.25em;
|
|
556
|
-
}
|
|
557
|
-
`,children:s(i.label)}),i.tooltip&&n.jsx(h.Tooltip,{title:s(i.tooltip),children:n.jsx(V.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))})}))}function kr(e){return n.jsx(h.Card,{children:n.jsx(yt.FormLayout,{layout:e.layout||"vertical",children:e.children})})}function Sr({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=Be(s),[u]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(y=>`${e}.${y}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return u}class Ar extends be{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ce),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ce["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:et,sort:Ln,pagination:zn,appends:We},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const o=l.useCompile(),{values:r}=T.useForm(),[s,a]=l.parseCollectionName(r.collection),i=l.useApp(),{collectionManager:c}=i.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(d=>{if(!d.interface)return!1;const m=i.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(m!=null&&m.sortable)}).map(d=>{var m,y;return{value:d.name,label:(m=d==null?void 0:d.uiSchema)!=null&&m.title?o((y=d==null?void 0:d.uiSchema)==null?void 0:y.title):d.name}})}});w(this,"components",{ArrayItems:yt.ArrayItems,FilterDynamicComponent:rt,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:At,RadioWithTooltip:Ne});w(this,"useVariables",Sr)}useInitializers(o){var r,s;return!o.config.collection||o.config.multiple?null:{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:je,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function Fr(e){const{getCollectionFields:t}=l.useCollectionManager_deprecated(),{path:o}=T.useField(),r=o.segments[o.segments.length-1],{values:s}=T.useForm(),[a,i]=l.parseCollectionName(s==null?void 0:s.collection),c=t(i,a),{type:u}=c.find(y=>y.name===r),d=Array.isArray(e.value)?e.value.join(","):e.value,m=g.useCallback(y=>{const x=y.target.value.trim(),b=["belongsTo","hasOne"].includes(u)?x||null:x.split(",").map(f=>f.trim()).filter(f=>f!=="");e.onChange(b)},[e.onChange,u]);return n.jsx(h.Input,A(C({},e),{value:d,onChange:m}))}const Do=T.observer(({value:e,disabled:t,onChange:o,filter:r})=>{const{token:s}=l.useToken(),{t:a}=q.useTranslation(),i=l.useCompile(),c=T.useForm(),{getCollectionFields:u}=l.useCollectionManager_deprecated(),d=me(),{values:m}=c,[y,x]=l.parseCollectionName(m==null?void 0:m.collection),b=u(x,y).filter(S=>S.uiSchema),f=r?b.filter(r.bind(m)):b,k=g.useMemo(()=>f.filter(S=>!e||!(S.name in e)),[f,e]),F=t||c.disabled,B=g.useMemo(()=>({onClick:({key:S})=>{o(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var E,L;return{key:S.name,label:i((L=(E=S.uiSchema)==null?void 0:E.title)!=null?L:S.name)}})}),[o,k,e]);return n.jsx("fieldset",{className:l.css`
|
|
561
|
+
`},properties:Sr[t]}}},components:{OnField:gt,RepeatField:kr,EndsByField:pr}})]})};function Tr(e,o){var c;const[t,r]=a.parseCollectionName(e.collection),s=a.useCompile(),l=je(t),i=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&i.push({key:"date",value:"date",label:N("Trigger time")}),e.mode===Ae.DATE_FIELD){const[u]=Ne(A(C({appends:["data",...((c=e.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}}],compile:s,getCollectionFields:l}));u&&i.push(u)}return i}class Nr extends Bo{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{ScheduleConfig:Fr});w(this,"useVariables",Tr)}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:t.collection,dataPath:"$context.data"}:null}}class Or extends be{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","calculation");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ie.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,r,{form:s}){const{values:l}=s,{evaluate:i}=Ie.evaluators.get(l.engine),c=t.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return N("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:Mo});w(this,"components",{WorkflowVariableTextArea:Po,RadioWithTooltip:ke,ValueBlock:Oe})}useVariables({key:t,title:r},{types:s,fieldNames:l=Te}){return s&&!s.some(i=>i in Qe||Object.values(Qe).some(c=>c.has(i)))?null:{value:t,label:r}}useInitializers(t){var r,s;return{name:(r=t.title)!=null?r:`#${t.id}`,type:"item",title:(s=t.title)!=null?s:`#${t.id}`,Component:Oe.Initializer,node:t,resultTitle:N("Calculation result")}}}const $t={DEFAULT:null,ON_TRUE:1,ON_FALSE:0};class Dr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from(Ie.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[r,s])=>t.concat(C({value:r},s)),[])},required:!0,default:"basic"},calculation:{type:"object",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,r,{form:s}){const{values:l}=s,{evaluate:i}=Ie.evaluators.get(l.engine),c=t.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return N("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"presetFieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,value:!0},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,value:!1}],default:!0}});w(this,"branching",({rejectOnFalse:t=!0}={})=>t?!1:[{label:`{{t('After end of branches', { ns: "${p}" })}}`,value:!1},{label:`{{t('Inside of "Yes" branch', { ns: "${p}" })}}`,value:$t.ON_TRUE},{label:`{{t('Inside of "No" branch', { ns: "${p}" })}}`,value:$t.ON_FALSE}]);w(this,"scope",{renderEngineReference:Mo,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:nt,WorkflowVariableTextArea:Po,RadioWithTooltip:ke})}Component({data:t}){const{t:r}=Y.useTranslation(),{nodes:s}=H(),{styles:l}=ne(),{id:i,config:{rejectOnFalse:c}}=t,u=s.find(m=>m.upstreamId===i&&m.branchIndex===1),d=s.find(m=>m.upstreamId===i&&m.branchIndex===0);return n.jsx(No,{data:t,children:c?null:n.jsxs("div",{className:l.nodeSubtreeClass,children:[n.jsxs("div",{className:l.branchBlockClass,children:[n.jsx(oo,{from:t,entry:d,branchIndex:0}),n.jsx(oo,{from:t,entry:u,branchIndex:1})]}),n.jsxs("div",{className:l.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:r("No")}),n.jsx("span",{style:{left:"4em"},children:r("Yes")})]})]})})}}class Er extends be{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${p}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:ce.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ce.FAILED}],required:!0,default:ce.RESOLVED}});w(this,"end",!0)}}function $r({key:e,title:o,config:t},r){var d,m;const[s,l]=a.parseCollectionName(t.collection),i=a.useCompile(),c=je(s),[u]=Ne(A(C({appends:[e,...((m=(d=t.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:l,name:e,type:"hasOne",target:l,uiSchema:{title:o}}],compile:i,getCollectionFields:c}));return u}class Ir extends be{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:to,sort:nr,pagination:rr,appends:We},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const t=a.useCompile(),{values:r}=T.useForm(),[s,l]=a.parseCollectionName(r.collection),i=a.useApp(),{collectionManager:c}=i.dataSourceManager.getDataSource(s);return c.getCollectionFields(l).filter(d=>{if(!d.interface)return!1;const m=i.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(m!=null&&m.sortable)}).map(d=>{var m,h;return{value:d.name,label:(m=d==null?void 0:d.uiSchema)!=null&&m.title?t((h=d==null?void 0:d.uiSchema)==null?void 0:h.title):d.name}})}});w(this,"components",{ArrayItems:bo.ArrayItems,FilterDynamicComponent:Re,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Io,RadioWithTooltip:ke});w(this,"useVariables",$r)}useInitializers(t){var r,s;return!t.config.collection||t.config.multiple?null:{name:(r=t.title)!=null?r:`#${t.id}`,type:"item",title:(s=t.title)!=null?s:`#${t.id}`,Component:Me,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function Pr(e){const{getCollectionFields:o}=a.useCollectionManager_deprecated(),{path:t}=T.useField(),r=t.segments[t.segments.length-1],{values:s}=T.useForm(),[l,i]=a.parseCollectionName(s==null?void 0:s.collection),c=o(i,l),{type:u}=c.find(h=>h.name===r),d=Array.isArray(e.value)?e.value.join(","):e.value,m=y.useCallback(h=>{const x=h.target.value.trim(),b=["belongsTo","hasOne"].includes(u)?x||null:x.split(",").map(f=>f.trim()).filter(f=>f!=="");e.onChange(b)},[e.onChange,u]);return n.jsx(g.Input,A(C({},e),{value:d,onChange:m}))}const It=T.observer(({value:e,disabled:o,onChange:t,filter:r})=>{const{token:s}=a.useToken(),{t:l}=Y.useTranslation(),i=a.useCompile(),c=T.useForm(),{getCollectionFields:u}=a.useCollectionManager_deprecated(),d=me(),{values:m}=c,[h,x]=a.parseCollectionName(m==null?void 0:m.collection),b=u(x,h).filter(S=>S.uiSchema),f=r?b.filter(r.bind(m)):b,k=y.useMemo(()=>f.filter(S=>!e||!(S.name in e)),[f,e]),F=o||c.disabled,M=y.useMemo(()=>({onClick:({key:S})=>{t(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var E,L;return{key:S.name,label:i((L=(E=S.uiSchema)==null?void 0:E.title)!=null?L:S.name)}})}),[t,k,e]);return n.jsx("fieldset",{className:a.css`
|
|
558
562
|
margin-top: 0.5em;
|
|
559
563
|
|
|
560
564
|
> .ant-formily-item {
|
|
@@ -564,8 +568,8 @@
|
|
|
564
568
|
line-height: 32px;
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
|
-
`,children:f.length?n.jsxs(
|
|
571
|
+
`,children:f.length?n.jsxs(a.CollectionProvider_deprecated,{name:x,dataSource:h,children:[f.filter(S=>e&&S.name in e).map(S=>{var L,D;const E=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?Pr:a.CollectionField;return n.jsxs(g.Form.Item,{label:i((D=(L=S.uiSchema)==null?void 0:L.title)!=null?D:S.name),labelAlign:"left",className:a.css`
|
|
568
572
|
.ant-form-item-control-input-content {
|
|
569
573
|
display: flex;
|
|
570
574
|
}
|
|
571
|
-
`,children:[n.jsx(l.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:M=>{o(A(C({},e),{[S.name]:M}))},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":E,"x-validator"(){return""}}}}})}),F?null:n.jsx(h.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(V.CloseCircleOutlined,{}),onClick:()=>{var N;const I=e,{[N=S.name]:M}=I,D=Q(I,[Zo(N)]);o(D)}})]},S.name)}),k.length?n.jsx(h.Dropdown,{menu:B,children:n.jsx(h.Button,{icon:n.jsx(V.PlusOutlined,{}),children:a("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Eo(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{Eo(o,t)})}function $o(){return{name:oe.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Io(e){const{workflow:t}=H(),{setFormValueChanged:o}=l.useActionContext();l.useAPIClient();const r=me(),{values:s,setValuesIn:a,disabled:i}=T.useForm(),c=Ge.toJS(s.params),[u,d]=l.parseCollectionName(s.collection),m=l.useSchemaOptionsContext(),[y,x]=g.useState(e.value&&Object.keys(e.value).length?e.value:$o()),b=g.useMemo(()=>ge.createForm({initialValues:c.values,disabled:t.executed,effects(){ge.onFormValuesChange(k=>{a("params.values",Ge.toJS(k.values)),o(!0)})}}),[t.executed]);T.useFormEffects(()=>{ge.onFieldValueChange("collection",k=>J(this,null,function*(){b.clearFormGraph("*");const F=$o();a("params.values",{}),x(F)}))});const f=g.useCallback(k=>{const[F]=Object.values(k.toJSON().properties);e.onChange(F);const B=new Set;Eo(F,E=>{var L;if(E["x-component"]==="AssignedField"&&(L=E["x-collection-field"])!=null&&L.startsWith(`${d}.`)){const[,$]=E["x-collection-field"].split(".");B.add($)}});const S={};Array.from(B).forEach(E=>{E in b.values&&(S[E]=b.values[E])}),a("params.values",S)},[d,e.onChange]);return n.jsx(h.Card,{children:n.jsx(l.CollectionManagerProvider,{dataSource:u,children:n.jsx(l.CollectionProvider,{name:d,children:n.jsx(l.RerenderDataBlockProvider,{children:n.jsx(l.FormProvider,{form:b,children:n.jsx(yt.FormLayout,{layout:"vertical",children:n.jsx(l.VariableScopeProvider,{scope:r,children:n.jsx(l.SchemaComponentProvider,{form:b,designable:!i,children:n.jsx(l.SchemaComponentOptions,A(C({},m),{children:n.jsx(l.SchemaComponent,{schema:y,onChange:f})}))})})})})})})})})}function Tr({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=Be(s),[u]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(y=>`${e}.${y}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return u}class Or extends be{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ce),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ce["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},ao),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:We}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{CollectionFieldset:Do,AssignedFieldsFormSchemaConfig:Io});w(this,"useVariables",Tr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var r,s;return o.config.collection?{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:je,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Nr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ce),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ce["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But association fields are not supported (unless foreign key in current collection), and the updated data will not trigger other workflows.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:A(C({},et),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return X.isValidFilter(o)?"":O("Please add at least one condition")}}),values:A(C({},ao),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{FilterDynamicComponent:rt,CollectionFieldset:Do,AssignedFieldsFormSchemaConfig:Io,RadioWithTooltip:Ne})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Dr extends be{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ce),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ce["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},et),{"x-validator"(o){return X.isValidFilter(o)?"":O("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:rt})}}const Er=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});function $r({children:e,workflow:t,execution:o,nodes:r}){const s=l.usePlugin(ue),a=s.triggers.get(t.type).components,i=r.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return n.jsx(Pe.Provider,{value:{workflow:t,nodes:r,execution:o},children:n.jsx(l.SchemaComponentOptions,{components:C(C({},a),i),children:e})})}class ue extends l.Plugin{constructor(){super(...arguments);w(this,"triggers",new X.Registry);w(this,"instructions",new X.Registry);w(this,"useTriggersOptions",()=>{const o=l.useCompile();return Array.from(this.triggers.getEntities()).map(i=>{var[r,c]=i,u=c,{title:s}=u,a=Q(u,["title"]);return{value:r,label:o(s),color:"gold",options:a}})})}isWorkflowSync(o){var r,s;return(s=(r=this.triggers.get(o.type))==null?void 0:r.sync)!=null?s:o.sync}registerTrigger(o,r){if(typeof r=="function")this.triggers.register(o,new r);else if(r)this.triggers.register(o,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,r){if(typeof r=="function")this.instructions.register(o,new r);else if(r instanceof be)this.instructions.register(o,r);else throw new TypeError("invalid instruction type to register")}load(){return J(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:Ce(":id"),element:n.jsx(so,{})}),this.app.router.add("admin.workflow.executions.id",{path:Re(":id"),element:n.jsx(Rt,{})}),this.app.addComponents({WorkflowPage:so,ExecutionPage:Rt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:Vn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(Er),this.app.schemaSettingsManager.addItem("actionSettings:delete","workflowConfig",{Component:l.WorkflowConfig,useVisible(){var r;const o=T.useFieldSchema();return oe.isValid((r=o==null?void 0:o["x-action-settings"])==null?void 0:r.triggerWorkflows)}}),this.registerTrigger("collection",Yn),this.registerTrigger("schedule",ur),this.registerInstruction("calculation",fr),this.registerInstruction("condition",br),this.registerInstruction("end",vr),this.registerInstruction("query",Ar),this.registerInstruction("create",Or),this.registerInstruction("update",Nr),this.registerInstruction("destroy",Dr)})}}v.BaseTypeSets=_e,v.Branch=Xe,v.CalculationConfig=No,v.CheckboxGroupWithTooltip=Cr,v.CollectionBlockInitializer=je,v.DetailsBlockProvider=wr,v.EXECUTION_STATUS=ae,v.ExecutionContextProvider=$r,v.ExecutionStatusOptions=qe,v.ExecutionStatusOptionsMap=Ye,v.FieldsSelect=Pt,v.Fieldset=kr,v.FilterDynamicComponent=rt,v.FlowContext=Pe,v.Instruction=be,v.JOB_STATUS=ie,v.JobButton=Ot,v.JobStatusOptions=xt,v.JobStatusOptionsMap=Ke,v.Node=Zt,v.NodeContext=Qe,v.NodeDefaultView=Nt,v.RadioWithTooltip=Ne,v.RemoveButton=Tt,v.SimpleDesigner=Ao,v.Trigger=Dt,v.ValueBlock=De,v.WorkflowVariableInput=At,v.WorkflowVariableJSON=dn,v.WorkflowVariableRawTextArea=cn,v.WorkflowVariableTextArea=Ft,v.calculators=Y,v.default=ue,v.defaultFieldNames=Fe,v.getCollectionFieldOptions=Te,v.getWorkflowDetailPath=Ce,v.getWorkflowExecutionsPath=Re,v.linkNodes=$t,v.nodesOptions=Ut,v.renderEngineReference=Mt,v.scopeOptions=Gt,v.systemOptions=qt,v.traverseSchema=It,v.triggerOptions=Ht,v.useAvailableUpstreams=Kt,v.useFlowContext=H,v.useGetAriaLabelOfAddButton=vt,v.useGetCollectionFields=Be,v.useNodeContext=ve,v.useNodeSavedConfig=Ve,v.useRecordTriggerWorkflowsActionProps=Un,v.useStyles=ne,v.useTrigger=Et,v.useTriggerWorkflowsActionProps=Jn,v.useUpstreamScopes=_t,v.useWorkflowAnyExecuted=io,v.useWorkflowExecuted=Hn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
575
|
+
`,children:[n.jsx(a.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:I=>{t(A(C({},e),{[S.name]:I}))},children:n.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":E,"x-validator"(){return""}}}}})}),F?null:n.jsx(g.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(V.CloseCircleOutlined,{}),onClick:()=>{var O;const B=e,{[O=S.name]:I}=B,$=Q(B,[Rt(O)]);t($)}})]},S.name)}),k.length?n.jsx(g.Dropdown,{menu:M,children:n.jsx(g.Button,{icon:n.jsx(V.PlusOutlined,{}),children:l("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Pt(e,o){o(e),e!=null&&e.properties&&Object.values(e.properties).forEach(t=>{Pt(t,o)})}function Mt(){return{name:te.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Bt(e){const{workflow:o}=H(),{setFormValueChanged:t}=a.useActionContext();a.useAPIClient();const r=me(),{values:s,setValuesIn:l,disabled:i}=T.useForm(),c=Ge.toJS(s.params),[u,d]=a.parseCollectionName(s.collection),m=a.useSchemaOptionsContext(),[h,x]=y.useState(e.value&&Object.keys(e.value).length?e.value:Mt()),b=y.useMemo(()=>fe.createForm({initialValues:c.values,disabled:o.executed,effects(){fe.onFormValuesChange(k=>{l("params.values",Ge.toJS(k.values)),t(!0)})}}),[o.executed]);T.useFormEffects(()=>{fe.onFieldValueChange("collection",k=>J(this,null,function*(){b.clearFormGraph("*");const F=Mt();l("params.values",{}),x(F)}))});const f=y.useCallback(k=>{const[F]=Object.values(k.toJSON().properties);e.onChange(F);const M=new Set;Pt(F,E=>{var L;if(E["x-component"]==="AssignedField"&&(L=E["x-collection-field"])!=null&&L.startsWith(`${d}.`)){const[,D]=E["x-collection-field"].split(".");M.add(D)}});const S={};Array.from(M).forEach(E=>{E in b.values&&(S[E]=b.values[E])}),l("params.values",S)},[d,e.onChange]);return n.jsx(g.Card,{children:n.jsx(a.CollectionManagerProvider,{dataSource:u,children:n.jsx(a.CollectionProvider,{name:d,children:n.jsx(a.RerenderDataBlockProvider,{children:n.jsx(a.FormProvider,{form:b,children:n.jsx(bo.FormLayout,{layout:"vertical",children:n.jsx(a.VariableScopeProvider,{scope:r,children:n.jsx(a.SchemaComponentProvider,{form:b,designable:!i,children:n.jsx(a.SchemaComponentOptions,A(C({},m),{children:n.jsx(a.SchemaComponent,{schema:h,onChange:f})}))})})})})})})})})}function Mr({key:e,title:o,config:t},r){var d,m;const[s,l]=a.parseCollectionName(t.collection),i=a.useCompile(),c=je(s),[u]=Ne(A(C({appends:[e,...((m=(d=t.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:l,name:e,type:"hasOne",target:l,uiSchema:{title:o}}],compile:i,getCollectionFields:c}));return u}class Br extends be{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},ht),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:We}}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{CollectionFieldset:It,AssignedFieldsFormSchemaConfig:Bt});w(this,"useVariables",Mr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(t){var r,s;return t.config.collection?{name:(r=t.title)!=null?r:`#${t.id}`,type:"item",title:(s=t.title)!=null?s:`#${t.id}`,Component:Me,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Vr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But association fields are not supported (unless foreign key in current collection), and the updated data will not trigger other workflows.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:A(C({},to),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(t){return X.isValidFilter(t)?"":N("Please add at least one condition")}}),values:A(C({},ht),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{FilterDynamicComponent:Re,CollectionFieldset:It,AssignedFieldsFormSchemaConfig:Bt,RadioWithTooltip:ke})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class jr extends be{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},to),{"x-validator"(t){return X.isValidFilter(t)?"":N("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:a.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Re})}}const Wr=new a.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:a.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=a.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:a.SecondConFirm},{name:"assignFieldValues",Component:a.AssignedFieldValues},{name:"skipRequiredValidation",Component:a.SkipValidation},{name:"afterSuccessfulSubmission",Component:a.AfterSuccess},{name:"bindWorkflow",Component:a.WorkflowConfig},{name:"delete",sort:100,Component:a.RemoveButton,useComponentProps(){const{removeButtonProps:e}=a.useSchemaToolbar();return e}}]});function Lr({children:e,workflow:o,execution:t,nodes:r}){const s=a.usePlugin(ae),l=s.triggers.get(o.type).components,i=r.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return n.jsx(Pe.Provider,{value:{workflow:o,nodes:r,execution:t},children:n.jsx(a.SchemaComponentOptions,{components:C(C({},l),i),children:e})})}class ae extends a.Plugin{constructor(){super(...arguments);w(this,"triggers",new X.Registry);w(this,"instructions",new X.Registry);w(this,"useTriggersOptions",()=>{const t=a.useCompile();return Array.from(this.triggers.getEntities()).map(i=>{var[r,c]=i,u=c,{title:s}=u,l=Q(u,["title"]);return{value:r,label:t(s),color:"gold",options:l}})})}isWorkflowSync(t){var r,s;return(s=(r=this.triggers.get(t.type))==null?void 0:r.sync)!=null?s:t.sync}registerTrigger(t,r){if(typeof r=="function")this.triggers.register(t,new r);else if(r)this.triggers.register(t,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,r){if(typeof r=="function")this.instructions.register(t,new r);else if(r instanceof be)this.instructions.register(t,r);else throw new TypeError("invalid instruction type to register")}load(){return J(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:Ce(":id"),element:n.jsx(mt,{})}),this.app.router.add("admin.workflow.executions.id",{path:qe(":id"),element:n.jsx(at,{})}),this.app.addComponents({WorkflowPage:mt,ExecutionPage:at}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:tr,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(Wr),this.app.schemaSettingsManager.addItem("actionSettings:delete","workflowConfig",{Component:a.WorkflowConfig,useVisible(){var r;const t=T.useFieldSchema();return te.isValid((r=t==null?void 0:t["x-action-settings"])==null?void 0:r.triggerWorkflows)}}),this.registerTrigger("collection",dr),this.registerTrigger("schedule",Nr),this.registerInstruction("calculation",Or),this.registerInstruction("condition",Dr),this.registerInstruction("end",Er),this.registerInstruction("query",Ir),this.registerInstruction("create",Br),this.registerInstruction("update",Vr),this.registerInstruction("destroy",jr)})}}v.BaseTypeSets=Qe,v.Branch=oo,v.CalculationConfig=nt,v.CheckboxGroupWithTooltip=Sn,v.CollectionBlockInitializer=Me,v.DetailsBlockProvider=ln,v.EXECUTION_STATUS=ie,v.ExecutionContextProvider=Lr,v.ExecutionStatusOptions=Ye,v.ExecutionStatusOptionsMap=_e,v.FieldsSelect=ko,v.Fieldset=Dn,v.FilterDynamicComponent=Re,v.FlowContext=Pe,v.Instruction=be,v.JOB_STATUS=ce,v.JobButton=To,v.JobStatusOptions=So,v.JobStatusOptionsMap=Ke,v.Node=qo,v.NodeContext=Ze,v.NodeDefaultView=No,v.RadioWithTooltip=ke,v.RemoveButton=Fo,v.SimpleDesigner=Ro,v.Trigger=Bo,v.ValueBlock=Oe,v.WorkflowVariableInput=Io,v.WorkflowVariableJSON=kn,v.WorkflowVariableRawTextArea=Cn,v.WorkflowVariableTextArea=Po,v.calculators=_,v.default=ae,v.defaultFieldNames=Te,v.getCollectionFieldOptions=Ne,v.getWorkflowDetailPath=Ce,v.getWorkflowExecutionsPath=qe,v.linkNodes=wo,v.nodesOptions=_o,v.renderEngineReference=Mo,v.scopeOptions=Zo,v.systemOptions=Qo,v.traverseSchema=Co,v.triggerOptions=Ko,v.useAvailableUpstreams=Ho,v.useFlowContext=H,v.useGetAriaLabelOfAddButton=Ao,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Ve,v.useRecordTriggerWorkflowsActionProps=lr,v.useStyles=ne,v.useTrigger=Vo,v.useTriggerWorkflowsActionProps=sr,v.useUpstreamScopes=Go,v.useWorkflowAnyExecuted=yt,v.useWorkflowExecuted=ar,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|