@nocobase/plugin-notification-manager 1.5.0-beta.1 → 1.5.0-beta.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/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@ant-design/icons"),require("antd"),require("react"),require("@formily/core"),require("@formily/react"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react-i18next","react/jsx-runtime","@ant-design/icons","antd","react","@formily/core","@formily/react","@formily/shared","@nocobase/utils/client","@formily/antd-v5"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["@nocobase/plugin-notification-manager"]={},s["@nocobase/client"],s["react-i18next"],s.jsxRuntime,s["@ant-design/icons"],s.antd,s.react,s["@formily/core"],s["@formily/react"],s["@formily/shared"],s["@nocobase/utils"],s["@formily/antd-v5"]))})(this,function(s,t,c,i,S,u,p,P,l,N,$,Y){"use strict";var Ae=Object.defineProperty,ve=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var L=(s,t,c)=>t in s?Ae(s,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[t]=c,f=(s,t)=>{for(var c in t||(t={}))Pe.call(t,c)&&L(s,c,t[c]);if(Z)for(var c of Z(t))Ne.call(t,c)&&L(s,c,t[c]);return s},h=(s,t)=>ve(s,Se(t));var D=(s,t,c)=>(L(s,typeof t!="symbol"?t+"":t,c),c);var T=(s,t,c)=>new Promise((i,S)=>{var u=l=>{try{P(c.next(l))}catch(N){S(N)}},p=l=>{try{P(c.throw(l))}catch(N){S(N)}},P=l=>l.done?i(l.value):Promise.resolve(l.value).then(u,p);P((c=c.apply(s,t)).next())});const _="@nocobase/plugin-notification-manager";function k(e){return t.i18n.t(e,{ns:_})}function b(){return c.useTranslation([_,"client","data-source-manager"],{nsMode:"fallback"})}var A=(e=>(e.templates="templates",e.channels="notificationChannels",e.messages="messages",e.logs="notificationSendLogs",e))(A||{});const z={name:A.channels,filterTargetKey:"name",autoGenId:!1,createdAt:!0,createdBy:!0,updatedAt:!0,updatedBy:!0,fields:[{name:"name",type:"uid",prefix:"s_",primaryKey:!0,interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input","x-read-pretty":!0,required:!0,description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},{name:"title",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}',required:!0}},{name:"options",type:"json",interface:"json",uiSchema:{type:"object","x-component":"ConfigForm"}},{name:"meta",type:"json",interface:"json"},{interface:"input",type:"string",name:"notificationType",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"description",type:"text",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea",title:'{{t("Description")}}'}}]},V={name:A.logs,title:"MessageLogs",fields:[{name:"id",type:"uuid",primaryKey:!0,allowNull:!1,interface:"uuid",uiSchema:{type:"string",title:'{{t("ID")}}',"x-component":"Input","x-read-pretty":!0}},{name:"channelName",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input"}},{name:"channelTitle",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}'}},{name:"triggerFrom",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Trigger from")}}'}},{name:"notificationType",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"status",type:"string",interface:"select",uiSchema:{type:"string","x-component":"Select",enum:[{label:'{{t("Success")}}',value:"success",color:"green"},{label:'{{t("Failure")}}',value:"failure",color:"red"}],title:'{{t("Status")}}'}},{name:"message",type:"json",interface:"json",uiSchema:{"x-component":"Input.JSON",title:'{{t("Message")}}',"x-component-props":{autoSize:{minRows:5}},autoSize:{minRows:5}}},{name:"reason",type:"text",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Failed reason")}}'}},{name:"createdAt",type:"date",interface:"createdAt",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{name:"updatedAt",type:"date",interface:"updatedAt",field:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}]},E=p.createContext({name:"",setName:()=>{}});E.displayName="ChannelTypeContext";const M=p.createContext({channelTypes:[]});M.displayName="ChannelTypesContext";const R=()=>{const{channelTypes:e}=p.useContext(M);return e};function ee(){const[e,o]=p.useState("");return{name:e,setName:o,NotificationTypeNameProvider:({children:a})=>i.jsx(E.Provider,{value:{name:e,setName:o},children:a})}}const K=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext();return{type:"primary",onClick(y,d){return T(this,null,function*(){var v,w;yield r.submit();const x=r.values;yield a.create({values:x});const{count:C=0,page:g=0,pageSize:F=0}=((v=n==null?void 0:n.data)==null?void 0:v.meta)||{};C%F===1&&g!==1&&n.run(h(f({},(w=n==null?void 0:n.params)==null?void 0:w[0]),{page:g-1})),d&&(d==null||d()),o==null||o(!0),e==null||e(!1)})}}},U=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext(),m=t.useCollection();return{type:"primary",onClick(d,x){return T(this,null,function*(){var w,X;yield r.submit();const C=r.values;yield a.update({values:C,filterByTk:C[m.filterTargetKey]});const{count:g=0,page:F=0,pageSize:v=0}=((w=n==null?void 0:n.data)==null?void 0:w.meta)||{};g%v===1&&F!==1&&n.run(h(f({},(X=n==null?void 0:n.params)==null?void 0:X[0]),{page:F-1})),x&&(x==null||x()),o==null||o(!0),e==null||e(!1)})}}},q=()=>{const e=t.useCollectionRecordData();return{form:p.useMemo(()=>P.createForm({initialValues:e}),[])}},te=()=>{var a;const e=t.useCollectionRecordData(),o=(a=e==null?void 0:e.meta)==null?void 0:a.editable,r={};return o===!1&&(r.display="none"),{style:r}},oe=()=>{var n;const e=t.useCollectionRecordData(),o=(n=e==null?void 0:e.meta)==null?void 0:n.deletable,r={},a=t.useDestroyActionProps();return o===!1&&(r.display="none"),h(f({},a),{style:r})},H=()=>{t.useActionContext();const{name:e}=p.useContext(E);return{form:p.useMemo(()=>P.createForm({values:{name:`s_${N.uid()}`,notificationType:e}}),[e])}},Q=()=>{const{setVisible:e}=t.useActionContext();return{type:"default",onClick(){e(!1)}}};p.createContext([]);const O=()=>{const{t:e}=b(),o=t.usePlugin(I),r=[];for(const[a,n]of o.channelTypes.getEntities()){const m=l.Schema.compile(n.title,{t:e}),y=h(f({},n),{name:n.type,key:n.type,value:n.type,title:m,label:m});r.push(y)}return r},ne={name:{"x-component":"CollectionField","x-decorator":"FormItem"},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},re={name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},ie={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",title:'{{t("Add new")}}',properties:h(f({},ne),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useCreateActionProps"}}}})}}},se={type:"void",name:N.uid(),"x-decorator":"TableBlockProvider","x-decorator-props":{collection:A.channels,action:"list",dragSort:!1,params:{sort:["createdAt"],pageSize:20}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}},filter:{"x-action":"filter",type:"object","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{title:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel display name")}}',"x-component-props":{width:100},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},name:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel name")}}',"x-component-props":{width:100},properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},description:{type:"void","x-component":"TableV2.Column",title:'{{t("Description")}}',"x-component-props":{width:200},properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column","x-component-props":{width:200},properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{edit:{type:"void",title:"Edit","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-use-component-props":"useRecordEditActionProps","x-decorator":"Space",properties:{drawer:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:h(f({},re),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:"Submit","x-component":"Action","x-use-component-props":"useEditActionProps"}}}})}}},delete:{type:"void",title:'{{t("Delete")}}',"x-decorator":"Space","x-component":"Action.Link","x-use-component-props":"useRecordDeleteActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}},ae=l.observer(()=>{var m,y;const e=l.useForm(),o=t.useCollectionRecord(),r=e.values.notificationType||((m=o==null?void 0:o.data)==null?void 0:m.notificationType),{channelTypes:a}=p.useContext(M),n=a.find(d=>d.type===r);return(y=n.components)!=null&&y.ChannelConfigForm?i.jsx(n.components.ChannelConfigForm,{}):null},{displayName:"ConfigForm"}),pe=()=>{const{setVisible:e}=t.useActionContext();return{run(){return T(this,null,function*(){e(!1)})}}},ce=()=>{const{t:e}=b(),[o,r]=p.useState(!1),{NotificationTypeNameProvider:a,name:n,setName:m}=ee(),y=t.useAPIClient(),d=R().filter(C=>{var g;return((g=C.meta)==null?void 0:g.creatable)!==!1}),x=d.length===0?[{key:"__empty__",label:i.jsx(u.Empty,{image:u.Empty.PRESENTED_IMAGE_SIMPLE,description:i.jsxs(i.Fragment,{children:[e("No channel enabled yet"),i.jsx("br",{})," ",i.jsx("a",{target:"_blank",href:y.auth.locale==="zh-CN"?"https://docs-cn.nocobase.com/handbook/notification-manager":"https://docs.nocobase.com/handbook/notification-manager",rel:"noreferrer",children:e("View documentation")})]})})}]:d.map(C=>({key:C.type,label:C.title,onClick:()=>{r(!0),m(C.type)}}));return i.jsx(t.ActionContextProvider,{value:{visible:o,setVisible:r},children:i.jsxs(a,{children:[i.jsx(u.Dropdown,{menu:{items:x},children:i.jsxs(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",i.jsx(S.DownOutlined,{})]})}),i.jsx(t.SchemaComponent,{scope:{useCloseAction:pe,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H},schema:ie})]})})},le=()=>(t.useAsyncData(),!1),G=()=>{const{t:e}=b(),o=O(),r=t.useSchemaComponentContext();return i.jsx(t.ExtendCollectionsProvider,{collections:[z,V],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},r),{designable:!1}),children:i.jsx(M.Provider,{value:{channelTypes:o},children:i.jsx(u.Card,{bordered:!1,children:i.jsx(t.SchemaComponent,{schema:se,components:{AddNew:ce,ConfigForm:ae},scope:{useCanNotDelete:le,t:e,notificationTypeOptions:o,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H,useRecordDeleteActionProps:oe,useRecordEditActionProps:te}})})})})})};G.displayName="ChannelManager";const me={id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0,"x-read-pretty":!0},channelName:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},channelTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},notificationType:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},triggerFrom:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},status:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},message:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},reason:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":[{dependencies:["status"],fulfill:{state:{visible:'{{$deps[0] === "failure"}}'}}}]},createdAt:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}},de={type:"void","x-uid":"t8tkmt2b9dd",name:A.logs,"x-decorator":"TableBlockProvider","x-decorator-props":{collection:V.name,action:"list",params:{sort:["-createdAt"]},showIndex:!0,dragSort:!1},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{"x-action":"filter","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["receiver","reason"]},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{createdAt:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Created at")}}',properties:{createdAt:{type:"string","x-component":"CollectionField","x-pattern":"readPretty","x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}}},triggerFrom:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Trigger from")}}',properties:{triggerFrom:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},channelTitle:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Channel display name")}}',properties:{channelTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status")}}',properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},reason:{type:"void","x-component":"TableV2.Column","x-component-props":{width:200},title:'{{t("Failed reason")}}',properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{t("Log detail")}}',"x-component":"Action.Drawer",properties:{detail:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps","x-decorator":"BlockItemCard",properties:h(f({},me),{footer:{type:"void","x-component":"Action.Drawer.Footer"}})}}}}}}}}}}},J=()=>{const{t:e}=b(),o=t.useSchemaComponentContext(),r=O();return i.jsx(t.ExtendCollectionsProvider,{collections:[V,z],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},o),{designable:!1}),children:i.jsx(u.Card,{bordered:!1,children:i.jsx(t.SchemaComponent,{schema:de,scope:{t:e,useEditFormProps:q,notificationTypeOptions:r}})})})})};J.displayName="LogManager";class ue{constructor(){D(this,"channelTypes",new $.Registry)}registerChannelType(o){this.channelTypes.register(o.type,o)}}const ye=p.createContext({typeMap:{}});ye.displayName="ChannelTypesContext";const W=()=>{const{t:e}=b(),o=t.usePlugin(I),r={};for(const[a,n]of o.channelTypes.getEntities()){const m=h(f({},n),{title:l.Schema.compile(n.title,{t:e})});r[n.type]=m}return r},j=p.createContext([]),xe=()=>({scope:p.useContext(j)}),fe=({value:e,children:o})=>i.jsx(j.Provider,{value:e,children:o}),Ce=l.observer(({variableOptions:e})=>{const o=l.useField(),{channelName:r}=o.form.values,[a,n]=p.useState(null),{t:m}=b(),y=t.useAPIClient();p.useEffect(()=>{T(this,null,function*(){var v;if(!r){n(null);return}const{data:F}=yield y.request({url:`/${A.channels}:get`,method:"get",params:{filterByTk:r}});n((v=F==null?void 0:F.data)==null?void 0:v.notificationType)})},[r,y]);const d=W(),{MessageConfigForm:x=()=>null}=(a?d[a]:{}).components||{},C={type:"void",properties:{channelName:{type:"string",title:'{{t("Channel")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{multiple:!1,manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:A.channels,action:"list"},style:{width:"100%"}}},message:{type:"void","x-component":"MessageConfigForm","x-component-props":{variableOptions:e}}}};return i.jsx(t.SchemaComponent,{schema:C,components:{MessageConfigForm:x,ArrayItems:Y.ArrayItems},scope:{t:m}})},{displayName:"MessageConfigForm"}),he=t.withDynamicSchemaProps(l.observer(({variableOptions:e,channelType:o})=>{var n;const r=W(),{ContentConfigForm:a=()=>null}=((n=o?r[o]:{})==null?void 0:n.components)||{};return i.jsx(a,{variableOptions:e})},{displayName:"ContentConfigForm"}));function ge({value:e,onChange:o,variableOptions:r}){return i.jsx(t.Variable.Input,{scope:r,value:e,onChange:o,children:i.jsx(t.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users",defaultParams:e?{filter:{id:e}}:void 0},manual:!1,value:e,onChange:o})})}function Fe(e){const o=l.useField(),r=t.useCollectionFilterOptions("users"),{token:a}=t.useToken(),n=p.useCallback(({value:m,onChange:y,renderSchemaComponent:d})=>i.jsx(t.Variable.Input,{value:m,onChange:y,scope:e.variableOptions,children:d()}),[e.variableOptions]);return i.jsx("div",{style:{border:`1px dashed ${a.colorBorder}`,padding:a.paddingSM},children:i.jsx(t.SchemaComponent,{basePath:o.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:r,dynamicComponent:n}}}}})})}function Te(e){return typeof e.value==="object"&&e.value?i.jsx(Fe,f({},e)):i.jsx(ge,f({},e))}function be(){const[e,o]=p.useState(!1),{t:r}=b(),a=Y.ArrayItems.useArray(),n=l.useForm(),m=(n==null?void 0:n.disabled)===!0,y=p.useCallback(()=>{a.field.push(""),o(!1)},[a.field]),d=p.useCallback(()=>{a.field.push({filter:{}}),o(!1)},[a.field]),x=i.jsx(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"dashed",block:!0,disabled:m,className:"ant-formily-array-base-addition",children:r("Add user")});return m?x:i.jsx(u.Popover,{open:e,onOpenChange:o,content:i.jsxs(u.Space,{direction:"vertical",size:"small",children:[i.jsx(u.Button,{type:"text",onClick:y,children:r("Select users")}),i.jsx(u.Button,{type:"text",onClick:d,children:r("Query users")})]}),children:x})}const B="notification-manager";class I extends t.Plugin{constructor(){super(...arguments);D(this,"manager");D(this,"useNotificationTypes",O)}get channelTypes(){return this.manager.channelTypes}registerChannelType(r){this.manager.registerChannelType(r)}afterAdd(){return T(this,null,function*(){})}beforeLoad(){return T(this,null,function*(){this.manager=new ue})}load(){return T(this,null,function*(){this.app.pluginSettingsManager.add(B,{title:k("Notification manager"),icon:"NotificationOutlined",aclSnippet:"pm.notification"}),this.app.pluginSettingsManager.add(`${B}.channels`,{title:k("Channels"),Component:G,aclSnippet:"pm.notification.channels",sort:1}),this.app.pluginSettingsManager.add(`${B}.logs`,{title:k("Logs"),Component:J,aclSnippet:"pm.notification.logs",sort:3})})}}s.ContentConfigForm=he,s.MessageConfigForm=Ce,s.NotificationVariableContext=j,s.NotificationVariableProvider=fe,s.PluginNotificationManagerClient=I,s.UserAddition=be,s.UserSelect=Te,s.default=I,s.useNotificationVariableOptions=xe,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
10
|
+
(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@ant-design/icons"),require("antd"),require("react"),require("@formily/core"),require("@formily/react"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react-i18next","react/jsx-runtime","@ant-design/icons","antd","react","@formily/core","@formily/react","@formily/shared","@nocobase/utils/client","@formily/antd-v5"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["@nocobase/plugin-notification-manager"]={},s["@nocobase/client"],s["react-i18next"],s.jsxRuntime,s["@ant-design/icons"],s.antd,s.react,s["@formily/core"],s["@formily/react"],s["@formily/shared"],s["@nocobase/utils"],s["@formily/antd-v5"]))})(this,function(s,t,c,i,S,u,p,P,l,N,$,Y){"use strict";var Ae=Object.defineProperty,ve=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var L=(s,t,c)=>t in s?Ae(s,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[t]=c,f=(s,t)=>{for(var c in t||(t={}))Pe.call(t,c)&&L(s,c,t[c]);if(Z)for(var c of Z(t))Ne.call(t,c)&&L(s,c,t[c]);return s},h=(s,t)=>ve(s,Se(t));var D=(s,t,c)=>(L(s,typeof t!="symbol"?t+"":t,c),c);var T=(s,t,c)=>new Promise((i,S)=>{var u=l=>{try{P(c.next(l))}catch(N){S(N)}},p=l=>{try{P(c.throw(l))}catch(N){S(N)}},P=l=>l.done?i(l.value):Promise.resolve(l.value).then(u,p);P((c=c.apply(s,t)).next())});const _="@nocobase/plugin-notification-manager";function k(e){return t.i18n.t(e,{ns:_})}function b(){return c.useTranslation([_,"client","data-source-manager"],{nsMode:"fallback"})}var A=(e=>(e.templates="templates",e.channels="notificationChannels",e.messages="messages",e.logs="notificationSendLogs",e))(A||{});const z={name:A.channels,filterTargetKey:"name",autoGenId:!1,createdAt:!0,createdBy:!0,updatedAt:!0,updatedBy:!0,fields:[{name:"name",type:"uid",prefix:"s_",primaryKey:!0,interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input",required:!0,description:"{{t('Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},{name:"title",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}',required:!0}},{name:"options",type:"json",interface:"json",uiSchema:{type:"object","x-component":"ConfigForm"}},{name:"meta",type:"json",interface:"json"},{interface:"input",type:"string",name:"notificationType",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"description",type:"text",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea",title:'{{t("Description")}}'}}]},V={name:A.logs,title:"MessageLogs",fields:[{name:"id",type:"uuid",primaryKey:!0,allowNull:!1,interface:"uuid",uiSchema:{type:"string",title:'{{t("ID")}}',"x-component":"Input","x-read-pretty":!0}},{name:"channelName",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input"}},{name:"channelTitle",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}'}},{name:"triggerFrom",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Trigger from")}}'}},{name:"notificationType",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"status",type:"string",interface:"select",uiSchema:{type:"string","x-component":"Select",enum:[{label:'{{t("Success")}}',value:"success",color:"green"},{label:'{{t("Failure")}}',value:"failure",color:"red"}],title:'{{t("Status")}}'}},{name:"message",type:"json",interface:"json",uiSchema:{"x-component":"Input.JSON",title:'{{t("Message")}}',"x-component-props":{autoSize:{minRows:5}},autoSize:{minRows:5}}},{name:"reason",type:"text",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Failed reason")}}'}},{name:"createdAt",type:"date",interface:"createdAt",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{name:"updatedAt",type:"date",interface:"updatedAt",field:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}]},E=p.createContext({name:"",setName:()=>{}});E.displayName="ChannelTypeContext";const M=p.createContext({channelTypes:[]});M.displayName="ChannelTypesContext";const R=()=>{const{channelTypes:e}=p.useContext(M);return e};function ee(){const[e,o]=p.useState("");return{name:e,setName:o,NotificationTypeNameProvider:({children:a})=>i.jsx(E.Provider,{value:{name:e,setName:o},children:a})}}const K=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext();return{type:"primary",onClick(y,d){return T(this,null,function*(){var v,w;yield r.submit();const x=r.values;yield a.create({values:x});const{count:C=0,page:g=0,pageSize:F=0}=((v=n==null?void 0:n.data)==null?void 0:v.meta)||{};C%F===1&&g!==1&&n.run(h(f({},(w=n==null?void 0:n.params)==null?void 0:w[0]),{page:g-1})),d&&(d==null||d()),o==null||o(!0),e==null||e(!1)})}}},U=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext(),m=t.useCollection();return{type:"primary",onClick(d,x){return T(this,null,function*(){var w,X;yield r.submit();const C=r.values;yield a.update({values:C,filterByTk:C[m.filterTargetKey]});const{count:g=0,page:F=0,pageSize:v=0}=((w=n==null?void 0:n.data)==null?void 0:w.meta)||{};g%v===1&&F!==1&&n.run(h(f({},(X=n==null?void 0:n.params)==null?void 0:X[0]),{page:F-1})),x&&(x==null||x()),o==null||o(!0),e==null||e(!1)})}}},q=()=>{const e=t.useCollectionRecordData();return{form:p.useMemo(()=>P.createForm({initialValues:e}),[])}},te=()=>{var a;const e=t.useCollectionRecordData(),o=(a=e==null?void 0:e.meta)==null?void 0:a.editable,r={};return o===!1&&(r.display="none"),{style:r}},oe=()=>{var n;const e=t.useCollectionRecordData(),o=(n=e==null?void 0:e.meta)==null?void 0:n.deletable,r={},a=t.useDestroyActionProps();return o===!1&&(r.display="none"),h(f({},a),{style:r})},H=()=>{t.useActionContext();const{name:e}=p.useContext(E);return{form:p.useMemo(()=>P.createForm({values:{name:`s_${N.uid()}`,notificationType:e}}),[e])}},Q=()=>{const{setVisible:e}=t.useActionContext();return{type:"default",onClick(){e(!1)}}};p.createContext([]);const O=()=>{const{t:e}=b(),o=t.usePlugin(I),r=[];for(const[a,n]of o.channelTypes.getEntities()){const m=l.Schema.compile(n.title,{t:e}),y=h(f({},n),{name:n.type,key:n.type,value:n.type,title:m,label:m});r.push(y)}return r},ne={name:{"x-component":"CollectionField","x-decorator":"FormItem"},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},re={name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},ie={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",title:'{{t("Add new")}}',properties:h(f({},ne),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useCreateActionProps"}}}})}}},se={type:"void",name:N.uid(),"x-decorator":"TableBlockProvider","x-decorator-props":{collection:A.channels,action:"list",dragSort:!1,params:{sort:["createdAt"],pageSize:20}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}},filter:{"x-action":"filter",type:"object","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{title:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel display name")}}',"x-component-props":{width:100},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},name:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel name")}}',"x-component-props":{width:100},properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},description:{type:"void","x-component":"TableV2.Column",title:'{{t("Description")}}',"x-component-props":{width:200},properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column","x-component-props":{width:200},properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{edit:{type:"void",title:"Edit","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-use-component-props":"useRecordEditActionProps","x-decorator":"Space",properties:{drawer:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:h(f({},re),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:"Submit","x-component":"Action","x-use-component-props":"useEditActionProps"}}}})}}},delete:{type:"void",title:'{{t("Delete")}}',"x-decorator":"Space","x-component":"Action.Link","x-use-component-props":"useRecordDeleteActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}},ae=l.observer(()=>{var m,y;const e=l.useForm(),o=t.useCollectionRecord(),r=e.values.notificationType||((m=o==null?void 0:o.data)==null?void 0:m.notificationType),{channelTypes:a}=p.useContext(M),n=a.find(d=>d.type===r);return(y=n.components)!=null&&y.ChannelConfigForm?i.jsx(n.components.ChannelConfigForm,{}):null},{displayName:"ConfigForm"}),pe=()=>{const{setVisible:e}=t.useActionContext();return{run(){return T(this,null,function*(){e(!1)})}}},ce=()=>{const{t:e}=b(),[o,r]=p.useState(!1),{NotificationTypeNameProvider:a,name:n,setName:m}=ee(),y=t.useAPIClient(),d=R().filter(C=>{var g;return((g=C.meta)==null?void 0:g.creatable)!==!1}),x=d.length===0?[{key:"__empty__",label:i.jsx(u.Empty,{image:u.Empty.PRESENTED_IMAGE_SIMPLE,description:i.jsxs(i.Fragment,{children:[e("No channel enabled yet"),i.jsx("br",{})," ",i.jsx("a",{target:"_blank",href:y.auth.locale==="zh-CN"?"https://docs-cn.nocobase.com/handbook/notification-manager":"https://docs.nocobase.com/handbook/notification-manager",rel:"noreferrer",children:e("View documentation")})]})})}]:d.map(C=>({key:C.type,label:C.title,onClick:()=>{r(!0),m(C.type)}}));return i.jsx(t.ActionContextProvider,{value:{visible:o,setVisible:r},children:i.jsxs(a,{children:[i.jsx(u.Dropdown,{menu:{items:x},children:i.jsxs(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",i.jsx(S.DownOutlined,{})]})}),i.jsx(t.SchemaComponent,{scope:{useCloseAction:pe,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H},schema:ie})]})})},le=()=>(t.useAsyncData(),!1),G=()=>{const{t:e}=b(),o=O(),r=t.useSchemaComponentContext();return i.jsx(t.ExtendCollectionsProvider,{collections:[z,V],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},r),{designable:!1}),children:i.jsx(M.Provider,{value:{channelTypes:o},children:i.jsx(u.Card,{bordered:!1,children:i.jsx(t.SchemaComponent,{schema:se,components:{AddNew:ce,ConfigForm:ae},scope:{useCanNotDelete:le,t:e,notificationTypeOptions:o,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H,useRecordDeleteActionProps:oe,useRecordEditActionProps:te}})})})})})};G.displayName="ChannelManager";const me={id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0,"x-read-pretty":!0},channelName:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},channelTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},notificationType:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},triggerFrom:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},status:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},message:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},reason:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":[{dependencies:["status"],fulfill:{state:{visible:'{{$deps[0] === "failure"}}'}}}]},createdAt:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}},de={type:"void","x-uid":"t8tkmt2b9dd",name:A.logs,"x-decorator":"TableBlockProvider","x-decorator-props":{collection:V.name,action:"list",params:{sort:["-createdAt"]},showIndex:!0,dragSort:!1},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{"x-action":"filter","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["receiver","reason"]},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{createdAt:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Created at")}}',properties:{createdAt:{type:"string","x-component":"CollectionField","x-pattern":"readPretty","x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}}},triggerFrom:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Trigger from")}}',properties:{triggerFrom:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},channelTitle:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Channel display name")}}',properties:{channelTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status")}}',properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},reason:{type:"void","x-component":"TableV2.Column","x-component-props":{width:200},title:'{{t("Failed reason")}}',properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{t("Log detail")}}',"x-component":"Action.Drawer",properties:{detail:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps","x-decorator":"BlockItemCard",properties:h(f({},me),{footer:{type:"void","x-component":"Action.Drawer.Footer"}})}}}}}}}}}}},J=()=>{const{t:e}=b(),o=t.useSchemaComponentContext(),r=O();return i.jsx(t.ExtendCollectionsProvider,{collections:[V,z],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},o),{designable:!1}),children:i.jsx(u.Card,{bordered:!1,children:i.jsx(t.SchemaComponent,{schema:de,scope:{t:e,useEditFormProps:q,notificationTypeOptions:r}})})})})};J.displayName="LogManager";class ue{constructor(){D(this,"channelTypes",new $.Registry)}registerChannelType(o){this.channelTypes.register(o.type,o)}}const ye=p.createContext({typeMap:{}});ye.displayName="ChannelTypesContext";const W=()=>{const{t:e}=b(),o=t.usePlugin(I),r={};for(const[a,n]of o.channelTypes.getEntities()){const m=h(f({},n),{title:l.Schema.compile(n.title,{t:e})});r[n.type]=m}return r},j=p.createContext([]),xe=()=>({scope:p.useContext(j)}),fe=({value:e,children:o})=>i.jsx(j.Provider,{value:e,children:o}),Ce=l.observer(({variableOptions:e})=>{const o=l.useField(),{channelName:r}=o.form.values,[a,n]=p.useState(null),{t:m}=b(),y=t.useAPIClient();p.useEffect(()=>{T(this,null,function*(){var v;if(!r){n(null);return}const{data:F}=yield y.request({url:`/${A.channels}:get`,method:"get",params:{filterByTk:r}});n((v=F==null?void 0:F.data)==null?void 0:v.notificationType)})},[r,y]);const d=W(),{MessageConfigForm:x=()=>null}=(a?d[a]:{}).components||{},C={type:"void",properties:{channelName:{type:"string",title:'{{t("Channel")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{multiple:!1,manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:A.channels,action:"list"},style:{width:"100%"}}},message:{type:"void","x-component":"MessageConfigForm","x-component-props":{variableOptions:e}}}};return i.jsx(t.SchemaComponent,{schema:C,components:{MessageConfigForm:x,ArrayItems:Y.ArrayItems},scope:{t:m}})},{displayName:"MessageConfigForm"}),he=t.withDynamicSchemaProps(l.observer(({variableOptions:e,channelType:o})=>{var n;const r=W(),{ContentConfigForm:a=()=>null}=((n=o?r[o]:{})==null?void 0:n.components)||{};return i.jsx(a,{variableOptions:e})},{displayName:"ContentConfigForm"}));function ge({value:e,onChange:o,variableOptions:r}){return i.jsx(t.Variable.Input,{scope:r,value:e,onChange:o,children:i.jsx(t.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users",defaultParams:e?{filter:{id:e}}:void 0},manual:!1,value:e,onChange:o})})}function Fe(e){const o=l.useField(),r=t.useCollectionFilterOptions("users"),{token:a}=t.useToken(),n=p.useCallback(({value:m,onChange:y,renderSchemaComponent:d})=>i.jsx(t.Variable.Input,{value:m,onChange:y,scope:e.variableOptions,children:d()}),[e.variableOptions]);return i.jsx("div",{style:{border:`1px dashed ${a.colorBorder}`,padding:a.paddingSM},children:i.jsx(t.SchemaComponent,{basePath:o.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:r,dynamicComponent:n}}}}})})}function Te(e){return typeof e.value==="object"&&e.value?i.jsx(Fe,f({},e)):i.jsx(ge,f({},e))}function be(){const[e,o]=p.useState(!1),{t:r}=b(),a=Y.ArrayItems.useArray(),n=l.useForm(),m=(n==null?void 0:n.disabled)===!0,y=p.useCallback(()=>{a.field.push(""),o(!1)},[a.field]),d=p.useCallback(()=>{a.field.push({filter:{}}),o(!1)},[a.field]),x=i.jsx(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"dashed",block:!0,disabled:m,className:"ant-formily-array-base-addition",children:r("Add user")});return m?x:i.jsx(u.Popover,{open:e,onOpenChange:o,content:i.jsxs(u.Space,{direction:"vertical",size:"small",children:[i.jsx(u.Button,{type:"text",onClick:y,children:r("Select users")}),i.jsx(u.Button,{type:"text",onClick:d,children:r("Query users")})]}),children:x})}const B="notification-manager";class I extends t.Plugin{constructor(){super(...arguments);D(this,"manager");D(this,"useNotificationTypes",O)}get channelTypes(){return this.manager.channelTypes}registerChannelType(r){this.manager.registerChannelType(r)}afterAdd(){return T(this,null,function*(){})}beforeLoad(){return T(this,null,function*(){this.manager=new ue})}load(){return T(this,null,function*(){this.app.pluginSettingsManager.add(B,{title:k("Notification manager"),icon:"NotificationOutlined",aclSnippet:"pm.notification"}),this.app.pluginSettingsManager.add(`${B}.channels`,{title:k("Channels"),Component:G,aclSnippet:"pm.notification.channels",sort:1}),this.app.pluginSettingsManager.add(`${B}.logs`,{title:k("Logs"),Component:J,aclSnippet:"pm.notification.logs",sort:3})})}}s.ContentConfigForm=he,s.MessageConfigForm=Ce,s.NotificationVariableContext=j,s.NotificationVariableProvider=fe,s.PluginNotificationManagerClient=I,s.UserAddition=be,s.UserSelect=Te,s.default=I,s.useNotificationVariableOptions=xe,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -25,7 +25,6 @@ declare const _default: {
|
|
|
25
25
|
type: string;
|
|
26
26
|
title: string;
|
|
27
27
|
'x-component': string;
|
|
28
|
-
'x-read-pretty': boolean;
|
|
29
28
|
required: boolean;
|
|
30
29
|
description: string;
|
|
31
30
|
enum?: undefined;
|
|
@@ -39,7 +38,6 @@ declare const _default: {
|
|
|
39
38
|
'x-component': string;
|
|
40
39
|
title: string;
|
|
41
40
|
required: boolean;
|
|
42
|
-
'x-read-pretty'?: undefined;
|
|
43
41
|
description?: undefined;
|
|
44
42
|
enum?: undefined;
|
|
45
43
|
};
|
|
@@ -53,7 +51,6 @@ declare const _default: {
|
|
|
53
51
|
type: string;
|
|
54
52
|
'x-component': string;
|
|
55
53
|
title?: undefined;
|
|
56
|
-
'x-read-pretty'?: undefined;
|
|
57
54
|
required?: undefined;
|
|
58
55
|
description?: undefined;
|
|
59
56
|
enum?: undefined;
|
|
@@ -77,7 +74,6 @@ declare const _default: {
|
|
|
77
74
|
'x-component': string;
|
|
78
75
|
enum: string;
|
|
79
76
|
required: boolean;
|
|
80
|
-
'x-read-pretty'?: undefined;
|
|
81
77
|
description?: undefined;
|
|
82
78
|
};
|
|
83
79
|
prefix?: undefined;
|
|
@@ -90,7 +86,6 @@ declare const _default: {
|
|
|
90
86
|
type: string;
|
|
91
87
|
'x-component': string;
|
|
92
88
|
title: string;
|
|
93
|
-
'x-read-pretty'?: undefined;
|
|
94
89
|
required?: undefined;
|
|
95
90
|
description?: undefined;
|
|
96
91
|
enum?: undefined;
|
|
@@ -49,9 +49,8 @@ var channel_default = {
|
|
|
49
49
|
type: "string",
|
|
50
50
|
title: '{{t("Channel name")}}',
|
|
51
51
|
"x-component": "Input",
|
|
52
|
-
"x-read-pretty": true,
|
|
53
52
|
required: true,
|
|
54
|
-
description: "{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"
|
|
53
|
+
description: "{{t('Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter.')}}"
|
|
55
54
|
}
|
|
56
55
|
},
|
|
57
56
|
{
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
|
-
"@nocobase/client": "1.5.0-beta.
|
|
14
|
-
"@nocobase/utils": "1.5.0-beta.
|
|
15
|
-
"@nocobase/server": "1.5.0-beta.
|
|
16
|
-
"@nocobase/logger": "1.5.0-beta.
|
|
13
|
+
"@nocobase/client": "1.5.0-beta.3",
|
|
14
|
+
"@nocobase/utils": "1.5.0-beta.3",
|
|
15
|
+
"@nocobase/server": "1.5.0-beta.3",
|
|
16
|
+
"@nocobase/logger": "1.5.0-beta.3",
|
|
17
17
|
"@formily/react": "2.3.0",
|
|
18
18
|
"@formily/core": "2.3.0",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
|
-
"@nocobase/database": "1.5.0-beta.
|
|
20
|
+
"@nocobase/database": "1.5.0-beta.3",
|
|
21
21
|
"@formily/shared": "2.3.2",
|
|
22
22
|
"@ant-design/icons": "5.2.6",
|
|
23
23
|
"@formily/antd-v5": "1.2.2",
|
|
24
|
-
"@nocobase/plugin-workflow": "1.5.0-beta.
|
|
24
|
+
"@nocobase/plugin-workflow": "1.5.0-beta.3"
|
|
25
25
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -35,5 +35,6 @@
|
|
|
35
35
|
"Failed reason": "Failed reason",
|
|
36
36
|
"Log detail": "Log detail",
|
|
37
37
|
"Message": "Message",
|
|
38
|
-
"Notification manager": "Notification manager"
|
|
38
|
+
"Notification manager": "Notification manager",
|
|
39
|
+
"Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter.": "Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter."
|
|
39
40
|
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -37,5 +37,6 @@
|
|
|
37
37
|
"Failed reason": "失败原因",
|
|
38
38
|
"Log detail": "日志详情",
|
|
39
39
|
"Message": "消息内容",
|
|
40
|
-
"Notification manager": "通知管理"
|
|
40
|
+
"Notification manager": "通知管理",
|
|
41
|
+
"Randomly generated and can not be modified. Support letters, numbers and underscores, must start with an letter.": "随机生成,不可修改。支持英文、数字和下划线,必须以英文字母开头。"
|
|
41
42
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Provides a unified management service that includes channel configuration, logging, and other features, supporting the configuration of various notification channels, including in-app message and email.",
|
|
5
5
|
"displayName.zh-CN": "通知管理",
|
|
6
6
|
"description.zh-CN": "提供统一的管理服务,涵盖渠道配置、日志记录等功能,支持多种通知渠道的配置,包括站内信和电子邮件等。",
|
|
7
|
-
"version": "1.5.0-beta.
|
|
7
|
+
"version": "1.5.0-beta.3",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@ant-design/icons": "5.x",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Notification"
|
|
31
31
|
],
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be"
|
|
33
33
|
}
|