@nocobase/plugin-acl 0.20.0-alpha.5 → 0.20.0-alpha.7
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 +2 -2
- package/dist/externalVersion.js +8 -8
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(h,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):(h=typeof globalThis!="undefined"?globalThis:h||self,u(h["@nocobase/plugin-acl"]={},h["@nocobase/client"],h.jsxRuntime,h.react,h.antd,h["@formily/react"],h["@ant-design/icons"],h["react-i18next"],h["@formily/shared"],h["@nocobase/utils"],h["@formily/core"],h.ahooks,h.lodash,h["antd-style"]))})(this,function(h,u,s,g,p,A,G,C,_,k,ce,Ze,le,Qe){"use strict";var Si=Object.defineProperty,wi=Object.defineProperties;var Ai=Object.getOwnPropertyDescriptors;var Je=Object.getOwnPropertySymbols;var Pi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable;var oe=(h,u,s)=>u in h?Si(h,u,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[u]=s,w=(h,u)=>{for(var s in u||(u={}))Pi.call(u,s)&&oe(h,s,u[s]);if(Je)for(var s of Je(u))Ii.call(u,s)&&oe(h,s,u[s]);return h},N=(h,u)=>wi(h,Ai(u));var ie=(h,u,s)=>(oe(h,typeof u!="symbol"?u+"":u,s),s);var S=(h,u,s)=>new Promise((g,p)=>{var A=_=>{try{C(s.next(_))}catch(k){p(k)}},G=_=>{try{C(s.throw(_))}catch(k){p(k)}},C=_=>_.done?g(_.value):Promise.resolve(_.value).then(A,G);C((s=s.apply(h,u)).next())});function O(){return C.useTranslation(["acl","client"],{nsMode:"fallback"})}const P=g.createContext({role:null});var U=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Re=Array.isArray,q=Re,et=typeof U=="object"&&U&&U.Object===Object&&U,tt=et,rt=tt,nt=typeof self=="object"&&self&&self.Object===Object&&self,at=rt||nt||Function("return this")(),K=at,st=K,ot=st.Symbol,z=ot,pe=z,de=Object.prototype,it=de.hasOwnProperty,ct=de.toString,j=pe?pe.toStringTag:void 0;function lt(e){var t=it.call(e,j),r=e[j];try{e[j]=void 0;var n=!0}catch(o){}var a=ct.call(e);return n&&(t?e[j]=r:delete e[j]),a}var ut=lt,pt=Object.prototype,dt=pt.toString;function ht(e){return dt.call(e)}var ft=ht,he=z,vt=ut,gt=ft,mt="[object Null]",yt="[object Undefined]",fe=he?he.toStringTag:void 0;function _t(e){return e==null?e===void 0?yt:mt:fe&&fe in Object(e)?vt(e):gt(e)}var Z=_t;function bt(e){return e!=null&&typeof e=="object"}var Q=bt,$t=Z,Ct=Q,xt="[object Symbol]";function St(e){return typeof e=="symbol"||Ct(e)&&$t(e)==xt}var R=St,wt=q,At=R,Pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,It=/^\w*$/;function Tt(e,t){if(wt(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||At(e)?!0:It.test(e)||!Pt.test(e)||t!=null&&e in Object(t)}var Ot=Tt;function Mt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ee=Mt,Ft=Z,Dt=ee,Et="[object AsyncFunction]",Nt="[object Function]",kt="[object GeneratorFunction]",qt="[object Proxy]";function jt(e){if(!Dt(e))return!1;var t=Ft(e);return t==Nt||t==kt||t==Et||t==qt}var Ht=jt,Gt=K,Ut=Gt["__core-js_shared__"],Kt=Ut,te=Kt,ve=function(){var e=/[^.]+$/.exec(te&&te.keys&&te.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function zt(e){return!!ve&&ve in e}var Lt=zt,Vt=Function.prototype,Wt=Vt.toString;function Bt(e){if(e!=null){try{return Wt.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Yt=Bt,Xt=Ht,Jt=Lt,Zt=ee,Qt=Yt,Rt=/[\\^$.*+?()[\]{}|]/g,er=/^\[object .+?Constructor\]$/,tr=Function.prototype,rr=Object.prototype,nr=tr.toString,ar=rr.hasOwnProperty,sr=RegExp("^"+nr.call(ar).replace(Rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function or(e){if(!Zt(e)||Jt(e))return!1;var t=Xt(e)?sr:er;return t.test(Qt(e))}var ir=or;function cr(e,t){return e==null?void 0:e[t]}var lr=cr,ur=ir,pr=lr;function dr(e,t){var r=pr(e,t);return ur(r)?r:void 0}var L=dr,hr=L,fr=hr(Object,"create"),V=fr,ge=V;function vr(){this.__data__=ge?ge(null):{},this.size=0}var gr=vr;function mr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var yr=mr,_r=V,br="__lodash_hash_undefined__",$r=Object.prototype,Cr=$r.hasOwnProperty;function xr(e){var t=this.__data__;if(_r){var r=t[e];return r===br?void 0:r}return Cr.call(t,e)?t[e]:void 0}var Sr=xr,wr=V,Ar=Object.prototype,Pr=Ar.hasOwnProperty;function Ir(e){var t=this.__data__;return wr?t[e]!==void 0:Pr.call(t,e)}var Tr=Ir,Or=V,Mr="__lodash_hash_undefined__";function Fr(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Or&&t===void 0?Mr:t,this}var Dr=Fr,Er=gr,Nr=yr,kr=Sr,qr=Tr,jr=Dr;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=Nr,M.prototype.get=kr,M.prototype.has=qr,M.prototype.set=jr;var Hr=M;function Gr(){this.__data__=[],this.size=0}var Ur=Gr;function Kr(e,t){return e===t||e!==e&&t!==t}var me=Kr,zr=me;function Lr(e,t){for(var r=e.length;r--;)if(zr(e[r][0],t))return r;return-1}var W=Lr,Vr=W,Wr=Array.prototype,Br=Wr.splice;function Yr(e){var t=this.__data__,r=Vr(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Br.call(t,r,1),--this.size,!0}var Xr=Yr,Jr=W;function Zr(e){var t=this.__data__,r=Jr(t,e);return r<0?void 0:t[r][1]}var Qr=Zr,Rr=W;function en(e){return Rr(this.__data__,e)>-1}var tn=en,rn=W;function nn(e,t){var r=this.__data__,n=rn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var an=nn,sn=Ur,on=Xr,cn=Qr,ln=tn,un=an;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=sn,F.prototype.delete=on,F.prototype.get=cn,F.prototype.has=ln,F.prototype.set=un;var pn=F,dn=L,hn=K,fn=dn(hn,"Map"),vn=fn,ye=Hr,gn=pn,mn=vn;function yn(){this.size=0,this.__data__={hash:new ye,map:new(mn||gn),string:new ye}}var _n=yn;function bn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var $n=bn,Cn=$n;function xn(e,t){var r=e.__data__;return Cn(t)?r[typeof t=="string"?"string":"hash"]:r.map}var B=xn,Sn=B;function wn(e){var t=Sn(this,e).delete(e);return this.size-=t?1:0,t}var An=wn,Pn=B;function In(e){return Pn(this,e).get(e)}var Tn=In,On=B;function Mn(e){return On(this,e).has(e)}var Fn=Mn,Dn=B;function En(e,t){var r=Dn(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var Nn=En,kn=_n,qn=An,jn=Tn,Hn=Fn,Gn=Nn;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=kn,D.prototype.delete=qn,D.prototype.get=jn,D.prototype.has=Hn,D.prototype.set=Gn;var _e=D,be=_e,Un="Expected a function";function re(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Un);var r=function(){var n=arguments,a=t?t.apply(this,n):n[0],o=r.cache;if(o.has(a))return o.get(a);var i=e.apply(this,n);return r.cache=o.set(a,i)||o,i};return r.cache=new(re.Cache||be),r}re.Cache=be;var Kn=re,zn=Kn,Ln=500;function Vn(e){var t=zn(e,function(n){return r.size===Ln&&r.clear(),n}),r=t.cache;return t}var Wn=Vn,Bn=Wn,Yn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Xn=/\\(\\)?/g,Jn=Bn(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Yn,function(r,n,a,o){t.push(a?o.replace(Xn,"$1"):n||r)}),t}),Zn=Jn;function Qn(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 Rn=Qn,$e=z,ea=Rn,ta=q,ra=R,na=1/0,Ce=$e?$e.prototype:void 0,xe=Ce?Ce.toString:void 0;function Se(e){if(typeof e=="string")return e;if(ta(e))return ea(e,Se)+"";if(ra(e))return xe?xe.call(e):"";var t=e+"";return t=="0"&&1/e==-na?"-0":t}var aa=Se,sa=aa;function oa(e){return e==null?"":sa(e)}var ia=oa,ca=q,la=Ot,ua=Zn,pa=ia;function da(e,t){return ca(e)?e:la(e,t)?[e]:ua(pa(e))}var Y=da,ha=R,fa=1/0;function va(e){if(typeof e=="string"||ha(e))return e;var t=e+"";return t=="0"&&1/e==-fa?"-0":t}var ne=va,ga=Y,ma=ne;function ya(e,t){t=ga(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[ma(t[r++])];return r&&r==n?e:void 0}var _a=ya,ba=L,$a=function(){try{var e=ba(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),we=$a,Ae=we;function Ca(e,t,r){t=="__proto__"&&Ae?Ae(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var xa=Ca,Sa=xa,wa=me,Aa=Object.prototype,Pa=Aa.hasOwnProperty;function Ia(e,t,r){var n=e[t];(!(Pa.call(e,t)&&wa(n,r))||r===void 0&&!(t in e))&&Sa(e,t,r)}var Ta=Ia,Oa=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function Fa(e,t){var r=typeof e;return t=t==null?Oa:t,!!t&&(r=="number"||r!="symbol"&&Ma.test(e))&&e>-1&&e%1==0&&e<t}var Pe=Fa,Da=Ta,Ea=Y,Na=Pe,Ie=ee,ka=ne;function qa(e,t,r,n){if(!Ie(e))return e;t=Ea(t,e);for(var a=-1,o=t.length,i=o-1,c=e;c!=null&&++a<o;){var l=ka(t[a]),v=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=i){var f=c[l];v=n?n(f,l,c):void 0,v===void 0&&(v=Ie(f)?f:Na(t[a+1])?[]:{})}Da(c,l,v),c=c[l]}return e}var ja=qa,Ha=_a,Ga=ja,Ua=Y;function Ka(e,t,r){for(var n=-1,a=t.length,o={};++n<a;){var i=t[n],c=Ha(e,i);r(c,i)&&Ga(o,Ua(i,e),c)}return o}var za=Ka;function La(e,t){return e!=null&&t in Object(e)}var Va=La,Wa=Z,Ba=Q,Ya="[object Arguments]";function Xa(e){return Ba(e)&&Wa(e)==Ya}var Ja=Xa,Te=Ja,Za=Q,Oe=Object.prototype,Qa=Oe.hasOwnProperty,Ra=Oe.propertyIsEnumerable,es=Te(function(){return arguments}())?Te:function(e){return Za(e)&&Qa.call(e,"callee")&&!Ra.call(e,"callee")},Me=es,ts=9007199254740991;function rs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ts}var ns=rs,as=Y,ss=Me,os=q,is=Pe,cs=ns,ls=ne;function us(e,t,r){t=as(t,e);for(var n=-1,a=t.length,o=!1;++n<a;){var i=ls(t[n]);if(!(o=e!=null&&r(e,i)))break;e=e[i]}return o||++n!=a?o:(a=e==null?0:e.length,!!a&&cs(a)&&is(i,a)&&(os(e)||ss(e)))}var ps=us,ds=Va,hs=ps;function fs(e,t){return e!=null&&hs(e,t,ds)}var vs=fs,gs=za,ms=vs;function ys(e,t){return gs(e,t,function(r,n){return ms(e,n)})}var _s=ys;function bs(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var $s=bs,Fe=z,Cs=Me,xs=q,De=Fe?Fe.isConcatSpreadable:void 0;function Ss(e){return xs(e)||Cs(e)||!!(De&&e&&e[De])}var ws=Ss,As=$s,Ps=ws;function Ee(e,t,r,n,a){var o=-1,i=e.length;for(r||(r=Ps),a||(a=[]);++o<i;){var c=e[o];t>0&&r(c)?t>1?Ee(c,t-1,r,n,a):As(a,c):n||(a[a.length]=c)}return a}var Is=Ee,Ts=Is;function Os(e){var t=e==null?0:e.length;return t?Ts(e,1):[]}var Ms=Os;function Fs(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 Ds=Fs,Es=Ds,Ne=Math.max;function Ns(e,t,r){return t=Ne(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,o=Ne(n.length-t,0),i=Array(o);++a<o;)i[a]=n[t+a];a=-1;for(var c=Array(t+1);++a<t;)c[a]=n[a];return c[t]=r(i),Es(e,this,c)}}var ks=Ns;function qs(e){return function(){return e}}var js=qs;function Hs(e){return e}var Gs=Hs,Us=js,ke=we,Ks=Gs,zs=ke?function(e,t){return ke(e,"toString",{configurable:!0,enumerable:!1,value:Us(t),writable:!0})}:Ks,Ls=zs,Vs=800,Ws=16,Bs=Date.now;function Ys(e){var t=0,r=0;return function(){var n=Bs(),a=Ws-(n-r);if(r=n,a>0){if(++t>=Vs)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Xs=Ys,Js=Ls,Zs=Xs,Qs=Zs(Js),Rs=Qs,eo=Ms,to=ks,ro=Rs;function no(e){return ro(to(e,void 0,eo),e+"")}var ao=no,so=_s,oo=ao,io=oo(function(e,t){return e==null?{}:so(e,t)}),co=io;const lo=ue(co),uo={type:"object",properties:{[_.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:lo(t,["title","name","default"])}),N(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 }}"}}}}}}}},ae=()=>{const{t:e}=O(),{data:t}=u.useResourceActionContext(),[r,n]=g.useState(!1),[a,o]=g.useState(null),{role:i,setRole:c}=g.useContext(P),l=((t==null?void 0:t.data)||[]).map(f=>({key:f.name,label:s.jsx(ae.Item,{item:f,onEdit:()=>{n(!0),o(f)}})})),v=({key:f})=>{c(((t==null?void 0:t.data)||[]).find(m=>m.name===f))};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:[i==null?void 0:i.name],onSelect:v}):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:uo})})})]})};ae.Item=function({item:t,onEdit:r}){const{t:n}=O(),{refreshAsync:a}=u.useResourceActionContext(),{modal:o,message:i}=p.App.useApp(),c=u.useAPIClient(),l=()=>{o.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:()=>S(this,null,function*(){yield c.resource("roles").destroy({filterByTk:t.name}),i.success(n("Deleted successfully")),yield a()})})},v=({key:f,domEvent:m})=>{switch(m.stopPropagation(),f){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:A.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:v},children:s.jsx(G.MoreOutlined,{})})]})]})};const qe=g.createContext([]),po=e=>{const{data:t,loading:r}=u.useRequest({resource:"availableActions",action:"list"});return r?s.jsx(p.Spin,{}):s.jsx(qe.Provider,{value:t==null?void 0:t.data,children:e.children})},ho=()=>g.useContext(qe);var fo="__lodash_hash_undefined__";function vo(e){return this.__data__.set(e,fo),this}var go=vo;function mo(e){return this.__data__.has(e)}var yo=mo,_o=_e,bo=go,$o=yo;function X(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new _o;++t<r;)this.add(e[t])}X.prototype.add=X.prototype.push=bo,X.prototype.has=$o;var Co=X;function xo(e,t,r,n){for(var a=e.length,o=r+(n?1:-1);n?o--:++o<a;)if(t(e[o],o,e))return o;return-1}var So=xo;function wo(e){return e!==e}var Ao=wo;function Po(e,t,r){for(var n=r-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}var Io=Po,To=So,Oo=Ao,Mo=Io;function Fo(e,t,r){return t===t?Mo(e,t,r):To(e,Oo,r)}var Do=Fo,Eo=Do;function No(e,t){var r=e==null?0:e.length;return!!r&&Eo(e,t,0)>-1}var ko=No;function qo(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 jo=qo;function Ho(e,t){return e.has(t)}var Go=Ho,Uo=L,Ko=K,zo=Uo(Ko,"Set"),Lo=zo;function Vo(){}var Wo=Vo;function Bo(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var je=Bo,se=Lo,Yo=Wo,Xo=je,Jo=1/0,Zo=se&&1/Xo(new se([,-0]))[1]==Jo?function(e){return new se(e)}:Yo,Qo=Zo,Ro=Co,ei=ko,ti=jo,ri=Go,ni=Qo,ai=je,si=200;function oi(e,t,r){var n=-1,a=ei,o=e.length,i=!0,c=[],l=c;if(r)i=!1,a=ti;else if(o>=si){var v=t?null:ni(e);if(v)return ai(v);i=!1,a=ri,l=new Ro}else l=t?[]:c;e:for(;++n<o;){var f=e[n],m=t?t(f):f;if(f=r||f!==0?f:0,i&&m===m){for(var x=l.length;x--;)if(l[x]===m)continue e;t&&l.push(m),c.push(f)}else a(l,m,r)||(l!==c&&l.push(m),c.push(f))}return c}var ii=oi,ci=ii;function li(e){return e&&e.length?ci(e):[]}var ui=li;const pi=ue(ui),di=e=>{var r;if(!e)return{};const t={};return(r=e==null?void 0:e.forEach)==null||r.call(e,n=>{const[a,o]=n.split(":");t[a]=o||"all"}),t},He=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},hi=A.connect(e=>{const{onChange:t}=e,r=ho(),n=u.useCompile(),{t:a}=C.useTranslation(),o=A.useField(),i=di(o.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:v=>{c?delete i[l.name]:i[l.name]="all",t(He(i))}})},{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:v=>{i[l.name]=v,t(He(i))}})}],dataSource:r==null?void 0:r.map(c=>{let l="all",v=!1;return i[c.name]&&(v=!0,l=i[c.name]),N(w({},c),{enabled:v,scope:l})})})})}),fi=A.connect(e=>{const{t}=C.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(i=>`!${i}`),o=pi([...e.value||[],...r]).filter(i=>i&&!a.includes(i)).map(i=>!n.includes(i)||r!=null&&r.includes(i)?i:`!${i}`);for(const i of n)!o.includes(i)&&!o.includes(`!${i}`)&&o.push(`!${i}`);e.onChange(o)},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")})})]})}),vi=({active:e})=>{const{role:t,setRole:r}=g.useContext(P),{t:n}=O(),a=u.useAPIClient(),{data:o}=u.useRequest(()=>a.resource("roles").get({filterByTk:t==null?void 0:t.name}).then(l=>{var f,m;const v=(f=l==null?void 0:l.data)==null?void 0:f.data;return(m=v.snippets)==null||m.forEach(x=>{v[x]=!0}),v}),{ready:e,refreshDeps:[t==null?void 0:t.name]}),i=Ze.useMemoizedFn(l=>S(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(()=>ce.createForm({values:o,effects(){ce.onFormValuesChange(l=>S(this,null,function*(){yield i(l)}))}}),[o,i]);return s.jsx(u.SchemaComponent,{components:{SnippetCheckboxGroup:fi,StrategyActions:hi},schema:{type:"void",name:_.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.")}}}})},Ge=g.createContext(null),Ue=(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=Ue(n.properties)),t.push(a)}return t},gi=()=>g.useContext(Ge),Ke=e=>{var o,i;const r={url:`uiSchemas:getProperties/${u.useAdminSchemaUid()}`},n=u.useRequest(r);if(n.loading)return s.jsx(p.Spin,{});const a=Ue((i=(o=n.data)==null?void 0:o.data)==null?void 0:i.properties);return s.jsx(Ge.Provider,{value:{service:n,items:a},children:e.children})},ze=Qe.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,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`
|
|
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
|
-
`),
|
|
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.roles",sort:3})})}}d.RolesManagerContext=A,d.default=Je,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.20.0-alpha.
|
|
2
|
+
"@nocobase/client": "0.20.0-alpha.7",
|
|
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.
|
|
10
|
-
"@nocobase/actions": "0.20.0-alpha.
|
|
11
|
-
"@nocobase/cache": "0.20.0-alpha.
|
|
12
|
-
"@nocobase/database": "0.20.0-alpha.
|
|
13
|
-
"@nocobase/server": "0.20.0-alpha.
|
|
9
|
+
"@nocobase/utils": "0.20.0-alpha.7",
|
|
10
|
+
"@nocobase/actions": "0.20.0-alpha.7",
|
|
11
|
+
"@nocobase/cache": "0.20.0-alpha.7",
|
|
12
|
+
"@nocobase/database": "0.20.0-alpha.7",
|
|
13
|
+
"@nocobase/server": "0.20.0-alpha.7",
|
|
14
14
|
"async-mutex": "0.3.2",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
|
-
"@nocobase/test": "0.20.0-alpha.
|
|
16
|
+
"@nocobase/test": "0.20.0-alpha.7",
|
|
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.
|
|
21
|
+
"@nocobase/acl": "0.20.0-alpha.7"
|
|
22
22
|
};
|
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.
|
|
7
|
+
"version": "0.20.0-alpha.7",
|
|
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": "
|
|
37
|
+
"gitHead": "78900f33a0112255c408799d8bbf0c9b513147cd"
|
|
38
38
|
}
|