@nocobase/plugin-acl 0.20.0-alpha.13 → 0.20.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(d,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("react-i18next"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/core"),require("ahooks"),require("lodash"),require("antd-style")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","@ant-design/icons","react-i18next","@formily/shared","@nocobase/utils/client","@formily/core","ahooks","lodash","antd-style"],u):(d=typeof globalThis!="undefined"?globalThis:d||self,u(d["@nocobase/plugin-acl"]={},d["@nocobase/client"],d.jsxRuntime,d.react,d.antd,d["@formily/react"],d["@ant-design/icons"],d["react-i18next"],d["@formily/shared"],d["@nocobase/utils"],d["@formily/core"],d.ahooks,d.lodash,d["antd-style"]))})(this,function(d,u,s,g,p,I,G,S,x,k,de,Qe,Z,Re){"use strict";var Si=Object.defineProperty,wi=Object.defineProperties;var Ai=Object.getOwnPropertyDescriptors;var Ze=Object.getOwnPropertySymbols;var Pi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable;var ue=(d,u,s)=>u in d?Si(d,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[u]=s,P=(d,u)=>{for(var s in u||(u={}))Pi.call(u,s)&&ue(d,s,u[s]);if(Ze)for(var s of Ze(u))Ii.call(u,s)&&ue(d,s,u[s]);return d},E=(d,u)=>wi(d,Ai(u));var pe=(d,u,s)=>(ue(d,typeof u!="symbol"?u+"":u,s),s);var w=(d,u,s)=>new Promise((g,p)=>{var I=x=>{try{S(s.next(x))}catch(k){p(k)}},G=x=>{try{S(s.throw(x))}catch(k){p(k)}},S=x=>x.done?g(x.value):Promise.resolve(x.value).then(I,G);S((s=s.apply(d,u)).next())});function T(){return S.useTranslation(["acl","client"],{nsMode:"fallback"})}const A=g.createContext({role:null});A.displayName="RolesManagerContext";var U=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function he(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var et=Array.isArray,q=et,tt=typeof U=="object"&&U&&U.Object===Object&&U,rt=tt,nt=rt,at=typeof self=="object"&&self&&self.Object===Object&&self,st=nt||at||Function("return this")(),K=st,ot=K,it=ot.Symbol,z=it,fe=z,ve=Object.prototype,ct=ve.hasOwnProperty,lt=ve.toString,j=fe?fe.toStringTag:void 0;function ut(e){var t=ct.call(e,j),r=e[j];try{e[j]=void 0;var n=!0}catch(i){}var a=lt.call(e);return n&&(t?e[j]=r:delete e[j]),a}var pt=ut,dt=Object.prototype,ht=dt.toString;function ft(e){return ht.call(e)}var vt=ft,ge=z,gt=pt,mt=vt,yt="[object Null]",_t="[object Undefined]",me=ge?ge.toStringTag:void 0;function bt(e){return e==null?e===void 0?_t:yt:me&&me in Object(e)?gt(e):mt(e)}var Q=bt;function $t(e){return e!=null&&typeof e=="object"}var R=$t,Ct=Q,xt=R,St="[object Symbol]";function wt(e){return typeof e=="symbol"||xt(e)&&Ct(e)==St}var ee=wt,At=q,Pt=ee,It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Tt=/^\w*$/;function Ot(e,t){if(At(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Pt(e)?!0:Tt.test(e)||!It.test(e)||t!=null&&e in Object(t)}var Mt=Ot;function Ft(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var te=Ft,Dt=Q,Nt=te,Et="[object AsyncFunction]",kt="[object Function]",qt="[object GeneratorFunction]",jt="[object Proxy]";function Ht(e){if(!Nt(e))return!1;var t=Dt(e);return t==kt||t==qt||t==Et||t==jt}var Gt=Ht,Ut=K,Kt=Ut["__core-js_shared__"],zt=Kt,re=zt,ye=function(){var e=/[^.]+$/.exec(re&&re.keys&&re.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Lt(e){return!!ye&&ye in e}var Vt=Lt,Wt=Function.prototype,Bt=Wt.toString;function Yt(e){if(e!=null){try{return Bt.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Xt=Yt,Jt=Gt,Zt=Vt,Qt=te,Rt=Xt,er=/[\\^$.*+?()[\]{}|]/g,tr=/^\[object .+?Constructor\]$/,rr=Function.prototype,nr=Object.prototype,ar=rr.toString,sr=nr.hasOwnProperty,or=RegExp("^"+ar.call(sr).replace(er,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ir(e){if(!Qt(e)||Zt(e))return!1;var t=Jt(e)?or:tr;return t.test(Rt(e))}var cr=ir;function lr(e,t){return e==null?void 0:e[t]}var ur=lr,pr=cr,dr=ur;function hr(e,t){var r=dr(e,t);return pr(r)?r:void 0}var L=hr,fr=L,vr=fr(Object,"create"),V=vr,_e=V;function gr(){this.__data__=_e?_e(null):{},this.size=0}var mr=gr;function yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _r=yr,br=V,$r="__lodash_hash_undefined__",Cr=Object.prototype,xr=Cr.hasOwnProperty;function Sr(e){var t=this.__data__;if(br){var r=t[e];return r===$r?void 0:r}return xr.call(t,e)?t[e]:void 0}var wr=Sr,Ar=V,Pr=Object.prototype,Ir=Pr.hasOwnProperty;function Tr(e){var t=this.__data__;return Ar?t[e]!==void 0:Ir.call(t,e)}var Or=Tr,Mr=V,Fr="__lodash_hash_undefined__";function Dr(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Mr&&t===void 0?Fr:t,this}var Nr=Dr,Er=mr,kr=_r,qr=wr,jr=Or,Hr=Nr;function O(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}O.prototype.clear=Er,O.prototype.delete=kr,O.prototype.get=qr,O.prototype.has=jr,O.prototype.set=Hr;var Gr=O;function Ur(){this.__data__=[],this.size=0}var Kr=Ur;function zr(e,t){return e===t||e!==e&&t!==t}var be=zr,Lr=be;function Vr(e,t){for(var r=e.length;r--;)if(Lr(e[r][0],t))return r;return-1}var W=Vr,Wr=W,Br=Array.prototype,Yr=Br.splice;function Xr(e){var t=this.__data__,r=Wr(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Yr.call(t,r,1),--this.size,!0}var Jr=Xr,Zr=W;function Qr(e){var t=this.__data__,r=Zr(t,e);return r<0?void 0:t[r][1]}var Rr=Qr,en=W;function tn(e){return en(this.__data__,e)>-1}var rn=tn,nn=W;function an(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var sn=an,on=Kr,cn=Jr,ln=Rr,un=rn,pn=sn;function M(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}M.prototype.clear=on,M.prototype.delete=cn,M.prototype.get=ln,M.prototype.has=un,M.prototype.set=pn;var dn=M,hn=L,fn=K,vn=hn(fn,"Map"),gn=vn,$e=Gr,mn=dn,yn=gn;function _n(){this.size=0,this.__data__={hash:new $e,map:new(yn||mn),string:new $e}}var bn=_n;function $n(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Cn=$n,xn=Cn;function Sn(e,t){var r=e.__data__;return xn(t)?r[typeof t=="string"?"string":"hash"]:r.map}var B=Sn,wn=B;function An(e){var t=wn(this,e).delete(e);return this.size-=t?1:0,t}var Pn=An,In=B;function Tn(e){return In(this,e).get(e)}var On=Tn,Mn=B;function Fn(e){return Mn(this,e).has(e)}var Dn=Fn,Nn=B;function En(e,t){var r=Nn(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var kn=En,qn=bn,jn=Pn,Hn=On,Gn=Dn,Un=kn;function F(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}F.prototype.clear=qn,F.prototype.delete=jn,F.prototype.get=Hn,F.prototype.has=Gn,F.prototype.set=Un;var Ce=F,xe=Ce,Kn="Expected a function";function ne(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Kn);var r=function(){var n=arguments,a=t?t.apply(this,n):n[0],i=r.cache;if(i.has(a))return i.get(a);var o=e.apply(this,n);return r.cache=i.set(a,o)||i,o};return r.cache=new(ne.Cache||xe),r}ne.Cache=xe;var zn=ne,Ln=zn,Vn=500;function Wn(e){var t=Ln(e,function(n){return r.size===Vn&&r.clear(),n}),r=t.cache;return t}var Bn=Wn,Yn=Bn,Xn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Jn=/\\(\\)?/g,Zn=Yn(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Xn,function(r,n,a,i){t.push(a?i.replace(Jn,"$1"):n||r)}),t}),Qn=Zn;function Rn(e,t){for(var r=-1,n=e==null?0:e.length,a=Array(n);++r<n;)a[r]=t(e[r],r,e);return a}var ea=Rn,Se=z,ta=ea,ra=q,na=ee,aa=1/0,we=Se?Se.prototype:void 0,Ae=we?we.toString:void 0;function Pe(e){if(typeof e=="string")return e;if(ra(e))return ta(e,Pe)+"";if(na(e))return Ae?Ae.call(e):"";var t=e+"";return t=="0"&&1/e==-aa?"-0":t}var sa=Pe,oa=sa;function ia(e){return e==null?"":oa(e)}var ca=ia,la=q,ua=Mt,pa=Qn,da=ca;function ha(e,t){return la(e)?e:ua(e,t)?[e]:pa(da(e))}var Y=ha,fa=ee,va=1/0;function ga(e){if(typeof e=="string"||fa(e))return e;var t=e+"";return t=="0"&&1/e==-va?"-0":t}var ae=ga,ma=Y,ya=ae;function _a(e,t){t=ma(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[ya(t[r++])];return r&&r==n?e:void 0}var ba=_a,$a=L,Ca=function(){try{var e=$a(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Ie=Ca,Te=Ie;function xa(e,t,r){t=="__proto__"&&Te?Te(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var Sa=xa,wa=Sa,Aa=be,Pa=Object.prototype,Ia=Pa.hasOwnProperty;function Ta(e,t,r){var n=e[t];(!(Ia.call(e,t)&&Aa(n,r))||r===void 0&&!(t in e))&&wa(e,t,r)}var Oa=Ta,Ma=9007199254740991,Fa=/^(?:0|[1-9]\d*)$/;function Da(e,t){var r=typeof e;return t=t==null?Ma:t,!!t&&(r=="number"||r!="symbol"&&Fa.test(e))&&e>-1&&e%1==0&&e<t}var Oe=Da,Na=Oa,Ea=Y,ka=Oe,Me=te,qa=ae;function ja(e,t,r,n){if(!Me(e))return e;t=Ea(t,e);for(var a=-1,i=t.length,o=i-1,c=e;c!=null&&++a<i;){var l=qa(t[a]),f=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=o){var v=c[l];f=n?n(v,l,c):void 0,f===void 0&&(f=Me(v)?v:ka(t[a+1])?[]:{})}Na(c,l,f),c=c[l]}return e}var Ha=ja,Ga=ba,Ua=Ha,Ka=Y;function za(e,t,r){for(var n=-1,a=t.length,i={};++n<a;){var o=t[n],c=Ga(e,o);r(c,o)&&Ua(i,Ka(o,e),c)}return i}var La=za;function Va(e,t){return e!=null&&t in Object(e)}var Wa=Va,Ba=Q,Ya=R,Xa="[object Arguments]";function Ja(e){return Ya(e)&&Ba(e)==Xa}var Za=Ja,Fe=Za,Qa=R,De=Object.prototype,Ra=De.hasOwnProperty,es=De.propertyIsEnumerable,ts=Fe(function(){return arguments}())?Fe:function(e){return Qa(e)&&Ra.call(e,"callee")&&!es.call(e,"callee")},Ne=ts,rs=9007199254740991;function ns(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=rs}var as=ns,ss=Y,os=Ne,is=q,cs=Oe,ls=as,us=ae;function ps(e,t,r){t=ss(t,e);for(var n=-1,a=t.length,i=!1;++n<a;){var o=us(t[n]);if(!(i=e!=null&&r(e,o)))break;e=e[o]}return i||++n!=a?i:(a=e==null?0:e.length,!!a&&ls(a)&&cs(o,a)&&(is(e)||os(e)))}var ds=ps,hs=Wa,fs=ds;function vs(e,t){return e!=null&&fs(e,t,hs)}var gs=vs,ms=La,ys=gs;function _s(e,t){return ms(e,t,function(r,n){return ys(e,n)})}var bs=_s;function $s(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var Cs=$s,Ee=z,xs=Ne,Ss=q,ke=Ee?Ee.isConcatSpreadable:void 0;function ws(e){return Ss(e)||xs(e)||!!(ke&&e&&e[ke])}var As=ws,Ps=Cs,Is=As;function qe(e,t,r,n,a){var i=-1,o=e.length;for(r||(r=Is),a||(a=[]);++i<o;){var c=e[i];t>0&&r(c)?t>1?qe(c,t-1,r,n,a):Ps(a,c):n||(a[a.length]=c)}return a}var Ts=qe,Os=Ts;function Ms(e){var t=e==null?0:e.length;return t?Os(e,1):[]}var Fs=Ms;function Ds(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var Ns=Ds,Es=Ns,je=Math.max;function ks(e,t,r){return t=je(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,i=je(n.length-t,0),o=Array(i);++a<i;)o[a]=n[t+a];a=-1;for(var c=Array(t+1);++a<t;)c[a]=n[a];return c[t]=r(o),Es(e,this,c)}}var qs=ks;function js(e){return function(){return e}}var Hs=js;function Gs(e){return e}var Us=Gs,Ks=Hs,He=Ie,zs=Us,Ls=He?function(e,t){return He(e,"toString",{configurable:!0,enumerable:!1,value:Ks(t),writable:!0})}:zs,Vs=Ls,Ws=800,Bs=16,Ys=Date.now;function Xs(e){var t=0,r=0;return function(){var n=Ys(),a=Bs-(n-r);if(r=n,a>0){if(++t>=Ws)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Js=Xs,Zs=Vs,Qs=Js,Rs=Qs(Zs),eo=Rs,to=Fs,ro=qs,no=eo;function ao(e){return no(ro(e,void 0,to),e+"")}var so=ao,oo=bs,io=so,co=io(function(e,t){return e==null?{}:oo(e,t)}),lo=co;const uo=he(lo),po={type:"object",properties:{[x.uid()]:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:e=>{const t=u.useRecord(),r=u.useRequest(()=>Promise.resolve({data:uo(t,["title","name","default"])}),E(P({},e),{manual:!0})),n=u.useActionContext();return g.useEffect(()=>{n.visible&&r.run()},[n.visible]),r}},title:'{{t("Edit role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default role")}}'},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 }}"}}}}}}}},se=()=>{const{t:e}=T(),{data:t}=u.useResourceActionContext(),[r,n]=g.useState(!1),[a,i]=g.useState(null),{role:o,setRole:c}=g.useContext(A),l=((t==null?void 0:t.data)||[]).map(v=>({key:v.name,label:s.jsx(se.Item,{item:v,onEdit:()=>{n(!0),i(v)}})})),f=({key:v})=>{c(((t==null?void 0:t.data)||[]).find(m=>m.name===v))};return g.useEffect(()=>{t!=null&&t.data.length&&c(t==null?void 0:t.data[0])},[t,c]),s.jsxs(s.Fragment,{children:[l.length?s.jsx(p.Menu,{style:{border:"none",maxHeight:"65vh",overflowY:"auto"},items:l,selectedKeys:[o==null?void 0:o.name],onSelect:f}):s.jsx(p.Empty,{image:p.Empty.PRESENTED_IMAGE_SIMPLE}),s.jsx(u.ActionContextProvider,{value:{visible:r,setVisible:n},children:s.jsx(u.RecordProvider,{record:a,collectionName:"departments",children:s.jsx(u.SchemaComponent,{scope:{t:e},schema:po})})})]})};se.Item=function({item:t,onEdit:r}){const{t:n}=T(),{refreshAsync:a}=u.useResourceActionContext(),{modal:i,message:o}=p.App.useApp(),c=u.useAPIClient(),l=()=>{i.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:()=>w(this,null,function*(){yield c.resource("roles").destroy({filterByTk:t.name}),o.success(n("Deleted successfully")),yield a()})})},f=({key:v,domEvent:m})=>{switch(m.stopPropagation(),v){case"edit":r();break;case"delete":l()}};return s.jsxs(p.Row,{children:[s.jsx(p.Col,{flex:3,style:{display:"inline-flex",alignItems:"center"},children:s.jsxs("span",{style:{whiteSpace:"nowrap",width:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:[s.jsx(G.TagOutlined,{}),s.jsx("span",{style:{marginLeft:"10px"},children:I.Schema.compile(t.title,{t:n})})]})}),s.jsxs(p.Col,{children:[t.default?s.jsx(p.Tag,{color:"success",bordered:!1,children:n("Default")}):null,s.jsx(p.Dropdown,{menu:{items:[{label:n("Edit"),key:"edit"},{label:n("Delete"),key:"delete"}],onClick:f},children:s.jsx(G.MoreOutlined,{})})]})]})};const oe=g.createContext([]);oe.displayName="AvailableActionsContext";const ho=e=>{const{data:t,loading:r}=u.useRequest({resource:"availableActions",action:"list"});return r?s.jsx(p.Spin,{}):s.jsx(oe.Provider,{value:t==null?void 0:t.data,children:e.children})},fo=()=>g.useContext(oe);var vo="__lodash_hash_undefined__";function go(e){return this.__data__.set(e,vo),this}var mo=go;function yo(e){return this.__data__.has(e)}var _o=yo,bo=Ce,$o=mo,Co=_o;function X(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new bo;++t<r;)this.add(e[t])}X.prototype.add=X.prototype.push=$o,X.prototype.has=Co;var xo=X;function So(e,t,r,n){for(var a=e.length,i=r+(n?1:-1);n?i--:++i<a;)if(t(e[i],i,e))return i;return-1}var wo=So;function Ao(e){return e!==e}var Po=Ao;function Io(e,t,r){for(var n=r-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}var To=Io,Oo=wo,Mo=Po,Fo=To;function Do(e,t,r){return t===t?Fo(e,t,r):Oo(e,Mo,r)}var No=Do,Eo=No;function ko(e,t){var r=e==null?0:e.length;return!!r&&Eo(e,t,0)>-1}var qo=ko;function jo(e,t,r){for(var n=-1,a=e==null?0:e.length;++n<a;)if(r(t,e[n]))return!0;return!1}var Ho=jo;function Go(e,t){return e.has(t)}var Uo=Go,Ko=L,zo=K,Lo=Ko(zo,"Set"),Vo=Lo;function Wo(){}var Bo=Wo;function Yo(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Ge=Yo,ie=Vo,Xo=Bo,Jo=Ge,Zo=1/0,Qo=ie&&1/Jo(new ie([,-0]))[1]==Zo?function(e){return new ie(e)}:Xo,Ro=Qo,ei=xo,ti=qo,ri=Ho,ni=Uo,ai=Ro,si=Ge,oi=200;function ii(e,t,r){var n=-1,a=ti,i=e.length,o=!0,c=[],l=c;if(r)o=!1,a=ri;else if(i>=oi){var f=t?null:ai(e);if(f)return si(f);o=!1,a=ni,l=new ei}else l=t?[]:c;e:for(;++n<i;){var v=e[n],m=t?t(v):v;if(v=r||v!==0?v:0,o&&m===m){for(var C=l.length;C--;)if(l[C]===m)continue e;t&&l.push(m),c.push(v)}else a(l,m,r)||(l!==c&&l.push(m),c.push(v))}return c}var ci=ii,li=ci;function ui(e){return e&&e.length?li(e):[]}var pi=ui;const di=he(pi),hi=e=>{var r;if(!e)return{};const t={};return(r=e==null?void 0:e.forEach)==null||r.call(e,n=>{const[a,i]=n.split(":");t[a]=i||"all"}),t},Ue=e=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];n==="all"?t.push(r):t.push(`${r}:${n}`)}return t},fi=I.connect(e=>{const{onChange:t}=e,r=fo(),n=u.useCompile(),{t:a}=S.useTranslation(),i=I.useField(),o=hi(i.value);return s.jsx("div",{children:s.jsx(p.Table,{rowKey:"name",size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:a("Action display name"),render:c=>n(c)},{dataIndex:"onNewRecord",title:a("Action type"),render:c=>c?s.jsx(p.Tag,{color:"green",children:a("Action on new records")}):s.jsx(p.Tag,{color:"geekblue",children:a("Action on existing records")})},{dataIndex:"enabled",title:a("Allow"),render:(c,l)=>s.jsx(p.Checkbox,{checked:c,"aria-label":`${l.name}_checkbox`,onChange:f=>{c?delete o[l.name]:o[l.name]="all",t(Ue(o))}})},{dataIndex:"scope",title:a("Data scope"),render:(c,l)=>!l.onNewRecord&&s.jsx(p.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:c,options:[{label:a("All records"),value:"all"},{label:a("Own records"),value:"own"}],onChange:f=>{o[l.name]=f,t(Ue(o))}})}],dataSource:r==null?void 0:r.map(c=>{let l="all",f=!1;return o[c.name]&&(f=!0,l=o[c.name]),E(P({},c),{enabled:f,scope:l})})})})}),vi=I.connect(e=>{const{t}=S.useTranslation();return s.jsxs(p.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:r=>{const n=["ui.*","pm","pm.*","app"],a=n.map(o=>`!${o}`),i=di([...e.value||[],...r]).filter(o=>o&&!a.includes(o)).map(o=>!n.includes(o)||r!=null&&r.includes(o)?o:`!${o}`);for(const o of n)!i.includes(o)&&!i.includes(`!${o}`)&&i.push(`!${o}`);e.onChange(i)},children:[s.jsx("div",{style:{marginTop:16},children:s.jsx(p.Checkbox,{value:"ui.*",children:t("Allows to configure interface")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm",children:t("Allows to install, activate, disable plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm.*",children:t("Allows to configure plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"app",children:t("Allows to clear cache, reboot application")})})]})}),gi=({active:e})=>{const{role:t,setRole:r}=g.useContext(A),{t:n}=T(),a=u.useAPIClient(),{data:i}=u.useRequest(()=>a.resource("roles").get({filterByTk:t==null?void 0:t.name}).then(l=>{var v,m;const f=(v=l==null?void 0:l.data)==null?void 0:v.data;return(m=f.snippets)==null||m.forEach(C=>{f[C]=!0}),f}),{ready:e,refreshDeps:[t==null?void 0:t.name]}),o=Qe.useMemoizedFn(l=>w(this,null,function*(){yield a.resource("roles").update({filterByTk:t.name,values:l.values}),r(P(P({},t),l.values)),p.message.success(n("Saved successfully"))})),c=g.useMemo(()=>de.createForm({values:i,effects(){de.onFormValuesChange(l=>w(this,null,function*(){yield o(l)}))}}),[i,o]);return s.jsx(u.SchemaComponent,{components:{SnippetCheckboxGroup:vi,StrategyActions:fi},schema:{type:"void",name:x.uid(),"x-component":"FormV2","x-component-props":{form:c},properties:{snippets:{title:n("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"},allowNewMenu:{title:n("Menu permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":n("New menu items are allowed to be accessed by default.")}}}})},ce=g.createContext(null);ce.displayName="MenuItemsContext";const Ke=(e={})=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r],a={title:n.title,uid:n["x-uid"]};n.properties&&(a.children=Ke(n.properties)),t.push(a)}return t},mi=()=>g.useContext(ce),ze=e=>{var i,o;const r={url:`uiSchemas:getProperties/${u.useAdminSchemaUid()}`},n=u.useRequest(r);if(n.loading)return s.jsx(p.Spin,{});const a=Ke((o=(i=n.data)==null?void 0:i.data)==null?void 0:o.properties);return s.jsx(ce.Provider,{value:{service:n,items:a},children:e.children})},Le=Re.createStyles(({css:e})=>e`
1
+ (function(d,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("react-i18next"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/core"),require("ahooks"),require("lodash"),require("antd-style")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","@ant-design/icons","react-i18next","@formily/shared","@nocobase/utils/client","@formily/core","ahooks","lodash","antd-style"],u):(d=typeof globalThis!="undefined"?globalThis:d||self,u(d["@nocobase/plugin-acl"]={},d["@nocobase/client"],d.jsxRuntime,d.react,d.antd,d["@formily/react"],d["@ant-design/icons"],d["react-i18next"],d["@formily/shared"],d["@nocobase/utils"],d["@formily/core"],d.ahooks,d.lodash,d["antd-style"]))})(this,function(d,u,s,g,p,I,G,S,x,k,de,Qe,Z,Re){"use strict";var Si=Object.defineProperty,wi=Object.defineProperties;var Ai=Object.getOwnPropertyDescriptors;var Ze=Object.getOwnPropertySymbols;var Pi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable;var ue=(d,u,s)=>u in d?Si(d,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[u]=s,w=(d,u)=>{for(var s in u||(u={}))Pi.call(u,s)&&ue(d,s,u[s]);if(Ze)for(var s of Ze(u))Ii.call(u,s)&&ue(d,s,u[s]);return d},T=(d,u)=>wi(d,Ai(u));var pe=(d,u,s)=>(ue(d,typeof u!="symbol"?u+"":u,s),s);var A=(d,u,s)=>new Promise((g,p)=>{var I=x=>{try{S(s.next(x))}catch(k){p(k)}},G=x=>{try{S(s.throw(x))}catch(k){p(k)}},S=x=>x.done?g(x.value):Promise.resolve(x.value).then(I,G);S((s=s.apply(d,u)).next())});function O(){return S.useTranslation(["acl","client"],{nsMode:"fallback"})}const P=g.createContext({role:null});P.displayName="RolesManagerContext";var U=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function he(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var et=Array.isArray,q=et,tt=typeof U=="object"&&U&&U.Object===Object&&U,rt=tt,nt=rt,at=typeof self=="object"&&self&&self.Object===Object&&self,st=nt||at||Function("return this")(),K=st,ot=K,it=ot.Symbol,z=it,fe=z,ve=Object.prototype,ct=ve.hasOwnProperty,lt=ve.toString,j=fe?fe.toStringTag:void 0;function ut(e){var t=ct.call(e,j),r=e[j];try{e[j]=void 0;var n=!0}catch(i){}var a=lt.call(e);return n&&(t?e[j]=r:delete e[j]),a}var pt=ut,dt=Object.prototype,ht=dt.toString;function ft(e){return ht.call(e)}var vt=ft,ge=z,gt=pt,mt=vt,yt="[object Null]",_t="[object Undefined]",me=ge?ge.toStringTag:void 0;function bt(e){return e==null?e===void 0?_t:yt:me&&me in Object(e)?gt(e):mt(e)}var Q=bt;function $t(e){return e!=null&&typeof e=="object"}var R=$t,Ct=Q,xt=R,St="[object Symbol]";function wt(e){return typeof e=="symbol"||xt(e)&&Ct(e)==St}var ee=wt,At=q,Pt=ee,It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Tt=/^\w*$/;function Ot(e,t){if(At(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Pt(e)?!0:Tt.test(e)||!It.test(e)||t!=null&&e in Object(t)}var Mt=Ot;function Ft(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var te=Ft,Dt=Q,Nt=te,Et="[object AsyncFunction]",kt="[object Function]",qt="[object GeneratorFunction]",jt="[object Proxy]";function Ht(e){if(!Nt(e))return!1;var t=Dt(e);return t==kt||t==qt||t==Et||t==jt}var Gt=Ht,Ut=K,Kt=Ut["__core-js_shared__"],zt=Kt,re=zt,ye=function(){var e=/[^.]+$/.exec(re&&re.keys&&re.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Lt(e){return!!ye&&ye in e}var Vt=Lt,Wt=Function.prototype,Bt=Wt.toString;function Yt(e){if(e!=null){try{return Bt.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Xt=Yt,Jt=Gt,Zt=Vt,Qt=te,Rt=Xt,er=/[\\^$.*+?()[\]{}|]/g,tr=/^\[object .+?Constructor\]$/,rr=Function.prototype,nr=Object.prototype,ar=rr.toString,sr=nr.hasOwnProperty,or=RegExp("^"+ar.call(sr).replace(er,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ir(e){if(!Qt(e)||Zt(e))return!1;var t=Jt(e)?or:tr;return t.test(Rt(e))}var cr=ir;function lr(e,t){return e==null?void 0:e[t]}var ur=lr,pr=cr,dr=ur;function hr(e,t){var r=dr(e,t);return pr(r)?r:void 0}var L=hr,fr=L,vr=fr(Object,"create"),V=vr,_e=V;function gr(){this.__data__=_e?_e(null):{},this.size=0}var mr=gr;function yr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _r=yr,br=V,$r="__lodash_hash_undefined__",Cr=Object.prototype,xr=Cr.hasOwnProperty;function Sr(e){var t=this.__data__;if(br){var r=t[e];return r===$r?void 0:r}return xr.call(t,e)?t[e]:void 0}var wr=Sr,Ar=V,Pr=Object.prototype,Ir=Pr.hasOwnProperty;function Tr(e){var t=this.__data__;return Ar?t[e]!==void 0:Ir.call(t,e)}var Or=Tr,Mr=V,Fr="__lodash_hash_undefined__";function Dr(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Mr&&t===void 0?Fr:t,this}var Nr=Dr,Er=mr,kr=_r,qr=wr,jr=Or,Hr=Nr;function M(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}M.prototype.clear=Er,M.prototype.delete=kr,M.prototype.get=qr,M.prototype.has=jr,M.prototype.set=Hr;var Gr=M;function Ur(){this.__data__=[],this.size=0}var Kr=Ur;function zr(e,t){return e===t||e!==e&&t!==t}var be=zr,Lr=be;function Vr(e,t){for(var r=e.length;r--;)if(Lr(e[r][0],t))return r;return-1}var W=Vr,Wr=W,Br=Array.prototype,Yr=Br.splice;function Xr(e){var t=this.__data__,r=Wr(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Yr.call(t,r,1),--this.size,!0}var Jr=Xr,Zr=W;function Qr(e){var t=this.__data__,r=Zr(t,e);return r<0?void 0:t[r][1]}var Rr=Qr,en=W;function tn(e){return en(this.__data__,e)>-1}var rn=tn,nn=W;function an(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var sn=an,on=Kr,cn=Jr,ln=Rr,un=rn,pn=sn;function F(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}F.prototype.clear=on,F.prototype.delete=cn,F.prototype.get=ln,F.prototype.has=un,F.prototype.set=pn;var dn=F,hn=L,fn=K,vn=hn(fn,"Map"),gn=vn,$e=Gr,mn=dn,yn=gn;function _n(){this.size=0,this.__data__={hash:new $e,map:new(yn||mn),string:new $e}}var bn=_n;function $n(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Cn=$n,xn=Cn;function Sn(e,t){var r=e.__data__;return xn(t)?r[typeof t=="string"?"string":"hash"]:r.map}var B=Sn,wn=B;function An(e){var t=wn(this,e).delete(e);return this.size-=t?1:0,t}var Pn=An,In=B;function Tn(e){return In(this,e).get(e)}var On=Tn,Mn=B;function Fn(e){return Mn(this,e).has(e)}var Dn=Fn,Nn=B;function En(e,t){var r=Nn(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var kn=En,qn=bn,jn=Pn,Hn=On,Gn=Dn,Un=kn;function D(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}D.prototype.clear=qn,D.prototype.delete=jn,D.prototype.get=Hn,D.prototype.has=Gn,D.prototype.set=Un;var Ce=D,xe=Ce,Kn="Expected a function";function ne(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Kn);var r=function(){var n=arguments,a=t?t.apply(this,n):n[0],i=r.cache;if(i.has(a))return i.get(a);var o=e.apply(this,n);return r.cache=i.set(a,o)||i,o};return r.cache=new(ne.Cache||xe),r}ne.Cache=xe;var zn=ne,Ln=zn,Vn=500;function Wn(e){var t=Ln(e,function(n){return r.size===Vn&&r.clear(),n}),r=t.cache;return t}var Bn=Wn,Yn=Bn,Xn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Jn=/\\(\\)?/g,Zn=Yn(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Xn,function(r,n,a,i){t.push(a?i.replace(Jn,"$1"):n||r)}),t}),Qn=Zn;function Rn(e,t){for(var r=-1,n=e==null?0:e.length,a=Array(n);++r<n;)a[r]=t(e[r],r,e);return a}var ea=Rn,Se=z,ta=ea,ra=q,na=ee,aa=1/0,we=Se?Se.prototype:void 0,Ae=we?we.toString:void 0;function Pe(e){if(typeof e=="string")return e;if(ra(e))return ta(e,Pe)+"";if(na(e))return Ae?Ae.call(e):"";var t=e+"";return t=="0"&&1/e==-aa?"-0":t}var sa=Pe,oa=sa;function ia(e){return e==null?"":oa(e)}var ca=ia,la=q,ua=Mt,pa=Qn,da=ca;function ha(e,t){return la(e)?e:ua(e,t)?[e]:pa(da(e))}var Y=ha,fa=ee,va=1/0;function ga(e){if(typeof e=="string"||fa(e))return e;var t=e+"";return t=="0"&&1/e==-va?"-0":t}var ae=ga,ma=Y,ya=ae;function _a(e,t){t=ma(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[ya(t[r++])];return r&&r==n?e:void 0}var ba=_a,$a=L,Ca=function(){try{var e=$a(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Ie=Ca,Te=Ie;function xa(e,t,r){t=="__proto__"&&Te?Te(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var Sa=xa,wa=Sa,Aa=be,Pa=Object.prototype,Ia=Pa.hasOwnProperty;function Ta(e,t,r){var n=e[t];(!(Ia.call(e,t)&&Aa(n,r))||r===void 0&&!(t in e))&&wa(e,t,r)}var Oa=Ta,Ma=9007199254740991,Fa=/^(?:0|[1-9]\d*)$/;function Da(e,t){var r=typeof e;return t=t==null?Ma:t,!!t&&(r=="number"||r!="symbol"&&Fa.test(e))&&e>-1&&e%1==0&&e<t}var Oe=Da,Na=Oa,Ea=Y,ka=Oe,Me=te,qa=ae;function ja(e,t,r,n){if(!Me(e))return e;t=Ea(t,e);for(var a=-1,i=t.length,o=i-1,c=e;c!=null&&++a<i;){var l=qa(t[a]),f=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=o){var v=c[l];f=n?n(v,l,c):void 0,f===void 0&&(f=Me(v)?v:ka(t[a+1])?[]:{})}Na(c,l,f),c=c[l]}return e}var Ha=ja,Ga=ba,Ua=Ha,Ka=Y;function za(e,t,r){for(var n=-1,a=t.length,i={};++n<a;){var o=t[n],c=Ga(e,o);r(c,o)&&Ua(i,Ka(o,e),c)}return i}var La=za;function Va(e,t){return e!=null&&t in Object(e)}var Wa=Va,Ba=Q,Ya=R,Xa="[object Arguments]";function Ja(e){return Ya(e)&&Ba(e)==Xa}var Za=Ja,Fe=Za,Qa=R,De=Object.prototype,Ra=De.hasOwnProperty,es=De.propertyIsEnumerable,ts=Fe(function(){return arguments}())?Fe:function(e){return Qa(e)&&Ra.call(e,"callee")&&!es.call(e,"callee")},Ne=ts,rs=9007199254740991;function ns(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=rs}var as=ns,ss=Y,os=Ne,is=q,cs=Oe,ls=as,us=ae;function ps(e,t,r){t=ss(t,e);for(var n=-1,a=t.length,i=!1;++n<a;){var o=us(t[n]);if(!(i=e!=null&&r(e,o)))break;e=e[o]}return i||++n!=a?i:(a=e==null?0:e.length,!!a&&ls(a)&&cs(o,a)&&(is(e)||os(e)))}var ds=ps,hs=Wa,fs=ds;function vs(e,t){return e!=null&&fs(e,t,hs)}var gs=vs,ms=La,ys=gs;function _s(e,t){return ms(e,t,function(r,n){return ys(e,n)})}var bs=_s;function $s(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var Cs=$s,Ee=z,xs=Ne,Ss=q,ke=Ee?Ee.isConcatSpreadable:void 0;function ws(e){return Ss(e)||xs(e)||!!(ke&&e&&e[ke])}var As=ws,Ps=Cs,Is=As;function qe(e,t,r,n,a){var i=-1,o=e.length;for(r||(r=Is),a||(a=[]);++i<o;){var c=e[i];t>0&&r(c)?t>1?qe(c,t-1,r,n,a):Ps(a,c):n||(a[a.length]=c)}return a}var Ts=qe,Os=Ts;function Ms(e){var t=e==null?0:e.length;return t?Os(e,1):[]}var Fs=Ms;function Ds(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var Ns=Ds,Es=Ns,je=Math.max;function ks(e,t,r){return t=je(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,i=je(n.length-t,0),o=Array(i);++a<i;)o[a]=n[t+a];a=-1;for(var c=Array(t+1);++a<t;)c[a]=n[a];return c[t]=r(o),Es(e,this,c)}}var qs=ks;function js(e){return function(){return e}}var Hs=js;function Gs(e){return e}var Us=Gs,Ks=Hs,He=Ie,zs=Us,Ls=He?function(e,t){return He(e,"toString",{configurable:!0,enumerable:!1,value:Ks(t),writable:!0})}:zs,Vs=Ls,Ws=800,Bs=16,Ys=Date.now;function Xs(e){var t=0,r=0;return function(){var n=Ys(),a=Bs-(n-r);if(r=n,a>0){if(++t>=Ws)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Js=Xs,Zs=Vs,Qs=Js,Rs=Qs(Zs),eo=Rs,to=Fs,ro=qs,no=eo;function ao(e){return no(ro(e,void 0,to),e+"")}var so=ao,oo=bs,io=so,co=io(function(e,t){return e==null?{}:oo(e,t)}),lo=co;const uo=he(lo),po={type:"object",properties:{[x.uid()]:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:e=>{const t=u.useRecord(),r=u.useRequest(()=>Promise.resolve({data:uo(t,["title","name","default"])}),T(w({},e),{manual:!0})),n=u.useActionContext();return g.useEffect(()=>{n.visible&&r.run()},[n.visible]),r}},title:'{{t("Edit role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default role")}}'},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 }}"}}}}}}}},se=()=>{const{t:e}=O(),{data:t}=u.useResourceActionContext(),[r,n]=g.useState(!1),[a,i]=g.useState(null),{role:o,setRole:c}=g.useContext(P),l=((t==null?void 0:t.data)||[]).map(v=>({key:v.name,label:s.jsx(se.Item,{item:v,onEdit:()=>{n(!0),i(v)}})})),f=({key:v})=>{c(((t==null?void 0:t.data)||[]).find(m=>m.name===v))};return g.useEffect(()=>{t!=null&&t.data.length&&c(t==null?void 0:t.data[0])},[t,c]),s.jsxs(s.Fragment,{children:[l.length?s.jsx(p.Menu,{style:{border:"none",maxHeight:"65vh",overflowY:"auto"},items:l,selectedKeys:[o==null?void 0:o.name],onSelect:f}):s.jsx(p.Empty,{image:p.Empty.PRESENTED_IMAGE_SIMPLE}),s.jsx(u.ActionContextProvider,{value:{visible:r,setVisible:n},children:s.jsx(u.RecordProvider,{record:a,collectionName:"departments",children:s.jsx(u.SchemaComponent,{scope:{t:e},schema:po})})})]})};se.Item=function({item:t,onEdit:r}){const{t:n}=O(),{refreshAsync:a}=u.useResourceActionContext(),{modal:i,message:o}=p.App.useApp(),c=u.useAPIClient(),l=()=>{i.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:()=>A(this,null,function*(){yield c.resource("roles").destroy({filterByTk:t.name}),o.success(n("Deleted successfully")),yield a()})})},f=({key:v,domEvent:m})=>{switch(m.stopPropagation(),v){case"edit":r();break;case"delete":l()}};return s.jsxs(p.Row,{children:[s.jsx(p.Col,{flex:3,style:{display:"inline-flex",alignItems:"center"},children:s.jsxs("span",{style:{whiteSpace:"nowrap",width:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:[s.jsx(G.TagOutlined,{}),s.jsx("span",{style:{marginLeft:"10px"},children:I.Schema.compile(t.title,{t:n})})]})}),s.jsxs(p.Col,{children:[t.default?s.jsx(p.Tag,{color:"success",bordered:!1,children:n("Default")}):null,s.jsx(p.Dropdown,{menu:{items:[{label:n("Edit"),key:"edit"},{label:n("Delete"),key:"delete"}],onClick:f},children:s.jsx(G.MoreOutlined,{})})]})]})};const oe=g.createContext([]);oe.displayName="AvailableActionsContext";const ho=e=>{const{data:t,loading:r}=u.useRequest({resource:"availableActions",action:"list"});return r?s.jsx(p.Spin,{}):s.jsx(oe.Provider,{value:t==null?void 0:t.data,children:e.children})},fo=()=>g.useContext(oe);var vo="__lodash_hash_undefined__";function go(e){return this.__data__.set(e,vo),this}var mo=go;function yo(e){return this.__data__.has(e)}var _o=yo,bo=Ce,$o=mo,Co=_o;function X(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new bo;++t<r;)this.add(e[t])}X.prototype.add=X.prototype.push=$o,X.prototype.has=Co;var xo=X;function So(e,t,r,n){for(var a=e.length,i=r+(n?1:-1);n?i--:++i<a;)if(t(e[i],i,e))return i;return-1}var wo=So;function Ao(e){return e!==e}var Po=Ao;function Io(e,t,r){for(var n=r-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}var To=Io,Oo=wo,Mo=Po,Fo=To;function Do(e,t,r){return t===t?Fo(e,t,r):Oo(e,Mo,r)}var No=Do,Eo=No;function ko(e,t){var r=e==null?0:e.length;return!!r&&Eo(e,t,0)>-1}var qo=ko;function jo(e,t,r){for(var n=-1,a=e==null?0:e.length;++n<a;)if(r(t,e[n]))return!0;return!1}var Ho=jo;function Go(e,t){return e.has(t)}var Uo=Go,Ko=L,zo=K,Lo=Ko(zo,"Set"),Vo=Lo;function Wo(){}var Bo=Wo;function Yo(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Ge=Yo,ie=Vo,Xo=Bo,Jo=Ge,Zo=1/0,Qo=ie&&1/Jo(new ie([,-0]))[1]==Zo?function(e){return new ie(e)}:Xo,Ro=Qo,ei=xo,ti=qo,ri=Ho,ni=Uo,ai=Ro,si=Ge,oi=200;function ii(e,t,r){var n=-1,a=ti,i=e.length,o=!0,c=[],l=c;if(r)o=!1,a=ri;else if(i>=oi){var f=t?null:ai(e);if(f)return si(f);o=!1,a=ni,l=new ei}else l=t?[]:c;e:for(;++n<i;){var v=e[n],m=t?t(v):v;if(v=r||v!==0?v:0,o&&m===m){for(var C=l.length;C--;)if(l[C]===m)continue e;t&&l.push(m),c.push(v)}else a(l,m,r)||(l!==c&&l.push(m),c.push(v))}return c}var ci=ii,li=ci;function ui(e){return e&&e.length?li(e):[]}var pi=ui;const di=he(pi),hi=e=>{var r;if(!e)return{};const t={};return(r=e==null?void 0:e.forEach)==null||r.call(e,n=>{const[a,i]=n.split(":");t[a]=i||"all"}),t},Ue=e=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];n==="all"?t.push(r):t.push(`${r}:${n}`)}return t},fi=I.connect(e=>{const{onChange:t}=e,r=fo(),n=u.useCompile(),{t:a}=S.useTranslation(),i=I.useField(),o=hi(i.value);return s.jsx("div",{children:s.jsx(p.Table,{rowKey:"name",size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:a("Action display name"),render:c=>n(c)},{dataIndex:"onNewRecord",title:a("Action type"),render:c=>c?s.jsx(p.Tag,{color:"green",children:a("Action on new records")}):s.jsx(p.Tag,{color:"geekblue",children:a("Action on existing records")})},{dataIndex:"enabled",title:a("Allow"),render:(c,l)=>s.jsx(p.Checkbox,{checked:c,"aria-label":`${l.name}_checkbox`,onChange:f=>{c?delete o[l.name]:o[l.name]="all",t(Ue(o))}})},{dataIndex:"scope",title:a("Data scope"),render:(c,l)=>!l.onNewRecord&&s.jsx(p.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:c,options:[{label:a("All records"),value:"all"},{label:a("Own records"),value:"own"}],onChange:f=>{o[l.name]=f,t(Ue(o))}})}],dataSource:r==null?void 0:r.map(c=>{let l="all",f=!1;return o[c.name]&&(f=!0,l=o[c.name]),T(w({},c),{enabled:f,scope:l})})})})}),vi=I.connect(e=>{const{t}=S.useTranslation();return s.jsxs(p.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:r=>{const n=["ui.*","pm","pm.*","app"],a=n.map(o=>`!${o}`),i=di([...e.value||[],...r]).filter(o=>o&&!a.includes(o)).map(o=>!n.includes(o)||r!=null&&r.includes(o)?o:`!${o}`);for(const o of n)!i.includes(o)&&!i.includes(`!${o}`)&&i.push(`!${o}`);e.onChange(i)},children:[s.jsx("div",{style:{marginTop:16},children:s.jsx(p.Checkbox,{value:"ui.*",children:t("Allows to configure interface")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm",children:t("Allows to install, activate, disable plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"pm.*",children:t("Allows to configure plugins")})}),s.jsx("div",{style:{marginTop:8},children:s.jsx(p.Checkbox,{value:"app",children:t("Allows to clear cache, reboot application")})})]})}),gi=({active:e})=>{const{role:t,setRole:r}=g.useContext(P),{t:n}=O(),a=u.useAPIClient(),{data:i}=u.useRequest(()=>a.resource("roles").get({filterByTk:t==null?void 0:t.name}).then(l=>{var v,m;const f=(v=l==null?void 0:l.data)==null?void 0:v.data;return(m=f.snippets)==null||m.forEach(C=>{f[C]=!0}),f}),{ready:e,refreshDeps:[t==null?void 0:t.name]}),o=Qe.useMemoizedFn(l=>A(this,null,function*(){yield a.resource("roles").update({filterByTk:t.name,values:l.values}),r(w(w({},t),l.values)),p.message.success(n("Saved successfully"))})),c=g.useMemo(()=>de.createForm({values:i,effects(){de.onFormValuesChange(l=>A(this,null,function*(){yield o(l)}))}}),[i,o]);return s.jsx(u.SchemaComponent,{components:{SnippetCheckboxGroup:vi,StrategyActions:fi},schema:{type:"void",name:x.uid(),"x-component":"FormV2","x-component-props":{form:c},properties:{snippets:{title:n("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"},allowNewMenu:{title:n("Menu permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":n("New menu items are allowed to be accessed by default.")}}}})},ce=g.createContext(null);ce.displayName="MenuItemsContext";const Ke=(e={})=>{const t=[];for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r],a={title:n.title,uid:n["x-uid"]};n.properties&&(a.children=Ke(n.properties)),t.push(a)}return t},mi=()=>g.useContext(ce),ze=e=>{var i,o;const r={url:`uiSchemas:getProperties/${u.useAdminSchemaUid()}`},n=u.useRequest(r);if(n.loading)return s.jsx(p.Spin,{});const a=Ke((o=(i=n.data)==null?void 0:i.data)==null?void 0:o.properties);return s.jsx(ce.Provider,{value:{service:n,items:a},children:e.children})},Le=Re.createStyles(({css:e})=>e`
2
2
  .ant-table-cell {
3
3
  > .ant-space-horizontal {
4
4
  .ant-space-item-split:has(+ .ant-space-item:empty) {
@@ -6,4 +6,4 @@
6
6
  }
7
7
  }
8
8
  }
9
- `),Ve=e=>{if(!Array.isArray(e))return[];const t=[];for(const r of e)t.push(r.uid),t.push(...Ve(r.children));return t},We=(e,t,r=[])=>{if(!e)return[];for(const n of e){if(r.push(n.uid),t(n))return r;if(n.children){const a=We(n.children,t,r);if(a.length)return a}r.pop()}return[]},Be=(e=[],t=[])=>{for(const r of e)t.push(r.uid),r.children&&r.children.length&&Be(r.children,t);return t},yi=({active:e})=>{const{styles:t}=Le(),{role:r}=g.useContext(A),n=u.useAPIClient(),{items:a}=mi(),{t:i}=S.useTranslation(),o=Ve(a),[c,l]=g.useState([]),{loading:f,refresh:v}=u.useRequest({resource:"roles.menuUiSchemas",resourceOf:r.name,action:"list",params:{paginate:!1}},{ready:!!r&&e,refreshDeps:[r==null?void 0:r.name],onSuccess(b){var y;l(((y=b==null?void 0:b.data)==null?void 0:y.map(h=>h["x-uid"]))||[])}}),m=n.resource("roles.menuUiSchemas",r.name),C=o.length===c.length,le=(b,y)=>w(this,null,function*(){const h=We(a,$=>$.uid===y.uid),_=Be(y==null?void 0:y.children,[]);if(b){const $=_.concat(y.uid),N=c.filter(H=>!$.includes(H));l([...N]),yield m.remove({values:$})}else{const $=_.concat(h);l(N=>Z.uniq([...N,...$])),yield m.add({values:$})}p.message.success(i("Saved successfully"))}),D=b=>b.map(y=>{const h=i(y.title);return y.children?E(P({},y),{title:h,children:D(y.children)}):E(P({},y),{title:h})});return s.jsx(p.Table,{className:t,loading:f,rowKey:"uid",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:i("Menu item title")},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:C,onChange:b=>w(this,null,function*(){C?yield m.set({values:[]}):yield m.set({values:o}),v(),p.message.success(i("Saved successfully"))})})," ",i("Accessible")]}),render:(b,y)=>{const h=c.includes(y.uid);return s.jsx(p.Checkbox,{checked:h,onChange:()=>le(h,y)})}}],dataSource:D(a)})},Ye=(e=[],t=[])=>{for(const r of e)t.push(r.aclSnippet),r.children&&r.children.length&&Ye(r.children,t);return t},_i=({active:e})=>{const t=u.useApp(),{styles:r}=Le(),{role:n}=g.useContext(A),a=u.useAPIClient(),i=u.useCompile(),o=t.pluginSettingsManager.getList(!1),c=t.pluginSettingsManager.getAclSnippets(),[l,f]=g.useState([]),v=g.useMemo(()=>Z.flatMap(o,h=>h.children?[h,...h.children]:h),[o]),m=g.useMemo(()=>l.includes("pm.*")&&l.every(h=>!h.startsWith("!pm.")),[l]),{t:C}=S.useTranslation(),{loading:le,refresh:D}=u.useRequest({resource:"roles.snippets",resourceOf:n.name,action:"list",params:{paginate:!1}},{ready:!!n&&e,refreshDeps:[n==null?void 0:n.name],onSuccess(h){f((h==null?void 0:h.data.filter(_=>v.find($=>_.includes(`!${$.aclSnippet}`)||!_.startsWith("!pm."))))||[])}}),b=a.resource("roles.snippets",n.name),y=(h,_)=>w(this,null,function*(){const N=Ye(_==null?void 0:_.children,[]).concat(_.aclSnippet);h?(yield b.add({values:N.map(H=>"!"+H)}),D()):(yield b.remove({values:N.map(H=>"!"+H)}),D()),p.message.success(C("Saved successfully"))});return s.jsx(p.Table,{className:r,loading:le,rowKey:"key",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:C("Plugin name"),render:h=>i(h)},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:m,onChange:()=>w(this,null,function*(){const h=c.map(_=>"!"+_);m?yield b.add({values:h}):yield b.remove({values:h}),D(),p.message.success(C("Saved successfully"))})})," ",C("Accessible")]}),render:(h,_)=>{const $=!l.includes("!"+_.aclSnippet);return s.jsx(p.Checkbox,{checked:$,onChange:()=>y($,_)})}}],dataSource:o.filter(h=>h.isTopLevel!==!1).map(h=>h.showTabs!==!1?h:Z.omit(h,"children"))})},J=e=>s.jsx("div",{style:{maxHeight:"60vh",overflowY:"auto"},children:e.children}),bi=({active:e})=>{var f;const{t}=T(),[r,n]=g.useState("general"),{role:a}=g.useContext(A),i=(f=a==null?void 0:a.snippets)==null?void 0:f.includes("pm.*"),c=u.useApp().getComponent("DataSourcePermissionManager"),l=g.useMemo(()=>[{key:"general",label:t("General"),children:s.jsx(J,{children:s.jsx(gi,{active:r==="general"&&e})})},{key:"menu",label:t("Menu"),children:s.jsx(J,{children:s.jsx(ze,{children:s.jsx(yi,{active:r==="menu"&&e})})})},...i?[{key:"plugin",label:t("Plugin settings"),children:s.jsx(J,{children:s.jsx(_i,{active:r==="plugin"&&e})})}]:[],...c?[{key:"dataSource",label:t("Data sources"),children:s.jsx(J,{children:s.jsx(ze,{children:s.jsx(c,{role:a,active:r==="dataSource"&&e})})})}]:[]],[i,r,e,t]);return g.useEffect(()=>{n("general")},[a==null?void 0:a.name]),s.jsx(ho,{children:s.jsx(p.Tabs,{type:"card",activeKey:r,onChange:v=>n(v),items:l})})},$i=()=>{const{t:e}=T();return s.jsx(u.SchemaComponent,{scope:{t:e},schema:{type:"void",properties:{newRole:{type:"void",title:e("New role"),"x-component":"Action","x-component-props":{type:"text",icon:"PlusOutlined",style:{width:"100%",textAlign:"left"}},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const r=u.useActionContext();return u.useRequest(()=>Promise.resolve({data:{name:`r_${x.uid()}`,snippets:["!ui.*","!pm","!pm.*"]}}),E(P({},t),{refreshDeps:[r.visible]}))}},title:e("New role"),properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":'{{t("Default role")}}'},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 }}"}}}}}}}}}}})},Xe={name:"roles",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Role display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Role UID")}}',type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:'{{t("Default role")}}',type:"boolean","x-component":"Checkbox"}}]},Ci=()=>{const{t:e}=T(),t=u.usePlugin(Je),[r,n]=g.useState("permissions"),a=Array.from(t.rolesManager.list()).map(([c,l])=>({key:c,label:I.Schema.compile(l.title,{t:e}),children:l.Component?g.createElement(l.Component,{active:r===c}):null})),[i,o]=g.useState(null);return s.jsx(A.Provider,{value:{role:i,setRole:o},children:s.jsx(p.Card,{children:s.jsxs(p.Row,{gutter:24,style:{flexWrap:"nowrap"},children:[s.jsx(p.Col,{flex:"280px",style:{borderRight:"1px solid #eee",minWidth:"250px"},children:s.jsx(u.ResourceActionProvider,{collection:Xe,request:{resource:"roles",action:"list",params:{pagination:!1,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}},children:s.jsxs(u.CollectionProvider_deprecated,{collection:Xe,children:[s.jsx(p.Row,{children:s.jsx($i,{})}),s.jsx(p.Divider,{style:{margin:"12px 0"}}),s.jsx(se,{})]})})}),s.jsx(p.Col,{flex:"auto",style:{overflow:"hidden"},children:s.jsx(p.Tabs,{activeKey:r,onChange:c=>n(c),items:[{key:"permissions",label:e("Permissions"),children:s.jsx(bi,{active:r==="permissions"})},...a]})})]})})})};class xi{constructor(){pe(this,"rolesManager",new k.Registry)}add(t,r){this.rolesManager.register(t,r)}list(){return this.rolesManager.getEntities()}}class Je extends u.Plugin{constructor(){super(...arguments);pe(this,"rolesManager",new xi)}load(){return w(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions.roles",{title:'{{t("Roles & Permissions")}}',icon:"LockOutlined",Component:Ci,aclSnippet:"pm.acl.roles",sort:3})})}}d.RolesManagerContext=A,d.default=Je,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
9
+ `),Ve=e=>{if(!Array.isArray(e))return[];const t=[];for(const r of e)t.push(r.uid),t.push(...Ve(r.children));return t},We=(e,t,r=[])=>{if(!e)return[];for(const n of e){if(r.push(n.uid),t(n))return r;if(n.children){const a=We(n.children,t,r);if(a.length)return a}r.pop()}return[]},Be=(e=[],t=[])=>{for(const r of e)t.push(r.uid),r.children&&r.children.length&&Be(r.children,t);return t},yi=({active:e})=>{const{styles:t}=Le(),{role:r}=g.useContext(P),n=u.useAPIClient(),{items:a}=mi(),{t:i}=S.useTranslation(),o=Ve(a),[c,l]=g.useState([]),{loading:f,refresh:v}=u.useRequest({resource:"roles.menuUiSchemas",resourceOf:r.name,action:"list",params:{paginate:!1}},{ready:!!r&&e,refreshDeps:[r==null?void 0:r.name],onSuccess(b){var y;l(((y=b==null?void 0:b.data)==null?void 0:y.map(h=>h["x-uid"]))||[])}}),m=n.resource("roles.menuUiSchemas",r.name),C=o.length===c.length,le=(b,y)=>A(this,null,function*(){const h=We(a,$=>$.uid===y.uid),_=Be(y==null?void 0:y.children,[]);if(b){const $=_.concat(y.uid),E=c.filter(H=>!$.includes(H));l([...E]),yield m.remove({values:$})}else{const $=_.concat(h);l(E=>Z.uniq([...E,...$])),yield m.add({values:$})}p.message.success(i("Saved successfully"))}),N=b=>b.map(y=>{const h=i(y.title);return y.children?T(w({},y),{title:h,children:N(y.children)}):T(w({},y),{title:h})});return s.jsx(p.Table,{className:t,loading:f,rowKey:"uid",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:i("Menu item title")},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:C,onChange:b=>A(this,null,function*(){C?yield m.set({values:[]}):yield m.set({values:o}),v(),p.message.success(i("Saved successfully"))})})," ",i("Accessible")]}),render:(b,y)=>{const h=c.includes(y.uid);return s.jsx(p.Checkbox,{checked:h,onChange:()=>le(h,y)})}}],dataSource:N(a)})},Ye=(e=[],t=[])=>{for(const r of e)t.push(r.aclSnippet),r.children&&r.children.length&&Ye(r.children,t);return t},_i=({active:e})=>{const t=u.useApp(),{styles:r}=Le(),{role:n}=g.useContext(P),a=u.useAPIClient(),i=u.useCompile(),o=t.pluginSettingsManager.getList(!1),c=t.pluginSettingsManager.getAclSnippets(),[l,f]=g.useState([]),v=g.useMemo(()=>Z.flatMap(o,h=>h.children?[h,...h.children]:h),[o]),m=g.useMemo(()=>l.includes("pm.*")&&l.every(h=>!h.startsWith("!pm.")),[l]),{t:C}=S.useTranslation(),{loading:le,refresh:N}=u.useRequest({resource:"roles.snippets",resourceOf:n.name,action:"list",params:{paginate:!1}},{ready:!!n&&e,refreshDeps:[n==null?void 0:n.name],onSuccess(h){f((h==null?void 0:h.data.filter(_=>v.find($=>_.includes(`!${$.aclSnippet}`)||!_.startsWith("!pm."))))||[])}}),b=a.resource("roles.snippets",n.name),y=(h,_)=>A(this,null,function*(){const E=Ye(_==null?void 0:_.children,[]).concat(_.aclSnippet);h?(yield b.add({values:E.map(H=>"!"+H)}),N()):(yield b.remove({values:E.map(H=>"!"+H)}),N()),p.message.success(C("Saved successfully"))});return s.jsx(p.Table,{className:r,loading:le,rowKey:"key",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:C("Plugin name"),render:h=>i(h)},{dataIndex:"accessible",title:s.jsxs(s.Fragment,{children:[s.jsx(p.Checkbox,{checked:m,onChange:()=>A(this,null,function*(){const h=c.map(_=>"!"+_);m?yield b.add({values:h}):yield b.remove({values:h}),N(),p.message.success(C("Saved successfully"))})})," ",C("Accessible")]}),render:(h,_)=>{const $=!l.includes("!"+_.aclSnippet);return s.jsx(p.Checkbox,{checked:$,onChange:()=>y($,_)})}}],dataSource:o.filter(h=>h.isTopLevel!==!1).map(h=>h.showTabs!==!1?h:Z.omit(h,"children"))})},J=e=>s.jsx("div",{style:{maxHeight:"60vh",overflowY:"auto"},children:e.children}),bi=({active:e})=>{var f;const{t}=O(),[r,n]=g.useState("general"),{role:a}=g.useContext(P),i=(f=a==null?void 0:a.snippets)==null?void 0:f.includes("pm.*"),c=u.useApp().getComponent("DataSourcePermissionManager"),l=g.useMemo(()=>[{key:"general",label:t("General"),children:s.jsx(J,{children:s.jsx(gi,{active:r==="general"&&e})})},{key:"menu",label:t("Menu"),children:s.jsx(J,{children:s.jsx(ze,{children:s.jsx(yi,{active:r==="menu"&&e})})})},...i?[{key:"plugin",label:t("Plugin settings"),children:s.jsx(J,{children:s.jsx(_i,{active:r==="plugin"&&e})})}]:[],...c?[{key:"dataSource",label:t("Data sources"),children:s.jsx(J,{children:s.jsx(ze,{children:s.jsx(c,{role:a,active:r==="dataSource"&&e})})})}]:[]],[i,r,e,t]);return g.useEffect(()=>{n("general")},[a==null?void 0:a.name]),s.jsx(ho,{children:s.jsx(p.Tabs,{type:"card",activeKey:r,onChange:v=>n(v),items:l})})},$i=()=>{const{t:e}=O();return s.jsx(u.SchemaComponent,{scope:{t:e},schema:{type:"void",properties:{newRole:{type:"void",title:e("New role"),"x-component":"Action","x-component-props":{type:"text",icon:"PlusOutlined",style:{width:"100%",textAlign:"left"}},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const r=u.useActionContext();return u.useRequest(()=>Promise.resolve({data:{name:`r_${x.uid()}`,snippets:["!ui.*","!pm","!pm.*"]}}),T(w({},t),{refreshDeps:[r.visible]}))}},title:e("New role"),properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":'{{t("Default role")}}'},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 }}"}}}}}}}}}}})},Xe={name:"roles",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Role display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Role UID")}}',type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:'{{t("Default role")}}',type:"boolean","x-component":"Checkbox"}}]},Ci=()=>{const{t:e}=O(),t=u.usePlugin(Je),[r,n]=g.useState("permissions"),a=Array.from(t.rolesManager.list()).map(([l,f])=>({key:l,label:I.Schema.compile(f.title,{t:e}),children:f.Component?g.createElement(f.Component,{active:r===l}):null})),[i,o]=g.useState(null),c=u.useSchemaComponentContext();return s.jsx(u.SchemaComponentContext.Provider,{value:T(w({},c),{designable:!1}),children:s.jsx(P.Provider,{value:{role:i,setRole:o},children:s.jsx(p.Card,{children:s.jsxs(p.Row,{gutter:24,style:{flexWrap:"nowrap"},children:[s.jsx(p.Col,{flex:"280px",style:{borderRight:"1px solid #eee",minWidth:"250px"},children:s.jsx(u.ResourceActionProvider,{collection:Xe,request:{resource:"roles",action:"list",params:{pagination:!1,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}},children:s.jsxs(u.CollectionProvider_deprecated,{collection:Xe,children:[s.jsx(p.Row,{children:s.jsx($i,{})}),s.jsx(p.Divider,{style:{margin:"12px 0"}}),s.jsx(se,{})]})})}),s.jsx(p.Col,{flex:"auto",style:{overflow:"hidden"},children:s.jsx(p.Tabs,{activeKey:r,onChange:l=>n(l),items:[{key:"permissions",label:e("Permissions"),children:s.jsx(bi,{active:r==="permissions"})},...a]})})]})})})})};class xi{constructor(){pe(this,"rolesManager",new k.Registry)}add(t,r){this.rolesManager.register(t,r)}list(){return this.rolesManager.getEntities()}}class Je extends u.Plugin{constructor(){super(...arguments);pe(this,"rolesManager",new xi)}load(){return A(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions.roles",{title:'{{t("Roles & Permissions")}}',icon:"LockOutlined",Component:Ci,aclSnippet:"pm.acl.roles",sort:3})})}}d.RolesManagerContext=P,d.default=Je,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,22 +1,22 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.20.0-alpha.13",
2
+ "@nocobase/client": "0.20.0-alpha.15",
3
3
  "react": "18.2.0",
4
4
  "@formily/shared": "2.3.0",
5
5
  "antd": "5.12.8",
6
6
  "@formily/react": "2.3.0",
7
7
  "@ant-design/icons": "5.2.6",
8
8
  "react-i18next": "11.18.6",
9
- "@nocobase/utils": "0.20.0-alpha.13",
10
- "@nocobase/actions": "0.20.0-alpha.13",
11
- "@nocobase/cache": "0.20.0-alpha.13",
12
- "@nocobase/database": "0.20.0-alpha.13",
13
- "@nocobase/server": "0.20.0-alpha.13",
9
+ "@nocobase/utils": "0.20.0-alpha.15",
10
+ "@nocobase/actions": "0.20.0-alpha.15",
11
+ "@nocobase/cache": "0.20.0-alpha.15",
12
+ "@nocobase/database": "0.20.0-alpha.15",
13
+ "@nocobase/server": "0.20.0-alpha.15",
14
14
  "async-mutex": "0.3.2",
15
15
  "lodash": "4.17.21",
16
- "@nocobase/test": "0.20.0-alpha.13",
16
+ "@nocobase/test": "0.20.0-alpha.15",
17
17
  "@formily/core": "2.3.0",
18
18
  "ahooks": "3.7.8",
19
19
  "@formily/antd-v5": "1.1.9",
20
20
  "antd-style": "3.4.5",
21
- "@nocobase/acl": "0.20.0-alpha.13"
21
+ "@nocobase/acl": "0.20.0-alpha.15"
22
22
  };
@@ -349,7 +349,7 @@ class PluginACL extends import_server.Plugin {
349
349
  await this.writeRolesToACL(options);
350
350
  }
351
351
  };
352
- this.app.on("afterLoad", async () => {
352
+ this.app.on("afterStart", async () => {
353
353
  await writeRolesToACL(this.app, {
354
354
  withOutResources: true
355
355
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "权限控制",
5
5
  "description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
6
6
  "description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
7
- "version": "0.20.0-alpha.13",
7
+ "version": "0.20.0-alpha.15",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/acl",
@@ -34,5 +34,5 @@
34
34
  "url": "git+https://github.com/nocobase/nocobase.git",
35
35
  "directory": "packages/plugins/acl"
36
36
  },
37
- "gitHead": "4c3ff74d14c8726759b65730eba0b15798ba6879"
37
+ "gitHead": "ec192dcfe2dadda913e2d4c67b3706d78d5d3b9c"
38
38
  }