@nocobase/plugin-workflow 0.16.0-alpha.6 → 0.17.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/components/CollectionBlockInitializer.d.ts +1 -1
- package/dist/client/components/ValueBlock.d.ts +1 -1
- package/dist/client/index.d.ts +5 -3
- package/dist/client/index.js +41 -41
- package/dist/client/nodes/aggregate.d.ts +3 -3
- package/dist/client/nodes/calculation.d.ts +3 -3
- package/dist/client/nodes/create.d.ts +2 -2
- package/dist/client/nodes/index.d.ts +3 -3
- package/dist/client/nodes/manual/FormBlockInitializer.d.ts +1 -1
- package/dist/client/nodes/manual/SchemaConfig.d.ts +4 -2
- package/dist/client/nodes/manual/forms/custom.d.ts +2 -0
- package/dist/client/nodes/manual/index.d.ts +4 -4
- package/dist/client/nodes/query.d.ts +2 -2
- package/dist/client/triggers/collection.d.ts +2 -2
- package/dist/client/triggers/form.d.ts +2 -2
- package/dist/client/triggers/index.d.ts +2 -2
- package/dist/client/triggers/schedule/index.d.ts +2 -2
- package/dist/externalVersion.js +8 -8
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(S,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","antd","react","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client"],r):(S=typeof globalThis!="undefined"?globalThis:S||self,r(S["@nocobase/plugin-workflow"]={},S.jsxRuntime,S["@ant-design/icons"],S["@nocobase/client"],S.antd,S.react,S["react-i18next"],S["@formily/core"],S["@formily/react"],S.lodash,S["@nocobase/utils"],S["react-router-dom"],S.dayjs,S["@formily/antd-v5"],S["@nocobase/evaluators"]))})(this,function(S,r,I,l,b,y,R,le,A,fe,K,ue,zo,be,je){"use strict";var Os=Object.defineProperty,Is=Object.defineProperties;var Ts=Object.getOwnPropertyDescriptors;var xo=Object.getOwnPropertySymbols;var Rt=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var jo=(S,r,I)=>r in S?Os(S,r,{enumerable:!0,configurable:!0,writable:!0,value:I}):S[r]=I,x=(S,r)=>{for(var I in r||(r={}))Rt.call(r,I)&&jo(S,I,r[I]);if(xo)for(var I of xo(r))en.call(r,I)&&jo(S,I,r[I]);return S},C=(S,r)=>Is(S,Ts(r));var on=S=>typeof S=="symbol"?S:S+"",W=(S,r)=>{var I={};for(var l in S)Rt.call(S,l)&&r.indexOf(l)<0&&(I[l]=S[l]);if(S!=null&&xo)for(var l of xo(S))r.indexOf(l)<0&&en.call(S,l)&&(I[l]=S[l]);return I};var bo=(S,r,I)=>(jo(S,typeof r!="symbol"?r+"":r,I),I);var G=(S,r,I)=>new Promise((l,b)=>{var y=A=>{try{le(I.next(A))}catch(fe){b(fe)}},R=A=>{try{le(I.throw(A))}catch(fe){b(fe)}},le=A=>A.done?l(A.value):Promise.resolve(A.value).then(y,R);le((I=I.apply(S,r)).next())});const ze=y.createContext({});function U(){return y.useContext(ze)}const u="workflow";function $(e,o={}){return l.i18n.t(e,C(x({},o),{ns:u}))}function vo(){return R.useTranslation(u)}const tn=l.createStyles(({css:e,token:o})=>({container:e`
|
|
2
2
|
margin-bottom: 1.5em;
|
|
3
3
|
padding: 1em;
|
|
4
4
|
background-color: ${o.colorFillAlter};
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
p {
|
|
24
24
|
color: ${o.colorTextDescription};
|
|
25
25
|
}
|
|
26
|
-
`}));function
|
|
26
|
+
`}));function Lo(e){const{label:o,title:n,description:t}=e,{styles:s}=tn();return r.jsxs("div",{className:l.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:n})})]}),t?r.jsx("p",{children:t}):null]})}function nn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wo={exports:{}};/*!
|
|
27
27
|
Copyright (c) 2018 Jed Watson.
|
|
28
28
|
Licensed under the MIT License (MIT), see
|
|
29
29
|
http://jedwatson.github.io/classnames
|
|
30
|
-
*/(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var t=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var a=typeof i;if(a==="string"||a==="number")t.push(i);else if(Array.isArray(i)){if(i.length){var c=n.apply(null,i);c&&t.push(c)}}else if(a==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){t.push(i.toString());continue}for(var d in i)o.call(i,d)&&i[d]&&t.push(d)}}}return t.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(
|
|
30
|
+
*/(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var t=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var a=typeof i;if(a==="string"||a==="number")t.push(i);else if(Array.isArray(i)){if(i.length){var c=n.apply(null,i);c&&t.push(c)}}else if(a==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){t.push(i.toString());continue}for(var d in i)o.call(i,d)&&i[d]&&t.push(d)}}}return t.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Wo);var rn=Wo.exports;const sn=nn(rn),ln=l.createStyles(({css:e,token:o})=>({statusButtonClass:e`
|
|
31
31
|
border: none;
|
|
32
32
|
.ant-tag {
|
|
33
33
|
width: 100%;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
`,noStatusButtonClass:e`
|
|
41
41
|
border-width: 2px;
|
|
42
|
-
`}));function
|
|
42
|
+
`}));function Le(e){var t;const{styles:o}=ln();let n=null;if(typeof e.status!="undefined"&&((t=e.statusMap)!=null&&t[e.status])){const{icon:s,color:i}=e.statusMap[e.status];n=r.jsx(b.Tag,{color:i,children:s})}return r.jsx(b.Button,C(x({},e),{shape:"circle",size:"small",className:sn(n?o.statusButtonClass:o.noStatusButtonClass,e.className),children:n}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Qe=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${u}" })}}`,color:"blue",icon:r.jsx(I.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${u}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(I.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${u}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${u}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${u}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${u}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${u}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${u}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${u}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${u}" })}}`}],Xe=Qe.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),ee={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Re=[{value:ee.PENDING,label:`{{t("Pending", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(I.ClockCircleOutlined,{})},{value:ee.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{})},{value:ee.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{})},{value:ee.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{})},{value:ee.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90})},{value:ee.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45})},{value:ee.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{})},{value:ee.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{})}],We=Re.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),Co=(e,o)=>({getAriaLabel:y.useCallback(t=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,o!=null?String(o):"",t].filter(Boolean).join("-"),[o,e==null?void 0:e.title,e==null?void 0:e.type])}),oe=l.createStyles(({css:e,token:o})=>({workflowPageClass:e`
|
|
43
43
|
flex-grow: 1;
|
|
44
44
|
overflow: hidden;
|
|
45
45
|
display: flex;
|
|
@@ -392,18 +392,18 @@
|
|
|
392
392
|
border-radius: 50%;
|
|
393
393
|
background-color: ${o.colorText};
|
|
394
394
|
color: ${o.colorBgContainer};
|
|
395
|
-
`}));function
|
|
395
|
+
`}));function an(){return!0}const wo=A.observer(e=>{const c=e,{filter:o=an}=c,n=W(c,["filter"]),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),{values:i}=A.useForm(),a=s(i==null?void 0:i.collection);return r.jsx(b.Select,C(x({popupMatchSelectWidth:!1},n),{options:a.filter(o).map(d=>{var p;return{label:t((p=d.uiSchema)==null?void 0:p.title),value:d.name}})}))},{displayName:"FieldsSelect"});function ko(e,o){o(e),e.properties&&Object.keys(e.properties).forEach(n=>{ko(e.properties[n],o)})}function ve(e,o,n=!1){const t=[];return e?o(e)&&(!n||!e.properties)?(t.push(e),t):(e.properties&&Object.keys(e.properties).forEach(s=>{t.push(...ve(e.properties[s],o))}),t):t}function cn(t){var s=t,{collection:e,dataSource:o}=s,n=W(s,["collection","dataSource"]);const{insert:i}=l.useSchemaInitializer(),{getTemplateSchemaByMode:a}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager(),d=l.useRecordCollectionDataSourceItems("FormItem"),p=c(e);function f(v){return G(this,arguments,function*({item:g}){const h=g.template?yield a(g):null,m={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:o},"x-component":"CardItem","x-component-props":{title:n.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};ko(m,k=>{k["x-uid"]&&delete k["x-uid"]}),i(m)})}return r.jsx(l.SchemaInitializerItem,C(x({},n),{onClick:f,items:d}))}function Ie(){const e=l.useSchemaInitializerItem();return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(cn,x({},e))})}const ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Uo={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
396
396
|
flex-direction: column;
|
|
397
|
-
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${u}" })}}`}
|
|
397
|
+
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${u}" })}}`},Te={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=A.useForm();return{options:l.useCollectionFilterOptions(e==null?void 0:e.collection),className:l.css`
|
|
398
398
|
position: relative;
|
|
399
399
|
width: 100%;
|
|
400
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},
|
|
400
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},dn={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"}}},un={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,max:100},default:20}}}}}}},$e={type:"array",title:`{{t("Preload associations", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},De={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},pn=[{label:`{{t("After record added", { ns: "${u}" })}}`,value:De.CREATED},{label:`{{t("After record updated", { ns: "${u}" })}}`,value:De.UPDATED},{label:`{{t("After record added or updated", { ns: "${u}" })}}`,value:De.SAVED},{label:`{{t("After record deleted", { ns: "${u}" })}}`,value:De.DELETED}],qo={title:`{{t("Collection event", { ns: "${u}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${u}" })}}`,fieldset:{collection:C(x({},ae),{"x-reactions":[...ae["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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${u}" })}}`,className:"auto-width"},enum:pn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${De.UPDATED})}}`}}}]},condition:C(x({},Te),{title:`{{t("Only triggers when match conditions", { ns: "${u}" })}}`,"x-component-props":{useProps:Te["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(x({},$e),{"x-reactions":[...$e["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${De.DELETED})}}`}}}]})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FieldsSelect:wo},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}}];return he(C(x({appends:["data",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}},Jo={title:`{{t("Form event", { ns: "${u}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${u}" })}}`,fieldset:{collection:C(x({},ae),{title:`{{t("Form data model", { ns: "${u}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${u}" })}}`,"x-reactions":[...ae["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(x({},$e),{title:`{{t("Associations to use", { ns: "${u}" })}}`})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:$("User submitted form")}}];return he(C(x({appends:["data","user",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function mn(){const e=l.useAPIClient(),o=A.useForm(),{field:n,__parent:t}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),i=ue.useNavigate(),a=A.useFieldSchema(),c=A.useField(),d=l.useCompile(),{modal:p}=b.App.useApp(),f=l.useCollectValuesToSubmit(),g=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var O,w,T;const{onSuccess:h,skipValidator:m,triggerWorkflows:k}=(O=a==null?void 0:a["x-action-settings"])!=null?O:{};m||(yield o.submit());const F=yield f();c.data=n.data||{},c.data.loading=!0;try{const P=yield e.resource("workflows").trigger({values:F,filterKeys:g,triggerWorkflows:k!=null&&k.length?k.map(B=>[B.workflowKey,B.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=P,(T=(w=t==null?void 0:t.service)==null?void 0:w.refresh)==null||T.call(w),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:d(h==null?void 0:h.successMessage),onOk:()=>G(this,null,function*(){yield o.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(K.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(P){c.data.loading=!1}})}}}const Fe={STATIC:0,COLLECTION_FIELD:1};function fn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Ho({value:e,onChange:o}){const{t:n}=R.useTranslation(),[t,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:l.css`
|
|
401
401
|
display: flex;
|
|
402
402
|
gap: 0.5em;
|
|
403
|
-
`,children:[r.jsx(wo,{value:e.field,onChange:i=>o(C(
|
|
403
|
+
`,children:[r.jsx(wo,{value:e.field,onChange:i=>o(C(x({},e),{field:i})),filter:fn,placeholder:n("Select field")}),e.field?r.jsx(b.Select,{value:t,onChange:i=>{s(i),o(C(x({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:$("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}]}):null,t?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(e.offset),onChange:i=>o(C(x({},e),{offset:(i!=null?i:0)*t}))}),r.jsx(b.Select,{value:e.unit||864e5,onChange:i=>o(C(x({},e),{unit:i})),options:[{value:864e5,label:$("Days")},{value:36e5,label:$("Hours")},{value:6e4,label:$("Minutes")},{value:1e3,label:$("Seconds")}]})]}):null]})}function hn({value:e,onChange:o}){const{t:n}=vo(),t=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:l.css`
|
|
404
404
|
display: flex;
|
|
405
405
|
gap: 0.5em;
|
|
406
|
-
`,children:[r.jsxs(b.Select,{value:t,onChange:s=>{o(s?s==="field"?{}:new Date:null)},children:[r.jsx(b.Select.Option,{value:null,children:n("No end")}),r.jsx(b.Select.Option,{value:"field",children:n("By field")}),r.jsx(b.Select.Option,{value:"date",children:n("By custom date")})]}),t==="field"?r.jsx(Ho,{value:e,onChange:o}):null,t==="date"?r.jsx(b.DatePicker,{showTime:!0,value:zo(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var ie=function(){return ie=Object.assign||function(e){for(var o,n=1,t=arguments.length;n<t;n++)for(var s in o=arguments[n])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},ie.apply(this,arguments)};function Yo(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(t=Object.getOwnPropertySymbols(e);s<t.length;s++)o.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(e,t[s])&&(n[t[s]]=e[t[s]])}return n}function eo(e,o,n){if(n||arguments.length===2)for(var t,s=0,i=o.length;s<i;s++)!t&&s in o||(t||(t=Array.prototype.slice.call(o,0,s)),t[s]=o[s]);return e.concat(t||Array.prototype.slice.call(o))}var gn=[{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"]}],V={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 _o(e,o){for(var n=[],t=e;t<=o;t++)n.push(t);return n}function oo(e){return e.sort(function(o,n){return o-n}),e}function Ko(e){var o=[];return e.forEach(function(n){o.indexOf(n)<0&&o.push(n)}),o}function de(e){return Object.entries(e).filter(function(o){var n=o[0],t=o[1];return n&&t}).map(function(o){return o[0]}).join(" ")}function Zo(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||V.errorInvalidCron})}function to(e){var o=parseInt(e,10),n=Number(e);return o===n?n:NaN}function Qo(e,o,n,t,s,i,a,c,d,p,f,x,v,h){n&&n(void 0),o(!1);var m=!1;if(!e){if(t==="always"||i&&t==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var S=gn.find(function(w){return w.name===e});S&&(e=S.value)}try{var F=function(w){if(typeof w!="string")throw new Error("Invalid cron string");var $=w.replace(/\s+/g," ").trim().split(" ");if($.length===5)return $.map(function(P,B){return function(L,E){if(L==="*"||L==="*/1")return[];var N=oo(Ko(ot(function(G,J,Y){if(Y){G=G.toUpperCase();for(var M=0;M<Y.length;M++)G=G.replace(Y[M],"".concat(M+J))}return G}(L,E.min,E.alt).split(",").map(function(G){var J,Y=G.split("/");if(Y.length>2)throw new Error('Invalid value "'.concat(L,' for "').concat(E.type,'"'));var M=Y[0],j=Y[1];J=M==="*"?_o(E.min,E.max):function(_,Q,ne){var re=_.split("-");if(re.length===1){var Ye=to(re[0]);if(isNaN(Ye))throw new Error('Invalid value "'.concat(Q,'" for ').concat(ne.type));return[Ye]}if(re.length===2){var he=to(re[0]),Be=to(re[1]);if(isNaN(he)||isNaN(Be))throw new Error('Invalid value "'.concat(Q,'" for ').concat(ne.type));if(Be<he)throw new Error('Max range is less than min range in "'.concat(_,'" for ').concat(ne.type));return _o(he,Be)}throw new Error('Invalid value "'.concat(_,'" for ').concat(ne.type))}(M,L,E);var W=function(_,Q){if(_!==void 0){var ne=to(_);if(isNaN(ne)||ne<1)throw new Error('Invalid interval step value "'.concat(_,'" for ').concat(Q.type));return ne}}(j,E),le=function(_,Q){if(Q){var ne=_[0];_=_.filter(function(re){return re%Q==ne%Q||re===ne})}return _}(J,W);return le}).flat(),E))),I=tt(N,E);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(E.type));return N.length===E.total?[]:N}(P,Ae[B])});throw new Error("Invalid cron string format")}(e),A=function(w){return w[3].length>0?"year":w[2].length>0?"month":w[4].length>0?"week":w[1].length>0?"day":w[0].length>0?"hour":"minute"}(F);h(A),d(F[0]),p(F[1]),f(F[2]),x(F[3]),v(F[4])}catch(w){m=!0}}m&&(s.current=e,o(!0),Zo(n,a))}function Xo(e,o,n,t,s,i,a){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(f,x){var v=Ae[x];return Ro(et(f,v),v,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!n?[]:n,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!t?[]:t],a);return c.join(" ")}function Ro(e,o,n,t,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,o)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=a&&function(c,d){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==d)return!1}return!0}(e,a)?function(c,d,p){var f=nt(c),x=rt(c),v=c.length===(x-f)/p+1;return!!(f===d.min&&x+p>d.max&&v)}(e,o,a)?"*/".concat(a):"".concat(Ne(nt(e),o,n,t,s),"-").concat(Ne(rt(e),o,n,t,s),"/").concat(a):function(c){var d=[],p=null;return c.forEach(function(f,x,v){f!==v[x+1]-1?p!==null?(d.push([p,f]),p=null):d.push(f):p===null&&(p=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ne(c[0],o,n,t,s),"-").concat(Ne(c[1],o,n,t,s)):Ne(c,o,n,t,s)}).join(",")}return i}function Ne(e,o,n,t,s){var i=e.toString(),a=o.type,c=o.alt,d=o.min,p=t&&(t===!0||t.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(n&&a==="week-days"||n&&a==="months"?i=c[e-d]:e<10&&(p||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var x=e>=12?"PM":"AM",v=e%12||12;v<10&&p&&(v=v.toString().padStart(2,"0")),i="".concat(v).concat(x)}return i}function et(e,o){var n=oo(Ko(ot(e,o)));if(n.length===0)return n;var t=tt(n,o);if(t!==void 0)throw new Error('Value "'.concat(t,'" out of range for ').concat(o.type));return n}function ot(e,o){return o.type==="week-days"&&(e=e.map(function(n){return n===7?0:n})),e}function tt(e,o){var n=e[0],t=e[e.length-1];return n<o.min?n:t>o.max?t:void 0}function nt(e){return e[0]}function rt(e){return e[e.length-1]}function Ue(e){var o=e.value,n=e.grid,t=n===void 0||n,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,f=e.readOnly,x=e.leadingZero,v=e.clockFormat,h=e.period,m=e.unit,S=e.periodicityOnDoubleClick,F=e.mode,A=Yo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),w=y.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(M){return M.toString()})},[o]),$=y.useMemo(function(){return s?s.map(function(M,j){return{value:(m.min===0?j:j+1).toString(),label:M}}):eo([],Array(m.total),!0).map(function(M,j){var W=m.min===0?j:j+1;return{value:W.toString(),label:Ne(W,m,d,x,v)}})},[s,x,d,v]),P=JSON.stringify(a),B=y.useCallback(function(M){var j=M.value;if(!o||o[0]!==Number(j))return r.jsx(r.Fragment,{});var W=Ro(et(o,m),m,d,x,v),le=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:le[1]?"".concat(a.everyText||V.everyText," ").concat(le[1]):W})},[o,P,d,x,v]),L=y.useCallback(function(M){var j=Array.isArray(M)?oo(M):[M],W=j;o&&(W=F==="single"?[]:eo([],o,!0),j.forEach(function(le){var _=Number(le);W=o.some(function(Q){return Q===_})?W.filter(function(Q){return Q!==_}):oo(eo(eo([],W,!0),[_],!1))})),W.length===m.total?i([]):i(W)},[i,o]),E=y.useCallback(function(M){if(M!==0&&M!==1){for(var j=m.total+m.min,W=[],le=m.min;le<j;le++)le%M==0&&W.push(le);var _=o&&W&&o.length===W.length&&o.every(function(ne,re){return ne===W[re]}),Q=W.length===$.length;i(Q||_?[]:W)}else i([])},[o,$,i]),N=y.useRef([]),I=y.useCallback(function(M){if(!f){var j=N.current;j.push({time:new Date().getTime(),value:Number(M)});var W=window.setTimeout(function(){S&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?E(Number(M)):L([j[j.length-2].value,j[j.length-1].value]):L(Number(M)),N.current=[]},300);return function(){window.clearTimeout(W)}}},[N,L,E,f,S]),G=y.useCallback(function(){f||i([])},[i,f]),J=y.useMemo(function(){var M;return de(((M={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,M))},[c]),Y=y.useMemo(function(){var M;return de(((M={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,M["react-js-cron-custom-select-dropdown"]=!0,M["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,M["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",M["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),M["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",M["react-js-cron-custom-select-dropdown-grid"]=!!t,M["".concat(c,"-select-dropdown")]=!!c,M["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,M))},[c,t,v,h]);return r.jsx(b.Select,ie({mode:F!=="single"||S?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:w,onClear:G,tagRender:B,className:J,popupClassName:Y,options:$,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},A))}function xn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[t.prefixHours!==""&&r.jsx("span",{children:t.prefixHours||V.prefixHours}),r.jsx(Ue,{placeholder:t.emptyHours||V.emptyHours,value:o,unit:Ae[1],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x})]}))}function bn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[p==="hour"?t.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):t.prefixMinutes!==""&&r.jsx("span",{children:t.prefixMinutes||V.prefixMinutes}),r.jsx(Ue,{placeholder:p==="hour"?t.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:t.emptyMinutes||V.emptyMinutes,value:o,unit:Ae[0],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x}),p==="hour"&&t.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function vn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=!i||i.length===0,h=y.useMemo(function(){var F;return de(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),m=JSON.stringify(t),S=y.useMemo(function(){return v?t.emptyMonthDays||V.emptyMonthDays:t.emptyMonthDaysShort||V.emptyMonthDaysShort},[v,m]);return!c||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0)?r.jsxs("div",ie({className:h},{children:[t.prefixMonthDays!==""&&r.jsx("span",{children:t.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ue,{placeholder:S,value:o,setValue:n,unit:Ae[2],locale:t,className:s,disabled:a,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function Cn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,f=e.mode,x=t.months||V.months,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[t.prefixMonths!==""&&r.jsx("span",{children:t.prefixMonths||V.prefixMonths}),r.jsx(Ue,{placeholder:t.emptyMonths||V.emptyMonths,optionsList:x,grid:!1,value:o,unit:ie(ie({},Ae[3]),{alt:t.altMonths||V.altMonths}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:f})]}))}function wn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:t.yearOption||V.yearOption}),d.includes("month")&&p.push({value:"month",label:t.monthOption||V.monthOption}),d.includes("week")&&p.push({value:"week",label:t.weekOption||V.weekOption}),d.includes("day")&&p.push({value:"day",label:t.dayOption||V.dayOption}),d.includes("hour")&&p.push({value:"hour",label:t.hourOption||V.hourOption}),d.includes("minute")&&p.push({value:"minute",label:t.minuteOption||V.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:t.rebootOption||V.rebootOption});var f=y.useCallback(function(m){a||n(m)},[n,a]),x=y.useMemo(function(){var m;return de(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=y.useMemo(function(){var m;return de(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":t.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,t.prefixPeriod]),h=y.useMemo(function(){var m;return de(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",ie({className:x},{children:[t.prefixPeriod!==""&&r.jsx("span",{children:t.prefixPeriod||V.prefixPeriod}),r.jsx(b.Select,{defaultValue:o,value:o,onChange:f,options:p,className:v,popupClassName:h,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(t))]}))}function kn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=t.weekDays||V.weekDays,h=p==="week"||!a||a.length===0,m=y.useMemo(function(){var $;return de((($={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,$["".concat(s,"-week-days")]=!!s,$))},[s,h]),S=JSON.stringify(t),F=y.useMemo(function(){return h?t.emptyWeekDays||V.emptyWeekDays:t.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,S]),A=p==="week"||!d||o&&o.length>0||(!o||o.length===0)&&(!a||a.length===0),w=!d||a&&a.length>0||(!a||a.length===0)&&(!o||o.length===0);return A?r.jsxs("div",ie({className:m},{children:[t.prefixWeekDays!==""&&(p==="week"||!w)&&r.jsx("span",{children:t.prefixWeekDays||V.prefixWeekDays}),t.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&w&&r.jsx("span",{children:t.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ue,{placeholder:F,optionsList:v,grid:!1,value:o,unit:ie(ie({},Ae[4]),{alt:t.altWeekDays||V.altWeekDays}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function Sn(e){var o=e.clearButton,n=o===void 0||o,t=e.clearButtonProps,s=t===void 0?{}:t,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?V:c,p=e.value,f=p===void 0?"":p,x=e.setValue,v=e.displayError,h=v===void 0||v,m=e.onError,S=e.className,F=e.defaultPeriod,A=F===void 0?"day":F,w=e.allowEmpty,$=w===void 0?"for-default-value":w,P=e.humanizeLabels,B=P===void 0||P,L=e.humanizeValue,E=L!==void 0&&L,N=e.disabled,I=N!==void 0&&N,G=e.readOnly,J=G!==void 0&&G,Y=e.leadingZero,M=Y!==void 0&&Y,j=e.shortcuts,W=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,le=e.clockFormat,_=e.periodicityOnDoubleClick,Q=_===void 0||_,ne=e.mode,re=ne===void 0?"multiple":ne,Ye=e.allowedDropdowns,he=Ye===void 0?["period","months","month-days","week-days","hours","minutes"]:Ye,Be=e.allowedPeriods,ks=Be===void 0?["year","month","week","day","hour","minute","reboot"]:Be,Ve=y.useRef(f),Bo=y.useRef(A),zt=y.useState(),xe=zt[0],lo=zt[1],Wt=y.useState(),_e=Wt[0],ao=Wt[1],Ut=y.useState(),co=Ut[0],uo=Ut[1],qt=y.useState(),Ke=qt[0],po=qt[1],Gt=y.useState(),mo=Gt[0],fo=Gt[1],Jt=y.useState(),ho=Jt[0],yo=Jt[1],Ht=y.useState(!1),Vo=Ht[0],Ze=Ht[1],Yt=y.useState(!1),go=Yt[0],_t=Yt[1],Ss=function(X){var ye=y.useRef(X);return y.useEffect(function(){ye.current=X},[X]),ye.current}(go),Kt=JSON.stringify(d);y.useEffect(function(){Qo(f,Ze,m,$,Ve,!0,d,W,yo,fo,ao,uo,po,lo)},[]),y.useEffect(function(){f!==Ve.current&&Qo(f,Ze,m,$,Ve,!1,d,W,yo,fo,ao,uo,po,lo)},[f,Ve,Kt,$,W]),y.useEffect(function(){if(!(xe||ho||co||_e||Ke||mo)||go||Ss)go&&_t(!1);else{var X=xe||Bo.current,ye=Xo(X,co,_e,Ke,mo,ho,E);x(ye,{selectedPeriod:X}),Ve.current=ye,m&&m(void 0),Ze(!1)}},[xe,_e,co,Ke,mo,ho,E,go]);var Zt=y.useCallback(function(){ao(void 0),uo(void 0),po(void 0),fo(void 0),yo(void 0);var X="",ye=xe!=="reboot"&&xe?xe:Bo.current;ye!==xe&&lo(ye),a==="fill-with-every"&&(X=Xo(ye,void 0,void 0,void 0,void 0,void 0)),x(X,{selectedPeriod:ye}),Ve.current=X,_t(!0),$==="never"&&a==="empty"?(Ze(!0),Zo(m,d)):(m&&m(void 0),Ze(!1))},[xe,x,m,a]),Fs=y.useMemo(function(){var X;return de(((X={"react-js-cron":!0,"react-js-cron-error":Vo&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(S)]=!!S,X["".concat(S,"-error")]=Vo&&h&&!!S,X["".concat(S,"-disabled")]=I&&!!S,X["".concat(S,"-read-only")]=J&&!!S,X))},[S,Vo,h,I,J]),jo=s.className,Qt=Yo(s,["className"]),Xt=y.useMemo(function(){var X;return de(((X={"react-js-cron-clear-button":!0})["".concat(S,"-clear-button")]=!!S,X["".concat(jo)]=!!jo,X))},[S,jo]),As=JSON.stringify(Qt),Rt=y.useMemo(function(){return n&&!J?r.jsx(b.Button,ie({className:Xt,danger:!0,type:"primary",disabled:I},Qt,{onClick:Zt},{children:d.clearButtonText||V.clearButtonText})):null},[n,J,Kt,Xt,I,As,Zt]),se=xe||Bo.current;return r.jsxs("div",ie({className:Fs},{children:[he.includes("period")&&r.jsx(wn,{value:se,setValue:lo,locale:d,className:S,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:ks}),se==="reboot"?Rt:r.jsxs(r.Fragment,{children:[se==="year"&&he.includes("months")&&r.jsx(Cn,{value:co,setValue:uo,locale:d,className:S,humanizeLabels:B,disabled:I,readOnly:J,period:se,periodicityOnDoubleClick:Q,mode:re}),(se==="year"||se==="month")&&he.includes("month-days")&&r.jsx(vn,{value:_e,setValue:ao,locale:d,className:S,weekDays:Ke,disabled:I,readOnly:J,leadingZero:M,period:se,periodicityOnDoubleClick:Q,mode:re}),(se==="year"||se==="month"||se==="week")&&he.includes("week-days")&&r.jsx(kn,{value:Ke,setValue:po,locale:d,className:S,humanizeLabels:B,monthDays:_e,disabled:I,readOnly:J,period:se,periodicityOnDoubleClick:Q,mode:re}),r.jsxs("div",{children:[se!=="minute"&&se!=="hour"&&he.includes("hours")&&r.jsx(xn,{value:mo,setValue:fo,locale:d,className:S,disabled:I,readOnly:J,leadingZero:M,clockFormat:le,period:se,periodicityOnDoubleClick:Q,mode:re}),se!=="minute"&&he.includes("minutes")&&r.jsx(bn,{value:ho,setValue:yo,locale:d,period:se,className:S,disabled:I,readOnly:J,leadingZero:M,clockFormat:le,periodicityOnDoubleClick:Q,mode:re}),Rt]})]})]}))}const Fn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},st=[{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 it(e){return st.filter(n=>typeof n.value=="number").reverse().find(n=>!(e%n.value))}function An(e){let o;switch(typeof e){case"number":return o=it(e),o?o.value:"none";case"string":return"cron"}return"none"}function On({value:e,onChange:o}){const{t:n}=vo(),t=it(e);return r.jsx(b.InputNumber,{value:e/t.value,onChange:s=>o(s*t.value),min:1,addonBefore:n("Every"),addonAfter:n(t.unitText),className:"auto-width"})}function Tn({value:e=null,onChange:o}){const{t:n}=vo(),t=An(e);function s(a){if(a==="none"){o(null);return}if(a==="cron"){o("0 * * * * *");return}o(a)}const i=Fn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:l.css`
|
|
406
|
+
`,children:[r.jsxs(b.Select,{value:t,onChange:s=>{o(s?s==="field"?{}:new Date:null)},children:[r.jsx(b.Select.Option,{value:null,children:n("No end")}),r.jsx(b.Select.Option,{value:"field",children:n("By field")}),r.jsx(b.Select.Option,{value:"date",children:n("By custom date")})]}),t==="field"?r.jsx(Ho,{value:e,onChange:o}):null,t==="date"?r.jsx(b.DatePicker,{showTime:!0,value:zo(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var se=function(){return se=Object.assign||function(e){for(var o,n=1,t=arguments.length;n<t;n++)for(var s in o=arguments[n])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},se.apply(this,arguments)};function Go(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(t=Object.getOwnPropertySymbols(e);s<t.length;s++)o.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(e,t[s])&&(n[t[s]]=e[t[s]])}return n}function eo(e,o,n){if(n||arguments.length===2)for(var t,s=0,i=o.length;s<i;s++)!t&&s in o||(t||(t=Array.prototype.slice.call(o,0,s)),t[s]=o[s]);return e.concat(t||Array.prototype.slice.call(o))}var yn=[{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"]}],V={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 _o(e,o){for(var n=[],t=e;t<=o;t++)n.push(t);return n}function oo(e){return e.sort(function(o,n){return o-n}),e}function Yo(e){var o=[];return e.forEach(function(n){o.indexOf(n)<0&&o.push(n)}),o}function de(e){return Object.entries(e).filter(function(o){var n=o[0],t=o[1];return n&&t}).map(function(o){return o[0]}).join(" ")}function Ko(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||V.errorInvalidCron})}function to(e){var o=parseInt(e,10),n=Number(e);return o===n?n:NaN}function Zo(e,o,n,t,s,i,a,c,d,p,f,g,v,h){n&&n(void 0),o(!1);var m=!1;if(!e){if(t==="always"||i&&t==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=yn.find(function(w){return w.name===e});k&&(e=k.value)}try{var F=function(w){if(typeof w!="string")throw new Error("Invalid cron string");var T=w.replace(/\s+/g," ").trim().split(" ");if(T.length===5)return T.map(function(P,B){return function(z,M){if(z==="*"||z==="*/1")return[];var N=oo(Yo(et(function(J,H,_){if(_){J=J.toUpperCase();for(var E=0;E<_.length;E++)J=J.replace(_[E],"".concat(E+H))}return J}(z,M.min,M.alt).split(",").map(function(J){var H,_=J.split("/");if(_.length>2)throw new Error('Invalid value "'.concat(z,' for "').concat(M.type,'"'));var E=_[0],j=_[1];H=E==="*"?_o(M.min,M.max):function(Y,Z,te){var ne=Y.split("-");if(ne.length===1){var _e=to(ne[0]);if(isNaN(_e))throw new Error('Invalid value "'.concat(Z,'" for ').concat(te.type));return[_e]}if(ne.length===2){var ye=to(ne[0]),Be=to(ne[1]);if(isNaN(ye)||isNaN(Be))throw new Error('Invalid value "'.concat(Z,'" for ').concat(te.type));if(Be<ye)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(te.type));return _o(ye,Be)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(te.type))}(E,z,M);var L=function(Y,Z){if(Y!==void 0){var te=to(Y);if(isNaN(te)||te<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(Z.type));return te}}(j,M),ie=function(Y,Z){if(Z){var te=Y[0];Y=Y.filter(function(ne){return ne%Z==te%Z||ne===te})}return Y}(H,L);return ie}).flat(),M))),D=ot(N,M);if(D!==void 0)throw new Error('Value "'.concat(D,'" out of range for ').concat(M.type));return N.length===M.total?[]:N}(P,Ae[B])});throw new Error("Invalid cron string format")}(e),O=function(w){return w[3].length>0?"year":w[2].length>0?"month":w[4].length>0?"week":w[1].length>0?"day":w[0].length>0?"hour":"minute"}(F);h(O),d(F[0]),p(F[1]),f(F[2]),g(F[3]),v(F[4])}catch(w){m=!0}}m&&(s.current=e,o(!0),Ko(n,a))}function Qo(e,o,n,t,s,i,a){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(f,g){var v=Ae[g];return Xo(Ro(f,v),v,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!n?[]:n,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!t?[]:t],a);return c.join(" ")}function Xo(e,o,n,t,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,o)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=a&&function(c,d){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==d)return!1}return!0}(e,a)?function(c,d,p){var f=tt(c),g=nt(c),v=c.length===(g-f)/p+1;return!!(f===d.min&&g+p>d.max&&v)}(e,o,a)?"*/".concat(a):"".concat(Ne(tt(e),o,n,t,s),"-").concat(Ne(nt(e),o,n,t,s),"/").concat(a):function(c){var d=[],p=null;return c.forEach(function(f,g,v){f!==v[g+1]-1?p!==null?(d.push([p,f]),p=null):d.push(f):p===null&&(p=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ne(c[0],o,n,t,s),"-").concat(Ne(c[1],o,n,t,s)):Ne(c,o,n,t,s)}).join(",")}return i}function Ne(e,o,n,t,s){var i=e.toString(),a=o.type,c=o.alt,d=o.min,p=t&&(t===!0||t.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(n&&a==="week-days"||n&&a==="months"?i=c[e-d]:e<10&&(p||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var g=e>=12?"PM":"AM",v=e%12||12;v<10&&p&&(v=v.toString().padStart(2,"0")),i="".concat(v).concat(g)}return i}function Ro(e,o){var n=oo(Yo(et(e,o)));if(n.length===0)return n;var t=ot(n,o);if(t!==void 0)throw new Error('Value "'.concat(t,'" out of range for ').concat(o.type));return n}function et(e,o){return o.type==="week-days"&&(e=e.map(function(n){return n===7?0:n})),e}function ot(e,o){var n=e[0],t=e[e.length-1];return n<o.min?n:t>o.max?t:void 0}function tt(e){return e[0]}function nt(e){return e[e.length-1]}function Ue(e){var o=e.value,n=e.grid,t=n===void 0||n,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,f=e.readOnly,g=e.leadingZero,v=e.clockFormat,h=e.period,m=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,O=Go(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),w=y.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(E){return E.toString()})},[o]),T=y.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):eo([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Ne(L,m,d,g,v)}})},[s,g,d,v]),P=JSON.stringify(a),B=y.useCallback(function(E){var j=E.value;if(!o||o[0]!==Number(j))return r.jsx(r.Fragment,{});var L=Xo(Ro(o,m),m,d,g,v),ie=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ie[1]?"".concat(a.everyText||V.everyText," ").concat(ie[1]):L})},[o,P,d,g,v]),z=y.useCallback(function(E){var j=Array.isArray(E)?oo(E):[E],L=j;o&&(L=F==="single"?[]:eo([],o,!0),j.forEach(function(ie){var Y=Number(ie);L=o.some(function(Z){return Z===Y})?L.filter(function(Z){return Z!==Y}):oo(eo(eo([],L,!0),[Y],!1))})),L.length===m.total?i([]):i(L)},[i,o]),M=y.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ie=m.min;ie<j;ie++)ie%E==0&&L.push(ie);var Y=o&&L&&o.length===L.length&&o.every(function(te,ne){return te===L[ne]}),Z=L.length===T.length;i(Z||Y?[]:L)}else i([])},[o,T,i]),N=y.useRef([]),D=y.useCallback(function(E){if(!f){var j=N.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){k&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?M(Number(E)):z([j[j.length-2].value,j[j.length-1].value]):z(Number(E)),N.current=[]},300);return function(){window.clearTimeout(L)}}},[N,z,M,f,k]),J=y.useCallback(function(){f||i([])},[i,f]),H=y.useMemo(function(){var E;return de(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),_=y.useMemo(function(){var E;return de(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!t,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,t,v,h]);return r.jsx(b.Select,se({mode:F!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:w,onClear:J,tagRender:B,className:H,popupClassName:_,options:T,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:D,onDeselect:D,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},O))}function gn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[t.prefixHours!==""&&r.jsx("span",{children:t.prefixHours||V.prefixHours}),r.jsx(Ue,{placeholder:t.emptyHours||V.emptyHours,value:o,unit:Ae[1],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:g})]}))}function xn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[p==="hour"?t.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):t.prefixMinutes!==""&&r.jsx("span",{children:t.prefixMinutes||V.prefixMinutes}),r.jsx(Ue,{placeholder:p==="hour"?t.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:t.emptyMinutes||V.emptyMinutes,value:o,unit:Ae[0],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:g}),p==="hour"&&t.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function bn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=!i||i.length===0,h=y.useMemo(function(){var F;return de(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),m=JSON.stringify(t),k=y.useMemo(function(){return v?t.emptyMonthDays||V.emptyMonthDays:t.emptyMonthDaysShort||V.emptyMonthDaysShort},[v,m]);return!c||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0)?r.jsxs("div",se({className:h},{children:[t.prefixMonthDays!==""&&r.jsx("span",{children:t.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ue,{placeholder:k,value:o,setValue:n,unit:Ae[2],locale:t,className:s,disabled:a,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function vn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,f=e.mode,g=t.months||V.months,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",se({className:v},{children:[t.prefixMonths!==""&&r.jsx("span",{children:t.prefixMonths||V.prefixMonths}),r.jsx(Ue,{placeholder:t.emptyMonths||V.emptyMonths,optionsList:g,grid:!1,value:o,unit:se(se({},Ae[3]),{alt:t.altMonths||V.altMonths}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:f})]}))}function Cn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:t.yearOption||V.yearOption}),d.includes("month")&&p.push({value:"month",label:t.monthOption||V.monthOption}),d.includes("week")&&p.push({value:"week",label:t.weekOption||V.weekOption}),d.includes("day")&&p.push({value:"day",label:t.dayOption||V.dayOption}),d.includes("hour")&&p.push({value:"hour",label:t.hourOption||V.hourOption}),d.includes("minute")&&p.push({value:"minute",label:t.minuteOption||V.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:t.rebootOption||V.rebootOption});var f=y.useCallback(function(m){a||n(m)},[n,a]),g=y.useMemo(function(){var m;return de(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=y.useMemo(function(){var m;return de(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":t.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,t.prefixPeriod]),h=y.useMemo(function(){var m;return de(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",se({className:g},{children:[t.prefixPeriod!==""&&r.jsx("span",{children:t.prefixPeriod||V.prefixPeriod}),r.jsx(b.Select,{defaultValue:o,value:o,onChange:f,options:p,className:v,popupClassName:h,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(t))]}))}function wn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,v=t.weekDays||V.weekDays,h=p==="week"||!a||a.length===0,m=y.useMemo(function(){var T;return de(((T={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,T["".concat(s,"-week-days")]=!!s,T))},[s,h]),k=JSON.stringify(t),F=y.useMemo(function(){return h?t.emptyWeekDays||V.emptyWeekDays:t.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,k]),O=p==="week"||!d||o&&o.length>0||(!o||o.length===0)&&(!a||a.length===0),w=!d||a&&a.length>0||(!a||a.length===0)&&(!o||o.length===0);return O?r.jsxs("div",se({className:m},{children:[t.prefixWeekDays!==""&&(p==="week"||!w)&&r.jsx("span",{children:t.prefixWeekDays||V.prefixWeekDays}),t.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&w&&r.jsx("span",{children:t.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ue,{placeholder:F,optionsList:v,grid:!1,value:o,unit:se(se({},Ae[4]),{alt:t.altWeekDays||V.altWeekDays}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function kn(e){var o=e.clearButton,n=o===void 0||o,t=e.clearButtonProps,s=t===void 0?{}:t,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?V:c,p=e.value,f=p===void 0?"":p,g=e.setValue,v=e.displayError,h=v===void 0||v,m=e.onError,k=e.className,F=e.defaultPeriod,O=F===void 0?"day":F,w=e.allowEmpty,T=w===void 0?"for-default-value":w,P=e.humanizeLabels,B=P===void 0||P,z=e.humanizeValue,M=z!==void 0&&z,N=e.disabled,D=N!==void 0&&N,J=e.readOnly,H=J!==void 0&&J,_=e.leadingZero,E=_!==void 0&&_,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ie=e.clockFormat,Y=e.periodicityOnDoubleClick,Z=Y===void 0||Y,te=e.mode,ne=te===void 0?"multiple":te,_e=e.allowedDropdowns,ye=_e===void 0?["period","months","month-days","week-days","hours","minutes"]:_e,Be=e.allowedPeriods,ks=Be===void 0?["year","month","week","day","hour","minute","reboot"]:Be,Ve=y.useRef(f),Po=y.useRef(O),zt=y.useState(),xe=zt[0],lo=zt[1],Lt=y.useState(),Ye=Lt[0],ao=Lt[1],Wt=y.useState(),co=Wt[0],uo=Wt[1],Ut=y.useState(),Ke=Ut[0],po=Ut[1],qt=y.useState(),mo=qt[0],fo=qt[1],Jt=y.useState(),ho=Jt[0],yo=Jt[1],Ht=y.useState(!1),Bo=Ht[0],Ze=Ht[1],Gt=y.useState(!1),go=Gt[0],_t=Gt[1],Ss=function(Q){var ge=y.useRef(Q);return y.useEffect(function(){ge.current=Q},[Q]),ge.current}(go),Yt=JSON.stringify(d);y.useEffect(function(){Zo(f,Ze,m,T,Ve,!0,d,L,yo,fo,ao,uo,po,lo)},[]),y.useEffect(function(){f!==Ve.current&&Zo(f,Ze,m,T,Ve,!1,d,L,yo,fo,ao,uo,po,lo)},[f,Ve,Yt,T,L]),y.useEffect(function(){if(!(xe||ho||co||Ye||Ke||mo)||go||Ss)go&&_t(!1);else{var Q=xe||Po.current,ge=Qo(Q,co,Ye,Ke,mo,ho,M);g(ge,{selectedPeriod:Q}),Ve.current=ge,m&&m(void 0),Ze(!1)}},[xe,Ye,co,Ke,mo,ho,M,go]);var Kt=y.useCallback(function(){ao(void 0),uo(void 0),po(void 0),fo(void 0),yo(void 0);var Q="",ge=xe!=="reboot"&&xe?xe:Po.current;ge!==xe&&lo(ge),a==="fill-with-every"&&(Q=Qo(ge,void 0,void 0,void 0,void 0,void 0)),g(Q,{selectedPeriod:ge}),Ve.current=Q,_t(!0),T==="never"&&a==="empty"?(Ze(!0),Ko(m,d)):(m&&m(void 0),Ze(!1))},[xe,g,m,a]),Fs=y.useMemo(function(){var Q;return de(((Q={"react-js-cron":!0,"react-js-cron-error":Bo&&h,"react-js-cron-disabled":D,"react-js-cron-read-only":H})["".concat(k)]=!!k,Q["".concat(k,"-error")]=Bo&&h&&!!k,Q["".concat(k,"-disabled")]=D&&!!k,Q["".concat(k,"-read-only")]=H&&!!k,Q))},[k,Bo,h,D,H]),Vo=s.className,Zt=Go(s,["className"]),Qt=y.useMemo(function(){var Q;return de(((Q={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,Q["".concat(Vo)]=!!Vo,Q))},[k,Vo]),As=JSON.stringify(Zt),Xt=y.useMemo(function(){return n&&!H?r.jsx(b.Button,se({className:Qt,danger:!0,type:"primary",disabled:D},Zt,{onClick:Kt},{children:d.clearButtonText||V.clearButtonText})):null},[n,H,Yt,Qt,D,As,Kt]),re=xe||Po.current;return r.jsxs("div",se({className:Fs},{children:[ye.includes("period")&&r.jsx(Cn,{value:re,setValue:lo,locale:d,className:k,disabled:D,readOnly:H,shortcuts:L,allowedPeriods:ks}),re==="reboot"?Xt:r.jsxs(r.Fragment,{children:[re==="year"&&ye.includes("months")&&r.jsx(vn,{value:co,setValue:uo,locale:d,className:k,humanizeLabels:B,disabled:D,readOnly:H,period:re,periodicityOnDoubleClick:Z,mode:ne}),(re==="year"||re==="month")&&ye.includes("month-days")&&r.jsx(bn,{value:Ye,setValue:ao,locale:d,className:k,weekDays:Ke,disabled:D,readOnly:H,leadingZero:E,period:re,periodicityOnDoubleClick:Z,mode:ne}),(re==="year"||re==="month"||re==="week")&&ye.includes("week-days")&&r.jsx(wn,{value:Ke,setValue:po,locale:d,className:k,humanizeLabels:B,monthDays:Ye,disabled:D,readOnly:H,period:re,periodicityOnDoubleClick:Z,mode:ne}),r.jsxs("div",{children:[re!=="minute"&&re!=="hour"&&ye.includes("hours")&&r.jsx(gn,{value:mo,setValue:fo,locale:d,className:k,disabled:D,readOnly:H,leadingZero:E,clockFormat:ie,period:re,periodicityOnDoubleClick:Z,mode:ne}),re!=="minute"&&ye.includes("minutes")&&r.jsx(xn,{value:ho,setValue:yo,locale:d,period:re,className:k,disabled:D,readOnly:H,leadingZero:E,clockFormat:ie,periodicityOnDoubleClick:Z,mode:ne}),Xt]})]})]}))}const Sn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},rt=[{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 st(e){return rt.filter(n=>typeof n.value=="number").reverse().find(n=>!(e%n.value))}function Fn(e){let o;switch(typeof e){case"number":return o=st(e),o?o.value:"none";case"string":return"cron"}return"none"}function An({value:e,onChange:o}){const{t:n}=vo(),t=st(e);return r.jsx(b.InputNumber,{value:e/t.value,onChange:s=>o(s*t.value),min:1,addonBefore:n("Every"),addonAfter:n(t.unitText),className:"auto-width"})}function On({value:e=null,onChange:o}){const{t:n}=vo(),t=Fn(e);function s(a){if(a==="none"){o(null);return}if(a==="cron"){o("0 * * * * *");return}o(a)}const i=Sn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:l.css`
|
|
407
407
|
display: flex;
|
|
408
408
|
flex-direction: ${t==="cron"?"column":"row"};
|
|
409
409
|
align-items: flex-start;
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
`,children:[r.jsx(b.Select,{value:t,onChange:s,className:"auto-width",children:
|
|
435
|
+
`,children:[r.jsx(b.Select,{value:t,onChange:s,className:"auto-width",children:rt.map(a=>r.jsx(b.Select.Option,{value:a.value,children:n(a.text)},a.value))}),typeof t=="number"?r.jsx(An,{value:e,onChange:o}):null,t==="cron"?r.jsx(kn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:a=>o(`0 ${a}`),clearButton:!1,locale:i}):null]})}const In={[Fe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${u}" })}}`,"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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}}},[Fe.COLLECTION_FIELD]:{collection:C(x({},ae),{"x-reactions":[...ae["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${u}" })}}`,"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: "${u}" })}}`,"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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}},appends:C(x({},$e),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Fe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Tn=[{value:Fe.STATIC,label:`{{t("Based on certain date", { ns: "${u}" })}}`},{value:Fe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${u}" })}}`}],$n=()=>{const{values:e={},clearFormGraph:o}=A.useForm(),[n,t]=y.useState(e.mode);return A.useFormEffects(()=>{le.onFieldValueChange("mode",s=>{t(s.value),o("collection"),o("startsOn"),o("repeat"),o("endsOn"),o("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${u}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Tn},required:!0,default:Fe.STATIC}}),r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${n}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
436
436
|
.ant-input-number {
|
|
437
437
|
width: auto;
|
|
438
438
|
min-width: 6em;
|
|
@@ -441,37 +441,37 @@
|
|
|
441
441
|
.ant-picker {
|
|
442
442
|
width: auto;
|
|
443
443
|
}
|
|
444
|
-
`},properties
|
|
444
|
+
`},properties:In[n]}}},components:{OnField:Ho,RepeatField:On,EndsByField:hn}})]})},it={title:`{{t("Schedule event", { ns: "${u}" })}}`,type:"schedule",description:`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${u}" })}}`,fieldset:{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{ScheduleConfig:$n},useVariables(e,o){var i;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&s.push({key:"date",value:"date",label:$("Trigger time")}),e.mode===Fe.COLLECTION_FIELD){const[a]=he(C(x({appends:["data",...((i=e.appends)==null?void 0:i.map(c=>`data.${c}`))||[]]},o),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:$("Trigger data")}}],compile:n,getCollectionFields:t}));a&&s.push(a)}return s},useInitializers(e){return e.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Ie,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Dn(){var i;const e=A.useForm(),o=l.useAPIClient(),{workflow:n}=(i=U())!=null?i:{},t=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return G(this,null,function*(){var c,d;if(n.executed){b.message.error($("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("workflows")).update)==null?void 0:d.call(c,{filterByTk:n.id,values:{config:e.values}}),t.setFormValueChanged(!1),t.setVisible(!1),s()})}}}const me=new K.Registry;me.register(Jo.type,Jo),me.register(qo.type,qo),me.register(it.type,it);function Nn(){const e=l.useCompile(),{workflow:o,execution:n}=U(),{styles:t}=oe();if(!n)return null;const s=me.get(o.type);return r.jsx(l.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(I.InfoOutlined,{}),shape:"circle",size:"small",className:t.nodeJobButtonClass,type:"primary"},properties:{[n.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:n},"x-component":"Action.Modal",title:r.jsxs("div",{className:l.cx(t.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(s.title)}),r.jsx("strong",{children:o.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",n.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
|
|
445
445
|
padding: 1em;
|
|
446
446
|
background-color: #eee;
|
|
447
|
-
`},"x-read-pretty":!0}}}}}})}function Mn(){return{form:
|
|
447
|
+
`},"x-read-pretty":!0}}}}}})}function Mn(){return{form:A.useForm()}}const En=()=>{const e=l.useAPIClient(),{workflow:o,refresh:n}=U(),[t,s]=y.useState(""),[i,a]=y.useState(!1),[c,d]=y.useState(!1),{styles:p}=oe(),f=l.useCompile(),{title:g,type:v,executed:h}=o,m=me.get(v),k=f(m.title),{fieldset:F,scope:O,components:w}=m,T=h?'{{t("View")}}':'{{t("Configure")}}',P=$("Trigger");y.useEffect(()=>{var D;o&&s((D=o.title)!=null?D:k)},[o]);const B=y.useMemo(()=>{const D=fe.cloneDeep(o==null?void 0:o.config);return le.createForm({initialValues:D,disabled:o==null?void 0:o.executed})},[o]),z=y.useCallback(D=>{a(D),D||B.reset()},[B]),M=y.useCallback(function(D){return G(this,null,function*(){var H,_;const J=D||k;s(J),J!==g&&(yield(_=(H=e.resource("workflows")).update)==null?void 0:_.call(H,{filterByTk:o.id,values:{title:J}}),n())})},[o]),N=y.useCallback(function(D){var H;if(D.target===D.currentTarget){a(!0);return}const J=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let _=D.target;_&&_!==D.currentTarget;_=_.parentNode)if(Array.from((H=_.classList)!=null?H:[]).some(E=>J.has(E))){a(!0),D.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${P}-${t}`,className:l.cx(p.nodeCardClass),onClick:N,children:[r.jsx("div",{className:l.cx(p.nodeMetaClass,"workflow-node-meta"),children:r.jsx(b.Tag,{color:"gold",children:P})}),r.jsx("div",{children:r.jsx(b.Input.TextArea,{value:t,onChange:D=>s(D.target.value),onBlur:D=>M(D.target.value),autoSize:!0})}),r.jsx(Nn,{}),r.jsx(l.ActionContextProvider,{value:{visible:i,setVisible:z,formValueChanged:c,setFormValueChanged:d},children:r.jsx(l.FormProvider,{form:B,children:r.jsx(l.SchemaComponent,{scope:C(x({},O),{useFormProviderProps:Mn}),components:w,schema:{name:`workflow-trigger-${o.id}`,type:"void",properties:{config:{type:"void","x-content":T,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:P,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:C(x({},m.description?{description:{type:"void","x-component":Lo,"x-component-props":{label:$("Trigger type"),title:m.title,description:m.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
448
448
|
.ant-select.auto-width {
|
|
449
449
|
width: auto;
|
|
450
450
|
min-width: 6em;
|
|
451
451
|
}
|
|
452
|
-
`},properties:F},actions:
|
|
452
|
+
`},properties:F},actions:x({},h?{}:{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:Dn}}}})})}}}})})})]})};function lt(){const{workflow:e}=U();return me.get(e.type)}function So(){return Array.from(me.getEntities()).map(t=>{var[e,s]=t,i=s,{title:o}=i,n=W(i,["title"]);return{value:e,label:o,color:"gold",options:n}})}const Ce={label:"label",value:"value",children:"children"},no={label:`{{t("Node result", { ns: "${u}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const o=ke(),n=He(o),t=[];return n.forEach(s=>{var c;const i=q.get(s.type),a=(c=i.useVariables)==null?void 0:c.call(i,s,e);a&&t.push(a)}),t}},ro={label:`{{t("Trigger variables", { ns: "${u}" })}}`,value:"$context",useOptions(e){var t,s;const{workflow:o}=U(),n=me.get(o.type);return(s=(t=n==null?void 0:n.useVariables)==null?void 0:t.call(n,o.config,e))!=null?s:null}},Fo={label:`{{t("Scope variables", { ns: "${u}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:o=Ce,current:n}=e,t=ke(),s=n!=null?n:t,i=At(s),a=[];return i.forEach(c=>{var f,g;const d=q.get(c.type),p=(f=d.useScopeVariables)==null?void 0:f.call(d,c,e);p&&a.push({key:c.key,[o.value]:c.key,[o.label]:(g=c.title)!=null?g:`#${c.id}`,[o.children]:p})}),a}},at={label:`{{t("System variables", { ns: "${u}" })}}`,value:"$system",useOptions({types:e,fieldNames:o=Ce}){return[...!e||e.includes("date")?[{key:"now",[o.label]:$("System time"),[o.value]:"now"}]:[]]}},Me={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 ct(e,o){var t,s,i,a,c,d;const n=typeof o;return n==="string"?(t=Me[o])==null?void 0:t.has(e.interface):n==="object"&&o.type==="reference"?Ao(e)?((s=o.options)==null?void 0:s.entity)&&(e.collectionName===((i=o.options)==null?void 0:i.collection)||((a=o.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((c=o.options)==null?void 0:c.collection)&&e.name==="id"||e.target===((d=o.options)==null?void 0:d.collection):!1:n==="function"?o(e):!1}function Ao(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Oo(e,o){if(o==null)return null;const n=`${e.name}.`;return o.filter(t=>t.startsWith(n)).map(t=>t.replace(n,""))}function Io({fields:e,types:o,appends:n,depth:t=1,compile:s,getCollectionFields:i}){return e.filter(a=>{const c=o!=null&&o.length?o.some(d=>ct(a,d)):!0;if(Ao(a)){if(n===null)return t?c||Io({fields:To(a.target,{compile:s,getCollectionFields:i}),types:o,depth:t-1,appends:n,compile:s,getCollectionFields:i}):!1;const d=Oo(a,n),p=n.includes(a.name);return c?p:((d==null?void 0:d.length)||p)&&Io({fields:To(a.target,{compile:s,getCollectionFields:i}),types:o,appends:d,compile:s,getCollectionFields:i}).length}else return c})}function so(e,o){var i,a;const n=l.useCompile(),t=(a=(i=e.useOptions)==null?void 0:i.call(e,o))==null?void 0:a.filter(Boolean),{fieldNames:s}=o;return{[s.label]:n(e.label),[s.value]:e.value,key:e[s.value],[s.children]:t,disabled:!t||!t.length}}function ce(e={}){var s;const o=Object.assign({},Ce,(s=e.fieldNames)!=null?s:{}),n=Object.assign(e,{fieldNames:o});return[so(Fo,n),so(no,n),so(ro,n),so(at,n)]}function To(e,{compile:o,getCollectionFields:n}){var a,c,d,p,f,g,v;const t=n(e),s=[],i=[];t.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const m=i[h];if(m.type==="belongsTo"){const k=s.find(F=>F.name===m.foreignKey);k?i.splice(h,0,C(x(x({},m),k),{uiSchema:C(x({},m.uiSchema),{title:(a=m.uiSchema)!=null&&a.title?`${o((c=m.uiSchema)==null?void 0:c.title)} ID`:k.name})})):i.splice(h,0,C(x({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:C(x({},m.uiSchema),{title:(d=m.uiSchema)!=null&&d.title?`${o((p=m.uiSchema)==null?void 0:p.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const k=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};i.splice(h,0,C(x({},m),{type:m.dataType,interface:k.interface,uiSchema:C(x({},k.uiSchema),{title:(g=k.uiSchema)!=null&&g.title?`${o((v=k.uiSchema)==null?void 0:v.title)} ID`:m.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Pn(e){const o=Oo(e.field,e.appends),n=he(x({collection:e.field.target,types:e.types,appends:o,depth:e.depth-1},this));e.loadChildren=null,n.length?e.children=n:(e.isLeaf=!0,!e.types||e.types.some(s=>ct(e.field,s))||(e.disabled=!0))}function he(e){const{fields:o,collection:n,types:t,appends:s=[],depth:i=1,compile:a,getCollectionFields:c,fieldNames:d=Ce}=e,p=To(n,{compile:a,getCollectionFields:c}),f=o!=null?o:p,g=Pn.bind({compile:a,getCollectionFields:c,fieldNames:d});return Io({fields:f,types:t,depth:i,appends:s,compile:a,getCollectionFields:c}).map(h=>{var O;const m=a(((O=h.uiSchema)==null?void 0:O.title)||h.name),k=Oo(h,s),F=!Ao(h)||k&&!k.length&&!s.includes(h.name)||!1;return{[d.label]:m,key:h.name,[d.value]:h.name,isLeaf:F,loadChildren:F?null:g,field:h,depth:i,appends:s,types:t}})}function qe(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.Input,x({scope:s},o))}function dt(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.TextArea,x({scope:s},o))}function ut(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.RawTextArea,x({scope:s},o))}function pt(n){var t=n,{variableOptions:e}=t,o=W(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.JSON,x({scope:s},o))}function Je({value:e,onChange:o,renderSchemaComponent:n}){const t=ce();return r.jsx(l.Variable.Input,{value:e,onChange:o,scope:t,children:n()})}const Ee=()=>null;function Bn(){const i=l.useSchemaInitializerItem(),{node:o,resultTitle:n}=i,t=W(i,["node","resultTitle"]),{insert:s}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({},t),{onClick:()=>{var a;s({type:"void",name:o.id,title:o.title,"x-component":"CardItem","x-component-props":{title:(a=o.title)!=null?a:`#${o.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:n,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}})}}))}function Vn({dataSource:e}){var s;const o=A.useFieldSchema(),{execution:n}=U();if(!n)return o.title;const t=K.parse(e)({$jobsMapByNodeKey:((s=n.jobs)!=null?s:[]).reduce((i,a)=>Object.assign(i,{[a.nodeId]:a.result}),{})});return r.jsx("pre",{className:l.css`
|
|
453
453
|
margin: 0;
|
|
454
|
-
`,children:JSON.stringify(t,null,2)})}
|
|
454
|
+
`,children:JSON.stringify(t,null,2)})}Ee.Initializer=Bn,Ee.Result=Vn;function jn(e){return["hasMany","belongsToMany"].includes(e.type)}function zn(){const e=l.useCompile();return[no,ro].map(o=>{var t;const n=(t=o.useOptions({types:[jn],appends:null,depth:4}))==null?void 0:t.filter(Boolean);return{label:e(o.label),value:o.value,key:o.value,children:e(n),disabled:n&&!n.length}})}function Ln(t){var s=t,{value:e,onChange:o}=s,n=W(s,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:a}=l.useCollectionManager(),c=zn(),[d,p]=y.useState(c),{associatedKey:f="",name:g}=e!=null?e:{};let v=[];const h=f.match(/^{{(.*)}}$/);h&&(v=[...h[1].trim().split(".").slice(0,-1),g]);const m=F=>G(this,null,function*(){var w;const O=F[F.length-1];!((w=O.children)!=null&&w.length)&&!O.isLeaf&&O.loadChildren&&(yield O.loadChildren(O),p(T=>[...T]))});y.useEffect(()=>{(()=>G(this,null,function*(){var w;if(!v||d.length<=1)return;let O=null;for(let T=0;T<v.length;T++){const P=v[T];try{T===0?O=d.find(B=>B.value===P):(O.loadChildren&&!((w=O.children)!=null&&w.length)&&(yield O.loadChildren(O)),O=O.children.find(B=>B.value===P))}catch(B){console.error(B)}}p([...d])}))()},[e,d.length]);const k=y.useCallback((F,O)=>{if(!(F!=null&&F.length)){i("collection",null),o({});return}const{field:w}=O.pop();if(!w||!["hasMany","belongsToMany"].includes(w.type))return;const{collectionName:T,target:P,name:B}=w,M=a(T).fields.find(N=>N.primaryKey);i("collection",P),o({name:B,associatedKey:`{{${F.slice(0,-1).join(".")}.${M.name}}}`,associatedCollection:T})},[o]);return r.jsx(b.Cascader,C(x({},n),{value:v,options:d,onChange:k,loadData:m}))}const Wn={title:`{{t("Aggregate", { ns: "${u}" })}}`,type:"aggregate",group:"collection",description:`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${u}" })}}`,fieldset:{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${u}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${u}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:C(x({},ae),{title:`{{t("Data of collection", { ns: "${u}" })}}`,"x-component-props":C(x({},ae["x-component-props"]),{className:null}),"x-reactions":[...ae["x-reactions"],{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]}),association:{type:"object",title:`{{t("Data of associated collection", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:C(x({},Te),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{SchemaComponentContext:l.SchemaComponentContext,FilterDynamicComponent:Je,FieldsSelect:wo,ValueBlock:Ee,AssociatedConfig:Ln},useVariables({key:e,title:o},{types:n,fieldNames:t=Ce}){return n&&!n.some(s=>s in Me||Object.values(Me).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o,n;return e.config.collection?{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ee.Initializer,node:e,resultTitle:$("Query result")}:null}};function io(e){const s=e,{options:o=[]}=s,n=W(s,["options"]),t=l.useCompile();return r.jsx(b.Radio.Group,C(x({},n),{children:o.map(i=>r.jsxs(b.Radio,{value:i.value,children:[r.jsx("span",{className:l.css`
|
|
455
455
|
& + .anticon {
|
|
456
456
|
margin-left: 0.25em;
|
|
457
457
|
}
|
|
458
|
-
`,children:t(i.label)}),i.tooltip&&r.jsx(b.Tooltip,{title:t(i.tooltip),children:r.jsx(
|
|
458
|
+
`,children:t(i.label)}),i.tooltip&&r.jsx(b.Tooltip,{title:t(i.tooltip),children:r.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))}))}const mt=e=>{const o=je.evaluators.get(e);return o&&o.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:l.css`
|
|
459
459
|
&:after {
|
|
460
460
|
content: ':';
|
|
461
461
|
}
|
|
462
462
|
& + a {
|
|
463
463
|
margin-left: 0.25em;
|
|
464
464
|
}
|
|
465
|
-
`,children:l.i18n.t("Syntax references")}),r.jsx("a",{href:o.link,target:"_blank",rel:"noreferrer",children:o.label})]}):null};function
|
|
465
|
+
`,children:l.i18n.t("Syntax references")}),r.jsx("a",{href:o.link,target:"_blank",rel:"noreferrer",children:o.label})]}):null};function Un(e){var n;return["belongsTo","hasOne"].includes(e.type)?((n=this.getCollection(e.collectionName))==null?void 0:n.template)==="expression"?!0:this.getCollectionFields(e.target).some(t=>t.interface==="expression"):!1}const qn=({value:e,onChange:o})=>{const{t:n}=R.useTranslation(),{getCollectionFields:t,getCollection:s}=l.useCollectionManager(),i=ce({types:[Un.bind({getCollectionFields:t,getCollection:s})]});return r.jsxs(be.FormLayout,{layout:"vertical",children:[r.jsx(be.FormItem,{colon:!0,label:n("Expression type",{ns:u}),children:r.jsxs(b.Radio.Group,{value:e===!1?!1:e||"",onChange:a=>{o(a.target.value)},children:[r.jsx(b.Radio,{value:!1,children:n("Static",{ns:u})}),r.jsx(b.Radio,{value:e||"",children:n("Dynamic",{ns:u})})]})}),e!==!1?r.jsx(be.FormItem,{label:n("Select dynamic expression",{ns:u}),extra:n("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:u}),children:r.jsx(l.Variable.Input,{value:e||"",onChange:a=>o(a),scope:i})}):null]})},Jn={title:`{{t("Calculation", { ns: "${u}" })}}`,type:"calculation",group:"control",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. The expression can be static or dynamic one from an expression collections.", { ns: "${u}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:je.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return $("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:mt},components:{WorkflowVariableInput:qe,WorkflowVariableTextArea:dt,RadioWithTooltip:io,DynamicConfig:qn,ValueBlock:Ee},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return n&&!n.some(s=>s in Me||Object.values(Me).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o,n;return{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ee.Initializer,node:e,resultTitle:$("Calculation result")}}},X=new K.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${u}" })}}`,type:"string",group:"string"});const Hn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${u}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${u}" })}}`},{value:"date",title:`{{t("Date", { ns: "${u}" })}}`}];function ft(e){return Array.from(X.getEntities()).filter(([o,n])=>n.group===e)}function Gn({calculator:e,operands:o=[],onChange:n}){const t=l.useCompile(),s=ce();return r.jsxs("fieldset",{className:l.css`
|
|
466
466
|
display: flex;
|
|
467
467
|
gap: 0.5em;
|
|
468
468
|
align-items: center;
|
|
469
469
|
flex-wrap: wrap;
|
|
470
|
-
`,children:[r.jsx(l.Variable.Input,{value:o[0],onChange:i=>n({calculator:e,operands:[i,o[1]]}),scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>n({operands:o,calculator:i}),placeholder
|
|
470
|
+
`,children:[r.jsx(l.Variable.Input,{value:o[0],onChange:i=>n({calculator:e,operands:[i,o[1]]}),scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>n({operands:o,calculator:i}),placeholder:$("Calculator"),popupMatchSelectWidth:!1,children:Hn.filter(i=>!!ft(i.value).length).map(i=>r.jsx(b.Select.OptGroup,{label:t(i.title),children:ft(i.value).map(([a,{name:c}])=>r.jsx(b.Select.Option,{value:a,children:t(c)},a))},i.value))}),r.jsx(l.Variable.Input,{value:o[1],onChange:i=>n({calculator:e,operands:[o[0],i]}),scope:s,useTypedConstant:!0})]})}function _n({value:e,onChange:o,onRemove:n}){if(!e)return null;const{calculator:t,operands:s=[]}=e;return r.jsxs("div",{className:l.css`
|
|
471
471
|
display: flex;
|
|
472
472
|
position: relative;
|
|
473
473
|
margin: 0.5em 0;
|
|
474
|
-
`,children:[e.group?r.jsx(ht,{value:e.group,onChange:i=>o(C(
|
|
474
|
+
`,children:[e.group?r.jsx(ht,{value:e.group,onChange:i=>o(C(x({},e),{group:i}))}):r.jsx(Gn,{operands:s,calculator:t,onChange:o}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:n,type:"link",icon:r.jsx(I.CloseCircleOutlined,{})})]})}function ht({value:e,onChange:o}){const{t:n}=R.useTranslation(),{type:t="and",calculations:s=[]}=e;function i(){o(C(x({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function a(){o(C(x({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),o(C(x({},e),{calculations:[...s]}))}function d(p,f){s.splice(p,1,f),o(C(x({},e),{calculations:[...s]}))}return r.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
475
475
|
position: relative;
|
|
476
476
|
width: 100%;
|
|
477
477
|
.node-type-condition-group {
|
|
@@ -490,14 +490,14 @@
|
|
|
490
490
|
width: auto;
|
|
491
491
|
min-width: 6em;
|
|
492
492
|
}
|
|
493
|
-
`,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:t,onChange:p=>o(C(
|
|
493
|
+
`,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:t,onChange:p=>o(C(x({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((p,f)=>r.jsx(_n,{value:p,onChange:d.bind(this,f),onRemove:()=>c(f)},`${p.calculator}_${f}`))}),r.jsxs("div",{className:l.css`
|
|
494
494
|
button {
|
|
495
495
|
padding: 0;
|
|
496
496
|
&:not(:last-child) {
|
|
497
497
|
margin-right: 1em;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:n("Add condition")}),r.jsx(b.Button,{type:"link",onClick:a,children:n("Add condition group")})]})]})}function
|
|
500
|
+
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:n("Add condition")}),r.jsx(b.Button,{type:"link",onClick:a,children:n("Add condition group")})]})]})}function Yn({value:e,onChange:o}){const n=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(ht,{value:n.group,onChange:t=>o(C(x({},n),{group:t}))})}const Kn={title:`{{t("Condition", { ns: "${u}" })}}`,type:"condition",group:"control",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: "${u}" })}}`,fieldset:{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${u}" })}}`}],...Array.from(je.evaluators.getEntities())].reduce((e,[o,n])=>e.concat(x({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${u}" })}}`,"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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return $("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},view:{},options:[{label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],component:function({data:o}){const{t:n}=R.useTranslation(),{nodes:t}=U(),{styles:s}=oe(),{id:i,config:{rejectOnFalse:a}}=o,c=t.find(p=>p.upstreamId===i&&p.branchIndex===1),d=t.find(p=>p.upstreamId===i&&p.branchIndex===0);return r.jsx(Ge,{data:o,children:a?null:r.jsxs("div",{className:s.nodeSubtreeClass,children:[r.jsxs("div",{className:s.branchBlockClass,children:[r.jsx(Oe,{from:o,entry:d,branchIndex:0}),r.jsx(Oe,{from:o,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})},scope:{renderEngineReference:mt,useWorkflowVariableOptions:ce},components:{CalculationConfig:Yn,CalculationExpression(e){const o=ce();return r.jsx(l.Variable.TextArea,x({scope:o},e))},RadioWithTooltip:io}};function Zn(e){const{getCollectionFields:o}=l.useCollectionManager(),{path:n}=A.useField(),t=n.segments[n.segments.length-1],{values:s}=A.useForm(),i=o(s==null?void 0:s.collection),{type:a}=i.find(p=>p.name===t),c=Array.isArray(e.value)?e.value.join(","):e.value;function d(p){const f=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(a)?f:f.split(/[,\s]+/))}return r.jsx(b.Input,C(x({},e),{value:c,onChange:d}))}const yt=A.observer(({value:e,disabled:o,onChange:n,filter:t})=>{const{token:s}=l.useToken(),{t:i}=R.useTranslation(),a=l.useCompile(),c=A.useForm(),{getCollection:d,getCollectionFields:p}=l.useCollectionManager(),f=ce(),{values:g}=c,v=g==null?void 0:g.collection,h=p(v).filter(w=>w.uiSchema),m=t?h.filter(t.bind(g)):h,k=y.useMemo(()=>m.filter(w=>!e||!(w.name in e)),[m,e]),F=o||c.disabled,O=y.useMemo(()=>({onClick:({key:w})=>{n(C(x({},e),{[w]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(w=>{var T,P;return{key:w.name,label:a((P=(T=w.uiSchema)==null?void 0:T.title)!=null?P:w.name)}})}),[n,k,e]);return r.jsx("fieldset",{className:l.css`
|
|
501
501
|
margin-top: 0.5em;
|
|
502
502
|
|
|
503
503
|
> .ant-formily-item {
|
|
@@ -507,14 +507,14 @@
|
|
|
507
507
|
line-height: 32px;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
`,children:m.length?r.jsxs(l.CollectionProvider,{collection:d(v),children:[m.filter(w=>e&&w.name in e).map(w=>{var P,B;const
|
|
510
|
+
`,children:m.length?r.jsxs(l.CollectionProvider,{collection:d(v),children:[m.filter(w=>e&&w.name in e).map(w=>{var P,B;const T=["belongsTo","hasOne","hasMany","belongsToMany"].includes(w.type)?Zn:l.CollectionField;return r.jsxs(b.Form.Item,{label:a((B=(P=w.uiSchema)==null?void 0:P.title)!=null?B:w.name),labelAlign:"left",className:l.css`
|
|
511
511
|
.ant-form-item-control-input-content {
|
|
512
512
|
display: flex;
|
|
513
513
|
}
|
|
514
|
-
`,children:[r.jsx(l.Variable.Input,{scope:f,value:e[w.name],changeOnSelect:!0,onChange:
|
|
514
|
+
`,children:[r.jsx(l.Variable.Input,{scope:f,value:e[w.name],changeOnSelect:!0,onChange:z=>{n(C(x({},e),{[w.name]:z}))},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[w.name]:{"x-component":T,"x-validator"(){return""}}}}})}),F?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(I.CloseCircleOutlined,{}),onClick:()=>{var N;const D=e,{[N=w.name]:z}=D,M=W(D,[on(N)]);n(M)}})]},w.name)}),k.length?r.jsx(b.Dropdown,{menu:O,children:r.jsx(b.Button,{icon:r.jsx(I.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:$("Please select collection first")})})},{displayName:"CollectionFieldSet"}),Qn={title:`{{t("Create record", { ns: "${u}" })}}`,type:"create",group:"collection",description:`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{values:Uo,appends:$e}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{CollectionFieldset:yt},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=he(C(x({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o,n;return e.config.collection?{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ie,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}:null},initializers:{}},gt=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Xn(e){return gt.slice().reverse().find(o=>!(e%o.value))}function Rn({value:e=6e4,onChange:o}){const n=Xn(e),t=Math.round(e/n.value);return r.jsxs("fieldset",{className:l.css`
|
|
515
515
|
display: flex;
|
|
516
516
|
gap: 0.5em;
|
|
517
|
-
`,children:[r.jsx(b.InputNumber,{min:1,value:t,onChange:s=>o(Math.round(s*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:s=>o(Math.round(t*s)),className:"auto-width",children:gt.map(s=>r.jsx(b.Select.Option,{value:s.value,children
|
|
517
|
+
`,children:[r.jsx(b.InputNumber,{min:1,value:t,onChange:s=>o(Math.round(s*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:s=>o(Math.round(t*s)),className:"auto-width",children:gt.map(s=>r.jsx(b.Select.Option,{value:s.value,children:$(s.label)},s.value))})]})}const er={title:`{{t("Delay", { ns: "${u}" })}}`,type:"delay",group:"control",description:`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${u}" })}}`,fieldset:{duration:{type:"number",title:`{{t("Duration", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${u}" })}}`,value:ee.RESOLVED},{label:`{{t("Fail and exit", { ns: "${u}" })}}`,value:ee.FAILED}],required:!0,default:ee.RESOLVED}},view:{},scope:{},components:{Duration:Rn}};function $o(e){const o=new Map;e.forEach(n=>o.set(n.id,n));for(const n of o.values())n.upstreamId&&(n.upstream=o.get(n.upstreamId)),n.downstreamId&&(n.downstream=o.get(n.downstreamId))}function Do(e){const o=e.$and||e.$or;return o?o.some(n=>{if(n.$and||n.$or)return Do(n);const[t]=Object.keys(n);if(!t||!n[t])return!1;const[s]=Object.keys(n[t]);return!(!s||typeof n[t][s]=="undefined")}):!1}const or={title:'{{t("Delete record")}}',type:"destroy",group:"collection",description:`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{filter:C(x({},Te),{"x-validator"(e){return Do(e)?"":`{{t("Please add at least one condition", { ns: "${u}" })}}`}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Je}};function tr(e,o){let n=e,t=null;for(let s=0;s<o.length;s++){const i=o[s],a=n.find(c=>c.value===i);if(!a)return null;t=a,!a.isLeaf&&a.loadChildren&&a.loadChildren(a),a.children&&(n=a.children)}return t}const nr={title:`{{t("Loop", { ns: "${u}" })}}`,type:"loop",group:"control",description:`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${u}" })}}`,fieldset:{target:{type:"string",title:`{{t("Loop target", { ns: "${u}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:l.css`
|
|
518
518
|
width: 100%;
|
|
519
519
|
|
|
520
520
|
.variable {
|
|
@@ -524,19 +524,19 @@
|
|
|
524
524
|
.ant-input.null-value {
|
|
525
525
|
width: 100%;
|
|
526
526
|
}
|
|
527
|
-
`},required:!0}},view:{},component:function({data:o}){var i;const{nodes:n}=U(),{styles:t}=
|
|
527
|
+
`},required:!0}},view:{},component:function({data:o}){var i;const{nodes:n}=U(),{styles:t}=oe(),s=n.find(a=>a.upstreamId===o.id&&a.branchIndex!=null);return r.jsx(Ge,{data:o,children:r.jsx("div",{className:t.nodeSubtreeClass,children:r.jsxs("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
528
528
|
padding-left: 20em;
|
|
529
|
-
`),children:[r.jsx(Oe,{from:o,entry:s,branchIndex:(i=s==null?void 0:s.branchIndex)!=null?i:0}),r.jsxs("div",{className:t.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:l.cx(t.addButtonClass,t.loopLineClass),children:r.jsx(O.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:qe},useScopeVariables(e,o){const n=l.useCompile(),{target:t}=e.config;if(!t)return null;const{fieldNames:s=we}=o;let i={key:"item",[s.value]:"item",[s.label]:D("Loop target")};if(typeof t=="string"&&t.startsWith("{{")&&t.endsWith("}}")){const a=t.slice(2,-2).split(".").map(p=>p.trim()),c=[Ao,no,ro].map(p=>{const f=p.useOptions(C(g({},o),{current:e})).filter(Boolean);return{[s.label]:n(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),d=nr(c,a);i=Object.assign({},d,i)}return[i,{key:"index",[s.value]:"index",[s.label]:D("Loop index")},{key:"length",[s.value]:"length",[s.label]:D("Loop length")}]}};function sr(e){const{execution:o,nodes:n}=U(),t=y.useMemo(()=>n.reduce((a,c)=>Object.assign(a,{[c.id]:c.key}),{}),[n]),s=y.useMemo(()=>{var a;return{$context:o==null?void 0:o.context,$jobsMapByNodeKey:((a=o==null?void 0:o.jobs)!=null?a:[]).reduce((c,d)=>Object.assign(c,{[t[d.nodeId]]:d.result}),{})}},[o]);return y.useMemo(()=>K.parse(e)(s),[o])}function xt(e){const o=T.useField(),n=y.useRef(null),{appends:t,updateAssociationValues:s}=l.useAssociationNames(),i=sr(e.dataSource),a=y.useMemo(()=>oe.createForm({values:i,readPretty:!0}),[i]),c={appends:t},d={loading:!1,data:{data:i}},f=l.useAPIClient().resource(e.collection),x=y.useContext(l.BlockRequestContext);return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:i,parent:!1,children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",field:o,service:d,resource:f,__parent:x},children:r.jsx(l.FormBlockContext.Provider,{value:{params:c,form:a,field:o,service:d,updateAssociationValues:s,formBlockRef:n},children:e.children})})})})}function bt(e){var w,$,P;const o=l.useRecord(),n=T.useFieldSchema(),t=T.useField(),s=y.useRef(null),{appends:i,updateAssociationValues:a}=l.useAssociationNames(),[c]=Object.keys((w=n.toJSON().properties)!=null?w:{}),d=($=o==null?void 0:o.result)==null?void 0:$[c],{findComponent:p}=l.useDesignable(),f=p((P=t.component)==null?void 0:P[0])||y.Fragment,x=y.useMemo(()=>oe.createForm({initialValues:d}),[d]),v=y.useMemo(()=>g({appends:i},e.params),[i,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:d}}),[d]),S=l.useAPIClient().resource(e.collection),F=y.useContext(l.BlockRequestContext),A=y.useMemo(()=>({params:v,form:x,field:t,service:h,updateAssociationValues:a,formBlockRef:s}),[t,x,v,h,a]);return!o.status||d?r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:d,parent:!1,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",props:e,field:t,service:h,resource:S,__parent:F},children:r.jsx(l.FormBlockContext.Provider,{value:A,children:r.jsxs(f,C(g({},t.componentProps),{children:[r.jsx(l.FormV2.Templates,{style:{marginBottom:18},form:x}),r.jsx("div",{ref:s,children:r.jsx(T.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})}):null}function ir(t){var s=t,{insert:e,schema:o}=s,n=z(s,["insert","schema"]);const{getTemplateSchemaByMode:i}=l.useSchemaTemplateManager(),a=l.useRecordCollectionDataSourceItems("FormItem");function c(p){return H(this,arguments,function*({item:d}){const f=d.template?yield i(d):null,x=l.createFormBlockSchema(C(g({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Z.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:f}));delete x["x-acl-action-props"],delete x["x-acl-action"];const[v]=Object.keys(x.properties);x.properties[v].properties.actions["x-decorator"]="ActionBarProvider",x.properties[v].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ko(x,h=>{h["x-uid"]&&delete h["x-uid"]}),e(x)})}return r.jsx(l.SchemaInitializer.Item,C(g({},n),{onClick:c,items:a}))}function vt(e){var o;return r.jsx(l.CollectionProvider,{collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(ir,g({},e))})}function lr(){const{name:e,title:o}=l.useCollection();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(l.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ar={title:`{{t("Create record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${u}" })}}`,children:[{key:"createRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:o})=>e.filter(n=>!n.hidden&&n.title.toLowerCase().includes(o.toLowerCase())).map(n=>({key:`createRecordForm-child-${n.name}`,type:"item",title:n.title,schema:{collection:n.name,title:`{{t("Create record", { ns: "${u}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:vt}))}]}},initializers:{},components:{CreateFormDesigner:lr},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]={type:"create",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:Ce(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{}}};function Ct(e){var p,f,x,v;const[o,n]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),t=l.useRecord(),s=T.useField(),i=T.useFieldSchema(),[a]=Object.keys((x=i.toJSON().properties)!=null?x:{}),c=(v=t==null?void 0:t.result)==null?void 0:v[a],d=y.useMemo(()=>oe.createForm({initialValues:c}),[c]);return!t.status||c?r.jsx(l.CollectionProvider,{collection:C(g({},e.collection),{fields:o}),children:r.jsx(l.RecordProvider,{record:c,parent:!1,children:r.jsx(l.FormBlockContext.Provider,{value:{form:d,field:s,setCollectionFields:n},children:e.children})})}):null}function cr(n){var t=n,{insert:e}=t,o=z(t,["insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({},o),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:K.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[K.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Z.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const wt={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function dr(e){const o={};return Object.keys(e).forEach(n=>{const t=e[n],{group:s="others"}=t;o[s]=o[s]||{},be.set(o,[s,n],t)}),Object.keys(wt).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:wt[n],children:Object.keys(o[n]||{}).map(t=>{const s=o[n][t];return g({value:t,title:s.title,name:t},o[n][t])}).sort((t,s)=>t.order-s.order)}))}function ur(){const{interfaces:e}=l.useCollectionManager();return dr(e).map(n=>({key:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({key:t.name,type:"item",title:t.title,component:mr,fieldInterface:t.name}))}))}const kt=y.createContext({});function pr(e){const{insertPosition:o="beforeEnd",component:n}=e,t=ur(),s=y.useContext(l.CollectionContext),[i,a]=y.useState(null),[c,d]=y.useState(),{setCollectionFields:p}=y.useContext(l.FormBlockContext);return r.jsxs(kt.Provider,{value:{onAddField(f){const S=be.cloneDeep(f),{properties:F}=S,A=F,{unique:x,type:v}=A,h=z(A,["unique","type"]),m=z(S,["properties"]);delete h.name["x-disabled"],a(C(g({},m),{properties:h}))},setCallback:d},children:[r.jsx(l.SchemaInitializer.Button,{wrap:l.gridRowColWrap,insertPosition:o,items:t,component:n,title:"{{t('Configure fields')}}"}),r.jsx(l.ActionContextProvider,{value:{visible:!!i},children:i?r.jsx(l.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(g({},i.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const f=T.useForm();return{run(){return H(this,null,function*(){d(null),a(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:x}=T.useForm();return{run(){return H(this,null,function*(){var A,w,$,P;const{default:h}=i,m=K.uid();if(h.name=(A=f.name)!=null?A:m,h.uiSchema.title=($=(w=f.uiSchema)==null?void 0:w.title)!=null?$:m,h.interface=i.name,(P=s.fields)==null?void 0:P.find(B=>B.name===h.name)){x("name").take().setFeedback({type:"error",messages:[D("Field name existed in form")]});return}const F=K.merge(h,f);p([...s.fields,F]),c({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:F},"x-collection-field":`${s.name}.${h.name}`,"x-designer":"FormItem.Designer"}),d(null),a(null)})}}}}}}}})},components:{ArrayTable:ve.ArrayTable}}):null})]})}function mr(e){const{item:o,insert:n}=e,{onAddField:t,setCallback:s}=y.useContext(kt),{getInterface:i}=l.useCollectionManager(),a=i(o.fieldInterface);return r.jsx(l.SchemaInitializer.Item,{onClick:()=>{s(()=>n),t(a)}},o.fieldInterface)}const St={title:`{{t("Custom form", { ns: "${u}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${u}" })}}`,component:cr}},initializers:{AddCustomFormField:pr},components:{CustomFormBlockProvider:Ct},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var c;const[s]=Object.keys(t.properties),i=t.properties[s],a=Ce(i.properties.grid,d=>d["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=a.map(d=>{var p,f;return(f=(p=d["x-component-props"])==null?void 0:p.field)!=null?f:d["x-interface-options"]}),o[s]={type:"custom",title:((c=t["x-component-props"])==null?void 0:c.title)||s,actions:Ce(i.properties.actions,d=>d["x-component"]==="Action").map(d=>{var p,f;return{status:d["x-decorator-props"].value,values:(f=(p=d["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:d.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{CustomFormBlockProvider:Ct}}};function fr(){const{name:e,title:o}=l.useCollection(),n=T.useFieldSchema(),{t}=R.useTranslation(),{dn:s}=l.useDesignable();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.ActionModalItem,{title:t("Filter settings",{ns:u}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var a;return{options:l.useCollectionFilterOptions((a=n==null?void 0:n["x-decorator-props"])==null?void 0:a.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:i})=>{n["x-decorator-props"].filter=i,s.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),s.refresh()}}),r.jsx(l.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const hr={title:`{{t("Update record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${u}" })}}`,children:[{key:"updateRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:o})=>e.filter(n=>!n.hidden&&n.title.toLowerCase().includes(o.toLowerCase())).map(n=>({key:`updateRecordForm-child-${n.name}`,type:"item",title:n.title,schema:{collection:n.name,title:`{{t("Update record", { ns: "${u}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:vt}))}]}},initializers:{},components:{FilterDynamicComponent:Ge,UpdateFormDesigner:fr},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]=C(g({},t["x-decorator-props"]),{type:"update",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:Ce(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}})})}),o}},block:{scope:{},components:{}}},ge=new K.Registry;ge.register("customForm",St),ge.register("createForm",ar),ge.register("updateForm",hr);function yr(){const{workflow:e}=U(),o=So();return o.useInitializers?o.useInitializers(e.config):null}const gr={customForm:St.title,record:`{{t("Data record", { ns: "${u}" })}}`};function xr(){var t,s;const e=T.useFieldSchema(),o=(s=gr[(t=e["x-designer-props"])==null?void 0:t.type])!=null?s:'{{t("Block")}}',n=l.useCompile();return r.jsxs(l.GeneralSchemaDesigner,{title:n(o),children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function br(e){const{collections:o}=l.useCollectionManager(),n=ke(),t=Je(n),s=[yr()].filter(Boolean),i=t.map(d=>{var f;const p=q.get(d.type);return(f=p==null?void 0:p.useInitializers)==null?void 0:f.call(p,d)}).filter(Boolean),a=[...s,...i.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${u}" })}}`,children:i}]:[]].filter(Boolean),c=[...a.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:a}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(ge.getValues()).map(d=>{const{useInitializer:p}=d.config;return p({collections:o})})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(l.SchemaInitializer.Button,C(g({},e),{wrap:l.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function vr(){var F,A,w;const e=y.useContext(l.SchemaComponentContext),{t:o}=R.useTranslation(),n=T.useFieldSchema(),t=ce(),[s,i]=y.useState(!1),[a,c]=y.useState((w=(A=(F=n==null?void 0:n["x-action-settings"])==null?void 0:F.assignedValues)==null?void 0:A.schema)!=null?w:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[d,p]=y.useState(null),{components:f}=l.useSchemaOptionsContext();y.useEffect(()=>{p(new T.Schema({properties:{grid:a}}))},[a]);const x=y.useMemo(()=>{var P,B;const $=(B=(P=n==null?void 0:n["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:B.values;return oe.createForm({initialValues:K.lodash.cloneDeep($),values:K.lodash.cloneDeep($)})},[]),v=l.useFormActiveFields(),h=o("Assign field values");function m(){i(!1)}function S(){n["x-action-settings"]||(n["x-action-settings"]={}),n["x-action-settings"].assignedValues||(n["x-action-settings"].assignedValues={}),n["x-action-settings"].assignedValues.schema=a,n["x-action-settings"].assignedValues.values=x.values,i(!1),setTimeout(()=>{var $;($=e.refresh)==null||$.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaSettings.Item,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:m,children:o("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:S,children:o("Submit")})]}),children:r.jsx(l.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(l.VariableScopeProvider,{scope:t,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:v==null?void 0:v.getActiveFieldsName,children:r.jsx(T.FormProvider,{form:x,children:r.jsxs(ve.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:D("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&d&&r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},e),{refresh(){c(K.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(l.SchemaComponent,{schema:d,components:f})})]})})})})})})]})}function Cr(e){return r.jsxs(l.GeneralSchemaDesigner,C(g({},e),{disableInitializer:!0,children:[r.jsx(l.Action.Designer.ButtonEditor,{}),r.jsx(vr,{}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function wr(s){var i=s,{action:e,actionProps:o,insert:n}=i,t=z(i,["action","actionProps","insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({},t),{onClick:()=>{n({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(g({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Ft(t){var s=t,{action:e,actionProps:o}=s,n=z(s,["action","actionProps"]);return r.jsx(l.InitializerWithSwitch,C(g({},n),{schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(g({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function kr(e){return r.jsx(l.SchemaInitializer.Button,C(g({},e),{items:[{key:Z.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${u}" })}}`,component:wr,action:Z.RESOLVED,actionProps:{type:"primary"}},{key:Z.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${u}" })}}`,component:Ft,action:Z.REJECTED,actionProps:{danger:!0}},{key:Z.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${u}" })}}`,component:Ft,action:Z.PENDING}],title:"{{t('Configure actions')}}"}))}function Sr(){return{run(){}}}function Fr({value:e,onChange:o}){const n=y.useContext(l.SchemaComponentContext),t=So(),s=ke(),i=Je(s),a=T.useForm(),{workflow:c}=U(),d={},p={};i.forEach(v=>{const h=q.get(v.type);Object.assign(d,h.initializers),Object.assign(p,h.components)});const f=y.useMemo(()=>new T.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:l.css`
|
|
530
|
-
.ant-drawer-body {
|
|
531
|
-
background: var(--nb-box-bg);
|
|
532
|
-
}
|
|
533
|
-
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${u}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),x=y.useCallback(function(){const{tabs:h}=K.lodash.get(f.toJSON(),"properties.drawer.properties"),m=Array.from(ge.getValues()).reduce((S,F)=>Object.assign(S,F.config.parseFormOptions(h)),{});a.setValuesIn("forms",m),o(h.properties)},[a,o,f]);return r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},n),{designable:!c.executed,refresh:x}),children:r.jsx(l.SchemaInitializerProvider,{initializers:g(g(g({AddBlockButton:br,AddActionButton:kr},t.initializers),d),Array.from(ge.getValues()).reduce((v,h)=>Object.assign(v,h.config.initializers),{})),children:r.jsx(l.SchemaComponent,{schema:f,components:C(g(g({},p),Array.from(ge.getValues()).reduce((v,h)=>Object.assign(v,h.config.components),{})),{FormBlockProvider:bt,DetailsBlockProvider:xt,ManualActionStatusProvider(v){return v.children},ActionBarProvider(v){return v.children},SimpleDesigner:xr,ManualActionDesigner:Cr}),scope:{useSubmit:Sr,useDetailsBlockProps:l.useFormBlockContext}})})})}function Ar(e){const{workflow:o}=U(),[n,t]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:o.executed?D("View user interface"):D("Configure user interface")}),r.jsx(l.ActionContextProvider,{value:{visible:n,setVisible:t,formValueChanged:!1},children:e.children})]})}function Or({value:e,onChange:o}){return r.jsxs("fieldset",{className:l.css`
|
|
529
|
+
`),children:[r.jsx(Oe,{from:o,entry:s,branchIndex:(i=s==null?void 0:s.branchIndex)!=null?i:0}),r.jsxs("div",{className:t.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:l.cx(t.addButtonClass,t.loopLineClass),children:r.jsx(I.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:qe},useScopeVariables(e,o){const n=l.useCompile(),{target:t}=e.config;if(!t)return null;const{fieldNames:s=Ce}=o;let i={key:"item",[s.value]:"item",[s.label]:$("Loop target")};if(typeof t=="string"&&t.startsWith("{{")&&t.endsWith("}}")){const a=t.slice(2,-2).split(".").map(p=>p.trim()),c=[Fo,no,ro].map(p=>{const f=p.useOptions(C(x({},o),{current:e})).filter(Boolean);return{[s.label]:n(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),d=tr(c,a);i=Object.assign({},d,i)}return[i,{key:"index",[s.value]:"index",[s.label]:$("Loop index")},{key:"length",[s.value]:"length",[s.label]:$("Loop length")}]}};function rr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function sr({multiple:e=!1,value:o=[],onChange:n}){const t=ce({types:[rr]});return r.jsx(l.Variable.Input,{scope:t,value:o[0],onChange:s=>{n([s])},children:r.jsx(l.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:o[0],onChange:s=>{n(s!=null?[s]:[])}})})}function ir({value:e,onChange:o}){return r.jsxs("fieldset",{className:l.css`
|
|
534
530
|
.ant-radio-group {
|
|
535
531
|
.anticon {
|
|
536
532
|
margin-left: 0.5em;
|
|
537
533
|
}
|
|
538
534
|
}
|
|
539
|
-
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),o(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:D("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:D("Separately")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:D("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:D("Collaboratively")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(ve.FormLayout,{layout:"vertical",children:r.jsx(l.FormItem,{label:D("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:o,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:D("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:D("All pass")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:D("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:D("Any pass")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function Tr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function $r({multiple:e=!1,value:o=[],onChange:n}){const t=ce({types:[Tr]});return r.jsx(l.Variable.Input,{scope:t,value:o[0],onChange:s=>{n([s])},children:r.jsx(l.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:o[0],onChange:s=>{n(s!=null?[s]:[])}})})}const At=l.BlockInitializers.items.find(e=>e.key==="media");At.children.find(e=>e.key==="workflowTodos")||At.children.push({key:"workflowTodos",type:"item",title:`{{t("Workflow todos", { ns: "${u}" })}}`,component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"});const Dr={title:`{{t("Manual", { ns: "${u}" })}}`,type:"manual",group:"manual",description:`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${u}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Ar,SchemaConfig:Fr,ModeConfig:Or,AssigneesSelect:$r},useVariables({key:e,title:o,config:n},{types:t,fieldNames:s=we}){var p;const i=l.useCompile(),{getCollectionFields:a}=l.useCollectionManager(),c=Object.keys((p=n.forms)!=null?p:{});if(!c.length)return null;const d=c.map(f=>{var m;const x=n.forms[f],v=fe({fields:(m=x.collection)==null?void 0:m.fields,collection:x.collection,types:t,compile:i,getCollectionFields:a}),h=i(x.title)||f;return v.length?{key:f,value:f,label:h,title:h,children:v}:null}).filter(Boolean);return d.length?{[s.value]:e,[s.label]:o,[s.children]:d}:null},useInitializers(e){var s;const{getCollection:o}=l.useCollectionManager(),n=Object.keys((s=e.config.forms)!=null?s:{});if(!n.length||e.config.mode)return null;const t=n.map(i=>{var d;const a=e.config.forms[i],{fields:c=[]}=o(a.collection);return c.length?{type:"item",title:(d=a.title)!=null?d:i,component:Te,collection:a.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${i}}}`}:null}).filter(Boolean);return t.length?{key:"forms",type:"subMenu",title:e.title,children:t}:null},initializers:{}},Ir={title:`{{t("Parallel branch", { ns: "${u}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${u}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${u}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${u}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${u}" })}}`}]},default:"all"}},view:{},component:function({data:o}){const{styles:n}=te(),{id:t,config:{mode:s}}=o,{workflow:i,nodes:a}=U(),c=a.reduce((h,m)=>m.upstreamId===t&&m.branchIndex!=null?h.concat(m):h,[]).sort((h,m)=>h.branchIndex-m.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:f}=Co(o),x=Array(Math.max(0,d-c.length)).fill(null),v=c[c.length-1];return r.jsx(He,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(h=>r.jsx(Oe,{from:o,entry:h,branchIndex:h.branchIndex},h.id)),x.map((h,m)=>r.jsx(Oe,{from:o,branchIndex:(v?v.branchIndex:0)+m+1,controller:c.length+m>1?r.jsx("div",{className:l.css`
|
|
535
|
+
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),o(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:$("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:$("Separately")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:$("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:$("Collaboratively")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(be.FormLayout,{layout:"vertical",children:r.jsx(l.FormItem,{label:$("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:o,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:$("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:$("All pass")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:$("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:$("Any pass")}),r.jsx(I.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function lr(e){const{execution:o,nodes:n}=U(),t=y.useMemo(()=>n.reduce((a,c)=>Object.assign(a,{[c.id]:c.key}),{}),[n]),s=y.useMemo(()=>{var a;return{$context:o==null?void 0:o.context,$jobsMapByNodeKey:((a=o==null?void 0:o.jobs)!=null?a:[]).reduce((c,d)=>Object.assign(c,{[t[d.nodeId]]:d.result}),{})}},[o]);return y.useMemo(()=>K.parse(e)(s),[o])}function xt(e){const o=A.useField(),n=y.useRef(null),{appends:t,updateAssociationValues:s}=l.useAssociationNames(),i=lr(e.dataSource),a=y.useMemo(()=>le.createForm({values:i,readPretty:!0}),[i]),c={appends:t},d={loading:!1,data:{data:i}},f=l.useAPIClient().resource(e.collection),g=y.useContext(l.BlockRequestContext);return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:i,parent:!1,children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",field:o,service:d,resource:f,__parent:g},children:r.jsx(l.FormBlockContext.Provider,{value:{params:c,form:a,field:o,service:d,updateAssociationValues:s,formBlockRef:n},children:e.children})})})})}function bt(e){var w,T,P;const o=l.useRecord(),n=A.useFieldSchema(),t=A.useField(),s=y.useRef(null),{appends:i,updateAssociationValues:a}=l.useAssociationNames(),[c]=Object.keys((w=n.toJSON().properties)!=null?w:{}),d=(T=o==null?void 0:o.result)==null?void 0:T[c],{findComponent:p}=l.useDesignable(),f=p((P=t.component)==null?void 0:P[0])||y.Fragment,g=y.useMemo(()=>le.createForm({initialValues:d}),[d]),v=y.useMemo(()=>x({appends:i},e.params),[i,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:d}}),[d]),k=l.useAPIClient().resource(e.collection),F=y.useContext(l.BlockRequestContext),O=y.useMemo(()=>({params:v,form:g,field:t,service:h,updateAssociationValues:a,formBlockRef:s}),[t,g,v,h,a]);return!o.status||d?r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:d,parent:!1,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",props:e,field:t,service:h,resource:k,__parent:F},children:r.jsx(l.FormBlockContext.Provider,{value:O,children:r.jsxs(f,C(x({},t.componentProps),{children:[r.jsx(l.FormV2.Templates,{style:{marginBottom:18},form:g}),r.jsx("div",{ref:s,children:r.jsx(A.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})}):null}function ar(n){var t=n,{schema:e}=t,o=W(t,["schema"]);const{getTemplateSchemaByMode:s}=l.useSchemaTemplateManager(),{insert:i}=l.useSchemaInitializer(),a=l.useRecordCollectionDataSourceItems("FormItem");function c(p){return G(this,arguments,function*({item:d}){const f=d.template?yield s(d):null,g=l.createFormBlockSchema(C(x({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:f}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[v]=Object.keys(g.properties);g.properties[v].properties.actions["x-decorator"]="ActionBarProvider",g.properties[v].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ko(g,h=>{h["x-uid"]&&delete h["x-uid"]}),i(g)})}return r.jsx(l.SchemaInitializerItem,C(x({},o),{onClick:c,items:a}))}function vt(){var o;const e=l.useSchemaInitializerItem();return r.jsx(l.CollectionProvider,{collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(ar,x({},e))})}function cr(){const{name:e,title:o}=l.useCollection();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(l.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const dr={title:`{{t("Create record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){const o=y.useMemo(()=>e.map(i=>({name:fe.camelCase(`createRecordForm-child-${i.name}`),type:"item",title:i.title,label:i.label,schema:{collection:i.name,title:`{{t("Create record", { ns: "${u}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:vt})),[e]),[n,t]=y.useState(!1),s=l.useMenuSearch(o,n,!0);return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${u}" })}}`,componentProps:{onOpenChange(i){t(i.length>0)}},children:s}},initializers:{},components:{CreateFormDesigner:cr},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]={type:"create",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:ve(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{}}};function Ct(e){var p,f,g,v;const[o,n]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),t=l.useRecord(),s=A.useField(),i=A.useFieldSchema(),[a]=Object.keys((g=i.toJSON().properties)!=null?g:{}),c=(v=t==null?void 0:t.result)==null?void 0:v[a],d=y.useMemo(()=>le.createForm({initialValues:c}),[c]);return!t.status||c?r.jsx(l.CollectionProvider,{collection:C(x({},e.collection),{fields:o}),children:r.jsx(l.RecordProvider,{record:c,parent:!1,children:r.jsx(l.FormBlockContext.Provider,{value:{form:d,field:s,setCollectionFields:n},children:e.children})})}):null}function ur(){const{insert:e}=l.useSchemaInitializer(),o=l.useSchemaInitializerItem();return r.jsx(l.SchemaInitializerItem,C(x({},o),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:K.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[K.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const wt={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function pr(e){const o={};return Object.keys(e).forEach(n=>{const t=e[n],{group:s="others"}=t;o[s]=o[s]||{},fe.set(o,[s,n],t)}),Object.keys(wt).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:wt[n],children:Object.keys(o[n]||{}).map(t=>{const s=o[n][t];return x({value:t,title:s.title,name:t},o[n][t])}).sort((t,s)=>t.order-s.order)}))}function mr(){const{interfaces:e}=l.useCollectionManager();return pr(e).map(n=>({name:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({name:t.name,type:"item",title:t.title,Component:yr,fieldInterface:t.name}))}))}const kt=y.createContext({}),fr=e=>{const[o,n]=y.useState(null),[t,s]=y.useState(),i=mr(),a=y.useContext(l.CollectionContext),{setCollectionFields:c}=y.useContext(l.FormBlockContext);return r.jsxs(kt.Provider,{value:{onAddField(d){const h=fe.cloneDeep(d),{properties:m}=h,k=m,{unique:p,type:f}=k,g=W(k,["unique","type"]),v=W(h,["properties"]);delete g.name["x-disabled"],n(C(x({},v),{properties:g}))},setCallback:s},children:[r.jsx(l.SchemaInitializerItems,C(x({},e),{items:i})),r.jsx(l.ActionContextProvider,{value:{visible:!!o},children:o?r.jsx(l.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(x({},o.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const d=A.useForm();return{run(){return G(this,null,function*(){s(null),n(null),d.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:d,query:p}=A.useForm();return{run(){return G(this,null,function*(){var k,F,O,w;const{default:g}=o,v=K.uid();if(g.name=(k=d.name)!=null?k:v,g.uiSchema.title=(O=(F=d.uiSchema)==null?void 0:F.title)!=null?O:v,g.interface=o.name,(w=a.fields)==null?void 0:w.find(T=>T.name===g.name)){p("name").take().setFeedback({type:"error",messages:[$("Field name existed in form")]});return}const m=K.merge(g,d);c([...a.fields,m]),t({name:g.name,type:g.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:m},"x-collection-field":`${a.name}.${g.name}`,"x-designer":"FormItem.Designer"}),s(null),n(null)})}}}}}}}})},components:{ArrayTable:be.ArrayTable}}):null})]})},hr=new l.SchemaInitializer({name:"AddCustomFormField",wrap:l.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:fr});function yr(){const e=l.useSchemaInitializerItem(),{insert:o,setVisible:n}=l.useSchemaInitializer(),{onAddField:t,setCallback:s}=y.useContext(kt),{getInterface:i}=l.useCollectionManager(),a=i(e.fieldInterface);return r.jsx(l.SchemaInitializerItem,x({onClick:()=>{s(()=>o),t(a),n(!1)}},e),e.fieldInterface)}const St={title:`{{t("Custom form", { ns: "${u}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${u}" })}}`,Component:ur}},initializers:{},components:{CustomFormBlockProvider:Ct},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var c;const[s]=Object.keys(t.properties),i=t.properties[s],a=ve(i.properties.grid,d=>d["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=a.map(d=>{var p,f;return(f=(p=d["x-component-props"])==null?void 0:p.field)!=null?f:d["x-interface-options"]}),o[s]={type:"custom",title:((c=t["x-component-props"])==null?void 0:c.title)||s,actions:ve(i.properties.actions,d=>d["x-component"]==="Action").map(d=>{var p,f;return{status:d["x-decorator-props"].value,values:(f=(p=d["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:d.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{CustomFormBlockProvider:Ct}}};function gr(){const{name:e,title:o}=l.useCollection(),n=A.useFieldSchema(),{t}=R.useTranslation(),{dn:s}=l.useDesignable();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsActionModalItem,{title:t("Filter settings",{ns:u}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var a;return{options:l.useCollectionFilterOptions((a=n==null?void 0:n["x-decorator-props"])==null?void 0:a.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:i})=>{n["x-decorator-props"].filter=i,s.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),s.refresh()}}),r.jsx(l.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const xr={title:`{{t("Update record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){const o=y.useMemo(()=>e.map(i=>({name:fe.camelCase(`updateRecordForm-child-${i.name}`),type:"item",title:i.title,label:i.label,schema:{collection:i.name,title:`{{t("Update record", { ns: "${u}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:vt})),[e]),[n,t]=y.useState(!1),s=l.useMenuSearch(o,n,!0);return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${u}" })}}`,componentProps:{onOpenChange(i){t(i.length>0)}},children:s}},initializers:{},components:{FilterDynamicComponent:Je,UpdateFormDesigner:gr},parseFormOptions(e){const o={};return ve(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]=C(x({},t["x-decorator-props"]),{type:"update",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:ve(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}})})}),o}},block:{scope:{},components:{}}},we=new K.Registry;we.register("customForm",St),we.register("createForm",dr),we.register("updateForm",xr);function br(){const{workflow:e}=U(),o=lt();return o.useInitializers?o.useInitializers(e.config):null}const vr={customForm:St.title,record:`{{t("Data record", { ns: "${u}" })}}`};function Cr(){var t,s;const e=A.useFieldSchema(),o=(s=vr[(t=e["x-designer-props"])==null?void 0:t.type])!=null?s:'{{t("Block")}}',n=l.useCompile();return r.jsxs(l.GeneralSchemaDesigner,{title:n(o),children:[r.jsx(l.SchemaSettingsBlockTitleItem,{}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const wr=new l.SchemaInitializer({name:"AddBlockButton",wrap:l.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){const e=ke(),o=He(e),n=[br()].filter(Boolean),t=o.map(i=>{var c;const a=q.get(i.type);return(c=a==null?void 0:a.useInitializers)==null?void 0:c.call(a,i)}).filter(Boolean);return[...n,...t.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${u}" })}}`,children:t}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const{collections:e}=l.useCollectionManager();return Array.from(we.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({collections:e})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});function kr(){var F,O,w;const e=y.useContext(l.SchemaComponentContext),{t:o}=R.useTranslation(),n=A.useFieldSchema(),t=ce(),[s,i]=y.useState(!1),[a,c]=y.useState((w=(O=(F=n==null?void 0:n["x-action-settings"])==null?void 0:F.assignedValues)==null?void 0:O.schema)!=null?w:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[d,p]=y.useState(null),{components:f}=l.useSchemaOptionsContext();y.useEffect(()=>{p(new A.Schema({properties:{grid:a}}))},[a]);const g=y.useMemo(()=>{var P,B;const T=(B=(P=n==null?void 0:n["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:B.values;return le.createForm({initialValues:K.lodash.cloneDeep(T),values:K.lodash.cloneDeep(T)})},[]),v=l.useFormActiveFields(),h=o("Assign field values");function m(){i(!1)}function k(){n["x-action-settings"]||(n["x-action-settings"]={}),n["x-action-settings"].assignedValues||(n["x-action-settings"].assignedValues={}),n["x-action-settings"].assignedValues.schema=a,n["x-action-settings"].assignedValues.values=g.values,i(!1),setTimeout(()=>{var T;(T=e.refresh)==null||T.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaSettingsItem,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:m,children:o("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:k,children:o("Submit")})]}),children:r.jsx(l.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(l.VariableScopeProvider,{scope:t,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:v==null?void 0:v.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:g,children:r.jsxs(be.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:$("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&d&&r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{refresh(){c(K.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(l.SchemaComponent,{schema:d,components:f})})]})})})})})})]})}function Sr(e){return r.jsxs(l.GeneralSchemaDesigner,C(x({},e),{disableInitializer:!0,children:[r.jsx(l.Action.Designer.ButtonEditor,{}),r.jsx(kr,{}),r.jsx(l.SchemaSettingsDivider,{}),r.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Fr(){const i=l.useSchemaInitializerItem(),{action:o,actionProps:n}=i,t=W(i,["action","actionProps"]),{insert:s}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({},t),{onClick:()=>{s({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o},"x-component":"Action","x-component-props":C(x({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Ft(){const e=l.useSchemaInitializerItem(),s=e,{action:o,actionProps:n}=s,t=W(s,["action","actionProps"]);return r.jsx(l.InitializerWithSwitch,C(x({},t),{item:e,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o},"x-component":"Action","x-component-props":C(x({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${o}`},type:"x-action"}))}const Ar=new l.SchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${u}" })}}`,Component:Fr,action:ee.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${u}" })}}`,Component:Ft,action:ee.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${u}" })}}`,Component:Ft,action:ee.PENDING}]});function Or(){return{run(){}}}function Ir({value:e,onChange:o}){const n=y.useContext(l.SchemaComponentContext),t=ke(),s=He(t),i=A.useForm(),{workflow:a}=U(),c={},d={};s.forEach(g=>{const v=q.get(g.type);Object.assign(c,v.initializers),Object.assign(d,v.components)});const p=y.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:l.css`
|
|
536
|
+
.ant-drawer-body {
|
|
537
|
+
background: var(--nb-box-bg);
|
|
538
|
+
}
|
|
539
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${u}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),f=y.useCallback(function(){const{tabs:v}=K.lodash.get(p.toJSON(),"properties.drawer.properties"),h=Array.from(we.getValues()).reduce((m,k)=>Object.assign(m,k.config.parseFormOptions(v)),{});i.setValuesIn("forms",h),o(v.properties)},[i,o,p]);return r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},n),{designable:!a.executed,refresh:f}),children:r.jsx(l.SchemaComponent,{schema:p,components:C(x(x({},d),Array.from(we.getValues()).reduce((g,v)=>Object.assign(g,v.config.components),{})),{FormBlockProvider:bt,DetailsBlockProvider:xt,ManualActionStatusProvider(g){return g.children},ActionBarProvider(g){return g.children},SimpleDesigner:Cr,ManualActionDesigner:Sr}),scope:{useSubmit:Or,useDetailsBlockProps:l.useFormBlockContext}})})}function Tr(e){const{workflow:o}=U(),[n,t]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:o.executed?$("View user interface"):$("Configure user interface")}),r.jsx(l.ActionContextProvider,{value:{visible:n,setVisible:t,formValueChanged:!1},children:e.children})]})}const $r={title:`{{t("Manual", { ns: "${u}" })}}`,type:"manual",group:"manual",description:`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${u}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Tr,SchemaConfig:Ir,ModeConfig:ir,AssigneesSelect:sr},useVariables({key:e,title:o,config:n},{types:t,fieldNames:s=Ce}){var p;const i=l.useCompile(),{getCollectionFields:a}=l.useCollectionManager(),c=Object.keys((p=n.forms)!=null?p:{});if(!c.length)return null;const d=c.map(f=>{var m;const g=n.forms[f],v=he({fields:(m=g.collection)==null?void 0:m.fields,collection:g.collection,types:t,compile:i,getCollectionFields:a}),h=i(g.title)||f;return v.length?{key:f,value:f,label:h,title:h,children:v}:null}).filter(Boolean);return d.length?{[s.value]:e,[s.label]:o,[s.children]:d}:null},useInitializers(e){var s;const{getCollection:o}=l.useCollectionManager(),n=Object.keys((s=e.config.forms)!=null?s:{});if(!n.length||e.config.mode)return null;const t=n.map(i=>{var d,p;const a=e.config.forms[i],{fields:c=[]}=o(a.collection);return c.length?{name:(d=a.title)!=null?d:i,type:"item",title:(p=a.title)!=null?p:i,Component:Ie,collection:a.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${i}}}`}:null}).filter(Boolean);return t.length?{name:"forms",key:"forms",type:"subMenu",title:e.title,children:t}:null},initializers:{}},Dr={title:`{{t("Parallel branch", { ns: "${u}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${u}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${u}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${u}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${u}" })}}`}]},default:"all"}},view:{},component:function({data:o}){const{styles:n}=oe(),{id:t,config:{mode:s}}=o,{workflow:i,nodes:a}=U(),c=a.reduce((h,m)=>m.upstreamId===t&&m.branchIndex!=null?h.concat(m):h,[]).sort((h,m)=>h.branchIndex-m.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:f}=Co(o),g=Array(Math.max(0,d-c.length)).fill(null),v=c[c.length-1];return r.jsx(Ge,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(h=>r.jsx(Oe,{from:o,entry:h,branchIndex:h.branchIndex},h.id)),g.map((h,m)=>r.jsx(Oe,{from:o,branchIndex:(v?v.branchIndex:0)+m+1,controller:c.length+m>1?r.jsx("div",{className:l.css`
|
|
540
540
|
padding-top: 2em;
|
|
541
541
|
|
|
542
542
|
> button {
|
|
@@ -544,9 +544,9 @@
|
|
|
544
544
|
transform: rotate(45deg);
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
`,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(
|
|
547
|
+
`,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(I.PlusOutlined,{}),onClick:()=>p(d-1),disabled:i.executed})}):null},`temp_${c.length+m}`))]}),r.jsx(b.Tooltip,{title:$("Add branch"),className:l.css`
|
|
548
548
|
visibility: ${i.executed?"hidden":"visible"};
|
|
549
|
-
`,children:r.jsx(b.Button,{"aria-label":f("add-branch"),icon:r.jsx(
|
|
549
|
+
`,children:r.jsx(b.Button,{"aria-label":f("add-branch"),icon:r.jsx(I.PlusOutlined,{}),className:l.css`
|
|
550
550
|
position: relative;
|
|
551
551
|
top: 1em;
|
|
552
552
|
transform-origin: center;
|
|
@@ -556,10 +556,10 @@
|
|
|
556
556
|
transform-origin: center;
|
|
557
557
|
transform: rotate(-45deg);
|
|
558
558
|
}
|
|
559
|
-
`,onClick:()=>p(d+1),disabled:i.executed})})]})})},components:{RadioWithTooltip:io}},Nr={title:`{{t("Query record", { ns: "${u}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${u}" })}}`,fieldset:{collection:ae,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${u}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${u}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter
|
|
559
|
+
`,onClick:()=>p(d+1),disabled:i.executed})})]})})},components:{RadioWithTooltip:io}},Nr={title:`{{t("Query record", { ns: "${u}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${u}" })}}`,fieldset:{collection:ae,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${u}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${u}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Te,sort:dn,pagination:un,appends:$e},"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: "${u}" })}}`}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const e=l.useCompile(),{getCollectionFields:o,getInterface:n}=l.useCollectionManager(),{values:t}=A.useForm();return o(t.collection).filter(i=>{if(!i.interface)return!1;const a=n(i.interface);return!!(a!=null&&a.sortable)}).map(i=>{var a,c;return{value:i.name,label:(a=i==null?void 0:i.uiSchema)!=null&&a.title?e((c=i==null?void 0:i.uiSchema)==null?void 0:c.title):i.name}})}},components:{ArrayItems:be.ArrayItems,FilterDynamicComponent:Je,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:qe},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=he(C(x({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o,n;return!e.config.collection||e.config.multiple?null:{name:(o=e.title)!=null?o:`#${e.id}`,type:"item",title:(n=e.title)!=null?n:`#${e.id}`,Component:Ie,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}},initializers:{}},Mr={title:`{{t("HTTP request", { ns: "${u}" })}}`,type:"request",group:"extended",description:`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${u}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${u}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${u}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${u}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${u}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{},components:{ArrayItems:be.ArrayItems,WorkflowVariableInput:qe,WorkflowVariableJSON:pt},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}},Er={title:`{{t("SQL action", { ns: "${u}" })}}`,type:"sql",group:"collection",description:`{{t("Execute a SQL statement in database.", { ns: "${u}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:l.css`
|
|
560
560
|
font-size: 80%;
|
|
561
561
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
562
|
-
`}}},scope:{},components:{WorkflowVariableRawTextArea:ut},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}};function Pr(n){var t=n,{onChange:e}=t,o=
|
|
562
|
+
`}}},scope:{},components:{WorkflowVariableRawTextArea:ut},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}};function Pr(n){var t=n,{onChange:e}=t,o=W(t,["onChange"]);const{getCollectionFields:s}=l.useCollectionManager(),i=A.useForm(),{collection:a}=i.values,c=s(a),d=A.useField();function p({target:f}){const g=d.query(".values").take();if(!g)return;const v=c.reduce((h,m)=>(m.name in g.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=g.value[m.name]),h),{});i.setValuesIn("params.values",v),e(f.value)}return r.jsx(io,C(x({},o),{onChange:p}))}const Br={title:`{{t("Update record", { ns: "${u}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${u}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${u}" })}}`},{label:`{{t("Update one by one", { ns: "${u}" })}}`,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: "${u}" })}}`}]},default:!1},filter:C(x({},Te),{title:`{{t("Only update records matching conditions", { ns: "${u}" })}}`,"x-validator"(e){return Do(e)?"":$("Please add at least one condition")}}),values:C(x({},Uo),{"x-component-props":{filter(e){var o;return((o=this.params)==null?void 0:o.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Je,CollectionFieldset:yt,IndividualHooksRadioWithTooltip:Pr}},q=new K.Registry;q.register("calculation",Jn),q.register("condition",Kn),q.register("parallel",Dr),q.register("loop",nr),q.register("delay",er),q.register("manual",$r),q.register("query",Nr),q.register("create",Qn),q.register("update",Br),q.register("destroy",or),q.register("aggregate",Wn),q.register("request",Mr),q.register("sql",Er);function Vr(){const e=A.useForm(),o=l.useAPIClient(),n=l.useActionContext(),{refresh:t}=l.useResourceActionContext(),s=ke(),{workflow:i}=U();return{run(){return G(this,null,function*(){var c,d;if(i.executed){b.message.error($("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),t()})}}}const No=y.createContext({});function ke(){return y.useContext(No)}function He(e){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)o.push(n);return o}function At(e){const o=[];if(!e)return[];for(let n=e;n;n=n.upstream)n.upstream&&n.branchIndex!=null&&o.push(n.upstream);return o}function Ot({data:e}){const{styles:o}=oe(),{getAriaLabel:n}=Co(e),{component:t=Ge}=q.get(e.type);return r.jsx(No.Provider,{value:e,children:r.jsxs("div",{className:l.cx(o.nodeBlockClass),children:[r.jsx(t,{data:e}),r.jsx($t,{"aria-label":n(),upstream:e})]})})}function It(){var p;const{t:e}=R.useTranslation(),o=l.useAPIClient(),{workflow:n,nodes:t,refresh:s}=(p=U())!=null?p:{},i=ke(),{modal:a}=b.App.useApp();if(!n)return null;const c=o.resource("flow_nodes");function d(){return G(this,null,function*(){function f(){return G(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:i.id}),s()})}const g=t.filter(m=>m===i?!1:K.parse(m.config).parameters.filter(({key:O})=>O.startsWith(`$jobsMapByNodeKey.${i.key}.`)||O===`$jobsMapByNodeKey.${i.key}`).length);if(g.length){a.error({title:$("Can not delete"),content:$("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:g.map(m=>`#${m.id}`).join(", ")})});return}const h=!t.find(m=>m.upstream===i&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):$("This node contains branches, deleting will also be preformed to them, are you sure?");a.confirm({title:e("Delete"),content:h,onOk:f})})}return n.executed?null:r.jsx(b.Button,{type:"text",shape:"circle",icon:r.jsx(I.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function Tt(){var i;const{execution:e,setViewJob:o}=U(),{jobs:n}=(i=ke())!=null?i:{},{styles:t}=oe();if(!e)return null;if(!n.length)return r.jsx(Le,{className:t.nodeJobButtonClass,disabled:!0});function s({key:a}){const c=n.find(d=>d.id==a);o(c)}return n.length>1?r.jsx(b.Dropdown,{menu:{items:n.map(a=>({key:a.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Le,{statusMap:We,status:a.status}),r.jsx("time",{children:K.str2moment(a.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:t.dropdownClass},children:r.jsx(Le,{statusMap:We,status:n[n.length-1].status,className:t.nodeJobButtonClass})}):r.jsx(Le,{statusMap:We,status:n[0].status,onClick:()=>o(n[0]),className:t.nodeJobButtonClass})}function jr(){return{form:A.useForm()}}function Ge(e){var B,z;const{data:o,children:n}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(B=U())!=null?B:{},{styles:c}=oe(),d=q.get(o.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=t(d.title),[g,v]=y.useState((z=o.title)!=null?z:f),[h,m]=y.useState(!1),[k,F]=y.useState(!1),O=y.useMemo(()=>{const M=fe.cloneDeep(o.config);return le.createForm({initialValues:M,disabled:i.executed})},[o,i]),w=y.useCallback(M=>{m(M),M||O.reset()},[O]),T=y.useCallback(function(M){return G(this,null,function*(){var D,J;const N=M||f;v(N),N!==o.title&&(yield(J=(D=s.resource("flow_nodes")).update)==null?void 0:J.call(D,{filterByTk:o.id,values:{title:N}}),a())})},[o]),P=y.useCallback(function(M){if(M.target===M.currentTarget){m(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let D=M.target;D&&D!==M.currentTarget&&D!==document.documentElement;D=D.parentNode)if(Array.from(D.classList).some(J=>N.has(J))){m(!0),M.stopPropagation();return}},[]);return r.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${o.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${f}-${g}`,className:l.cx(c.nodeCardClass,{configuring:h}),onClick:P,children:[r.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(b.Tag,{children:f}),r.jsx("span",{className:"workflow-node-id",children:o.id})]}),r.jsx(b.Input.TextArea,{disabled:i.executed,value:g,onChange:M=>v(M.target.value),onBlur:M=>T(M.target.value),autoSize:!0}),r.jsx(It,{}),r.jsx(Tt,{}),r.jsx(l.ActionContextProvider,{value:{visible:h,setVisible:w,formValueChanged:k,setFormValueChanged:F},children:r.jsx(l.FormProvider,{form:O,children:r.jsx(l.SchemaComponent,{scope:C(x({},d.scope),{useFormProviderProps:jr}),components:d.components,schema:{type:"void",properties:C(x({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":p,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${d.type}_${o.id}`]:{type:"void",title:r.jsxs("div",{className:l.css`
|
|
563
563
|
display: flex;
|
|
564
564
|
justify-content: space-between;
|
|
565
565
|
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
code {
|
|
575
575
|
font-weight: normal;
|
|
576
576
|
}
|
|
577
|
-
`,children:[r.jsx("strong",{children:o.title}),r.jsx(b.Tooltip,{title
|
|
577
|
+
`,children:[r.jsx("strong",{children:o.title}),r.jsx(b.Tooltip,{title:$("Variable key of node"),children:r.jsx(b.Tag,{children:r.jsx("code",{children:o.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:C(x({},d.description?{description:{type:"void","x-component":Lo,"x-component-props":{label:$("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
578
578
|
.ant-input,
|
|
579
579
|
.ant-select,
|
|
580
580
|
.ant-cascader-picker,
|
|
@@ -586,17 +586,17 @@
|
|
|
586
586
|
min-width: 6em;
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
`},properties:d.fieldset},actions:i.executed?null:{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:Vr}}}}})}})}})})})]}),n]})}function
|
|
589
|
+
`},properties:d.fieldset},actions:i.executed?null:{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:Vr}}}}})}})}})})})]}),n]})}function $t(e){var h;const{upstream:o,branchIndex:n=null}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(h=U())!=null?h:{},c=Array.from(q.getValues()),{styles:d}=oe(),p=y.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${u}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${u}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${u}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${u}" })}}`}].filter(m=>c.filter(k=>k.group===m.key).length).map(m=>{const k=c.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({workflow:i,upstream:o,branchIndex:n}):!0));return C(x({},m),{type:"group",children:k.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(O=>({role:"button","aria-label":O.key,key:O.key,label:O.label})):null}))})}),[n,c,o,i]),f=y.useMemo(()=>i?s.resource("workflows.nodes",i.id):null,[i==null?void 0:i.id]),g=y.useCallback(k=>G(this,[k],function*({keyPath:m}){var P,B,z;const F=m.pop(),O={},[w]=m,T=q.get(F);if(w){const{value:M}=(B=(P=T.options)==null?void 0:P.find(N=>N.key===w))!=null?B:{};Object.assign(O,typeof M=="function"?M():M)}f&&(yield f.create({values:{type:F,upstreamId:(z=o==null?void 0:o.id)!=null?z:null,branchIndex:n,title:t(T.title),config:O}}),a())}),[n,f==null?void 0:f.create,o==null?void 0:o.id]),v=y.useMemo(()=>({onClick:g,items:t(p)}),[p,g]);return i?r.jsx("div",{className:d.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],menu:v,disabled:i.executed,overlayClassName:l.css`
|
|
590
590
|
.ant-dropdown-menu-root {
|
|
591
591
|
max-height: 30em;
|
|
592
592
|
overflow-y: auto;
|
|
593
593
|
}
|
|
594
|
-
`,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(
|
|
594
|
+
`,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(I.PlusOutlined,{})})})}):null}function Oe({from:e=null,entry:o=null,branchIndex:n=null,controller:t=null,className:s,end:i}){const{styles:a}=oe(),{getAriaLabel:c}=Co(e,n),d=[];for(let p=o;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:l.cx("workflow-branch",a.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),t,r.jsx($t,{"aria-label":c(),upstream:e,branchIndex:n}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(Ot,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(I.CloseOutlined,{})}):null]})}function Dt({entry:e}){const{styles:o}=oe(),{workflow:n}=U(),[t,s]=y.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:t/100},children:r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
|
|
595
595
|
margin-top: 0 !important;
|
|
596
|
-
`),children:r.jsxs("div",{className:o.branchClass,children:[n!=null&&n.executed?r.jsx(b.Alert,{type:"warning",message
|
|
596
|
+
`),children:r.jsxs("div",{className:o.branchClass,children:[n!=null&&n.executed?r.jsx(b.Alert,{type:"warning",message:$("Executed workflow cannot be modified"),showIcon:!0,className:l.css`
|
|
597
597
|
margin-bottom: 1em;
|
|
598
|
-
`}):null,r.jsx(
|
|
598
|
+
`}):null,r.jsx(En,{}),r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
|
|
599
599
|
margin-top: 0 !important;
|
|
600
|
-
`),children:r.jsx(Oe,{entry:e})}),r.jsx("div",{className:o.terminalClass,children:D("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:t,onChange:s})})]})}const Pe=e=>`/admin/workflow/workflows/${e}`,Mo=e=>`/admin/workflow/executions/${e}`;function Lr(e,o=[]){const n=new Map;e.forEach(t=>{t.jobs=[],n.set(t.id,t)}),o.forEach(t=>{const s=n.get(t.nodeId);s.jobs.push(t),t.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(t=>{t.jobs=t.jobs.sort((s,i)=>s.id-i.id)})}function zr(){const e=l.useCompile(),{viewJob:o,setViewJob:n}=U(),{styles:t}=te(),{node:s={}}=o!=null?o:{},i=q.get(s.type);return r.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.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:r.jsxs("div",{className:t.nodeTitleClass,children:[r.jsx(b.Tag,{children:e(i==null?void 0:i.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Re,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:t.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function Wr(e){const{execution:o}=U(),n=l.useAPIClient(),t=ue.useNavigate(),{styles:s}=te(),[i,a]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{a(f.data)}).catch(()=>{})},[o]),y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[o]);const p=y.useCallback(({key:f})=>{f!=o.id&&t(Mo(f))},[o]);return o?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${o.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:K.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(We,{statusMap:Xe,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${o.id}`}),r.jsx(O.DownOutlined,{})]})}):null}function Ur(){var m;const e=l.useCompile(),{data:o,loading:n}=l.useResourceActionContext(),{setTitle:t}=l.useDocumentTitle(),[s,i]=y.useState(null),a=l.useApp();if(y.useEffect(()=>{var $;const{workflow:w}=($=o==null?void 0:o.data)!=null?$:{};t==null||t(`${w!=null&&w.title?`${w.title} - `:""}${D("Execution history")}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const S=(m=o==null?void 0:o.data)!=null?m:{},{jobs:c=[],workflow:F={}}=S,A=F,{nodes:d=[],revisions:p=[]}=A,f=z(A,["nodes","revisions"]),x=z(S,["jobs","workflow"]);Io(d),Lr(d,c);const v=d.find(w=>!w.upstream),h=Xe[x.status];return r.jsxs(ze.Provider,{value:{workflow:f.type?f:null,nodes:d,execution:x,viewJob:s,setViewJob:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:a.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(ue.Link,{to:Pe(f.id),children:f.title})},{title:r.jsx(Wr,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:h.color,children:e(h.label)}),r.jsx("time",{children:K.str2moment(x.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Nt,{entry:v}),r.jsx(zr,{})]})}const Et=()=>{const e=ue.useParams(),{styles:o}=te();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.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:Ur}})})},Mt=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext();return r.jsx(ue.Link,{to:Mo(o),onClick:()=>n(!1),children:e("View")})},qr={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:o}=l.useActionContext();return r.jsx(ue.Link,{to:Pe(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Qe}}]},Pt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:qr,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:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:o,defaultRequest:n}=l.useResourceActionContext(),{resource:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return H(this,null,function*(){var a;yield t.destroy({filter:(a=n.params)==null?void 0:a.filter}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,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: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{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",properties:{status:{type:"number","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",title:`{{t("Details", { ns: "${u}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function Gr(t){var s=t,{request:e,filter:o={}}=s,n=z(s,["request","filter"]);var c;const{workflow:i}=U(),a=C(g({},n),{request:C(g({},e),{params:C(g({},e==null?void 0:e.params),{filter:C(g({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,g({},a))}function Jr(){var L;const e=ue.useNavigate(),{t:o}=R.useTranslation(),n=l.useApp(),{data:t,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[d,p]=y.useState(!1),{styles:f}=te(),{modal:x}=b.App.useApp();if(y.useEffect(()=>{var I;const{title:N}=(I=t==null?void 0:t.data)!=null?I:{};c==null||c(`${D("Workflow")}${N?`: ${N}`:""}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const E=(L=t==null?void 0:t.data)!=null?L:{},{nodes:v=[],revisions:h=[]}=E,m=z(E,["nodes","revisions"]);Io(v);const S=v.find(N=>!N.upstream);function F({key:N}){N!=m.id&&e(Pe(N))}function A(N){return H(this,null,function*(){yield a.update({filterByTk:m.id,values:{enabled:N}}),s()})}function w(){return H(this,null,function*(){const{data:{data:N}}=yield a.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function $(){return H(this,null,function*(){const N=m.current?D("Delete a main version will cause all other revisions to be deleted too."):"";x.confirm({title:o("Are you sure you want to delete it?"),content:N,onOk(){return H(this,null,function*(){var G;yield a.destroy({filterByTk:m.id}),b.message.success(o("Operation succeeded")),e(m.current?n.pluginSettingsManager.getRoutePath("workflow"):Pe((G=h.find(J=>J.current))==null?void 0:G.id))})}})})}function P(I){return H(this,arguments,function*({key:N}){switch(N){case"history":p(!0);return;case"revision":return w();case"delete":return $()}})}const B=m.executed&&!h.find(N=>!N.executed&&new Date(N.createdAt)>new Date(m.createdAt));return r.jsxs(ze.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:n.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((N,I)=>I.id-N.id).map((N,I)=>({role:"button","aria-label":`version-${I}`,key:`${N.id}`,icon:N.current?r.jsx(O.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${N.id}`}),r.jsx("time",{children:K.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:D("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(O.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:m.enabled,onChange:A,checkedChildren:D("On"),unCheckedChildren:D("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:D("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:D("Copy to new version"),disabled:!B},{role:"button","aria-label":"delete",key:"delete",label:o("Delete")}],onClick:P},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(O.EllipsisOutlined,{})})}),r.jsx(l.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(l.SchemaComponent,{schema:Pt,components:{ExecutionResourceProvider:Gr,ExecutionLink:Mt}})})]})]}),r.jsx(Nt,{entry:S})]})}const Bt=()=>{const e=ue.useParams(),{styles:o}=te();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.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:Jr}})})},Hr=t=>{var s=t,{request:e,filter:o={}}=s,n=z(s,["request","filter"]);var c;const i=l.useRecord(),a=C(g({},n),{request:C(g({},e),{params:C(g({},e==null?void 0:e.params),{filter:C(g({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,g({},a))},Yr=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext(),{getAriaLabel:t}=l.useGetAriaLabelOfAction("Configure");return r.jsx(ue.Link,{"aria-label":t(),to:Pe(o),onClick:()=>n(!1),children:e("Configure")})};function _r(t){var s=t,{component:e="div",children:o}=s,n=z(s,["component","children"]);const[i,a]=y.useState(!1),c=T.useFieldSchema();return r.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[y.createElement(e,C(g({},n),{onClick(){a(!0)}}),o),r.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Kr}=l.interfacesProperties,Zr={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${u}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${u}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:g({},Kr)},Vt={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: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},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: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Se={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},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: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Qr={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Vt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Vt},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{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"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Se.title,type:Se.type,description:Se.description,options:Se.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}}},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 n=l.useRecord();return y.createElement("a",g({"aria-label":`executed-${n.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Pt}}}},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:Se.title,enabled:Se.enabled,description:Se.description,options:Se.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: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"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}=R.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:n,targetKey:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[t]:i}=l.useRecord(),{values:a}=T.useForm();return{run(){return H(this,null,function*(){yield n.revision({filterByTk:i,values:a}),b.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 jt(e){var i;const n=l.useCompile()(e.label),t=y.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Xe[e.value])!=null?i:{};return r.jsx(b.Tag,{color:s,onMouseDown:t,closable:e.closable,onClose:e.onClose,children:n})}function Xr(e){const o=l.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(jt,g({},e)),e.description?r.jsx("span",{children:o(e.description)}):null]})}function Rr(o){var e=z(o,[]);const n=e.multiple?"multiple":null;return r.jsx(b.Select,C(g({role:"button","data-testid":`select-${n||"single"}`},e),{mode:n,optionLabelProp:"label",tagRender:jt,children:Qe.filter(t=>!!t.value&&t.value!==pe.ABORTED).map(t=>r.jsx(b.Select.Option,C(g({},t),{children:r.jsx(Xr,g({},t))}),t.value))}))}const es=y.createContext({});function os(){const e=y.useContext(l.SchemaComponentContext);return r.jsx(b.Card,{bordered:!1,children:r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},e),{designable:!1}),children:r.jsx(l.SchemaComponent,{schema:Qr,components:{WorkflowLink:Yr,ExecutionResourceProvider:Hr,ExecutionLink:Mt,OpenDrawer:_r,ExecutionStatusSelect:Rr},scope:{getTriggersOptions:Fo}})})})}const ts=e=>{const o=y.useContext(l.PluginManagerContext),n=y.useContext(l.CollectionManagerContext);return r.jsx(l.PluginManagerContext.Provider,{value:{components:g({},o==null?void 0:o.components)},children:r.jsx(l.CollectionManagerContext.Provider,{value:C(g({},n),{interfaces:C(g({},n.interfaces),{expression:Zr})}),children:r.jsx(es.Provider,{value:{triggers:me,instructions:q},children:e.children})})})},ns=T.observer(e=>{const{onChange:o}=e,n=T.useField(),t=T.useForm(),i=[...n.path.segments.slice(0,-1),"sourceCollection"].join("."),[a,c]=y.useState(t.getValuesIn(i)),d=l.useCompile(),{getCollectionFields:p}=l.useCollectionManager();T.useFormEffects(()=>{oe.onFormInitialValuesChange(x=>{c(x.getValuesIn(i))}),oe.onFieldInputValueChange(i,x=>{c(x.value),o(null)})});const f=fe({collection:a,compile:d,getCollectionFields:p});return r.jsx(l.Variable.TextArea,C(g({},e),{scope:f}))},{displayName:"InternalExpression"});function rs(e){const{t:o}=R.useTranslation(),n=l.useRecord(),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),i=y.useMemo(()=>fe({collection:n.sourceCollection,compile:t,getCollectionFields:s}),[n.sourceCollection,n.sourceCollection]);return e.value?r.jsx(l.Variable.TextArea,C(g({},e),{scope:i})):r.jsx(b.Tag,{children:o("Unconfigured",{ns:u})})}const ss=T.connect(ns,T.mapReadPretty(rs)),is={title:`{{t("Task", { ns: "${u}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},ls={title:`{{t("Workflow", { ns: "${u}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},as={title:`{{t("Workflow todos", { ns: "${u}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-component":"Select",enum:Re}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},cs=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),ds=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),us=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.nickname)!=null?t:(n=e.value)==null?void 0:n.id},{displayName:"UserColumn"}),Po=()=>r.jsx(l.SchemaComponent,{components:{NodeColumn:cs,WorkflowColumn:ds,UserColumn:us},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${u}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${u}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${u}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function ps(e){var p;const{data:o}=l.useCurrentUserContext(),{userJob:n}=U(),{status:t,result:s,userId:i}=n,a=T.useFieldSchema(),{name:c}=a.parent.toJSON();let{children:d}=e;return t?s[c]||(d=null):((p=o==null?void 0:o.data)==null?void 0:p.id)!==i&&(d=null),d}const ms=y.createContext(null);function fs({value:e,children:o}){const{userJob:n}=U(),t=T.useField(),s=T.useFieldSchema();return y.useEffect(()=>{n.status&&(t.disabled=!0,t.visible=n.status===e&&n.result._===s.name)},[n,e,t]),r.jsx(ms.Provider,{value:e,children:o})}function hs(){const e=l.useAPIClient(),{setVisible:o}=l.useActionContext(),{values:n,submit:t}=T.useForm(),s=T.useFieldSchema(),{service:i}=l.useTableBlockContext(),{userJob:a}=U(),{name:c}=s,{name:d}=s.parent.parent;return{run(){return H(this,null,function*(){a.status||(yield t(),yield e.resource("users_jobs").submit({filterByTk:a.id,values:{result:{[d]:n,_:c}}}),o(!1),i.refresh())})}}}function ys(e){var p;const o=l.useAPIClient(),{id:n}=l.useRecord(),[t,s]=y.useState(null),[i,a]=y.useState(null);y.useEffect(()=>{var f,x;n&&((x=(f=o.resource("users_jobs")).get)==null||x.call(f,{filterByTk:n,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var w;const $=(w=v==null?void 0:v.data)!=null?w:{},{node:h,workflow:P={}}=$,B=P,{nodes:m=[]}=B,S=z(B,["nodes"]),L=$,{execution:F}=L,A=z(L,["node","workflow","execution"]);Io(m),a(h),s({userJob:A,workflow:S,nodes:m,execution:F})}))},[n]);const d=Je(t==null?void 0:t.nodes.find(f=>f.id===i.id)).reduce((f,{type:x})=>Object.assign(f,q.get(x).components),{});return i&&t?r.jsx(ze.Provider,{value:t,children:r.jsx(l.SchemaComponent,{components:g(g({FormBlockProvider:bt,DetailsBlockProvider:xt,ActionBarProvider:ps,ManualActionStatusProvider:fs},Array.from(ge.getValues()).reduce((f,x)=>Object.assign(f,x.block.components),{})),d),scope:g({useSubmit:hs,useFormBlockProps:gs,useDetailsBlockProps:xs},Array.from(ge.getValues()).reduce((f,x)=>Object.assign(f,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=i.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function gs(){var i;const{userJob:e}=U(),o=l.useRecord(),{data:n}=l.useCurrentUserContext(),{form:t}=l.useFormBlockContext(),s=e.status?o?"readPretty":"disabled":((i=n==null?void 0:n.data)==null?void 0:i.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{t==null||t.setPattern(s)},[s,t]),{form:t}}function xs(){const{form:e}=l.useFormBlockContext();return{form:e}}function bs(){const e=l.useCompile(),{status:o,updatedAt:n}=l.useRecord(),t=Le[o];return o?r.jsxs(b.Space,{children:[r.jsx("time",{className:l.css`
|
|
600
|
+
`),children:r.jsx(Oe,{entry:e})}),r.jsx("div",{className:o.terminalClass,children:$("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:t,onChange:s})})]})}const Pe=e=>`/admin/workflow/workflows/${e}`,Mo=e=>`/admin/workflow/executions/${e}`;function zr(e,o=[]){const n=new Map;e.forEach(t=>{t.jobs=[],n.set(t.id,t)}),o.forEach(t=>{const s=n.get(t.nodeId);s.jobs.push(t),t.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(t=>{t.jobs=t.jobs.sort((s,i)=>s.id-i.id)})}function Lr(){const e=l.useCompile(),{viewJob:o,setViewJob:n}=U(),{styles:t}=oe(),{node:s={}}=o!=null?o:{},i=q.get(s.type);return r.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.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:r.jsxs("div",{className:t.nodeTitleClass,children:[r.jsx(b.Tag,{children:e(i==null?void 0:i.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Re,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:t.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function Wr(e){const{execution:o}=U(),n=l.useAPIClient(),t=ue.useNavigate(),{styles:s}=oe(),[i,a]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{a(f.data)}).catch(()=>{})},[o]),y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[o]);const p=y.useCallback(({key:f})=>{f!=o.id&&t(Mo(f))},[o]);return o?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${o.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:K.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Le,{statusMap:Xe,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${o.id}`}),r.jsx(I.DownOutlined,{})]})}):null}function Ur(){var m;const e=l.useCompile(),{data:o,loading:n}=l.useResourceActionContext(),{setTitle:t}=l.useDocumentTitle(),[s,i]=y.useState(null),a=l.useApp();if(y.useEffect(()=>{var T;const{workflow:w}=(T=o==null?void 0:o.data)!=null?T:{};t==null||t(`${w!=null&&w.title?`${w.title} - `:""}${$("Execution history")}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const k=(m=o==null?void 0:o.data)!=null?m:{},{jobs:c=[],workflow:F={}}=k,O=F,{nodes:d=[],revisions:p=[]}=O,f=W(O,["nodes","revisions"]),g=W(k,["jobs","workflow"]);$o(d),zr(d,c);const v=d.find(w=>!w.upstream),h=Xe[g.status];return r.jsxs(ze.Provider,{value:{workflow:f.type?f:null,nodes:d,execution:g,viewJob:s,setViewJob:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:a.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx(ue.Link,{to:Pe(f.id),children:f.title})},{title:r.jsx(Wr,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:h.color,children:e(h.label)}),r.jsx("time",{children:K.str2moment(g.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Dt,{entry:v}),r.jsx(Lr,{})]})}const Nt=()=>{const e=ue.useParams(),{styles:o}=oe();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.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:Ur}})})},Mt=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext();return r.jsx(ue.Link,{to:Mo(o),onClick:()=>n(!1),children:e("View")})},qr={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:o}=l.useActionContext();return r.jsx(ue.Link,{to:Pe(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Qe}}]},Et={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:qr,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:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:o,defaultRequest:n}=l.useResourceActionContext(),{resource:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return G(this,null,function*(){var a;yield t.destroy({filter:(a=n.params)==null?void 0:a.filter}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,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: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{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",properties:{status:{type:"number","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",title:`{{t("Details", { ns: "${u}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function Jr(t){var s=t,{request:e,filter:o={}}=s,n=W(s,["request","filter"]);var c;const{workflow:i}=U(),a=C(x({},n),{request:C(x({},e),{params:C(x({},e==null?void 0:e.params),{filter:C(x({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,x({},a))}function Hr(){var z;const e=ue.useNavigate(),{t:o}=R.useTranslation(),n=l.useApp(),{data:t,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[d,p]=y.useState(!1),{styles:f}=oe(),{modal:g}=b.App.useApp();if(y.useEffect(()=>{var D;const{title:N}=(D=t==null?void 0:t.data)!=null?D:{};c==null||c(`${$("Workflow")}${N?`: ${N}`:""}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const M=(z=t==null?void 0:t.data)!=null?z:{},{nodes:v=[],revisions:h=[]}=M,m=W(M,["nodes","revisions"]);$o(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=m.id&&e(Pe(N))}function O(N){return G(this,null,function*(){yield a.update({filterByTk:m.id,values:{enabled:N}}),s()})}function w(){return G(this,null,function*(){const{data:{data:N}}=yield a.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function T(){return G(this,null,function*(){const N=m.current?$("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:o("Are you sure you want to delete it?"),content:N,onOk(){return G(this,null,function*(){var J;yield a.destroy({filterByTk:m.id}),b.message.success(o("Operation succeeded")),e(m.current?n.pluginSettingsManager.getRoutePath("workflow"):Pe((J=h.find(H=>H.current))==null?void 0:J.id))})}})})}function P(D){return G(this,arguments,function*({key:N}){switch(N){case"history":p(!0);return;case"revision":return w();case"delete":return T()}})}const B=m.executed&&!h.find(N=>!N.executed&&new Date(N.createdAt)>new Date(m.createdAt));return r.jsxs(ze.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:n.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((N,D)=>D.id-N.id).map((N,D)=>({role:"button","aria-label":`version-${D}`,key:`${N.id}`,icon:N.current?r.jsx(I.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${N.id}`}),r.jsx("time",{children:K.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:$("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(I.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:m.enabled,onChange:O,checkedChildren:$("On"),unCheckedChildren:$("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:$("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:$("Copy to new version"),disabled:!B},{role:"button","aria-label":"delete",key:"delete",label:o("Delete")}],onClick:P},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(I.EllipsisOutlined,{})})}),r.jsx(l.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(l.SchemaComponent,{schema:Et,components:{ExecutionResourceProvider:Jr,ExecutionLink:Mt}})})]})]}),r.jsx(Dt,{entry:k})]})}const Pt=()=>{const e=ue.useParams(),{styles:o}=oe();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.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:Hr}})})},Gr=t=>{var s=t,{request:e,filter:o={}}=s,n=W(s,["request","filter"]);var c;const i=l.useRecord(),a=C(x({},n),{request:C(x({},e),{params:C(x({},e==null?void 0:e.params),{filter:C(x({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,x({},a))},_r=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext(),{getAriaLabel:t}=l.useGetAriaLabelOfAction("Configure");return r.jsx(ue.Link,{"aria-label":t(),to:Pe(o),onClick:()=>n(!1),children:e("Configure")})};function Yr(t){var s=t,{component:e="div",children:o}=s,n=W(s,["component","children"]);const[i,a]=y.useState(!1),c=A.useFieldSchema();return r.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[y.createElement(e,C(x({},n),{onClick(){a(!0)}}),o),r.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Kr}=l.interfacesProperties,Zr={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${u}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${u}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:x({},Kr)},Bt={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: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},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: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Se={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},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: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Qr={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Bt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Bt},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{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"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Se.title,type:Se.type,description:Se.description,options:Se.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}}},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 n=l.useRecord();return y.createElement("a",x({"aria-label":`executed-${n.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Et}}}},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:Se.title,enabled:Se.enabled,description:Se.description,options:Se.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: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"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}=R.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:n,targetKey:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[t]:i}=l.useRecord(),{values:a}=A.useForm();return{run(){return G(this,null,function*(){yield n.revision({filterByTk:i,values:a}),b.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 Vt(e){var i;const n=l.useCompile()(e.label),t=y.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Xe[e.value])!=null?i:{};return r.jsx(b.Tag,{color:s,onMouseDown:t,closable:e.closable,onClose:e.onClose,children:n})}function Xr(e){const o=l.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Vt,x({},e)),e.description?r.jsx("span",{children:o(e.description)}):null]})}function Rr(o){var e=W(o,[]);const n=e.multiple?"multiple":null;return r.jsx(b.Select,C(x({role:"button","data-testid":`select-${n||"single"}`},e),{mode:n,optionLabelProp:"label",tagRender:Vt,children:Qe.filter(t=>!!t.value&&t.value!==pe.ABORTED).map(t=>r.jsx(b.Select.Option,C(x({},t),{children:r.jsx(Xr,x({},t))}),t.value))}))}const es=y.createContext({});function os(){const e=y.useContext(l.SchemaComponentContext);return r.jsx(b.Card,{bordered:!1,children:r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{designable:!1}),children:r.jsx(l.SchemaComponent,{schema:Qr,components:{WorkflowLink:_r,ExecutionResourceProvider:Gr,ExecutionLink:Mt,OpenDrawer:Yr,ExecutionStatusSelect:Rr},scope:{getTriggersOptions:So}})})})}const ts=e=>{const o=y.useContext(l.CollectionManagerContext);return r.jsx(l.CollectionManagerContext.Provider,{value:C(x({},o),{interfaces:C(x({},o.interfaces),{expression:Zr})}),children:r.jsx(es.Provider,{value:{triggers:me,instructions:q},children:e.children})})},ns=A.observer(e=>{const{onChange:o}=e,n=A.useField(),t=A.useForm(),i=[...n.path.segments.slice(0,-1),"sourceCollection"].join("."),[a,c]=y.useState(t.getValuesIn(i)),d=l.useCompile(),{getCollectionFields:p}=l.useCollectionManager();A.useFormEffects(()=>{le.onFormInitialValuesChange(g=>{c(g.getValuesIn(i))}),le.onFieldInputValueChange(i,g=>{c(g.value),o(null)})});const f=he({collection:a,compile:d,getCollectionFields:p});return r.jsx(l.Variable.TextArea,C(x({},e),{scope:f}))},{displayName:"InternalExpression"});function rs(e){const{t:o}=R.useTranslation(),n=l.useRecord(),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),i=y.useMemo(()=>he({collection:n.sourceCollection,compile:t,getCollectionFields:s}),[n.sourceCollection,n.sourceCollection]);return e.value?r.jsx(l.Variable.TextArea,C(x({},e),{scope:i})):r.jsx(b.Tag,{children:o("Unconfigured",{ns:u})})}const ss=A.connect(ns,A.mapReadPretty(rs)),is={title:`{{t("Task", { ns: "${u}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},ls={title:`{{t("Workflow", { ns: "${u}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},as={title:`{{t("Workflow todos", { ns: "${u}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-component":"Select",enum:Re}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},cs=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),ds=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),us=A.observer(()=>{var o,n,t;const e=A.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.nickname)!=null?t:(n=e.value)==null?void 0:n.id},{displayName:"UserColumn"}),Eo=()=>r.jsx(l.SchemaComponent,{components:{NodeColumn:cs,WorkflowColumn:ds,UserColumn:us},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${u}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${u}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${u}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function ps(e){var p;const{data:o}=l.useCurrentUserContext(),{userJob:n}=U(),{status:t,result:s,userId:i}=n,a=A.useFieldSchema(),{name:c}=a.parent.toJSON();let{children:d}=e;return t?s[c]||(d=null):((p=o==null?void 0:o.data)==null?void 0:p.id)!==i&&(d=null),d}const ms=y.createContext(null);function fs({value:e,children:o}){const{userJob:n}=U(),t=A.useField(),s=A.useFieldSchema();return y.useEffect(()=>{n.status&&(t.disabled=!0,t.visible=n.status===e&&n.result._===s.name)},[n,e,t]),r.jsx(ms.Provider,{value:e,children:o})}function hs(){const e=l.useAPIClient(),{setVisible:o}=l.useActionContext(),{values:n,submit:t}=A.useForm(),s=A.useFieldSchema(),{service:i}=l.useTableBlockContext(),{userJob:a}=U(),{name:c}=s,{name:d}=s.parent.parent;return{run(){return G(this,null,function*(){a.status||(yield t(),yield e.resource("users_jobs").submit({filterByTk:a.id,values:{result:{[d]:n,_:c}}}),o(!1),i.refresh())})}}}function ys(e){var p;const o=l.useAPIClient(),{id:n}=l.useRecord(),[t,s]=y.useState(null),[i,a]=y.useState(null);y.useEffect(()=>{var f,g;n&&((g=(f=o.resource("users_jobs")).get)==null||g.call(f,{filterByTk:n,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var w;const T=(w=v==null?void 0:v.data)!=null?w:{},{node:h,workflow:P={}}=T,B=P,{nodes:m=[]}=B,k=W(B,["nodes"]),z=T,{execution:F}=z,O=W(z,["node","workflow","execution"]);$o(m),a(h),s({userJob:O,workflow:k,nodes:m,execution:F})}))},[n]);const d=He(t==null?void 0:t.nodes.find(f=>f.id===i.id)).reduce((f,{type:g})=>Object.assign(f,q.get(g).components),{});return i&&t?r.jsx(ze.Provider,{value:t,children:r.jsx(l.SchemaComponent,{components:x(x({FormBlockProvider:bt,DetailsBlockProvider:xt,ActionBarProvider:ps,ManualActionStatusProvider:fs},Array.from(we.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),d),scope:x({useSubmit:hs,useFormBlockProps:gs,useDetailsBlockProps:xs},Array.from(we.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=i.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function gs(){var i;const{userJob:e}=U(),o=l.useRecord(),{data:n}=l.useCurrentUserContext(),{form:t}=l.useFormBlockContext(),s=e.status?o?"readPretty":"disabled":((i=n==null?void 0:n.data)==null?void 0:i.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{t==null||t.setPattern(s)},[s,t]),{form:t}}function xs(){const{form:e}=l.useFormBlockContext();return{form:e}}function bs(){const e=l.useCompile(),{status:o,updatedAt:n}=l.useRecord(),t=We[o];return o?r.jsxs(b.Space,{children:[r.jsx("time",{className:l.css`
|
|
601
601
|
margin-right: 0.5em;
|
|
602
|
-
`,children:zo(n).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:t.icon,color:t.color,children:e(t.label)})]}):null}function vs(){var i;const e=y.useContext(l.SchemaComponentContext),{id:o,node:n,workflow:t,status:s}=l.useRecord();return r.jsx(l.SchemaComponentContext.Provider,{value:C(
|
|
602
|
+
`,children:zo(n).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:t.icon,color:t.color,children:e(t.label)})]}):null}function vs(){var i;const e=y.useContext(l.SchemaComponentContext),{id:o,node:n,workflow:t,status:s}=l.useRecord();return r.jsx(l.SchemaComponentContext.Provider,{value:C(x({},e),{reset(){},designable:!1}),children:r.jsx(l.SchemaComponent,{components:{FooterStatus:bs,FlowContextProvider:ys},schema:{type:"void",name:`drawer-${o}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(i=n.title)!=null?i:`#${n.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function Cs({params:e={},children:o}){const i=l.useCollectionManager(),{collections:n}=i,t=W(i,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(x({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(l.CollectionManagerProvider,C(x({},t),{collections:[...n,is,ls,as],children:r.jsx(l.TableBlockProvider,C(x({name:"workflow-todo"},s),{children:o}))}))}Eo.Drawer=vs,Eo.Decorator=Cs;const ws=()=>{const e=l.useSchemaInitializerItem(),{insert:o}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,C(x({icon:r.jsx(I.TableOutlined,{})},e),{onClick:()=>{o({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class jt extends l.Plugin{constructor(){super(...arguments);bo(this,"triggers",me);bo(this,"getTriggersOptions",So);bo(this,"instructions",q)}load(){return G(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(ts),this.addSchemaInitializers(),this.app.pluginSettingsManager.add(u,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${u}" })}}`,Component:os,aclSnippet:"pm.workflow.workflows"})})}addSchemaInitializers(){this.app.schemaInitializerManager.add(wr),this.app.schemaInitializerManager.add(Ar),this.app.schemaInitializerManager.add(hr),this.app.schemaInitializerManager.get("BlockInitializers").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${u}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:mn})}addComponents(){this.app.addComponents({WorkflowPage:Pt,ExecutionPage:Nt,WorkflowTodo:Eo,WorkflowTodoBlockInitializer:ws,DynamicExpression:ss})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Pe(":id"),element:r.jsx(Pt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Mo(":id"),element:r.jsx(Nt,{})})}}S.BaseTypeSets=Me,S.Branch=Oe,S.EXECUTION_STATUS=pe,S.ExecutionStatusOptions=Qe,S.ExecutionStatusOptionsMap=Xe,S.FlowContext=ze,S.JOB_STATUS=ee,S.JobButton=Tt,S.JobStatusOptions=Re,S.JobStatusOptionsMap=We,S.Node=Ot,S.NodeContext=No,S.NodeDefaultView=Ge,S.RemoveButton=It,S.WorkflowPlugin=jt,S.WorkflowVariableInput=qe,S.WorkflowVariableJSON=pt,S.WorkflowVariableRawTextArea=ut,S.WorkflowVariableTextArea=dt,S.default=jt,S.defaultFieldNames=Ce,S.getCollectionFieldOptions=he,S.getTriggersOptions=So,S.instructions=q,S.nodesOptions=no,S.scopeOptions=Fo,S.systemOptions=at,S.triggerOptions=ro,S.triggers=me,S.useAvailableUpstreams=He,S.useFlowContext=U,S.useNodeContext=ke,S.useStyles=oe,S.useTrigger=lt,S.useUpstreamScopes=At,S.useWorkflowVariableOptions=ce,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|