@nocobase/plugin-acl 2.1.0-beta.42 → 2.1.0-beta.44

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.
@@ -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 P}});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 &.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 O=function(){return e},e}function j(){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 j=function(){return e},e}function C(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 I(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 A(){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 P(){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),P=S[0],M=S[1],T=E((0,c.useState)(null),2),R=T[0],F=T[1],D=E((0,c.useState)("permissions"),2),_=D[0],L=D[1],z=E((0,c.useState)("general"),2),B=z[0],G=z[1],U=(0,r.css)(O(),m.marginLG),N={height:"100%",minHeight:0,overflow:"auto",paddingRight:m.paddingXS},W=(0,r.css)(j()),X=(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}:{}]}})})()},{}),q=(0,c.useMemo)(function(){var e,t;return null!=(e=null==(t=X.data)?void 0:t.data)?e:[]},[null==(e=X.data)?void 0:e.data]),H=(0,i.useRequest)(function(){return g(function(){var e,n,r;return k(this,function(a){switch(a.label){case 0:if(!P)return[2,null];return[4,t.api.resource("roles").get({filterByTk:P})];case 1:return[2,null!=(e=null==(r=a.sent())||null==(n=r.data)?void 0:n.data)?e:null]}})})()},{manual:!0,ready:!!P,onSuccess:function(e){F(e)}}),K=(0,i.useMemoizedFn)(function(){H.run()});(0,c.useEffect)(function(){if(!(P&&q.some(function(e){return e.name===P}))){if(q[0])return void M(q[0].name);M(null)}},[q,P]),(0,c.useEffect)(function(){P?K():F(null)},[K,P]),(0,c.useEffect)(function(){G("general")},[null==R?void 0:R.name]);var V=(0,i.useMemoizedFn)(function(e){(F(e),(null==e?void 0:e.name)&&e.name!==P)?M(e.name):e||M(null)}),$=(0,i.useMemoizedFn)(function(e){t.viewer.open({type:"drawer",width:"50%",closable:!0,content:function(){return s().createElement(I,{role:e,onSubmitted:function(){return g(function(){return k(this,function(e){switch(e.label){case 0:return[4,X.refreshAsync()];case 1:return e.sent(),[4,H.refreshAsync()];case 2:return e.sent(),[2]}})})()},onRoleChange:V})}})}),J=(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(),P===e.name&&(F(null),M(null)),t.message.success(n("Deleted successfully")),[4,X.refreshAsync()];case 2:return r.sent(),[2]}})})()}),Q=(0,i.useMemoizedFn)(function(e){return[{key:"edit",label:n("Edit")},{key:"delete",label:n("Delete"),disabled:e.default}]}),Y=(0,i.useMemoizedFn)(function(e,t){return g(function(){return k(this,function(r){return"edit"===e?$(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,J(t)];case 1:return e.sent(),[2]}})})()}}),[2]})})()}),Z=(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:C(v.current,n,r.componentLoader)}})},[d.rolesManager]),ee=(0,c.useMemo)(function(){return d.settingsUI.getPermissionsTabs({activeKey:B,activeRole:R,currentUserRole:p,onRoleChange:V}).map(function(e){return{key:e.key,label:e.label,Component:C(w.current,e.key,e.componentLoader)}})},[d.settingsUI,B,p,V,R]);(0,c.useEffect)(function(){!ee.length||ee.some(function(e){return e.key===B})||G(ee[0].key)},[B,ee]);var et=Z.map(function(e){var t=e.key,n=e.label,r=e.Component;return{key:t,label:n,children:s().createElement("div",{style:N},s().createElement(c.Suspense,{fallback:null},s().createElement(r,{active:_===t,role:R,onRoleChange:V})))}}),en=ee.map(function(e){var t=e.key,n=e.label,r=e.Component;return{key:t,label:n,children:s().createElement("div",{style:N},s().createElement(c.Suspense,{fallback:null},s().createElement(r,{activeKey:B,activeRole:R,currentUserRole:p,onRoleChange:V})))}}),er=[{key:"permissions",label:n("Permissions"),children:en.length?s().createElement(u.Tabs,{type:"card",className:W,style:{height:"100%",minHeight:0},activeKey:B,onChange:G,items:en}):s().createElement("div",{style:{color:m.colorTextDescription}},n("Select a role to configure permissions"))}].concat(function(e){if(Array.isArray(e))return h(e)}(et)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(et)||x(et)||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,null,s().createElement("div",{style:{display:"flex",gap:m.marginLG,alignItems:"stretch",flexWrap:"nowrap"}},s().createElement("div",{style:{flex:"0 0 320px",minWidth:320,paddingRight:m.paddingLG,borderRight:"1px solid ".concat(m.colorBorderSecondary)}},s().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:m.marginSM}},s().createElement(u.Button,{type:"text",icon:s().createElement(a.PlusOutlined,null),onClick:function(){return $()},style:{paddingInline:0}},n("New role")),s().createElement(A,null)),s().createElement(u.Divider,{style:{marginBlock:m.marginSM}}),q.length?s().createElement(u.List,{loading:X.loading,dataSource:q,split:!1,renderItem:function(e){var t=(null==R?void 0:R.name)===e.name;return s().createElement(u.List.Item,{onClick:function(){return M(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:Q(e),onClick:function(t){var n=t.key;return g(function(){return k(this,function(t){switch(t.label){case 0:return[4,Y(String(n),e)];case 1:return t.sent(),[2]}})})()}},trigger:["click"]},s().createElement(u.Button,{type:"text",icon:s().createElement(a.MoreOutlined,null)})))))}}):X.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,maxHeight:"70vh",minHeight:320,overflow:"hidden",display:"flex",flexDirection:"column"}},P&&H.loading&&(null==R?void 0:R.name)!==P?s().createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},s().createElement(u.Spin,null)):R?s().createElement(u.Tabs,{className:"acl-role-tabs ".concat(U),style:{flex:1,minHeight:0},activeKey:_,onChange:L,items:er}):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;
@@ -7,3 +7,6 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export { default } from './plugin';
10
+ export * from './locale';
11
+ export * from './plugin';
12
+ export * from './registries';
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@nocobase/client-v2")):"function"==typeof define&&define.amd?define("@nocobase/plugin-acl/client-v2",["@nocobase/client-v2"],e):"object"==typeof exports?exports["@nocobase/plugin-acl/client-v2"]=e(require("@nocobase/client-v2")):t["@nocobase/plugin-acl/client-v2"]=e(t["@nocobase/client-v2"])}(self,function(t){return function(){"use strict";var e={485:function(e){e.exports=t}},n={};function r(t){var o=n[t];if(void 0!==o)return o.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.g.importScripts&&(o=r.g.location+"");var o,i=r.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var c=i.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!o||!/^http(s?):/.test(o));)o=c[u--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");r.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var a={};return!function(){var t="",e="u">typeof document?document.currentScript:null;if(e&&e.src&&(t=e.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!t){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),t=n+"static/plugins/@nocobase/plugin-acl/dist/client-v2/")}if(!t){if(!(t=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var o=window.location.pathname||"/",i=o.indexOf("/v2/");t=i>=0?o.slice(0,i+1):"/"}t&&(t=t.replace(/\/v2\/?$/,"/")),t||(t="/"),"/"!==t.charAt(t.length-1)&&(t+="/"),t+="static/plugins/@nocobase/plugin-acl/dist/client-v2/"}r.p=t}(),!function(){r.r(a),r.d(a,{default:function(){return g}});var t=r(485);function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function n(t,e,n,r,o,i,c){try{var u=t[i](c),a=u.value}catch(t){n(t);return}u.done?e(a):Promise.resolve(a).then(r,o)}function o(t){return function(){var e=this,r=arguments;return new Promise(function(o,i){var c=t.apply(e,r);function u(t){n(c,o,i,u,a,"next",t)}function a(t){n(c,o,i,u,a,"throw",t)}u(void 0)})}}function i(t,e,n){return e=p(e),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t,v()?Reflect.construct(e,n||[],p(t).constructor):e.apply(t,n))}function c(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function u(t,e,n){return(u=v()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&h(o,n.prototype),o}).apply(null,arguments)}function l(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function s(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),t}function f(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&h(t,e)}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(t){var e="function"==typeof Map?new Map:void 0;return(y=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,p(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,t)})(t)}function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(v=function(){return!!t})()}function d(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=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=e.call(t,i)}catch(t){l=[6,t],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var m=function(t){function n(){var t;return c(this,n),t=i(this,n,arguments),f(t,"section","preferences"),f(t,"sort",300),f(t,"label","Switch role"),t}return b(n,t),s(n,[{key:"prepare",value:function(){return o(function(){var t,n,r,o,i,c,u,a;return d(this,function(l){return i=Array.isArray(null==(t=this.context.user)?void 0:t.roles)?this.context.user.roles:[],c=null==(r=this.context.acl)||null==(n=r.data)?void 0:n.roleMode,u=this.context.api.auth.role,a=function(t){if(Array.isArray(t))return e(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 e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(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"===c&&a.unshift({name:"__union__",title:this.context.t("Full permissions",{ns:"@nocobase/plugin-acl"})}),this.options=a.map(function(t){return{value:t.name,label:t.title||t.name}}),this.value=u||(null==(o=this.options[0])?void 0:o.value),this.ready=this.options.length>1&&"only-use-union"!==c,[2]})}).call(this)}},{key:"onChange",value:function(t){return o(function(){return d(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)}}]),n}(t.UserCenterSelectItemModel);f(m,"itemId","switch-role");var g=function(e){function n(){return c(this,n),i(this,n,arguments)}return b(n,e),s(n,[{key:"load",value:function(){return o(function(){return d(this,function(e){return this.app.use(t.ACLRolesCheckProvider),this.app.flowEngine.registerModels({UIEditorTopbarActionModel:t.UIEditorTopbarActionModel,SwitchRoleItemModel:m}),[2]})}).call(this)}}]),n}(y(t.Plugin))}(),a}()});
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:3,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:"5bb5da39540ee7ed",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,O=v.g.document;if(!w&&O&&(O.currentScript&&"SCRIPT"===O.currentScript.tagName.toUpperCase()&&(w=O.currentScript.src),!w)){var k=O.getElementsByTagName("script");if(k.length)for(var _=k.length-1;_>-1&&(!w||!/^http(s?):/.test(w));)w=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){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),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}()});
@@ -6,4 +6,6 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export {};
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;
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- export default function AppInfoDemoRoute(): React.JSX.Element;
10
+ export default function RolesManagementPage(): React.JSX.Element;
@@ -7,4 +7,5 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- export default function DemoFlowSettingsLazyField(): React.JSX.Element;
10
+ import type { PermissionTabProps } from '../../registries';
11
+ export default function DesktopRoutesPermissionsTab(props: PermissionTabProps): React.JSX.Element;
@@ -7,8 +7,10 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- /**
11
- * v2 右上角 UI Editor 开关。
12
- */
13
- export declare const DesignableSwitch: React.MemoExoticComponent<import("@formily/reactive-react").ReactFC<unknown>>;
14
- export default DesignableSwitch;
10
+ import type { Role } from '../../registries';
11
+ interface PluginPermissionsTableProps {
12
+ active: boolean;
13
+ role: Role;
14
+ }
15
+ export default function PluginPermissionsTable(props: PluginPermissionsTableProps): React.JSX.Element;
16
+ export {};
@@ -7,4 +7,5 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- export default function DemoHomepageRoute(): React.JSX.Element;
10
+ import type { PermissionTabProps } from '../../registries';
11
+ export default function SystemPermissionsTab(props: PermissionTabProps): React.JSX.Element;
@@ -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 type { PluginSettingsPageType } from '@nocobase/client-v2';
10
+ import type { Role } from '../../registries';
11
+ export type TFunction = (key: string, options?: Record<string, unknown>) => string;
12
+ export interface RoleSnippetsPayload {
13
+ data?: string[];
14
+ }
15
+ export declare function toRoleSnippetsPayload(responseData: unknown): RoleSnippetsPayload;
16
+ export declare function translateTitle(title: unknown, t: TFunction): unknown;
17
+ export declare function mergeRoleSnippets(role: Role, snippets: string[]): Role;
18
+ export declare function getSettingsChildren(item: PluginSettingsPageType): PluginSettingsPageType[];
@@ -6,8 +6,11 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { Plugin } from '@nocobase/client-v2';
10
- export declare class PluginAclClientV2 extends Plugin {
9
+ import { Application, Plugin } from '@nocobase/client-v2';
10
+ import { ACLSettingsUI, RolesManager } from './registries';
11
+ export declare class PluginAclClientV2 extends Plugin<any, Application> {
12
+ rolesManager: RolesManager;
13
+ settingsUI: ACLSettingsUI;
11
14
  load(): Promise<void>;
12
15
  }
13
16
  export default PluginAclClientV2;
@@ -0,0 +1,60 @@
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 { ComponentType, ReactNode } from 'react';
10
+ export interface Role {
11
+ createdAt?: string;
12
+ updatedAt?: string;
13
+ name: string;
14
+ title: string;
15
+ description?: string;
16
+ strategy?: {
17
+ actions?: string[];
18
+ };
19
+ default?: boolean;
20
+ hidden?: boolean;
21
+ allowConfigure?: boolean;
22
+ allowNewMenu?: boolean;
23
+ snippets?: string[];
24
+ }
25
+ export interface RoleTabProps {
26
+ active: boolean;
27
+ role: Role | null;
28
+ onRoleChange: (role: Role | null) => void;
29
+ }
30
+ export interface PermissionTabProps {
31
+ activeKey: string;
32
+ activeRole: Role | null;
33
+ currentUserRole: Role | null;
34
+ onRoleChange: (role: Role | null) => void;
35
+ }
36
+ export type ComponentLoader<Props> = () => Promise<{
37
+ default: ComponentType<Props>;
38
+ }>;
39
+ export interface RoleTabOptions {
40
+ title: ReactNode;
41
+ componentLoader: ComponentLoader<RoleTabProps>;
42
+ sort?: number;
43
+ }
44
+ export interface PermissionTabOptions {
45
+ key: string;
46
+ label: ReactNode;
47
+ componentLoader: ComponentLoader<PermissionTabProps>;
48
+ sort?: number;
49
+ }
50
+ export type PermissionTabOptionResolver = PermissionTabOptions | ((props: PermissionTabProps) => PermissionTabOptions | null | undefined);
51
+ export declare class RolesManager {
52
+ private readonly items;
53
+ add(name: string, options: RoleTabOptions): void;
54
+ list(): [string, RoleTabOptions][];
55
+ }
56
+ export declare class ACLSettingsUI {
57
+ private readonly permissionTabs;
58
+ addPermissionsTab(options: PermissionTabOptionResolver): void;
59
+ getPermissionsTabs(props: PermissionTabProps): PermissionTabOptions[];
60
+ }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.42",
11
+ "@nocobase/client": "2.1.0-beta.44",
12
12
  "antd": "5.24.2",
13
13
  "react": "18.2.0",
14
14
  "react-i18next": "11.18.6",
@@ -17,16 +17,17 @@ module.exports = {
17
17
  "@formily/react": "2.3.7",
18
18
  "@ant-design/icons": "5.6.1",
19
19
  "lodash": "4.18.1",
20
- "@nocobase/utils": "2.1.0-beta.42",
21
- "@nocobase/client-v2": "2.1.0-beta.42",
22
- "@nocobase/actions": "2.1.0-beta.42",
23
- "@nocobase/cache": "2.1.0-beta.42",
24
- "@nocobase/database": "2.1.0-beta.42",
25
- "@nocobase/server": "2.1.0-beta.42",
26
- "@nocobase/acl": "2.1.0-beta.42",
27
- "@nocobase/test": "2.1.0-beta.42",
20
+ "@nocobase/utils": "2.1.0-beta.44",
21
+ "@nocobase/flow-engine": "2.1.0-beta.44",
22
+ "@nocobase/client-v2": "2.1.0-beta.44",
23
+ "@nocobase/actions": "2.1.0-beta.44",
24
+ "@nocobase/cache": "2.1.0-beta.44",
25
+ "@nocobase/database": "2.1.0-beta.44",
26
+ "@nocobase/server": "2.1.0-beta.44",
27
+ "@nocobase/acl": "2.1.0-beta.44",
28
+ "@nocobase/test": "2.1.0-beta.44",
28
29
  "@formily/core": "2.3.7",
29
30
  "@formily/antd-v5": "1.2.3",
30
31
  "antd-style": "3.7.1",
31
- "@nocobase/flow-engine": "2.1.0-beta.42"
32
+ "@emotion/css": "11.13.0"
32
33
  };
@@ -1,6 +1,14 @@
1
1
  {
2
+ "Accessible": "Accessible",
3
+ "Allow access": "Allow access",
2
4
  "Allow roles union": "Allow roles union",
5
+ "Allows to clear cache, reboot application": "Allows to clear cache, reboot application",
6
+ "Allows to configure interface": "Allows to configure interface",
7
+ "Allows to configure plugins": "Allows to configure plugins",
8
+ "Allows to install, activate, disable plugins": "Allows to install, activate, disable plugins",
3
9
  "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.": "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.",
10
+ "Desktop routes": "Desktop routes",
11
+ "Configure permissions": "Configure permissions",
4
12
  "Data sources": "Data sources",
5
13
  "Desktop menu": "Desktop menu",
6
14
  "Do not use role union. Users need to switch between their roles individually.": "Do not use role union. Users need to switch between their roles individually.",
@@ -9,14 +17,21 @@
9
17
  "General": "General",
10
18
  "Independent roles": "Independent roles",
11
19
  "New role": "New role",
20
+ "New routes are allowed to be accessed by default": "New routes are allowed to be accessed by default",
12
21
  "Permissions": "Permissions",
13
22
  "Please select role mode": "Please select role mode",
14
23
  "Plugin settings": "Plugin settings",
24
+ "Plugin name": "Plugin name",
25
+ "Route name": "Route name",
26
+ "Route permissions": "Route permissions",
15
27
  "Role mode": "Role mode",
16
28
  "Role mode doc": "https://docs.nocobase.com/handbook/acl/manual",
17
29
  "Roles & Permissions": "Roles & Permissions",
18
30
  "Roles union only": "Roles union only",
19
31
  "Saved successfully": "Saved successfully",
32
+ "Select a role to configure permissions": "Select a role to configure permissions",
33
+ "System": "System",
20
34
  "The current user has no roles. Please try another account.": "The current user has no roles. Please try another account.",
21
- "The user role does not exist. Please try signing in again": "The user role does not exist. Please try signing in again"
22
- }
35
+ "The user role does not exist. Please try signing in again": "The user role does not exist. Please try signing in again",
36
+ "Users & Permissions": "Users & Permissions"
37
+ }
@@ -1,6 +1,14 @@
1
1
  {
2
+ "Accessible": "可访问",
3
+ "Allow access": "允许访问",
2
4
  "Allow roles union": "允许角色并集",
5
+ "Allows to clear cache, reboot application": "允许清除缓存、重启应用",
6
+ "Allows to configure interface": "允许配置界面",
7
+ "Allows to configure plugins": "允许配置插件",
8
+ "Allows to install, activate, disable plugins": "允许安装、激活、禁用插件",
3
9
  "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.": "允许用户使用角色并集,即可以同时使用自己拥有的所有角色的权限,也允许用户逐个切换自己的角色。",
10
+ "Desktop routes": "桌面端路由",
11
+ "Configure permissions": "配置权限",
4
12
  "Data sources": "数据源",
5
13
  "Desktop menu": "桌面端菜单",
6
14
  "Do not use role union. Users need to switch between their roles individually.": "不使用角色并集,用户需要逐个切换自己拥有的角色。",
@@ -9,14 +17,21 @@
9
17
  "General": "通用",
10
18
  "Independent roles": "独立角色",
11
19
  "New role": "新建角色",
20
+ "New routes are allowed to be accessed by default": "默认允许访问新路由",
12
21
  "Permissions": "权限",
13
22
  "Please select role mode": "请选择角色模式",
14
23
  "Plugin settings": "插件设置",
24
+ "Plugin name": "插件名称",
25
+ "Route name": "路由名称",
26
+ "Route permissions": "路由权限",
15
27
  "Role mode": "角色模式",
16
28
  "Role mode doc": "https://docs-cn.nocobase.com/handbook/acl/manual",
17
29
  "Roles & Permissions": "角色和权限",
18
30
  "Roles union only": "仅角色并集",
19
31
  "Saved successfully": "保存成功",
32
+ "Select a role to configure permissions": "选择一个角色以配置权限",
33
+ "System": "系统",
20
34
  "The current user has no roles. Please try another account.": "当前用户没有角色,请使用其他账号。",
21
- "The user role does not exist. Please try signing in again": "用户角色不存在,请尝试重新登录。"
22
- }
35
+ "The user role does not exist. Please try signing in again": "用户角色不存在,请尝试重新登录。",
36
+ "Users & Permissions": "用户和权限"
37
+ }
@@ -43,7 +43,7 @@ var import_constants = require("../constants");
43
43
  var import_enum = require("../enum");
44
44
  var import_lodash = __toESM(require("lodash"));
45
45
  async function setCurrentRole(ctx, next) {
46
- var _a, _b, _c;
46
+ var _a, _b;
47
47
  let currentRole = ctx.get("X-Role");
48
48
  if (currentRole === "anonymous") {
49
49
  ctx.state.currentRole = currentRole;
@@ -114,7 +114,7 @@ async function setCurrentRole(ctx, next) {
114
114
  role = (defaultRoleModel == null ? void 0 : defaultRoleModel.roleName) || ((_b = userRoles[0]) == null ? void 0 : _b.name);
115
115
  }
116
116
  ctx.state.currentRole = role;
117
- ctx.state.currentRoles = role === import_constants.UNION_ROLE_KEY ? [(_c = userRoles[0]) == null ? void 0 : _c.name] : [role];
117
+ ctx.state.currentRoles = role === import_constants.UNION_ROLE_KEY ? userRoles.map((role2) => role2.name) : [role];
118
118
  if (!ctx.state.currentRoles.length) {
119
119
  return ctx.throw(401, {
120
120
  code: "ROLE_NOT_FOUND_ERR",
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
7
7
  "description.ru-RU": "На основе ролей, ресурсов и действий система контроля доступа может точно управлять разрешениями на изменение интерфейса, работу с данными, доступ к меню и разрешениями для подключаемых модулей.",
8
8
  "description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
9
- "version": "2.1.0-beta.42",
9
+ "version": "2.1.0-beta.44",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/acl",
@@ -46,5 +46,5 @@
46
46
  "url": "git+https://github.com/nocobase/nocobase.git",
47
47
  "directory": "packages/plugins/acl"
48
48
  },
49
- "gitHead": "619b4d06c934bf3266ba7f388438db018217c87d"
49
+ "gitHead": "540d4897b1696cc24c0754521b0b766978b4933c"
50
50
  }
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export default function FlowSettingsComponentLoaderDemoRoute(): React.JSX.Element;