@nocobase/plugin-workflow-action-trigger 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ActionTrigger.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/externalVersion.js +18 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/locale/index.d.ts +8 -0
- package/dist/locale/index.js +9 -0
- package/dist/server/ActionTrigger.d.ts +8 -0
- package/dist/server/ActionTrigger.js +9 -0
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/20240307215012-change-name.d.ts +8 -0
- package/dist/server/migrations/20240307215012-change-name.js +9 -0
- package/package.json +2 -2
- package/src/client/ActionTrigger.tsx +0 -213
- package/src/client/__e2e__/configuration.test.ts +0 -675
- package/src/client/__e2e__/workflowCRUD.test.ts +0 -178
- package/src/client/index.ts +0 -96
- package/src/index.ts +0 -2
- package/src/locale/en-US.json +0 -9
- package/src/locale/index.ts +0 -12
- package/src/locale/ko_KR.json +0 -9
- package/src/locale/zh-CN.json +0 -18
- package/src/server/ActionTrigger.ts +0 -177
- package/src/server/Plugin.ts +0 -11
- package/src/server/__tests__/trigger.test.ts +0 -778
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20240307215012-change-name.ts +0 -22
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/client';
|
|
2
10
|
import { Trigger, useWorkflowAnyExecuted, CheckboxGroupWithTooltip, RadioWithTooltip } from '@nocobase/plugin-workflow/client';
|
|
3
11
|
export default class extends Trigger {
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Plugin } from '@nocobase/client';
|
|
2
10
|
export default class extends Plugin {
|
|
3
11
|
load(): Promise<void>;
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","@formily/react","react-i18next"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-workflow-action-trigger"]={},o["@nocobase/client"],o["@nocobase/plugin-workflow"],o["@formily/react"],o["react-i18next"]))})(this,function(o,e,t,w,m){"use strict";var E=Object.defineProperty,$=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var k=(o,e,t)=>e in o?E(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))v.call(e,t)&&k(o,t,e[t]);if(S)for(var t of S(e))D.call(e,t)&&k(o,t,e[t]);return o},f=(o,e)=>$(o,M(e));var s=(o,e,t)=>(k(o,typeof e!="symbol"?e+"":e,t),t);var F=(o,e,t)=>new Promise((w,m)=>{var i=r=>{try{c(t.next(r))}catch(l){m(l)}},a=r=>{try{c(t.throw(r))}catch(l){m(l)}},c=r=>r.done?w(r.value):Promise.resolve(r.value).then(i,a);c((t=t.apply(o,e)).next())});const i="workflow-action-trigger";function a(u,A={}){const{t:n}=c(A);return n(u)}function c(u){return m.useTranslation(i,u)}const r={CREATE:"create",UPDATE:"update",UPSERT:"updateOrCreate",DESTROY:"destroy"};class l extends t.Trigger{constructor(){super(...arguments);s(this,"title",`{{t("Post-action event", { ns: "${i}" })}}`);s(this,"description",`{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or "submit to workflow". Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: "${i}" })}}`);s(this,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:`{{t("The collection to which the triggered data belongs.", { ns: "${i}" })}}`},"x-component":"DataSourceCollectionCascader","x-disabled":"{{ useWorkflowAnyExecuted() }}",title:`{{t("Collection", { ns: "${i}" })}}`,"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:`{{t("Trigger mode", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "${i}" })}}`,value:!1},{label:`{{t("Global mode, triggered after the completion of the following actions", { ns: "${i}" })}}`,value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:`{{t("Select actions", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Create record action", { ns: "${i}" })}}`,value:r.CREATE},{label:`{{t("Update record action", { ns: "${i}" })}}`,value:r.UPDATE}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:`{{t("Associations to use", { ns: "${i}" })}}`,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: "workflow" })}}',"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:n}=w.useForm();return n==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});s(this,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted});s(this,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip});s(this,"isActionTriggerable",(n,d)=>d.action==="customize:triggerWorkflows"||["create","update","customize:update"].includes(d.action)&&!n.global)}useVariables(n,d){var y;const T=e.useCompile(),{getCollectionFields:I}=e.useCollectionManager_deprecated(),z=a("Trigger data"),x=a("User submitted action"),C=a("Role of user submitted action"),W=[{collectionName:n.collection,name:"data",type:"hasOne",target:n.collection,uiSchema:{title:z}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:x}},{name:"roleName",uiSchema:{title:C}}];return t.getCollectionFieldOptions(f(g({appends:["data","user",...((y=n.appends)==null?void 0:y.map(R=>`data.${R}`))||[]]},d),{fields:W,compile:T,getCollectionFields:I}))}useInitializers(n){return n.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${i}" })}}`,Component:t.CollectionBlockInitializer,collection:n.collection,dataPath:"$context.data"}:null}}const h={name:"submitToWorkflow",title:'{{t("Submit to workflow", { ns: "workflow" })}}',Component:"CustomizeActionInitializer",schema:{title:'{{t("Submit to workflow", { ns: "workflow" })}}',"x-component":"Action","x-use-component-props":"useTriggerWorkflowsActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Submitted successfully")}}'},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},p={name:"submitToWorkflow",title:'{{t("Submit to workflow", { ns: "workflow" })}}',Component:"CustomizeActionInitializer",schema:{title:'{{t("Submit to workflow", { ns: "workflow" })}}',"x-component":"Action","x-use-component-props":"useRecordTriggerWorkflowsActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Submitted successfully")}}'},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},b=f(g({},p),{schema:f(g({},p.schema),{"x-component":"Action.Link"})});class P extends e.Plugin{load(){return F(this,null,function*(){this.app.pm.get("workflow").registerTrigger("action",l),this.app.addScopes({useTriggerWorkflowsActionProps:t.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:t.useRecordTriggerWorkflowsActionProps}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.submitToWorkflow",p),this.app.schemaInitializerManager.get("details:configureActions").add("customize.submitToWorkflow",p),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.submitToWorkflow",b),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.submitToWorkflow",b),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.submitToWorkflow",b)})}}o.default=P,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
module.exports = {
|
|
2
11
|
"@formily/react": "2.3.0",
|
|
3
|
-
"@nocobase/client": "1.0.0-alpha.
|
|
4
|
-
"@nocobase/plugin-workflow": "1.0.0-alpha.
|
|
12
|
+
"@nocobase/client": "1.0.0-alpha.3",
|
|
13
|
+
"@nocobase/plugin-workflow": "1.0.0-alpha.3",
|
|
5
14
|
"react-i18next": "11.18.6",
|
|
6
15
|
"lodash": "4.17.21",
|
|
7
16
|
"sequelize": "6.35.2",
|
|
8
|
-
"@nocobase/database": "1.0.0-alpha.
|
|
9
|
-
"@nocobase/server": "1.0.0-alpha.
|
|
10
|
-
"@nocobase/actions": "1.0.0-alpha.
|
|
11
|
-
"@nocobase/data-source-manager": "1.0.0-alpha.
|
|
12
|
-
"@nocobase/plugin-workflow-test": "1.0.0-alpha.
|
|
13
|
-
"@nocobase/test": "1.0.0-alpha.
|
|
14
|
-
"@nocobase/utils": "1.0.0-alpha.
|
|
17
|
+
"@nocobase/database": "1.0.0-alpha.3",
|
|
18
|
+
"@nocobase/server": "1.0.0-alpha.3",
|
|
19
|
+
"@nocobase/actions": "1.0.0-alpha.3",
|
|
20
|
+
"@nocobase/data-source-manager": "1.0.0-alpha.3",
|
|
21
|
+
"@nocobase/plugin-workflow-test": "1.0.0-alpha.3",
|
|
22
|
+
"@nocobase/test": "1.0.0-alpha.3",
|
|
23
|
+
"@nocobase/utils": "1.0.0-alpha.3"
|
|
15
24
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export * from './server';
|
|
2
10
|
export { default } from './server';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export declare const NAMESPACE = "workflow-action-trigger";
|
|
2
10
|
export declare function useLang(key: string, options?: {}): string;
|
|
3
11
|
export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-action-trigger", undefined>;
|
package/dist/locale/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { DefaultContext } from '@nocobase/server';
|
|
2
10
|
import { Context as ActionContext, Next } from '@nocobase/actions';
|
|
3
11
|
import WorkflowPlugin, { Trigger, WorkflowModel } from '@nocobase/plugin-workflow';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Plugin } from '@nocobase/server';
|
|
2
10
|
export default class extends Plugin {
|
|
3
11
|
load(): Promise<void>;
|
package/dist/server/Plugin.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export { default } from './Plugin';
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Migration } from '@nocobase/server';
|
|
2
10
|
export default class extends Migration {
|
|
3
11
|
appVersion: string;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:操作后事件",
|
|
5
5
|
"description": "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.",
|
|
6
6
|
"description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
|
|
7
|
-
"version": "1.0.0-alpha.
|
|
7
|
+
"version": "1.0.0-alpha.3",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@nocobase/server": "1.x",
|
|
22
22
|
"@nocobase/test": "1.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "7ccb137c7616cba5d238f87368239640e1d9ace1",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"Workflow"
|
|
27
27
|
]
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { useForm } from '@formily/react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
SchemaInitializerItemType,
|
|
5
|
-
useCollectionDataSource,
|
|
6
|
-
useCollectionManager_deprecated,
|
|
7
|
-
useCompile,
|
|
8
|
-
} from '@nocobase/client';
|
|
9
|
-
import {
|
|
10
|
-
Trigger,
|
|
11
|
-
CollectionBlockInitializer,
|
|
12
|
-
getCollectionFieldOptions,
|
|
13
|
-
useWorkflowAnyExecuted,
|
|
14
|
-
CheckboxGroupWithTooltip,
|
|
15
|
-
RadioWithTooltip,
|
|
16
|
-
} from '@nocobase/plugin-workflow/client';
|
|
17
|
-
import { NAMESPACE, useLang } from '../locale';
|
|
18
|
-
|
|
19
|
-
const COLLECTION_TRIGGER_ACTION = {
|
|
20
|
-
CREATE: 'create',
|
|
21
|
-
UPDATE: 'update',
|
|
22
|
-
UPSERT: 'updateOrCreate',
|
|
23
|
-
DESTROY: 'destroy',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default class extends Trigger {
|
|
27
|
-
title = `{{t("Post-action event", { ns: "${NAMESPACE}" })}}`;
|
|
28
|
-
description = `{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or "submit to workflow". Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: "${NAMESPACE}" })}}`;
|
|
29
|
-
fieldset = {
|
|
30
|
-
collection: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
required: true,
|
|
33
|
-
'x-decorator': 'FormItem',
|
|
34
|
-
'x-decorator-props': {
|
|
35
|
-
tooltip: `{{t("The collection to which the triggered data belongs.", { ns: "${NAMESPACE}" })}}`,
|
|
36
|
-
},
|
|
37
|
-
'x-component': 'DataSourceCollectionCascader',
|
|
38
|
-
'x-disabled': '{{ useWorkflowAnyExecuted() }}',
|
|
39
|
-
title: `{{t("Collection", { ns: "${NAMESPACE}" })}}`,
|
|
40
|
-
'x-reactions': [
|
|
41
|
-
{
|
|
42
|
-
target: 'appends',
|
|
43
|
-
effects: ['onFieldValueChange'],
|
|
44
|
-
fulfill: {
|
|
45
|
-
state: {
|
|
46
|
-
value: [],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
global: {
|
|
53
|
-
type: 'boolean',
|
|
54
|
-
title: `{{t("Trigger mode", { ns: "${NAMESPACE}" })}}`,
|
|
55
|
-
'x-decorator': 'FormItem',
|
|
56
|
-
'x-component': 'RadioWithTooltip',
|
|
57
|
-
'x-component-props': {
|
|
58
|
-
direction: 'vertical',
|
|
59
|
-
options: [
|
|
60
|
-
{
|
|
61
|
-
label: `{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "${NAMESPACE}" })}}`,
|
|
62
|
-
value: false,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: `{{t("Global mode, triggered after the completion of the following actions", { ns: "${NAMESPACE}" })}}`,
|
|
66
|
-
value: true,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
default: false,
|
|
71
|
-
'x-reactions': [
|
|
72
|
-
{
|
|
73
|
-
dependencies: ['collection'],
|
|
74
|
-
fulfill: {
|
|
75
|
-
state: {
|
|
76
|
-
visible: '{{!!$deps[0]}}',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
actions: {
|
|
83
|
-
type: 'number',
|
|
84
|
-
title: `{{t("Select actions", { ns: "${NAMESPACE}" })}}`,
|
|
85
|
-
'x-decorator': 'FormItem',
|
|
86
|
-
'x-component': 'CheckboxGroupWithTooltip',
|
|
87
|
-
'x-component-props': {
|
|
88
|
-
direction: 'vertical',
|
|
89
|
-
options: [
|
|
90
|
-
{ label: `{{t("Create record action", { ns: "${NAMESPACE}" })}}`, value: COLLECTION_TRIGGER_ACTION.CREATE },
|
|
91
|
-
{ label: `{{t("Update record action", { ns: "${NAMESPACE}" })}}`, value: COLLECTION_TRIGGER_ACTION.UPDATE },
|
|
92
|
-
// { label: `{{t("upsert", { ns: "${NAMESPACE}" })}}`, value: COLLECTION_TRIGGER_ACTION.UPSERT },
|
|
93
|
-
// {
|
|
94
|
-
// label: `{{t("Delete single or many records", { ns: "${NAMESPACE}" })}}`,
|
|
95
|
-
// value: COLLECTION_TRIGGER_ACTION.DESTROY,
|
|
96
|
-
// },
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
required: true,
|
|
100
|
-
'x-reactions': [
|
|
101
|
-
{
|
|
102
|
-
dependencies: ['collection', 'global'],
|
|
103
|
-
fulfill: {
|
|
104
|
-
state: {
|
|
105
|
-
visible: '{{!!$deps[0] && !!$deps[1]}}',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
appends: {
|
|
112
|
-
type: 'array',
|
|
113
|
-
title: `{{t("Associations to use", { ns: "${NAMESPACE}" })}}`,
|
|
114
|
-
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: "workflow" })}}`,
|
|
115
|
-
'x-decorator': 'FormItem',
|
|
116
|
-
'x-component': 'AppendsTreeSelect',
|
|
117
|
-
'x-component-props': {
|
|
118
|
-
title: 'Preload associations',
|
|
119
|
-
multiple: true,
|
|
120
|
-
useCollection() {
|
|
121
|
-
const { values } = useForm();
|
|
122
|
-
return values?.collection;
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
'x-reactions': [
|
|
126
|
-
{
|
|
127
|
-
dependencies: ['collection'],
|
|
128
|
-
fulfill: {
|
|
129
|
-
state: {
|
|
130
|
-
visible: '{{!!$deps[0]}}',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
scope = {
|
|
138
|
-
useCollectionDataSource,
|
|
139
|
-
useWorkflowAnyExecuted,
|
|
140
|
-
};
|
|
141
|
-
components = {
|
|
142
|
-
RadioWithTooltip,
|
|
143
|
-
CheckboxGroupWithTooltip,
|
|
144
|
-
};
|
|
145
|
-
isActionTriggerable = (config, context) => {
|
|
146
|
-
return (
|
|
147
|
-
context.action === 'customize:triggerWorkflows' ||
|
|
148
|
-
(['create', 'update', 'customize:update'].includes(context.action) && !config.global)
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
useVariables(config, options) {
|
|
152
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
153
|
-
const compile = useCompile();
|
|
154
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
155
|
-
const { getCollectionFields } = useCollectionManager_deprecated();
|
|
156
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
157
|
-
const langTriggerData = useLang('Trigger data');
|
|
158
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
159
|
-
const langUserSubmittedForm = useLang('User submitted action');
|
|
160
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
161
|
-
const langRoleSubmittedForm = useLang('Role of user submitted action');
|
|
162
|
-
const rootFields = [
|
|
163
|
-
{
|
|
164
|
-
collectionName: config.collection,
|
|
165
|
-
name: 'data',
|
|
166
|
-
type: 'hasOne',
|
|
167
|
-
target: config.collection,
|
|
168
|
-
uiSchema: {
|
|
169
|
-
title: langTriggerData,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
collectionName: 'users',
|
|
174
|
-
name: 'user',
|
|
175
|
-
type: 'hasOne',
|
|
176
|
-
target: 'users',
|
|
177
|
-
uiSchema: {
|
|
178
|
-
title: langUserSubmittedForm,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
name: 'roleName',
|
|
183
|
-
uiSchema: {
|
|
184
|
-
title: langRoleSubmittedForm,
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
];
|
|
188
|
-
const result = getCollectionFieldOptions({
|
|
189
|
-
// depth,
|
|
190
|
-
appends: ['data', 'user', ...(config.appends?.map((item) => `data.${item}`) || [])],
|
|
191
|
-
...options,
|
|
192
|
-
fields: rootFields,
|
|
193
|
-
compile,
|
|
194
|
-
getCollectionFields,
|
|
195
|
-
});
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
useInitializers(config): SchemaInitializerItemType | null {
|
|
199
|
-
if (!config.collection) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
name: 'triggerData',
|
|
205
|
-
type: 'item',
|
|
206
|
-
key: 'triggerData',
|
|
207
|
-
title: `{{t("Trigger data", { ns: "${NAMESPACE}" })}}`,
|
|
208
|
-
Component: CollectionBlockInitializer,
|
|
209
|
-
collection: config.collection,
|
|
210
|
-
dataPath: '$context.data',
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|