@nocobase/plugin-acl 2.1.0-beta.9 → 2.1.0
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/949.7ad4ad3b554e5452.js +10 -0
- package/dist/client/971.50ecf7b6ac572080.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/336.c27dbbf4b362f3c2.js +10 -0
- package/dist/client-v2/532.be9165ee6b4d34c1.js +10 -0
- package/dist/client-v2/800.020212b7d7b3875d.js +10 -0
- package/dist/client-v2/870.1d9bac44ccd1f650.js +10 -0
- package/dist/client-v2/components/ResourceFormDrawer.d.ts +33 -0
- package/dist/client-v2/index.d.ts +12 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +11 -0
- package/dist/client-v2/models/user-center/SwitchRoleItemModel.d.ts +18 -0
- package/dist/client-v2/pages/RolesManagementPage.d.ts +10 -0
- package/dist/client-v2/pages/permissions/DesktopRoutesPermissionsTab.d.ts +11 -0
- package/dist/client-v2/pages/permissions/PluginPermissionsTable.d.ts +16 -0
- package/dist/client-v2/pages/permissions/SystemPermissionsTab.d.ts +11 -0
- package/dist/client-v2/pages/permissions/utils.d.ts +18 -0
- package/dist/client-v2/plugin.d.ts +16 -0
- package/dist/client-v2/registries.d.ts +60 -0
- package/dist/externalVersion.js +13 -10
- package/dist/locale/en-US.json +17 -2
- package/dist/locale/zh-CN.json +17 -2
- package/dist/server/actions/apply-data-permissions.d.ts +10 -0
- package/dist/server/actions/apply-data-permissions.js +208 -0
- package/dist/server/actions/data-source-compat.d.ts +13 -0
- package/dist/server/actions/data-source-compat.js +189 -0
- package/dist/server/collections/roles-users.js +1 -0
- package/dist/server/collections/roles.js +1 -0
- package/dist/server/collections/rolesResources.js +1 -0
- package/dist/server/collections/rolesResourcesActions.js +1 -0
- package/dist/server/collections/rolesResourcesScopes.js +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +6 -0
- package/dist/server/middlewares/check-association-operate.js +9 -6
- package/dist/server/middlewares/check-change-with-association.d.ts +1 -0
- package/dist/server/middlewares/check-change-with-association.js +3 -1
- package/dist/server/middlewares/check-query-permission.d.ts +10 -0
- package/dist/server/middlewares/check-query-permission.js +64 -0
- package/dist/server/middlewares/setCurrentRole.js +2 -2
- package/dist/server/middlewares/with-acl-meta.js +1 -1
- package/dist/server/query/apply-query-permission.d.ts +27 -0
- package/dist/server/query/apply-query-permission.js +242 -0
- package/dist/server/server.js +18 -0
- package/dist/swagger/index.d.ts +1113 -145
- package/dist/swagger/index.js +986 -180
- package/package.json +4 -2
- package/dist/client/0655d5ded9f45bb1.js +0 -10
- package/dist/client/50204a14518b3a0d.js +0 -10
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).push([["949"],{916:function(e,t,r){r.r(t),r.d(t,{RolesManagement:function(){return $}});var n=r(230),o=r(342),l=r(59),a=r(155),i=r.n(a),c=r(747),u=r(79),s=r(166),f=function(){var e=(0,u.P)().t;return i().createElement(o.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:{textAlign:"left"}},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,r,n=(0,o.useActionContext)();return(0,o.useRequest)(function(){return Promise.resolve({data:{name:"r_".concat((0,s.uid)()),snippets:["!ui.*","!pm","!pm.*"]}})},(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),r=r={refreshDeps:[n.visible]},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))}},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 }}"}}}}}}}}}}})},p=r(268),m=r(375),y=r(773);function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var b={type:"object",properties:d({},(0,s.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,r,n=(0,o.useRecord)(),l=(0,o.useRequest)(function(){return Promise.resolve({data:(0,y.pick)(n,["title","name","default"])})},(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){d(e,t,r[t])})}return e}({},e),r=r={manual:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t)),i=(0,o.useActionContext)();return(0,a.useEffect)(function(){i.visible&&l.run()},[i.visible]),l}},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")}}',"x-reactions":function(e){e.initialValue?e.disabled=!0:e.disabled=!1}},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 }}"}}}}}})};function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var h=function(e){var t,r=e.loadMore,n=function(e){if(Array.isArray(e))return e}(t=(0,a.useState)(null))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return v(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=n[0],l=n[1],i=(0,a.useRef)(null),c=(0,a.useCallback)(function(e){e&&(i.current&&i.current.disconnect(),i.current=new IntersectionObserver(function(t){t.forEach(function(t){t.target===e.current&&t.isIntersecting&&(i.current&&i.current.unobserve(e.current),r())})}),e.current&&i.current&&i.current.observe(e.current))},[r]);return(0,a.useEffect)(function(){return c(o),function(){i.current&&i.current.disconnect()}},[o,c]),{lastItem:o,setLastItem:l}};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function w(e,t,r,n,o,l,a){try{var i=e[l](a),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function O(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var l=e.apply(t,r);function a(e){w(l,n,o,a,i,"next",e)}function i(e){w(l,n,o,a,i,"throw",e)}a(void 0)})}}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(l.push(r.value),!t||l.length!==t);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw n}}return l}}(e,t)||S(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(e,t)}}function x(e,t){var r,n,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:c(0)}),i(a,"throw",{value:c(1)}),i(a,"return",{value:c(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function c(i){return function(c){var u=[i,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(l=0)),l;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){l.label=u[1];break}if(6===u[0]&&l.label<o[1]){l.label=o[1],o=u;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(u);break}o[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var j=function(){var e=(0,u.P)().t,t=(0,o.useResourceActionContext)(),r=t.data,n=t.mutate,c=E((0,a.useState)(!1),2),s=c[0],f=c[1],m=E((0,a.useState)(null),2),y=m[0],d=m[1],v=(0,a.useContext)(p.s),g=v.role,w=v.setRole,S=E((0,a.useState)([]),2),P=S[0],C=S[1],I=E((0,a.useState)(!1),2),R=I[0],k=I[1],D=(0,o.useAPIClient)(),T=h({loadMore:(0,a.useCallback)(function(){return O(function(){var e,t;return x(this,function(o){switch(o.label){case 0:if(!(e=null==r?void 0:r.meta)||e.page>=e.totalPage)return[2];return k(!0),[4,D.resource("roles").list({page:e.page+1,pageSize:e.pageSize,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]})];case 1:return n((null==(t=o.sent())?void 0:t.data)||{}),k(!1),[2]}})})()},[r])}),M=T.lastItem,F=T.setLastItem;(0,a.useEffect)(function(){P[0]&&w(P[0])},[P,w]),(0,a.useEffect)(function(){if(null==r||null==(e=r.data)?void 0:e.length){var e,t;F(i().createRef()),(null==(t=r.meta)?void 0:t.page)>1?C(function(e){return e.concat(r.data)}):C(r.data)}},[r,F]);var U=(0,a.useMemo)(function(){return P.map(function(e,t){return{key:e.name,label:t===P.length-1?i().createElement("div",{ref:M},i().createElement(j.Item,{item:e,onEdit:function(){f(!0),d(e)}})):i().createElement(j.Item,{item:e,onEdit:function(){f(!0),d(e)}})}})},[P,M]);return i().createElement(i().Fragment,null,P.length?i().createElement(l.Menu,{style:{border:"none",maxHeight:"65vh",overflowY:"auto"},items:A(U).concat(A(R?[{key:"loading",label:i().createElement(l.Spin,null)}]:[])),selectedKeys:[null==g?void 0:g.name],onSelect:function(e){var t=e.key;w(P.find(function(e){return e.name===t}))}}):i().createElement(l.Empty,{image:l.Empty.PRESENTED_IMAGE_SIMPLE}),i().createElement(o.ActionContextProvider,{value:{visible:s,setVisible:f}},i().createElement(o.RecordProvider,{record:y,collectionName:"departments"},i().createElement(o.SchemaComponent,{scope:{t:e},schema:b}))))};j.Item=function(e){var t=e.item,r=e.onEdit,a=(0,u.P)().t,c=(0,o.useResourceActionContext)().refreshAsync,s=l.App.useApp(),f=s.modal,p=s.message,y=(0,o.useAPIClient)(),d=function(){f.confirm({title:a("Delete"),content:a("Are you sure you want to delete it?"),onOk:function(){return O(function(){return x(this,function(e){switch(e.label){case 0:return[4,y.resource("roles").destroy({filterByTk:t.name})];case 1:return e.sent(),p.success(a("Deleted successfully")),[4,c()];case 2:return e.sent(),[2]}})})()}})},b=n.Schema.compile(t.title,{t:a});return i().createElement(l.Row,null,i().createElement(l.Col,{flex:3,style:{display:"inline-flex",alignItems:"center",flex:"1 1 0",minWidth:0,paddingRight:"8px"}},i().createElement("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",width:"100%"}},i().createElement(m.TagOutlined,null),i().createElement("span",{style:{marginLeft:"10px"},title:b},b))),i().createElement(l.Col,null,t.default?i().createElement(l.Tag,{color:"success",bordered:!1},a("Default")):null,i().createElement(l.Dropdown,{menu:{items:[{label:a("Edit"),key:"edit"},{label:a("Delete"),key:"delete"}],onClick:function(e){var t=e.key;switch(e.domEvent.stopPropagation(),t){case"edit":r();break;case"delete":d()}}}},i().createElement(m.MoreOutlined,null))))};var P=r(570);function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var I=function(e){return i().createElement("div",{style:{maxHeight:"60vh",overflowY:"auto"}},e.children)},R=function(e){var t,r=e.active,n=(0,u.P)().t,s=function(e){if(Array.isArray(e))return e}(t=i().useState("general"))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return C(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return C(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),f=s[0],m=s[1],y=(0,a.useContext)(p.s),d=y.role,b=y.setRole,v=(0,o.usePlugin)(c.default),h=(0,o.useACLRoleContext)(),g=(0,a.useMemo)(function(){return v.settingsUI.getPermissionsTabs({t:n,activeKey:f,TabLayout:I,activeRole:d,currentUserRole:h}).filter(Boolean)},[f,v.settingsUI,d,n,h]),w=(0,o.useAPIClient)(),O=(0,o.useRequest)(function(){return w.resource("roles").get({filterByTk:null==d?void 0:d.name}).then(function(e){var t,r,n=null==e||null==(t=e.data)?void 0:t.data;return null==(r=n.snippets)||r.forEach(function(e){n[e]=!0}),n})},{ready:r&&!!d,refreshDeps:[null==d?void 0:d.name]}).data;return(0,a.useEffect)(function(){m("general")},[null==d?void 0:d.name]),(0,a.useEffect)(function(){b(O)},[O,b]),i().createElement(P.c,null,i().createElement(l.Tabs,{type:"card",activeKey:f,onChange:function(e){return m(e)},items:g}))},k=r(625);function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var T=function(){var e,t=(0,u.P)().t,r=(0,o.useAPIClient)(),n=(0,o.useCurrentRoleMode)(),c=function(e){if(Array.isArray(e))return e}(e=(0,a.useState)(n||"default"))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return D(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return D(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=c[0],f=c[1],p=(0,k.useRequest)(function(e){return r.resource("roles").setSystemRoleMode({values:{roleMode:e}})},{manual:!0,onSuccess:function(e,r){f(r[0]),l.message.success(t("Saved successfully")),window.location.reload()}}).run;return i().createElement("div",null,i().createElement(l.Select,{value:s,onChange:function(e){return p(e)},options:[{value:"default",label:t("Independent roles"),desc:t("Do not use role union. Users need to switch between their roles individually.")},{value:"allow-use-union",label:t("Allow roles union"),desc:t("Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.")},{value:"only-use-union",label:t("Roles union only"),desc:t("Force users to use only role union. They cannot switch between individual roles.")}],optionRender:function(e){return i().createElement(l.Tooltip,{placement:"right",title:i().createElement("div",null,e.data.desc)},i().createElement(l.Flex,{justify:"space-between"},i().createElement("span",{style:{display:"inline-flex",paddingRight:8}},e.data.label)))}}))};function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(l.push(r.value),!t||l.length!==t);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw n}}return l}}(e,t)||U(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){if(e){if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}}var _={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"}}]},$=function(){var e=(0,u.P)().t,t=(0,o.usePlugin)(c.default),r=F(i().useState("permissions"),2),s=r[0],m=r[1],y=Array.from(t.rolesManager.list()).map(function(t){var r=F(t,2),o=r[0],l=r[1];return{key:o,label:n.Schema.compile(l.title,{t:e}),children:l.Component?i().createElement(l.Component,{active:s===o}):null}}),d=F((0,a.useState)(null),2),b=d[0],v=d[1],h=(0,o.useSchemaComponentContext)(),g=(0,a.useMemo)(function(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},h),t=t={designable:!1},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e},[h]);return i().createElement(o.SchemaComponentContext.Provider,{value:g},i().createElement(p.s.Provider,{value:{role:b,setRole:v}},i().createElement(l.Card,null,i().createElement(l.Row,{gutter:24,style:{flexWrap:"nowrap"}},i().createElement(l.Col,{flex:"280px",style:{borderRight:"1px solid #eee",minWidth:"350px"}},i().createElement(o.ResourceActionProvider,{collection:_,request:{resource:"roles",action:"list",params:{filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}}},i().createElement(o.CollectionProvider_deprecated,{collection:_},i().createElement(l.Row,{justify:"space-between",align:"middle",style:{width:"100%"}},i().createElement(f,null),i().createElement(T,null)),i().createElement(l.Divider,{style:{margin:"12px 0"}}),i().createElement(j,null)))),i().createElement(l.Col,{flex:"auto",style:{overflow:"hidden"}},i().createElement(l.Tabs,{activeKey:s,onChange:function(e){return m(e)},items:[{key:"permissions",label:e("Permissions"),children:i().createElement(R,{active:"permissions"===s})}].concat(function(e){if(Array.isArray(e))return M(e)}(y)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(y)||U(y)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}))))))}},79:function(e,t,r){r.d(t,{P:function(){return o}});var n=r(953);function o(){return(0,n.useTranslation)(["@nocobase/plugin-acl","client"],{nsMode:"fallback"})}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).push([["971"],{486:function(e,t,n){n.r(t),n.d(t,{GeneralPermissions:function(){return _}});var r=n(452),o=n(230),a=n(166),l=n(342),i=n(625),u=n(59),c=n(773),s=n.n(c),f=n(155),p=n.n(f),m=n(953),y=n(79),d=n(268),b=n(143);function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){h(a,r,o,l,i,"next",e)}function i(e){h(a,r,o,l,i,"throw",e)}l(void 0)})}}function w(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return v(e,t)}}function S(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:u(0)}),i(l,"throw",{value:u(1)}),i(l,"return",{value:u(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=!0,r=!1,o=void 0;try{for(var a,l=e[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){var i=a.value;t.push(i.aclSnippet),i.children&&i.children.length&&O(i.children,t)}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t},x=function(e){var t,n=e.active,r=(0,l.useApp)(),o=(0,b.I)().styles,a=(0,f.useContext)(d.s).role,i=(0,l.useAPIClient)(),y=(0,l.useCompile)(),h=r.pluginSettingsManager.getList(!1),x=r.pluginSettingsManager.getAclSnippets(),A=function(e){if(Array.isArray(e))return e}(t=(0,f.useState)((null==a?void 0:a.snippets)||[]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){l=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw n}}return o}}(t)||w(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),j=A[0],k=A[1],P=(0,f.useMemo)(function(){return(0,c.flatMap)(h,function(e){var t;return e.children?[e].concat(function(e){if(Array.isArray(e))return v(e)}(t=e.children)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||w(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):e})},[h]),C=(0,f.useMemo)(function(){return j.includes("pm.*")&&j.every(function(e){return!e.startsWith("!pm.")})},[j]),E=(0,m.useTranslation)().t,I=(0,l.useRequest)({resource:"roles.snippets",resourceOf:null==a?void 0:a.name,action:"list",params:{paginate:!1}},{ready:!!a&&n,refreshDeps:[null==a?void 0:a.name],manual:!0,onSuccess:function(e){k((null==e?void 0:e.data.filter(function(e){return P.find(function(t){return e.includes("!".concat(t.aclSnippet))||!e.startsWith("!pm.")})}))||[])}}),T=I.loading,M=I.refresh;if(a){var F=i.resource("roles.snippets",null==a?void 0:a.name);return p().createElement(u.Table,{className:o,loading:T,rowKey:"key",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:E("Plugin name"),render:function(e){return y(e)}},{dataIndex:"accessible",title:p().createElement(p().Fragment,null,p().createElement(u.Checkbox,{checked:C,onChange:function(){return g(function(){var e;return S(this,function(t){switch(t.label){case 0:if(e=x.map(function(e){return"!"+e}),C)return[3,2];return[4,F.remove({values:e})];case 1:return t.sent(),[3,4];case 2:return[4,F.add({values:e})];case 3:t.sent(),t.label=4;case 4:return M(),u.message.success(E("Saved successfully")),[2]}})})()}}),E("Accessible")),render:function(e,t){var n=!j.includes("!"+t.aclSnippet);return p().createElement(u.Checkbox,{checked:n,onChange:function(){return g(function(){var e;return S(this,function(r){switch(r.label){case 0:if(e=O(null==t?void 0:t.children,[]).concat(t.aclSnippet),n)return[3,2];return[4,F.remove({values:e.map(function(e){return"!"+e})})];case 1:return r.sent(),M(),[3,4];case 2:return[4,F.add({values:e.map(function(e){return"!"+e})})];case 3:r.sent(),M(),r.label=4;case 4:return u.message.success(E("Saved successfully")),[2]}})})()}})}}],dataSource:h.filter(function(e){return!1!==e.isTopLevel}).map(function(e){return!1!==e.showTabs?e:s().omit(e,"children")})})}},A=n(570);function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=function(e){if(!e)return{};var t,n={};return null==e||null==(t=e.forEach)||t.call(e,function(e){var t,r=function(e){if(Array.isArray(e))return e}(t=e.split(":"))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){l=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return j(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return j(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],a=r[1];n[o]=a||"all"}),n},P=function(e){var t=[];for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];"all"===r?t.push(n):t.push("".concat(n,":").concat(r))}return t},C=(0,o.connect)(function(e){var t=e.onChange,n=(0,A.K)(),r=(0,l.useCompile)(),a=(0,m.useTranslation)().t,i=k((0,o.useField)().value);return p().createElement("div",null,p().createElement(u.Table,{rowKey:"name",size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:a("Action display name"),render:function(e){return r(e)}},{dataIndex:"onNewRecord",title:a("Action type"),render:function(e){return e?p().createElement(u.Tag,{color:"green"},a("Action on new records")):p().createElement(u.Tag,{color:"geekblue"},a("Action on existing records"))}},{dataIndex:"enabled",title:a("Allow"),render:function(e,n){return p().createElement(u.Checkbox,{checked:e,"aria-label":"".concat(n.name,"_checkbox"),onChange:function(r){e?delete i[n.name]:i[n.name]="all",t(P(i))}})}},{dataIndex:"scope",title:a("Data scope"),render:function(e,n){return!n.onNewRecord&&p().createElement(u.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:e,options:[{label:a("All records"),value:"all"},{label:a("Own records"),value:"own"}],onChange:function(e){i[n.name]=e,t(P(i))}})}}],dataSource:null==n?void 0:n.map(function(e){var t,n,r="all",o=!1;return i[e.name]&&(o=!0,r=i[e.name]),t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),n=n={enabled:o,scope:r},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t})}))});function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function T(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){I(a,r,o,l,i,"next",e)}function i(e){I(a,r,o,l,i,"throw",e)}l(void 0)})}}function M(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return E(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:u(0)}),i(l,"throw",{value:u(1)}),i(l,"return",{value:u(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var D=(0,o.connect)(function(e){var t=(0,m.useTranslation)().t;return p().createElement(u.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:function(t){var n=["ui.*","pm","pm.*","app"],r=n.map(function(e){return"!".concat(e)}),o=(0,c.uniq)(M(e.value||[]).concat(M(t))).filter(function(e){return e&&!r.includes(e)}).map(function(e){return!n.includes(e)||(null==t?void 0:t.includes(e))?e:"!".concat(e)}),a=!0,l=!1,i=void 0;try{for(var u,s=n[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;o.includes(f)||o.includes("!".concat(f))||o.push("!".concat(f))}}catch(e){l=!0,i=e}finally{try{a||null==s.return||s.return()}finally{if(l)throw i}}e.onChange(o)}},p().createElement("div",{style:{marginTop:16}},p().createElement(u.Checkbox,{value:"ui.*"},t("Allows to configure interface"))),p().createElement("div",{style:{marginTop:8}},p().createElement(u.Checkbox,{value:"pm"},t("Allows to install, activate, disable plugins"))),p().createElement("div",{style:{marginTop:8}},p().createElement(u.Checkbox,{value:"pm.*"},t("Allows to configure plugins"))),p().createElement("div",{style:{marginTop:8}},p().createElement(u.Checkbox,{value:"app"},t("Allows to clear cache, reboot application"))))}),_=function(){var e,t=(0,f.useContext)(d.s),n=t.role,o=t.setRole,c=(0,y.P)().t,s=(0,l.useAPIClient)(),m=null==n||null==(e=n.snippets)?void 0:e.includes("pm.*"),b=(0,i.useMemoizedFn)(function(e){return T(function(){return F(this,function(t){switch(t.label){case 0:return[4,s.resource("roles").update({filterByTk:n.name,values:{snippets:e.values.snippets}})];case 1:return t.sent(),o(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},n,e.values)),u.message.success(c("Saved successfully")),[2]}})})()}),v=(0,f.useMemo)(function(){return(0,r.createForm)({values:n,effects:function(){(0,r.onFormValuesChange)(function(e){return T(function(){return F(this,function(t){switch(t.label){case 0:return[4,b(e)];case 1:return t.sent(),[2]}})})()})}})},[n,b]);return p().createElement(l.SchemaComponent,{components:{SnippetCheckboxGroup:D,StrategyActions:C,PluginPermissions:x},scope:{pm:m},schema:{type:"void",name:(0,a.uid)(),"x-component":"div",properties:{general:{"x-component":"FormV2","x-component-props":{form:v},properties:{snippets:{title:c("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"}}},plugins:{"x-component":"FormV2",properties:{pluginSettings:{title:c("Plugin settings"),"x-decorator":"FormItem","x-component":"PluginPermissions","x-visible":"{{pm}}"}}}}}})}},79:function(e,t,n){n.d(t,{P:function(){return o}});var r=n(953);function o(){return(0,r.useTranslation)(["@nocobase/plugin-acl","client"],{nsMode:"fallback"})}}}]);
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("lodash"),require("ahooks"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/utils/client"),require("antd-style"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["@formily/core","@formily/antd-v5","react","lodash","ahooks","@formily/shared","@nocobase/client","@formily/react","@ant-design/icons","@nocobase/utils/client","antd-style","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("lodash"),require("ahooks"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/utils/client"),require("antd-style"),require("antd"),require("react-i18next")):e["@nocobase/plugin-acl"]=t(e["@formily/core"],e["@formily/antd-v5"],e.react,e.lodash,e.ahooks,e["@formily/shared"],e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/utils/client"],e["antd-style"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,a,c,u,l,s,p,f){return function(){var d,m,y,b,v,h,g={400:function(e,t,n){"use strict";n.d(t,{T:function(){return r}});var r=(0,n(156).createContext)({role:null});r.displayName="RolesManagerContext"},898:function(e,t,n){"use strict";n.d(t,{U:function(){return u},r:function(){return l}});var r=n(772),o=n(721),i=n(156),a=n.n(i),c=(0,i.createContext)([]);c.displayName="AvailableActionsContext";var u=function(e){var t=(0,r.useRequest)({resource:"availableActions",action:"list"}),n=t.data;return t.loading?a().createElement(o.Spin,null):a().createElement(c.Provider,{value:null==n?void 0:n.data},e.children)},l=function(){return(0,i.useContext)(c)}},720:function(e,t,n){"use strict";n.r(t),n.d(t,{DesktopAllRoutesProvider:function(){return A},MenuPermissions:function(){return E}});var r=n(563),o=n(875),i=n(772),a=n(749),c=n(721),u=n(467),l=n(156),s=n.n(l),p=n(238),f=n(400);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){m(i,r,o,a,c,"next",e)}function c(e){m(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}function x(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function w(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return n},n}var S=function(e,t){return Array.isArray(e)?e.map(function(e){var n,r=S(e.children,e),o=0===r.length;return{title:e.title,id:e.id,children:o?null:r,hideChildren:o,firstTabId:null==(n=r[0])?void 0:n.id,parent:t}}):[]},O=function(e){if(!Array.isArray(e))return[];var t=[],n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t.push(c.id),t.push.apply(t,h(O(c.children)))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t},C=(0,i.css)(w()),P=function(e,t,n){return e.map(function(e){var r,o=((null==(r=e.title)?void 0:r.match(/^\s*\{\{\s*.+?\s*\}\}\s*$/))?n(e.title):t(e.title))||t("Unnamed");return e.children?v(b({},e),{title:o,children:P(e.children,t,n)}):v(b({},e),{title:o})})},k=(0,l.createContext)({routeList:[]}),j=function(e){var t=e.children,n=e.refreshRef,r=(0,i.useAPIClient)(),o=(0,l.useMemo)(function(){return r.resource("desktopRoutes")},[r]),a=(0,i.useRequest)(function(){return o.list({tree:!0,sort:"sort",paginate:!1,filter:{hidden:{$ne:!0}}}).then(function(e){return e.data})},{manual:!0}),c=a.data,u=a.runAsync;n&&(n.current=u);var p=(0,l.useMemo)(function(){return(null==c?void 0:c.data)||[]},[c]),f=(0,l.useMemo)(function(){return{routeList:p}},[p]);return s().createElement(k.Provider,{value:f},t)},A=function(e){var t=e.children,n=e.active,r=s().useRef(function(){});return(0,l.useEffect)(function(){if(n){var e;null==(e=r.current)||e.call(r)}},[n]),s().createElement(j,{refreshRef:r},t)},E=function(e){var t,n,d,m,v=e.active,w=S((0,l.useContext)(k).routeList),j=(0,l.useContext)(f.T),A=j.role,E=j.setRole,R=(0,i.useAPIClient)(),T=(0,p.useTranslation)().t,_=O(w),F=(t=(0,l.useState)([]),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(c)throw r}}return i}}(t,2)||g(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),I=F[0],q=F[1],M=(0,i.useRequest)({resource:"roles.desktopRoutes",resourceOf:A.name,action:"list",params:{paginate:!1,filter:{hidden:{$ne:!0}}}},{ready:!!A&&v,refreshDeps:[null==A?void 0:A.name],onSuccess:function(e){var t;q((null==e||null==(t=e.data)?void 0:t.map(function(e){return e.id}))||[])}}),N=M.loading,D=M.refresh,B=R.resource("roles.desktopRoutes",A.name),z=_.length===I.length,L=(0,i.useAllAccessDesktopRoutes)().refresh,V=(n=y(function(e,t){var n,r,o,i,a,l,s,p;return x(this,function(f){switch(f.label){case 0:if(!e)return[3,2];return n=I.filter(function(e){return e!==t.id}),r=[t.id],t.parent&&0===t.parent.children.filter(function(e){return n.includes(e.id)}).length&&(n=n.filter(function(e){return e!==t.parent.id}),r.push(t.parent.id)),t.children&&(n=n.filter(function(e){return!O(t.children).includes(e)}),(o=r).push.apply(o,h(O(t.children)))),q(n),[4,B.remove({values:r})];case 1:return f.sent(),[3,4];case 2:return i=h(I).concat([t.id]),a=[t.id],t.parent&&!i.includes(t.parent.id)&&(i.push(t.parent.id),a.push(t.parent.id)),t.children&&(p=O(t.children),(l=i).push.apply(l,h(p)),(s=a).push.apply(s,h(p))),q((0,u.uniq)(i)),[4,B.add({values:a})];case 3:f.sent(),f.label=4;case 4:return L(),c.message.success(T("Saved successfully")),[2]}})}),function(e,t){return n.apply(this,arguments)}),U=(0,a.useMemoizedFn)((d=y(function(e){return x(this,function(t){switch(t.label){case 0:return[4,R.resource("roles").update({filterByTk:A.name,values:e.values})];case 1:return t.sent(),E(b({},A,e.values)),c.message.success(T("Saved successfully")),[2]}})}),function(e){return d.apply(this,arguments)})),K=(0,l.useMemo)(function(){return(0,r.createForm)({values:A,effects:function(){var e;(0,r.onFormValuesChange)((e=y(function(e){return x(this,function(t){switch(t.label){case 0:return[4,U(e)];case 1:return t.sent(),[2]}})}),function(t){return e.apply(this,arguments)}))}})},[A,U]),$=(0,i.useCompile)();return s().createElement(s().Fragment,null,s().createElement(i.SchemaComponent,{schema:{type:"void",name:(0,o.uid)(),"x-component":"FormV2","x-component-props":{form:K},properties:{allowNewMenu:{title:T("Route permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":T("New routes are allowed to be accessed by default")}}}}),s().createElement(c.Table,{className:C,loading:N,rowKey:"id",pagination:!1,expandable:{defaultExpandAllRows:!1},columns:[{dataIndex:"title",title:T("Route name")},{dataIndex:"accessible",title:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{checked:z,onChange:(m=y(function(e){return x(this,function(e){switch(e.label){case 0:if(!z)return[3,2];return[4,B.set({values:[]})];case 1:return e.sent(),[3,4];case 2:return[4,B.set({values:_})];case 3:e.sent(),e.label=4;case 4:return D(),L(),c.message.success(T("Saved successfully")),[2]}})}),function(e){return m.apply(this,arguments)})})," ",T("Accessible")),render:function(e,t){var n=I.includes(t.id);return s().createElement(c.Checkbox,{checked:n,onChange:function(){return V(n,t)}})}}],dataSource:P(w,T,$)}))}},77:function(e,t,n){"use strict";n.r(t),n.d(t,{PluginACLClient:function(){return $},RolesManagerContext:function(){return q.T},default:function(){return G},RoleResourceCollectionContext:function(){return I}});var r=n(772),o=n(156),i=n.n(o),a=n(720),c=n(581),u=(0,r.lazy)(function(){return c("imported_-1r1jup3_component",n.e("86").then(n.bind(n,229)))},"GeneralPermissions").GeneralPermissions,l=(0,r.lazy)(function(){return c("imported_1qalbop_component",Promise.resolve().then(n.bind(n,720)))},"MenuPermissions").MenuPermissions,s=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="permissionsTabs",n=[function(e){var t=e.t,n=e.TabLayout;return{key:"general",label:t("System"),sort:10,children:i().createElement(n,null,i().createElement(u,null))}},function(e){var t=e.activeKey,n=e.t,r=e.TabLayout;return{key:"menu",label:n("Desktop routes"),sort:20,children:i().createElement(r,null,i().createElement(a.DesktopAllRoutesProvider,{active:"menu"===t},i().createElement(l,{active:"menu"===t})))}}],e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"addPermissionsTab",value:function(e){this.permissionsTabs.push(e)}},{key:"getPermissionsTabs",value:function(e){return this.permissionsTabs.map(function(t){return"function"==typeof t?t(e):t}).sort(function(e,t){var n,r;return(null!=(n=null==e?void 0:e.sort)?n:100)-(null!=(r=null==t?void 0:t.sort)?r:100)})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),p=n(584),f=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="rolesManager",n=new p.Registry,e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"add",value:function(e,t){this.rolesManager.register(e,t)}},{key:"list",value:function(){return this.rolesManager.getEntities()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),d=n(238),m=n(721),y=n(467),b=n.n(y);function v(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var h=function(){var e,t,n,o=(0,d.useTranslation)().t,a=(0,r.useAPIClient)(),c=b().cloneDeep((0,r.useCurrentRoles)()),u=(0,r.useCurrentRoleMode)(),l=null==(n=c.find(function(e){return e.name===a.auth.role}))?void 0:n.name;return("allow-use-union"===u&&c.unshift({name:"__union__",title:o("Full permissions",{ns:"acl"})}),c.length<=1||"only-use-union"===u)?null:i().createElement(r.SchemaSettingsItem,{eventKey:"SwitchRole",title:"SwitchRole"},i().createElement(r.SelectWithTitle,{title:o("Switch role"),fieldNames:{label:"title",value:"name"},options:c.reduce(function(e,t){return e.push(t),"__union__"===t.name&&e.push({name:"divider",title:i().createElement(m.Divider,{style:{margin:"2px 1px"}}),disabled:!0,style:{minHeight:0,height:"auto",padding:0}}),e},[]),defaultValue:l||c[0].name,onChange:(e=function(e){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return a.auth.setRole(e),[4,a.resource("users").setDefaultRole({values:{roleName:e}})];case 1:return t.sent(),location.reload(),window.location.reload(),[2]}})},t=function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){v(i,r,o,a,c,"next",e)}function c(e){v(i,r,o,a,c,"throw",e)}a(void 0)})},function(e){return t.apply(this,arguments)})}))},g=n(632),x=n(505),w=n(898),S=n(563),O={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},C={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:O,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams:function(){return{filter:{$or:[{resourceName:(0,o.useContext)(I).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":function(){var e=(0,o.useContext)(I).name,t=(0,r.useFormBlockContext)();return(0,o.useEffect)(function(){t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(I);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(I);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var k=(0,o.createContext)(null);k.displayName="RolesResourcesScopesSelectedRowKeysContext";var j=function(e){var t,n=(t=(0,o.useState)([]),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(c)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return P(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return P(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=n[0],a=n[1];return i().createElement(k.Provider,{value:[r,a]},e.children)},A=function(e){var t=(0,o.useMemo)(function(){return(0,S.createForm)({values:{scope:e.value}})},[]);return i().createElement(r.FormProvider,{form:t},i().createElement(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:j},scope:{onChange:function(t){var n;null==e||null==(n=e.onChange)||n.call(e,t)}},schema:C}))},E=n(438);function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var F=function(e){var t,n={};return null==e||null==(t=e.forEach)||t.call(e,function(e){e.name&&(n[e.name]=e,n[e.name].scope=(0,y.isEmpty)(e.scope)?null:e.scope)}),n},I=(0,o.createContext)({});I.displayName="RoleResourceCollectionContext",(0,x.connect)(function(e){var t,n=(0,E.y)().styles,o=function(t){var n=t.map(function(e){return _(T({},e),{scope:(0,y.isEmpty)(e.scope)?null:e.scope})});e.onChange(n)};(0,x.useForm)();var a=(0,r.useRecord)(),c=(0,w.r)(),u=(0,r.useCollectionManager_deprecated)(),l=u.getCollection,s=u.getCollectionFields,p=l(a.collectionName),f=s(a.collectionName),b=(0,r.useCompile)(),v=(0,d.useTranslation)().t,h=F((0,x.useField)().value||[]),S=function(e,t){var n,r=null==h?void 0:h[e];return!!r&&(null==r||null==(n=r.fields)?void 0:n.includes(t))},O=c.filter(function(e){return e.allowConfigureFields}),C=null==f||null==(D=f.filter(function(e){return e.interface}))?void 0:D.map(function(e){var t=T({},e),n=!0,r=!1,o=void 0;try{for(var i,a=O[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t[c.name]=S(c.name,e.name)}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t}),P=function(e){if(h[e])delete h[e];else{var t,n;h[e]={name:e,fields:null==f||null==(n=f.filter(function(e){return e.interface}))||null==(t=n.map)?void 0:t.call(n,function(e){return e.name})}}o(Object.values(h))},k=function(e,t){h[e]?(h[e].scope=t,o(Object.values(h))):(P(e),h[e].scope=t)},j={},q=!0,M=!1,N=void 0;try{for(var D,B,z=O[Symbol.iterator]();!(q=(B=z.next()).done);q=!0){var L,V,U,K=B.value;j[K.name]=(null==f||null==(L=f.filter(function(e){return e.interface}))?void 0:L.length)===(null==h||null==(U=h[K.name])||null==(V=U.fields)?void 0:V.length)}}catch(e){M=!0,N=e}finally{try{q||null==z.return||z.return()}finally{if(M)throw N}}return i().createElement("div",null,i().createElement(I.Provider,{value:p},i().createElement(g.FormLayout,{layout:"vertical"},i().createElement(g.FormItem,{label:v("Action permission")},i().createElement(m.Table,{className:n,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:v("Action display name"),render:function(e){return b(e)}},{dataIndex:"onNewRecord",title:v("Action type"),render:function(e){return e?i().createElement(m.Tag,{color:"green"},v("Action on new records")):i().createElement(m.Tag,{color:"geekblue"},v("Action on existing records"))}},{dataIndex:"enabled",title:v("Allow"),render:function(e,t){return i().createElement(m.Checkbox,{checked:e,onChange:function(){P(t.name)}})}},{dataIndex:"scope",title:v("Data scope"),render:function(e,t){return!t.onNewRecord&&i().createElement(A,{value:e,onChange:function(e){k(t.name,e)}})}}],dataSource:null==c?void 0:c.map(function(e){var t=!1,n=null;return h[e.name]&&(t=!0,e.onNewRecord||(n=h[e.name].scope)),_(T({},e),{enabled:t,scope:n})})})),i().createElement(g.FormItem,{label:v("Field permission")},i().createElement(m.Table,{className:n,pagination:!1,dataSource:C,columns:[{dataIndex:["uiSchema","title"],title:v("Field display name"),render:function(e){return b(e)}}].concat(function(e){if(Array.isArray(e))return R(e)}(t=O.map(function(e){var t=null==j?void 0:j[e.name];return{dataIndex:e.name,title:i().createElement(i().Fragment,null,i().createElement(m.Checkbox,{checked:t,onChange:function(){var n,r=h[e.name]||{name:e.name};t?r.fields=[]:r.fields=null==f||null==(n=f.map)?void 0:n.call(f,function(e){return e.name}),h[e.name]=r,o(Object.values(h))}})," ",b(e.displayName)),render:function(t,n){return i().createElement(m.Checkbox,{checked:t,"aria-label":"".concat(e.name,"_checkbox"),onChange:function(){var r=h[e.name]||{name:e.name},i=r.fields||[];if(t){var a=i.indexOf(n.name);i.splice(a,1)}else i.push(n.name);r.fields=i,h[e.name]=r,o(Object.values(h))}})}}}))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return R(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return R(e,t)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})))))});var q=n(400),M=n(581);function N(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function D(e,t,n){return(D=U()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&L(o,n.prototype),o}).apply(null,arguments)}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function V(e){var t="function"==typeof Map?new Map:void 0;return(V=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,z(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)})(e)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}var K=(0,r.lazy)(function(){return M("imported_-1obaqk_component",n.e("646").then(n.bind(n,176)))},"RolesManagement").RolesManagement,$=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=z(t),B(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,U()?Reflect.construct(t,r||[],z(this).constructor):t.apply(this,r)),"rolesManager",new f),B(e,"settingsUI",new s),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&L(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return t.pluginSettingsManager.add("users-permissions.roles",{title:t.t("Roles & Permissions"),icon:"LockOutlined",Component:K,aclSnippet:"pm.acl.roles",sort:3}),t.app.addUserCenterSettingsItem({name:"divider_switchRole",type:"divider",sort:200}),t.app.addUserCenterSettingsItem({name:"switchRole",Component:h,sort:300}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){N(i,r,o,a,c,"next",e)}function c(e){N(i,r,o,a,c,"throw",e)}a(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(V(r.Plugin)),G=$},438:function(e,t,n){"use strict";function r(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return r=function(){return n},n}n.d(t,{y:function(){return o}});var o=(0,n(202).createStyles)(function(e){return(0,e.css)(r())})},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=u},632:function(e){"use strict";e.exports=t},563:function(t){"use strict";t.exports=e},505:function(e){"use strict";e.exports=c},875:function(e){"use strict";e.exports=i},772:function(e){"use strict";e.exports=a},584:function(e){"use strict";e.exports=l},749:function(e){"use strict";e.exports=o},721:function(e){"use strict";e.exports=p},202:function(e){"use strict";e.exports=s},467:function(e){"use strict";e.exports=r},156:function(e){"use strict";e.exports=n},238:function(e){"use strict";e.exports=f}},x={};function w(e){var t=x[e];if(void 0!==t)return t.exports;var n=x[e]={exports:{}};return g[e](n,n.exports,w),n.exports}return w.m=g,w.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return w.d(t,{a:t}),t},w.d=function(e,t){for(var n in t)w.o(t,n)&&!w.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},w.f={},w.e=function(e){return Promise.all(Object.keys(w.f).reduce(function(t,n){return w.f[n](e,t),t},[]))},w.u=function(e){return""+({646:"0655d5ded9f45bb1",86:"50204a14518b3a0d"})[e]+".js"},w.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),w.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d={},m="@nocobase/plugin-acl:",w.l=function(e,t,n,r){if(d[e])return void d[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var u=a[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==m+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,w.nc&&o.setAttribute("nonce",w.nc),o.setAttribute("data-webpack",m+n),o.src=e),d[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=d[e];if(delete d[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},w.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(y=window.__webpack_public_path__||"/").endsWith("/")||(y+="/"),w.p=y+"static/plugins/@nocobase/plugin-acl/dist/client/",b={909:0},w.f.j=function(e,t){var n=w.o(b,e)?b[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=b[e]=[t,r]});t.push(n[2]=r);var o=w.p+w.u(e),i=Error();w.l(o,function(t){if(w.o(b,e)&&(0!==(n=b[e])&&(b[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},v=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==b[e]})){for(n in i)w.o(i,n)&&(w.m[n]=i[n]);a&&a(w)}for(e&&e(t);c<o.length;c++)r=o[c],w.o(b,r)&&b[r]&&b[r][0](),b[r]=0},(h=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(v.bind(null,0)),h.push=v.bind(null,h.push.bind(h)),w(77)}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl",["react-i18next","@formily/antd-v5","@formily/react","@ant-design/icons","ahooks","@formily/core","@formily/shared","react","antd","@nocobase/client","antd-style","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-acl"]=t(require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("@ant-design/icons"),require("ahooks"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-acl"]=t(e["react-i18next"],e["@formily/antd-v5"],e["@formily/react"],e["@ant-design/icons"],e.ahooks,e["@formily/core"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["antd-style"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,c,l,u,s,p,f){return function(){"use strict";var m,d,y,b={268:function(e,t,n){n.d(t,{s:function(){return r}});var r=(0,n(155).createContext)({role:null});r.displayName="RolesManagerContext"},570:function(e,t,n){n.d(t,{K:function(){return u},c:function(){return l}});var r=n(342),o=n(59),i=n(155),a=n.n(i),c=(0,i.createContext)([]);c.displayName="AvailableActionsContext";var l=function(e){var t=(0,r.useRequest)({resource:"availableActions",action:"list"}),n=t.data;return t.loading?a().createElement(o.Spin,null):a().createElement(c.Provider,{value:null==n?void 0:n.data},e.children)},u=function(){return(0,i.useContext)(c)}},365:function(e,t,n){n.r(t),n.d(t,{DesktopAllRoutesProvider:function(){return A},MenuPermissions:function(){return E}});var r=n(452),o=n(166),i=n(342),a=n(625),c=n(59),l=n(773),u=n(155),s=n.n(u),p=n(953),f=n(268);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){d(i,r,o,a,c,"next",e)}function c(e){d(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}function x(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function w(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return n},n}var O=function(e,t){return Array.isArray(e)?e.map(function(e){var n,r=O(e.children,e),o=0===r.length;return{title:e.title,id:e.id,children:o?null:r,hideChildren:o,firstTabId:null==(n=r[0])?void 0:n.id,parent:t}}):[]},S=function(e){if(!Array.isArray(e))return[];var t=[],n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t.push(c.id),t.push.apply(t,h(S(c.children)))}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t},P=(0,i.css)(w()),C=function(e,t,n){return e.map(function(e){var r,o=((null==(r=e.title)?void 0:r.match(/^\s*\{\{\s*.+?\s*\}\}\s*$/))?n(e.title):t(e.title))||t("Unnamed");return e.children?v(b({},e),{title:o,children:C(e.children,t,n)}):v(b({},e),{title:o})})},j=(0,u.createContext)({routeList:[]}),k=function(e){var t=e.children,n=e.refreshRef,r=(0,i.useAPIClient)(),o=(0,u.useMemo)(function(){return r.resource("desktopRoutes")},[r]),a=(0,i.useRequest)(function(){return o.list({tree:!0,sort:"sort",paginate:!1,filter:{hidden:{$ne:!0}}}).then(function(e){return e.data})},{manual:!0}),c=a.data,l=a.runAsync;n&&(n.current=l);var p=(0,u.useMemo)(function(){return(null==c?void 0:c.data)||[]},[c]),f=(0,u.useMemo)(function(){return{routeList:p}},[p]);return s().createElement(j.Provider,{value:f},t)},A=function(e){var t=e.children,n=e.active,r=s().useRef(function(){});return(0,u.useEffect)(function(){if(n){var e;null==(e=r.current)||e.call(r)}},[n]),s().createElement(k,{refreshRef:r},t)},E=function(e){var t,n=e.active,m=O((0,u.useContext)(j).routeList),d=(0,u.useContext)(f.s),v=d.role,w=d.setRole,k=(0,i.useAPIClient)(),A=(0,p.useTranslation)().t,E=S(m),R=function(e){if(Array.isArray(e))return e}(t=(0,u.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||g(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),I=R[0],T=R[1],_=(0,i.useRequest)({resource:"roles.desktopRoutes",resourceOf:v.name,action:"list",params:{paginate:!1,filter:{hidden:{$ne:!0}}}},{ready:!!v&&n,refreshDeps:[null==v?void 0:v.name],onSuccess:function(e){var t;T((null==e||null==(t=e.data)?void 0:t.map(function(e){return e.id}))||[])}}),F=_.loading,q=_.refresh,M=k.resource("roles.desktopRoutes",v.name),N=E.length===I.length,D=(0,i.useAllAccessDesktopRoutes)().refresh,B=(0,a.useMemoizedFn)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,k.resource("roles").update({filterByTk:v.name,values:e.values})];case 1:return t.sent(),w(b({},v,e.values)),c.message.success(A("Saved successfully")),[2]}})})()}),$=(0,u.useMemo)(function(){return(0,r.createForm)({values:v,effects:function(){(0,r.onFormValuesChange)(function(e){return y(function(){return x(this,function(t){switch(t.label){case 0:return[4,B(e)];case 1:return t.sent(),[2]}})})()})}})},[v,B]),L=(0,i.useCompile)();return s().createElement(s().Fragment,null,s().createElement(i.SchemaComponent,{schema:{type:"void",name:(0,o.uid)(),"x-component":"FormV2","x-component-props":{form:$},properties:{allowNewMenu:{title:A("Route permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":A("New routes are allowed to be accessed by default")}}}}),s().createElement(c.Table,{className:P,loading:F,rowKey:"id",pagination:!1,expandable:{defaultExpandAllRows:!1},columns:[{dataIndex:"title",title:A("Route name")},{dataIndex:"accessible",title:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{checked:N,onChange:function(e){return y(function(){return x(this,function(e){switch(e.label){case 0:if(!N)return[3,2];return[4,M.set({values:[]})];case 1:return e.sent(),[3,4];case 2:return[4,M.set({values:E})];case 3:e.sent(),e.label=4;case 4:return q(),D(),c.message.success(A("Saved successfully")),[2]}})})()}})," ",A("Accessible")),render:function(e,t){var n=I.includes(t.id);return s().createElement(c.Checkbox,{checked:n,onChange:function(){return y(function(){var e,r,o,i,a,u,s,p;return x(this,function(f){switch(f.label){case 0:if(!n)return[3,2];return e=I.filter(function(e){return e!==t.id}),r=[t.id],t.parent&&0===t.parent.children.filter(function(t){return e.includes(t.id)}).length&&(e=e.filter(function(e){return e!==t.parent.id}),r.push(t.parent.id)),t.children&&(e=e.filter(function(e){return!S(t.children).includes(e)}),(o=r).push.apply(o,h(S(t.children)))),T(e),[4,M.remove({values:r})];case 1:return f.sent(),[3,4];case 2:return i=h(I).concat([t.id]),a=[t.id],t.parent&&!i.includes(t.parent.id)&&(i.push(t.parent.id),a.push(t.parent.id)),t.children&&(p=S(t.children),(u=i).push.apply(u,h(p)),(s=a).push.apply(s,h(p))),T((0,l.uniq)(i)),[4,M.add({values:a})];case 3:f.sent(),f.label=4;case 4:return D(),c.message.success(A("Saved successfully")),[2]}})})()}})}}],dataSource:C(m,A,L)}))}},747:function(e,t,n){n.r(t),n.d(t,{PluginACLClient:function(){return V},default:function(){return K},RoleResourceCollectionContext:function(){return _},RolesManagerContext:function(){return F.s}});var r=n(342),o=n(155),i=n.n(o),a=n(365),c=(0,r.lazy)(function(){return n.e("971").then(n.bind(n,486))},"GeneralPermissions").GeneralPermissions,l=(0,r.lazy)(function(){return Promise.resolve().then(n.bind(n,365))},"MenuPermissions").MenuPermissions,u=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="permissionsTabs",n=[function(e){var t=e.t,n=e.TabLayout;return{key:"general",label:t("System"),sort:10,children:i().createElement(n,null,i().createElement(c,null))}},function(e){var t=e.activeKey,n=e.t,r=e.TabLayout;return{key:"menu",label:n("Desktop routes"),sort:20,children:i().createElement(r,null,i().createElement(a.DesktopAllRoutesProvider,{active:"menu"===t},i().createElement(l,{active:"menu"===t})))}}],e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"addPermissionsTab",value:function(e){this.permissionsTabs.push(e)}},{key:"getPermissionsTabs",value:function(e){return this.permissionsTabs.map(function(t){return"function"==typeof t?t(e):t}).sort(function(e,t){var n,r;return(null!=(n=null==e?void 0:e.sort)?n:100)-(null!=(r=null==t?void 0:t.sort)?r:100)})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),s=n(768),p=function(){var e;function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="rolesManager",n=new s.Registry,e in this?Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[e]=n}return e=[{key:"add",value:function(e,t){this.rolesManager.register(e,t)}},{key:"list",value:function(){return this.rolesManager.getEntities()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}(),f=n(953),m=n(59),d=n(773),y=n.n(d);function b(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}var v=function(){var e,t=(0,f.useTranslation)().t,n=(0,r.useAPIClient)(),o=y().cloneDeep((0,r.useCurrentRoles)()),a=(0,r.useCurrentRoleMode)(),c=null==(e=o.find(function(e){return e.name===n.auth.role}))?void 0:e.name;return("allow-use-union"===a&&o.unshift({name:"__union__",title:t("Full permissions",{ns:"acl"})}),o.length<=1||"only-use-union"===a)?null:i().createElement(r.SchemaSettingsItem,{eventKey:"SwitchRole",title:"SwitchRole"},i().createElement(r.SelectWithTitle,{title:t("Switch role"),fieldNames:{label:"title",value:"name"},options:o.reduce(function(e,t){return e.push(t),"__union__"===t.name&&e.push({name:"divider",title:i().createElement(m.Divider,{style:{margin:"2px 1px"}}),disabled:!0,style:{minHeight:0,height:"auto",padding:0}}),e},[]),defaultValue:c||o[0].name,onChange:function(e){var t;return(t=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return n.auth.setRole(e),[4,n.resource("users").setDefaultRole({values:{roleName:e}})];case 1:return t.sent(),location.reload(),window.location.reload(),[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){b(i,r,o,a,c,"next",e)}function c(e){b(i,r,o,a,c,"throw",e)}a(void 0)})})()}}))},h=n(418),g=n(230),x=n(570),w=n(452),O={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},S={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:O,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams:function(){return{filter:{$or:[{resourceName:(0,o.useContext)(_).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":function(){var e=(0,o.useContext)(_).name,t=(0,r.useFormBlockContext)();return(0,o.useEffect)(function(){t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(_);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:O,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,o.useContext)(_);return{options:(0,r.useFilterOptions)(e.name)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=(0,o.createContext)(null);C.displayName="RolesResourcesScopesSelectedRowKeysContext";var j=function(e){var t,n=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return P(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return P(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=n[0],a=n[1];return i().createElement(C.Provider,{value:[r,a]},e.children)},k=function(e){var t=(0,o.useMemo)(function(){return(0,w.createForm)({values:{scope:e.value}})},[]);return i().createElement(r.FormProvider,{form:t},i().createElement(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:j},scope:{onChange:function(t){var n;null==e||null==(n=e.onChange)||n.call(e,t)}},schema:S}))},A=n(143);function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function I(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var T=function(e){var t,n={};return null==e||null==(t=e.forEach)||t.call(e,function(e){e.name&&(n[e.name]=e,n[e.name].scope=(0,d.isEmpty)(e.scope)?null:e.scope)}),n},_=(0,o.createContext)({});_.displayName="RoleResourceCollectionContext",(0,g.connect)(function(e){var t,n=(0,A.I)().styles,o=function(t){var n=t.map(function(e){return I(R({},e),{scope:(0,d.isEmpty)(e.scope)?null:e.scope})});e.onChange(n)};(0,g.useForm)();var a=(0,r.useRecord)(),c=(0,x.K)(),l=(0,r.useCollectionManager_deprecated)(),u=l.getCollection,s=l.getCollectionFields,p=u(a.collectionName),y=s(a.collectionName),b=(0,r.useCompile)(),v=(0,f.useTranslation)().t,w=T((0,g.useField)().value||[]),O=function(e,t){var n,r=null==w?void 0:w[e];return!!r&&(null==r||null==(n=r.fields)?void 0:n.includes(t))},S=c.filter(function(e){return e.allowConfigureFields}),P=null==y||null==(D=y.filter(function(e){return e.interface}))?void 0:D.map(function(e){var t=R({},e),n=!0,r=!1,o=void 0;try{for(var i,a=S[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c=i.value;t[c.name]=O(c.name,e.name)}}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return t}),C=function(e){if(w[e])delete w[e];else{var t,n;w[e]={name:e,fields:null==y||null==(n=y.filter(function(e){return e.interface}))||null==(t=n.map)?void 0:t.call(n,function(e){return e.name})}}o(Object.values(w))},j=function(e,t){w[e]?(w[e].scope=t,o(Object.values(w))):(C(e),w[e].scope=t)},F={},q=!0,M=!1,N=void 0;try{for(var D,B,$=S[Symbol.iterator]();!(q=(B=$.next()).done);q=!0){var L,z,V,K=B.value;F[K.name]=(null==y||null==(L=y.filter(function(e){return e.interface}))?void 0:L.length)===(null==w||null==(V=w[K.name])||null==(z=V.fields)?void 0:z.length)}}catch(e){M=!0,N=e}finally{try{q||null==$.return||$.return()}finally{if(M)throw N}}return i().createElement("div",null,i().createElement(_.Provider,{value:p},i().createElement(h.FormLayout,{layout:"vertical"},i().createElement(h.FormItem,{label:v("Action permission")},i().createElement(m.Table,{className:n,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:v("Action display name"),render:function(e){return b(e)}},{dataIndex:"onNewRecord",title:v("Action type"),render:function(e){return e?i().createElement(m.Tag,{color:"green"},v("Action on new records")):i().createElement(m.Tag,{color:"geekblue"},v("Action on existing records"))}},{dataIndex:"enabled",title:v("Allow"),render:function(e,t){return i().createElement(m.Checkbox,{checked:e,onChange:function(){C(t.name)}})}},{dataIndex:"scope",title:v("Data scope"),render:function(e,t){return!t.onNewRecord&&i().createElement(k,{value:e,onChange:function(e){j(t.name,e)}})}}],dataSource:null==c?void 0:c.map(function(e){var t=!1,n=null;return w[e.name]&&(t=!0,e.onNewRecord||(n=w[e.name].scope)),I(R({},e),{enabled:t,scope:n})})})),i().createElement(h.FormItem,{label:v("Field permission")},i().createElement(m.Table,{className:n,pagination:!1,dataSource:P,columns:[{dataIndex:["uiSchema","title"],title:v("Field display name"),render:function(e){return b(e)}}].concat(function(e){if(Array.isArray(e))return E(e)}(t=S.map(function(e){var t=null==F?void 0:F[e.name];return{dataIndex:e.name,title:i().createElement(i().Fragment,null,i().createElement(m.Checkbox,{checked:t,onChange:function(){var n,r=w[e.name]||{name:e.name};t?r.fields=[]:r.fields=null==y||null==(n=y.map)?void 0:n.call(y,function(e){return e.name}),w[e.name]=r,o(Object.values(w))}})," ",b(e.displayName)),render:function(t,n){return i().createElement(m.Checkbox,{checked:t,"aria-label":"".concat(e.name,"_checkbox"),onChange:function(){var r=w[e.name]||{name:e.name},i=r.fields||[];if(t){var a=i.indexOf(n.name);i.splice(a,1)}else i.push(n.name);r.fields=i,w[e.name]=r,o(Object.values(w))}})}}}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return E(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})))))});var F=n(268);function q(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function M(e,t,n){return(M=L()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&B(o,n.prototype),o}).apply(null,arguments)}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e){var t="function"==typeof Map?new Map:void 0;return($=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return M(e,arguments,D(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),B(n,e)})(e)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(L=function(){return!!e})()}var z=(0,r.lazy)(function(){return n.e("949").then(n.bind(n,916))},"RolesManagement").RolesManagement,V=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=D(t),N(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,L()?Reflect.construct(t,r||[],D(this).constructor):t.apply(this,r)),"rolesManager",new p),N(e,"settingsUI",new u),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&B(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.add("users-permissions.roles",{title:this.t("Roles & Permissions"),icon:"LockOutlined",Component:z,aclSnippet:"pm.acl.roles",sort:3}),this.app.addUserCenterSettingsItem({name:"divider_switchRole",type:"divider",sort:200}),this.app.addUserCenterSettingsItem({name:"switchRole",Component:v,sort:300}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){q(i,r,o,a,c,"next",e)}function c(e){q(i,r,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}($(r.Plugin)),K=V},143:function(e,t,n){function r(){var e,t,n=(e=["\n .ant-table-cell {\n > .ant-space-horizontal {\n .ant-space-item-split:has(+ .ant-space-item:empty) {\n display: none;\n }\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return r=function(){return n},n}n.d(t,{I:function(){return o}});var o=(0,n(235).createStyles)(function(e){return(0,e.css)(r())})},375:function(e){e.exports=r},418:function(e){e.exports=t},452:function(e){e.exports=i},230:function(e){e.exports=n},166:function(e){e.exports=a},342:function(e){e.exports=u},768:function(e){e.exports=p},625:function(e){e.exports=o},59:function(e){e.exports=l},235:function(e){e.exports=s},773:function(e){e.exports=f},155:function(e){e.exports=c},953:function(t){t.exports=e},745:function(e,t,n){var r="",o="u">typeof document?document.currentScript:null;if(o&&o.src&&(r=o.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!r){var i=window.__webpack_public_path__||"";i&&("/"!==i.charAt(i.length-1)&&(i+="/"),r=i+"static/plugins/@nocobase/plugin-acl/dist/client/")}if(!r){var a=window.__nocobase_modern_client_prefix__||"v",c="/"+(a=String(a).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(r=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",u=l.indexOf(c);r=u>=0?l.slice(0,u+1):"/"}r&&(r=r.replace(RegExp("/"+a+"/?$"),"/")),r||(r="/"),"/"!==r.charAt(r.length-1)&&(r+="/"),r+="static/plugins/@nocobase/plugin-acl/dist/client/"}n.p=r}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e](n,n.exports,h),n.exports}h.m=b,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return""+e+"."+({949:"7ad4ad3b554e5452",971:"50ecf7b6ac572080"})[e]+".js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},h.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var l=a[c];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-acl:"+n){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl:"+n),o.src=e),g[e]=[t];var u=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=g[e];if(delete g[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(x=h.g.location+"");var g,x,w=h.g.document;if(!x&&w&&(w.currentScript&&"SCRIPT"===w.currentScript.tagName.toUpperCase()&&(x=w.currentScript.src),!x)){var O=w.getElementsByTagName("script");if(O.length)for(var S=O.length-1;S>-1&&(!x||!/^http(s?):/.test(x));)x=O[S--].src}if(!x)throw Error("Automatic publicPath is not supported in this browser");return h.p=x.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),m={889:0},h.f.j=function(e,t){var n=h.o(m,e)?m[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=m[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(m,e)&&(0!==(n=m[e])&&(m[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},d=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==m[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);a&&a(h)}for(e&&e(t);c<o.length;c++)r=o[c],h.o(m,r)&&m[r]&&m[r][0](),m[r]=0},(y=self.webpackChunk_nocobase_plugin_acl=self.webpackChunk_nocobase_plugin_acl||[]).forEach(d.bind(null,0)),y.push=d.bind(null,y.push.bind(y)),h(745),h(747)}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl_client_v2=self.webpackChunk_nocobase_plugin_acl_client_v2||[]).push([["336"],{227:function(e,t,r){r.r(t),r.d(t,{default:function(){return x}});var n=r(694),o=r(59),a=r(155),l=r.n(a),u=r(488),c=r(485),i=r(625);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){var r,n;return r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),n=n={snippets:t},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}),r}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r,n,o,a,l){try{var u=e[a](l),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function b(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){y(a,n,o,l,u,"next",e)}function u(e){y(a,n,o,l,u,"throw",e)}l(void 0)})}}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function m(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(e,t)}}function g(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:c(0)}),u(l,"throw",{value:c(1)}),u(l,"return",{value:c(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function c(u){return function(c){var i=[u,c];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function O(e){var t,r,f=(0,n.useFlowContext)(),p=(0,u.kj)(),y=(0,a.useMemo)(function(){return f.app.pluginSettingsManager.getList(!1).map(function(e){var t,r=(null!=(t=e.children)?t:[]).filter(function(t){return t.key!==e.key&&t.title!==e.title});return r.length?h(d({},e),{children:r}):h(d({},e),{children:void 0})})},[f.app]),O=f.app.pluginSettingsManager.getAclSnippets(),w=(0,a.useMemo)(function(){return y.flatMap(function(e){return e.children?[e].concat(m(e.children)):[e]})},[y]),j=function(e){if(Array.isArray(e))return e}(t=(0,a.useState)(null!=(r=e.role.snippets)?r:[]))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw r}}return o}}(t)||v(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),S=j[0],k=j[1],A=f.api.resource("roles.snippets",e.role.name),P=(0,i.useRequest)(function(){return b(function(){var e,t;return g(this,function(r){switch(r.label){case 0:return[4,A.list({paginate:!1})];case 1:var n;return[2,null!=(e=(!(n=null==(t=r.sent())?void 0:t.data)||(void 0===n?"undefined":n&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)!="object"?{}:{data:Array.isArray(n.data)?n.data:[]}).data)?e:[]]}})})()},{ready:e.active&&!!e.role.name,refreshDeps:[e.role.name],onSuccess:function(e){k(e.filter(function(e){return w.find(function(t){return e.includes("!".concat(t.aclSnippet))||!e.startsWith("!pm.")})}))}}),x=P.loading,E=P.refreshAsync,I=S.includes("pm.*")&&S.every(function(e){return!e.startsWith("!pm.")}),T=(0,a.useMemo)(function(){return[{dataIndex:"title",title:p("Plugin name"),render:function(e){return"string"!=typeof e?e:p(e)||p("Unnamed")}},{dataIndex:"accessible",title:l().createElement(o.Checkbox,{checked:I,onChange:function(){return b(function(){var e;return g(this,function(t){switch(t.label){case 0:if(e=O.map(function(e){return"!".concat(e)}),!I)return[3,2];return[4,A.add({values:e})];case 1:return t.sent(),[3,4];case 2:return[4,A.remove({values:e})];case 3:t.sent(),t.label=4;case 4:return[4,E()];case 5:return t.sent(),f.message.success(p("Saved successfully")),[2]}})})()}},p("Allow access")),render:function(e,t){var r=[t.aclSnippet].concat(m(function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return(t.children?function(e){if(Array.isArray(e))return s(e)}(r=t.children)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e){if(e){if("string"==typeof e)return s(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return s(e,void 0)}}(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}():[]).forEach(function(t){t.aclSnippet&&n.push(t.aclSnippet),e(t,n)}),n}(t))).filter(Boolean).map(function(e){return"!".concat(e)}),n=r.every(function(e){return!S.includes(e)});return l().createElement(o.Checkbox,{checked:n,onChange:function(){return b(function(){return g(this,function(e){switch(e.label){case 0:if(!n)return[3,2];return[4,A.add({values:r})];case 1:return e.sent(),[3,4];case 2:return[4,A.remove({values:r})];case 3:e.sent(),e.label=4;case 4:return[4,E()];case 5:return e.sent(),f.message.success(p("Saved successfully")),[2]}})})()}})}}]},[O,I,f.message,E,A,S,p]),C=y.filter(function(e){return!1!==e.isTopLevel}).map(function(e){return!1!==e.showTabs?e:(e.children,function(e,t){if(null==e)return{};var r,n,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var r,n,o={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}(e,["children"]))});return l().createElement(c.Table,{loading:x,rowKey:"key",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:T,dataSource:C})}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t,r,n,o,a,l){try{var u=e[a](l),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function S(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){j(a,n,o,l,u,"next",e)}function u(e){j(a,n,o,l,u,"throw",e)}l(void 0)})}}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,u=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(u)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return w(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:c(0)}),u(l,"throw",{value:c(1)}),u(l,"return",{value:c(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function c(u){return function(c){var i=[u,c];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}var P=["ui.*","pm","pm.*","app"];function x(e){var t,r=(0,n.useFlowContext)(),c=(0,u.kj)(),i=o.theme.useToken().token,s=e.activeRole,p=k((0,a.useState)(),2),y=p[0],b=p[1],d=k((0,a.useState)(null!=(t=null==s?void 0:s.snippets)?t:[]),2),h=d[0],m=d[1];(0,a.useEffect)(function(){var e;m(null!=(e=null==s?void 0:s.snippets)?e:[])},[null==s?void 0:s.name,null==s?void 0:s.snippets]);var v=(0,a.useMemo)(function(){return[{key:"ui.*",label:c("Allows to configure interface")},{key:"pm",label:c("Allows to install, activate, disable plugins")},{key:"pm.*",label:c("Allows to configure plugins")},{key:"app",label:c("Allows to clear cache, reboot application")}]},[c]);if(!s)return l().createElement(o.Typography.Text,{type:"secondary"},c("Select a role to configure permissions"));var g=h.includes("pm.*");return l().createElement("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:i.marginSM}},l().createElement(o.Typography.Text,{strong:!0},c("Configure permissions")),l().createElement(o.Checkbox.Group,{value:h.filter(function(e){return P.includes(e)})},l().createElement("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:i.marginXS}},v.map(function(t){return l().createElement(o.Checkbox,{key:t.key,value:t.key,disabled:!!y,onChange:function(n){return S(function(){var o;return A(this,function(a){var l,u,i,p;switch(a.label){case 0:l=t.key,u=n.target.checked,(i=h.filter(function(e){return e!==l&&e!=="!".concat(l)})).push(u?l:"!".concat(l)),P.forEach(function(e){i.includes(e)||i.includes("!".concat(e))||i.push("!".concat(e))}),m(o=Array.from(new Set(i))),b(t.key),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,(p=o,S(function(){return A(this,function(e){switch(e.label){case 0:return[4,r.api.resource("roles").update({filterByTk:s.name,values:{snippets:p}})];case 1:return e.sent(),[2]}})})())];case 2:return a.sent(),e.onRoleChange(f(s,o)),r.message.success(c("Saved successfully")),[3,4];case 3:return b(void 0),[7];case 4:return[2]}})})()}},t.label)}))),g?l().createElement(l().Fragment,null,l().createElement(o.Typography.Text,{strong:!0},c("Plugin settings")),l().createElement(O,{active:"general"===e.activeKey,role:f(s,h)})):null)}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl_client_v2=self.webpackChunk_nocobase_plugin_acl_client_v2||[]).push([["532"],{407:function(e,t,n){n.r(t),n.d(t,{default:function(){return M}});var r=n(477),a=n(375),l=n(485),o=n(694),i=n(625),u=n(59),c=n(155),s=n.n(c);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,o){try{var i=e[l](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,a)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e){var t,n=d(u.Form.useForm(),1)[0],r=null!=(t=e.form)?t:n,a=d((0,c.useState)(!1),2),o=a[0],f=a[1];(0,c.useEffect)(function(){var t;r.resetFields(),r.setFieldsValue(null!=(t=e.initialValues)?t:{})},[r,e.initialValues]);var p=(0,i.useMemoizedFn)(function(){var t;return(t=function(){var t,n;return function(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:u(0)}),i(o,"throw",{value:u(1)}),i(o,"return",{value:u(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,r.validateFields()];case 1:t=a.sent(),f(!0),a.label=2;case 2:return a.trys.push([2,,5,6]),[4,e.onSubmit(t,r)];case 3:return a.sent(),[4,null==(n=e.onSubmitted)?void 0:n.call(e,t)];case 4:return a.sent(),[3,6];case 5:return f(!1),[7];case 6:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,a){var l=t.apply(e,n);function o(e){m(l,r,a,o,i,"next",e)}function i(e){m(l,r,a,o,i,"throw",e)}o(void 0)})})()});return s().createElement(l.DrawerFormLayout,{title:e.title,onSubmit:p,submitting:o,submitText:e.submitText,cancelText:e.cancelText,footer:e.footer},s().createElement(u.Form,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({form:r,layout:"vertical"},e.formProps),"function"==typeof e.children?e.children({form:r,submitting:o}):e.children))}var b=n(488),y=n(667);function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t,n,r,a,l,o){try{var i=e[l](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,a)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){v(l,r,a,o,i,"next",e)}function i(e){v(l,r,a,o,i,"throw",e)}o(void 0)})}}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||x(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function x(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}}function k(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:u(0)}),i(o,"throw",{value:u(1)}),i(o,"return",{value:u(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function O(){var e=S(["\n height: calc(100vh - 160px);\n min-height: 0;\n\n > .ant-card-body {\n height: 100%;\n min-height: 0;\n overflow: hidden;\n }\n "]);return O=function(){return e},e}function j(){var e=S(["\n &.acl-role-tabs > .ant-tabs-nav {\n margin-bottom: ","px;\n }\n\n &.acl-role-tabs,\n &.acl-role-tabs > .ant-tabs-content-holder,\n &.acl-role-tabs > .ant-tabs-content-holder > .ant-tabs-content,\n &.acl-role-tabs > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {\n min-height: 0;\n }\n\n &.acl-role-tabs {\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n\n &.acl-role-tabs > .ant-tabs-nav {\n flex: none;\n }\n\n &.acl-role-tabs > .ant-tabs-content-holder {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n &.acl-role-tabs > .ant-tabs-content-holder > .ant-tabs-content,\n &.acl-role-tabs > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {\n height: 100%;\n min-height: 0;\n }\n\n &.acl-role-tabs > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {\n overflow: hidden;\n padding: 0;\n }\n "]);return j=function(){return e},e}function C(){var e=S(["\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n\n > .ant-tabs-nav {\n flex: none;\n }\n\n > .ant-tabs-content-holder {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n }\n\n > .ant-tabs-content-holder > .ant-tabs-content,\n > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {\n height: 100%;\n min-height: 0;\n }\n\n > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {\n overflow: hidden;\n padding: 0;\n }\n "]);return C=function(){return e},e}function I(e,t,n){var r=e.get(t);if((null==r?void 0:r.loader)===n)return r.Component;var a=(0,c.lazy)(n);return e.set(t,{loader:n,Component:a}),a}function A(e){var t,n=(0,o.useFlowContext)(),r=(0,b.kj)(),a=!!e.role;return s().createElement(p,{title:a?r("Edit role"):r("New role"),initialValues:e.role?{title:e.role.title,name:e.role.name,default:e.role.default}:{name:(0,o.randomId)("r_"),default:!1},submitText:r("Submit"),cancelText:r("Cancel"),onSubmit:function(t){return g(function(){var r,l,o,i;return k(this,function(u){switch(u.label){case 0:if(!(a&&(null==(r=e.role)?void 0:r.name)))return[3,2];return[4,n.api.resource("roles").update({filterByTk:e.role.name,values:t})];case 1:return i=u.sent(),e.onRoleChange(null!=(l=null==i||null==(o=i.data)?void 0:o.data)?l:w({},e.role,t)),[2];case 2:var c,s;return[4,n.api.resource("roles").create({values:(c=w({},t),s=s={snippets:["!ui.*","!pm","!pm.*"]},Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(c,e,Object.getOwnPropertyDescriptor(s,e))}),c)})];case 3:return u.sent(),[2]}})})()},onSubmitted:function(){return g(function(){return k(this,function(t){switch(t.label){case 0:return n.message.success(r("Saved successfully")),[4,e.onSubmitted()];case 1:return t.sent(),[2]}})})()}},s().createElement(u.Form.Item,{name:"title",label:r("Role display name"),rules:[{required:!0}]},s().createElement(u.Input,null)),s().createElement(u.Form.Item,{name:"name",label:r("Role UID"),rules:[{required:!0}],normalize:function(e){var t;return null==e||null==(t=e.trim)?void 0:t.call(e)}},s().createElement(u.Input,{disabled:a})),s().createElement(u.Form.Item,{name:"default",valuePropName:"checked"},s().createElement(u.Checkbox,{disabled:!!(null==(t=e.role)?void 0:t.default)},r("Default role"))))}function P(){var e=(0,o.useFlowContext)(),t=(0,b.kj)(),n=E((0,c.useState)(function(){var t,n;return(null==(n=e.acl)||null==(t=n.data)?void 0:t.roleMode)||"default"}),2),r=n[0],a=n[1],l=(0,i.useRequest)(function(t){return g(function(){return k(this,function(n){switch(n.label){case 0:return[4,e.api.resource("roles").setSystemRoleMode({values:{roleMode:t}})];case 1:return n.sent(),[2,t]}})})()},{manual:!0,onSuccess:function(n){a(n),e.message.success(t("Saved successfully")),window.location.reload()}}),f=l.runAsync,m=l.loading;return s().createElement(u.Select,{value:r,loading:m,onChange:function(e){return f(e)},options:[{value:"default",label:t("Independent roles")},{value:"allow-use-union",label:t("Allow roles union")},{value:"only-use-union",label:t("Roles union only")}]})}function M(){var e,t=(0,o.useFlowContext)(),n=(0,b.kj)(),f=u.App.useApp().modal,m=u.theme.useToken().token,d=t.app.pm.get(y.A),p=function(e){if(!e)return null;var t="string"==typeof e.name?e.name:e.role||null,n="string"==typeof e.title?e.title:t;return t&&n?{name:t,title:n,snippets:Array.isArray(e.snippets)?e.snippets:[],strategy:e.strategy,allowConfigure:e.allowConfigure}:null}((0,l.useACLRoleContext)()),v=s().useRef(new Map),w=s().useRef(new Map),S=E((0,c.useState)(null),2),M=S[0],T=S[1],R=E((0,c.useState)(null),2),F=R[0],D=R[1],_=E((0,c.useState)("permissions"),2),L=_[0],z=_[1],B=E((0,c.useState)("general"),2),H=B[0],G=B[1],N=(0,r.css)(O()),U=(0,r.css)(j(),m.marginLG),W={height:"100%",minHeight:0,overflow:"hidden"},X={height:"100%",minHeight:0,overflow:"auto",paddingRight:m.paddingXS},q=(0,r.css)(C()),K=(0,i.useRequest)(function(){return g(function(){var e;return k(this,function(n){switch(n.label){case 0:return[4,t.api.resource("roles").list({paginate:!1,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]})];case 1:var r;return[2,(r=null==(e=n.sent())?void 0:e.data)&&(void 0===r?"undefined":r&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)=="object"?{data:Array.isArray(r.data)?r.data:[],meta:r.meta}:{}]}})})()},{}),V=(0,c.useMemo)(function(){var e,t;return null!=(e=null==(t=K.data)?void 0:t.data)?e:[]},[null==(e=K.data)?void 0:e.data]),$=(0,i.useRequest)(function(){return g(function(){var e,n,r;return k(this,function(a){switch(a.label){case 0:if(!M)return[2,null];return[4,t.api.resource("roles").get({filterByTk:M})];case 1:return[2,null!=(e=null==(r=a.sent())||null==(n=r.data)?void 0:n.data)?e:null]}})})()},{manual:!0,ready:!!M,onSuccess:function(e){D(e)}}),J=(0,i.useMemoizedFn)(function(){$.run()});(0,c.useEffect)(function(){if(!(M&&V.some(function(e){return e.name===M}))){if(V[0])return void T(V[0].name);T(null)}},[V,M]),(0,c.useEffect)(function(){M?J():D(null)},[J,M]),(0,c.useEffect)(function(){G("general")},[null==F?void 0:F.name]);var Q=(0,i.useMemoizedFn)(function(e){(D(e),(null==e?void 0:e.name)&&e.name!==M)?T(e.name):e||T(null)}),Y=(0,i.useMemoizedFn)(function(e){t.viewer.open({type:"drawer",width:"50%",closable:!0,content:function(){return s().createElement(A,{role:e,onSubmitted:function(){return g(function(){return k(this,function(e){switch(e.label){case 0:return[4,K.refreshAsync()];case 1:return e.sent(),[4,$.refreshAsync()];case 2:return e.sent(),[2]}})})()},onRoleChange:Q})}})}),Z=(0,i.useMemoizedFn)(function(e){return g(function(){return k(this,function(r){switch(r.label){case 0:return[4,t.api.resource("roles").destroy({filterByTk:e.name})];case 1:return r.sent(),M===e.name&&(D(null),T(null)),t.message.success(n("Deleted successfully")),[4,K.refreshAsync()];case 2:return r.sent(),[2]}})})()}),ee=(0,i.useMemoizedFn)(function(e){return[{key:"edit",label:n("Edit")},{key:"delete",label:n("Delete"),disabled:e.default}]}),et=(0,i.useMemoizedFn)(function(e,t){return g(function(){return k(this,function(r){return"edit"===e?Y(t):"delete"===e&&f.confirm({title:n("Delete"),content:n("Are you sure you want to delete it?"),onOk:function(){return g(function(){return k(this,function(e){switch(e.label){case 0:return[4,Z(t)];case 1:return e.sent(),[2]}})})()}}),[2]})})()}),en=(0,c.useMemo)(function(){return d.rolesManager.list().map(function(e){var t=E(e,2),n=t[0],r=t[1];return{key:n,label:r.title,Component:I(v.current,n,r.componentLoader)}})},[d.rolesManager]),er=(0,c.useMemo)(function(){return d.settingsUI.getPermissionsTabs({activeKey:H,activeRole:F,currentUserRole:p,onRoleChange:Q}).map(function(e){return{key:e.key,label:e.label,Component:I(w.current,e.key,e.componentLoader)}})},[d.settingsUI,H,p,Q,F]);(0,c.useEffect)(function(){!er.length||er.some(function(e){return e.key===H})||G(er[0].key)},[H,er]);var ea=en.map(function(e){var t=e.key,n=e.label,r=e.Component;return{key:t,label:n,children:s().createElement("div",{style:W},s().createElement(c.Suspense,{fallback:null},s().createElement(r,{active:L===t,role:F,onRoleChange:Q})))}}),el=er.map(function(e){var t=e.key,n=e.label,r=e.Component;return{key:t,label:n,children:s().createElement("div",{style:X},s().createElement(c.Suspense,{fallback:null},s().createElement(r,{activeKey:H,activeRole:F,currentUserRole:p,onRoleChange:Q})))}}),eo=[{key:"permissions",label:n("Permissions"),children:el.length?s().createElement(u.Tabs,{type:"card",className:q,style:{height:"100%",minHeight:0},activeKey:H,onChange:G,items:el}):s().createElement("div",{style:{color:m.colorTextDescription}},n("Select a role to configure permissions"))}].concat(function(e){if(Array.isArray(e))return h(e)}(ea)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(ea)||x(ea)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return s().createElement(u.Card,{className:N},s().createElement("div",{style:{height:"100%",minHeight:0,display:"flex",gap:m.marginLG,alignItems:"stretch",flexWrap:"nowrap"}},s().createElement("div",{style:{flex:"0 0 320px",minWidth:320,minHeight:0,paddingRight:m.paddingLG,borderRight:"1px solid ".concat(m.colorBorderSecondary),display:"flex",flexDirection:"column",overflow:"hidden"}},s().createElement("div",{style:{display:"flex",flex:"0 0 auto",justifyContent:"space-between",alignItems:"center",gap:m.marginSM}},s().createElement(u.Button,{type:"text",icon:s().createElement(a.PlusOutlined,null),onClick:function(){return Y()},style:{paddingInline:0}},n("New role")),s().createElement(P,null)),s().createElement(u.Divider,{style:{flex:"0 0 auto",marginBlock:m.marginSM}}),s().createElement("div",{style:{flex:1,minHeight:0,overflow:"auto"}},V.length?s().createElement(u.List,{loading:K.loading,dataSource:V,split:!1,renderItem:function(e){var t=(null==F?void 0:F.name)===e.name;return s().createElement(u.List.Item,{onClick:function(){return T(e.name)},style:{cursor:"pointer",padding:"".concat(m.paddingXS,"px ").concat(m.paddingSM,"px"),marginBottom:m.marginXXS,borderRadius:m.borderRadiusLG,background:t?m.controlItemBgActive:"transparent"}},s().createElement("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:m.marginSM,minWidth:0}},s().createElement(u.Typography.Text,{ellipsis:!0,style:{flex:"1 1 auto",minWidth:0}},s().createElement("span",{style:{display:"inline-flex",alignItems:"center",gap:m.marginXS,minWidth:0}},s().createElement(a.TagOutlined,null),s().createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},n(e.title)))),s().createElement("div",{style:{display:"inline-flex",alignItems:"center",gap:m.marginXS,flex:"0 0 auto"},onClick:function(e){e.stopPropagation()}},e.default?s().createElement(u.Tag,{color:"success"},n("Default")):null,s().createElement(u.Dropdown,{menu:{items:ee(e),onClick:function(t){var n=t.key;return g(function(){return k(this,function(t){switch(t.label){case 0:return[4,et(String(n),e)];case 1:return t.sent(),[2]}})})()}},trigger:["click"]},s().createElement(u.Button,{type:"text",icon:s().createElement(a.MoreOutlined,null)})))))}}):K.loading?s().createElement(u.List,{loading:!0}):s().createElement(u.Empty,{image:u.Empty.PRESENTED_IMAGE_SIMPLE}))),s().createElement("div",{style:{flex:"1 1 auto",minWidth:0,height:"100%",minHeight:320,overflow:"hidden",display:"flex",flexDirection:"column"}},M&&$.loading&&(null==F?void 0:F.name)!==M?s().createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},s().createElement(u.Spin,null)):F?s().createElement(u.Tabs,{className:"acl-role-tabs ".concat(U),style:{flex:1,minHeight:0},activeKey:L,onChange:z,items:eo}):s().createElement(u.Typography.Text,{type:"secondary"},n("Select a role to configure permissions")))))}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl_client_v2=self.webpackChunk_nocobase_plugin_acl_client_v2||[]).push([["800"],{235:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(485),o=n(694),u=n(625),a=n(59),i=n(773),c=n(155),l=n.n(c),s=n(488);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,o,u,a){try{var i=e[u](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var u=e.apply(t,n);function a(e){d(u,r,o,a,i,"next",e)}function i(e){d(u,r,o,a,i,"throw",e)}a(void 0)})}}function y(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}function b(e,t){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:c(0)}),i(a,"throw",{value:c(1)}),i(a,"return",{value:c(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function c(i){return function(c){var l=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,r=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){u=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){u.label=l[1];break}if(6===l[0]&&u.label<o[1]){u.label=o[1],o=l;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(l);break}o[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function m(e){return Array.isArray(e)?e.flatMap(function(e){return[e.id].concat(y(m(e.children)))}):[]}function v(e){return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?{data:Array.isArray(e.data)?e.data:[]}:{}}function g(e){var t,n=(0,o.useFlowContext)(),f=(0,s.kj)(),d=a.theme.useToken().token,g=e.activeRole,w=function(e){if(Array.isArray(e))return e}(t=(0,c.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],u=!0,a=!1;try{for(r=r.call(e);!(u=(t=r.next()).done)&&(o.push(t.value),2!==o.length);u=!0);}catch(e){a=!0,n=e}finally{try{u||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||h(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),O=w[0],S=w[1],j="menu"===e.activeKey,k=(0,u.useRequest)(function(){return p(function(){var e,t;return b(this,function(r){switch(r.label){case 0:return[4,n.api.resource("desktopRoutes").list({tree:!0,sort:"sort",paginate:!1,filter:{hidden:{$ne:!0}}})];case 1:return[2,null!=(e=v(null==(t=r.sent())?void 0:t.data).data)?e:[]]}})})()},{ready:j,refreshDeps:[j]}),A=(0,c.useMemo)(function(){return function e(t,n){return Array.isArray(t)?t.map(function(t){var r=e(t.children,t.id);return{id:t.id,title:t.title,parentId:n,children:r.length?r:void 0}}):[]}(k.data)},[k.data]),x=(0,c.useMemo)(function(){return function e(t){return t.flatMap(function(t){var n;return[t].concat(y(e(null!=(n=t.children)?n:[])))})}(A)},[A]),I=(0,c.useMemo)(function(){return m(A)},[A]),M=(0,c.useMemo)(function(){return new Map(x.map(function(e){return[e.id,e]}))},[x]),P=g?n.api.resource("roles.desktopRoutes",g.name):null,E=(0,u.useRequest)(function(){return p(function(){var e,t,n;return b(this,function(r){switch(r.label){case 0:if(!P)return[2,[]];return[4,P.list({paginate:!1,filter:{hidden:{$ne:!0}}})];case 1:return[2,null!=(e=null==(t=v(null==(n=r.sent())?void 0:n.data).data)?void 0:t.map(function(e){return e.id}))?e:[]]}})})()},{ready:j&&!!P,refreshDeps:[null==g?void 0:g.name,j],onSuccess:function(e){S(e)}}),C=(0,u.useMemoizedFn)(function(){return p(function(){var e;return b(this,function(t){switch(t.label){case 0:if(!P)return[2];return S(e=O.length===I.length?[]:I),[4,P.set({values:e})];case 1:return t.sent(),[4,E.refreshAsync()];case 2:return t.sent(),n.message.success(f("Saved successfully")),[2]}})})()}),T=(0,u.useMemoizedFn)(function(e){return p(function(){var t,r,o,u,a,c;return b(this,function(l){switch(l.label){case 0:if(!P)return[2];if(t=O.includes(e.id),r=m(e.children),o=t?O.filter(function(t){return t!==e.id&&!r.includes(t)}):(0,i.uniq)(y(O).concat([e.id],y(r))),e.parentId&&(c=null==(a=M.get(e.parentId))||null==(u=a.children)?void 0:u.some(function(e){return o.includes(e.id)}),t&&!c&&(o=o.filter(function(t){return t!==e.parentId})),t||o.includes(e.parentId)||o.push(e.parentId)),S(o),!t)return[3,2];return[4,P.remove({values:O.filter(function(e){return!o.includes(e)})})];case 1:return l.sent(),[3,4];case 2:return[4,P.add({values:o.filter(function(e){return!O.includes(e)})})];case 3:l.sent(),l.label=4;case 4:return[4,E.refreshAsync()];case 5:return l.sent(),n.message.success(f("Saved successfully")),[2]}})})()}),_=(0,c.useMemo)(function(){return[{dataIndex:"title",title:f("Route name"),render:function(e){return"string"!=typeof e?f("Unnamed"):f(e)||f("Unnamed")}},{dataIndex:"accessible",title:l().createElement(a.Checkbox,{checked:!!I.length&&O.length===I.length,onChange:C},f("Allow access")),render:function(e,t){return l().createElement(a.Checkbox,{checked:O.includes(t.id),onChange:function(){return T(t)}})}}]},[I.length,O,C,f,T]);return g?l().createElement("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:d.marginSM}},l().createElement(a.Typography.Text,{strong:!0},f("Route permissions")),l().createElement(a.Checkbox,{checked:!!g.allowNewMenu,onChange:function(t){return p(function(){var r;return b(this,function(o){var u,a,i;switch(o.label){case 0:return[4,(u={allowNewMenu:r=t.target.checked},p(function(){return b(this,function(e){switch(e.label){case 0:return[4,n.api.resource("roles").update({filterByTk:g.name,values:u})];case 1:return e.sent(),[2]}})})())];case 1:return o.sent(),e.onRoleChange((a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},g),i=i={allowNewMenu:r},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))}),a)),n.message.success(f("Saved successfully")),[2]}})})()}},f("New routes are allowed to be accessed by default")),l().createElement(r.Table,{rowKey:"id",loading:k.loading||E.loading,pagination:!1,expandable:{defaultExpandAllRows:!1},columns:_,dataSource:A})):l().createElement(a.Typography.Text,{type:"secondary"},f("Select a role to configure permissions"))}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_acl_client_v2=self.webpackChunk_nocobase_plugin_acl_client_v2||[]).push([["870"],{173:function(t,e,r){r.r(e),r.d(e,{SwitchRoleItemModel:function(){return p}});var n=r(485);function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){r(t);return}a.done?e(l):Promise.resolve(l).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var u=t.apply(e,r);function a(t){i(u,n,o,a,l,"next",t)}function l(t){i(u,n,o,a,l,"throw",t)}a(void 0)})}}function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(s=function(){return!!t})()}function f(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(u,"next",{value:l(0)}),a(u,"throw",{value:l(1)}),a(u,"return",{value:l(2)}),"function"==typeof Symbol&&a(u,Symbol.iterator,{value:function(){return this}}),u;function l(a){return function(l){var c=[a,l];if(r)throw TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var p=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function r(){var t,e,n;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,n=arguments,e=l(e),a(t=function(t,e){var r;if(e&&("object"==((r=e)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,s()?Reflect.construct(e,n||[],l(this).constructor):e.apply(this,n)),"section","preferences"),a(t,"sort",300),a(t,"label","Switch role"),t}return r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&c(r,t),e=[{key:"prepare",value:function(){return u(function(){var t,e,r,n,i,u,a,l;return f(this,function(c){return i=Array.isArray(null==(t=this.context.user)?void 0:t.roles)?this.context.user.roles:[],u=null==(r=this.context.acl)||null==(e=r.data)?void 0:e.roleMode,a=this.context.api.auth.role,l=function(t){if(Array.isArray(t))return o(t)}(i)||function(t){if("u">typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t){if(t){if("string"==typeof t)return o(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return o(t,void 0)}}(i)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),"allow-use-union"===u&&l.unshift({name:"__union__",title:this.context.t("Full permissions",{ns:"@nocobase/plugin-acl"})}),this.options=l.map(function(t){return{value:t.name,label:t.title||t.name}}),this.value=a||(null==(n=this.options[0])?void 0:n.value),this.ready=this.options.length>1&&"only-use-union"!==u,[2]})}).call(this)}},{key:"onChange",value:function(t){return u(function(){return f(this,function(e){switch(e.label){case 0:return this.context.api.auth.setRole(t),[4,this.context.api.resource("users").setDefaultRole({values:{roleName:t}})];case 1:return e.sent(),window.location.reload(),[2]}})}).call(this)}}],function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(r.prototype,e),r}(n.UserCenterSelectItemModel);a(p,"itemId","switch-role"),e.default=p}}]);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { type FormInstance, type FormProps } from 'antd';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export interface ResourceFormDrawerRenderArgs<Values extends object> {
|
|
12
|
+
form: FormInstance<Values>;
|
|
13
|
+
submitting: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ResourceFormDrawerProps<Values extends object = Record<string, unknown>> {
|
|
16
|
+
title: React.ReactNode;
|
|
17
|
+
initialValues?: Partial<Values>;
|
|
18
|
+
form?: FormInstance<Values>;
|
|
19
|
+
formProps?: Omit<FormProps<Values>, 'form' | 'initialValues' | 'children'>;
|
|
20
|
+
children: React.ReactNode | ((args: ResourceFormDrawerRenderArgs<Values>) => React.ReactNode);
|
|
21
|
+
onSubmit: (values: Values, form: FormInstance<Values>) => Promise<void> | void;
|
|
22
|
+
onSubmitted?: (values: Values) => Promise<void> | void;
|
|
23
|
+
submitText?: React.ReactNode;
|
|
24
|
+
cancelText?: React.ReactNode;
|
|
25
|
+
footer?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Drawer-hosted antd form for settings CRUD pages. The caller owns the API
|
|
29
|
+
* branch (create/update/etc.); this component only handles form lifecycle,
|
|
30
|
+
* validation, loading state, and the shared drawer chrome.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ResourceFormDrawer<Values extends object = Record<string, unknown>>(props: ResourceFormDrawerProps<Values>): React.JSX.Element;
|
|
33
|
+
export default ResourceFormDrawer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './plugin';
|
|
10
|
+
export * from './locale';
|
|
11
|
+
export * from './plugin';
|
|
12
|
+
export * from './registries';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl/client-v2",["ahooks","@emotion/css","@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/flow-engine","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-acl/client-v2"]=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):e["@nocobase/plugin-acl/client-v2"]=t(e.ahooks,e["@emotion/css"],e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"],e.lodash)}(self,function(e,t,n,r,o,i,u,c){return function(){"use strict";var a,l,s,f,p,b,d={667:function(e,t,n){n.d(t,{h:function(){return p}});var r=n(485),o=n(101);function i(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function u(e,t,n){return(u=f()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&l(o,n.prototype),o}).apply(null,arguments)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return u(e,arguments,a(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function u(){var e,t,n;if(!(this instanceof u))throw TypeError("Cannot call a class as a function");return t=u,n=arguments,t=a(t),c(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,f()?Reflect.construct(t,n||[],a(this).constructor):t.apply(this,n)),"rolesManager",new o.H),c(e,"settingsUI",new o.k),e}return u.prototype=Object.create(e&&e.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),e&&l(u,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.app.use(r.ACLRolesCheckProvider),this.pluginSettingsManager.addMenuItem({key:"users-permissions",title:this.t("Users & Permissions"),isPinned:!0,sort:200,icon:"TeamOutlined",showTabs:!0}),this.pluginSettingsManager.addPageTabItem({menuKey:"users-permissions",key:"roles",title:this.t("Roles & Permissions"),icon:"LockOutlined",aclSnippet:"pm.acl.roles",sort:4,componentLoader:function(){return n.e("532").then(n.bind(n,407))}}),this.settingsUI.addPermissionsTab({key:"general",label:String(this.t("System")),sort:10,componentLoader:function(){return n.e("336").then(n.bind(n,227))}}),this.settingsUI.addPermissionsTab({key:"menu",label:String(this.t("Desktop routes")),sort:20,componentLoader:function(){return n.e("800").then(n.bind(n,235))}}),this.flowEngine.registerModelLoaders({UIEditorTopbarActionModel:{loader:function(){return Promise.resolve().then(n.t.bind(n,485,23)).then(function(e){return e.UIEditorTopbarActionModel})}},SwitchRoleItemModel:{extends:"UserCenterItemModel",loader:function(){return n.e("870").then(n.bind(n,173))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var u=e.apply(t,n);function c(e){i(u,r,o,c,a,"next",e)}function a(e){i(u,r,o,c,a,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(u.prototype,t),u}(s(r.Plugin));t.A=p},488:function(e,t,n){n.d(t,{CU:function(){return i},MZ:function(){return c},kj:function(){return u}});var r=n(694);function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var i="@nocobase/plugin-acl";function u(){var e=(0,r.useFlowEngine)();return function(t,n){return e.context.t(t,o({ns:[i,"acl","client"]},n))}}function c(e,t){return(0,r.tExpr)(e,o({ns:[i,"acl","client"]},t))}},101:function(e,t,n){function r(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{H:function(){return c},k:function(){return a}});var c=function(){function e(){r(this,e),u(this,"items",new Map)}return i(e,[{key:"add",value:function(e,t){this.items.set(e,t)}},{key:"list",value:function(){return Array.from(this.items.entries()).sort(function(e,t){var n,r;return(null!=(n=e[1].sort)?n:100)-(null!=(r=t[1].sort)?r:100)})}}]),e}(),a=function(){function e(){r(this,e),u(this,"permissionTabs",new Map)}return i(e,[{key:"addPermissionsTab",value:function(e){var t="function"==typeof e?"callback:".concat(this.permissionTabs.size):e.key;this.permissionTabs.set(t,e)}},{key:"getPermissionsTabs",value:function(e){return Array.from(this.permissionTabs.values()).map(function(t){return"function"==typeof t?t(e):t}).filter(function(e){return!!e}).sort(function(e,t){var n,r;return(null!=(n=e.sort)?n:100)-(null!=(r=t.sort)?r:100)})}}]),e}()},375:function(e){e.exports=i},477:function(e){e.exports=t},485:function(e){e.exports=n},694:function(e){e.exports=u},625:function(t){t.exports=e},59:function(e){e.exports=o},773:function(e){e.exports=c},155:function(e){e.exports=r}},h={};function v(e){var t=h[e];if(void 0!==t)return t.exports;var n=h[e]={exports:{}};return d[e](n,n.exports,v),n.exports}v.m=d,v.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return v.d(t,{a:t}),t},g=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},v.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var n=Object.create(null);v.r(n);var r={};y=y||[null,g({}),g([]),g(g)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~y.indexOf(o);o=g(o))Object.getOwnPropertyNames(o).forEach(function(t){r[t]=function(){return e[t]}});return r.default=function(){return e},v.d(n,r),n},v.d=function(e,t){for(var n in t)v.o(t,n)&&!v.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},v.f={},v.e=function(e){return Promise.all(Object.keys(v.f).reduce(function(t,n){return v.f[n](e,t),t},[]))},v.u=function(e){return""+e+"."+({336:"c27dbbf4b362f3c2",532:"be9165ee6b4d34c1",800:"020212b7d7b3875d",870:"1d9bac44ccd1f650"})[e]+".js"},v.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),v.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={},v.l=function(e,t,n,r){if(m[e])return void m[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-acl/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,v.nc&&o.setAttribute("nonce",v.nc),o.setAttribute("data-rspack","@nocobase/plugin-acl/client-v2:"+n),o.src=e),m[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=m[e];if(delete m[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},v.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},v.g.importScripts&&(w=v.g.location+"");var y,g,m,w,_=v.g.document;if(!w&&_&&(_.currentScript&&"SCRIPT"===_.currentScript.tagName.toUpperCase()&&(w=_.currentScript.src),!w)){var O=_.getElementsByTagName("script");if(O.length)for(var k=O.length-1;k>-1&&(!w||!/^http(s?):/.test(w));)w=O[k--].src}if(!w)throw Error("Automatic publicPath is not supported in this browser");v.p=w.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a={889:0},v.f.j=function(e,t){var n=v.o(a,e)?a[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=a[e]=[t,r]});t.push(n[2]=r);var o=v.p+v.u(e),i=Error();v.l(o,function(t){if(v.o(a,e)&&(0!==(n=a[e])&&(a[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},l=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==a[e]})){for(n in i)v.o(i,n)&&(v.m[n]=i[n]);u&&u(v)}for(e&&e(t);c<o.length;c++)r=o[c],v.o(a,r)&&a[r]&&a[r][0](),a[r]=0},(s=self.webpackChunk_nocobase_plugin_acl_client_v2=self.webpackChunk_nocobase_plugin_acl_client_v2||[]).forEach(l.bind(null,0)),s.push=l.bind(null,s.push.bind(s));var j={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-acl/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",u=i.indexOf(o);e=u>=0?i.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-acl/dist/client-v2/"}v.p=e}(),v.r(j),v.d(j,{ACLSettingsUI:function(){return b.k},NAMESPACE:function(){return p.CU},PluginAclClientV2:function(){return f.h},RolesManager:function(){return b.H},default:function(){return f.A},tExpr:function(){return p.MZ},useT:function(){return p.kj}}),f=v(667),p=v(488),b=v(101),j}()});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NAMESPACE = "@nocobase/plugin-acl";
|
|
10
|
+
export declare function useT(): (key: string, options?: Record<string, unknown>) => string;
|
|
11
|
+
export declare function tExpr(key: string, options?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { UserCenterSelectItemModel } from '@nocobase/client-v2';
|
|
10
|
+
export declare class SwitchRoleItemModel extends UserCenterSelectItemModel {
|
|
11
|
+
static itemId: string;
|
|
12
|
+
section: "preferences";
|
|
13
|
+
sort: number;
|
|
14
|
+
label: string;
|
|
15
|
+
prepare(): Promise<void>;
|
|
16
|
+
onChange(value: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export default SwitchRoleItemModel;
|