@nocobase/plugin-data-source-manager 1.5.0-beta.3 → 1.5.0-beta.4

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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["210"],{186:function(e,t,n){n.r(t),n.d(t,{DatabaseConnectionManagerPane:function(){return R}});var r=n("875"),o=n("772"),a=n("721"),i=n("156"),c=n.n(i),u=n("238"),l=n("60"),s=n("421"),p=n("382"),d=n("482"),f=n("212"),y=n("573");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 b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{!i&&null!=o.return&&o.return()}finally{if(c)throw r}}return a}}(e,t)||h(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 v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=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 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)}}var g=function(){var e=b((0,i.useState)({}),2),t=e[0],n=e[1],s=(0,o.usePlugin)(l.default),p=(0,o.useCompile)(),m=b((0,i.useState)(!1),2),h=m[0],g=m[1],x=(0,u.useTranslation)().t,A=b((0,i.useState)(null),2),C=A[0],S=A[1],k=(0,o.useAPIClient)();return c().createElement("div",null,c().createElement(o.ActionContext.Provider,{value:{visible:h,setVisible:g}},c().createElement(a.Dropdown,{menu:{onClick:function(e){if("__empty__"!==e.key){var t,o,a,i=s.types.get(e.key);S(e.key),g(!0),n({type:"object",properties:(t={},o=(0,r.uid)(),a={type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:e.key,key:"d_".concat((0,r.uid)())}},title:p("{{t('Add new')}}")+" - "+p(i.label),properties:{body:{type:"void","x-component":i.DataSourceSettingsForm},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{testConnection:{title:'{{ t("Test Connection",{ ns: "'.concat(y.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==i?void 0:i.disableTestConnection},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 }}",actionCallback:"{{ dataSourceCreateCallback }}"}}}}}},o in t?Object.defineProperty(t,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[o]=a,t)})}},items:[s.types.size?null:{key:"__empty__",label:c().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:c().createElement(c().Fragment,null,x("No external data source plugin installed",{ns:y.A7}),c().createElement("br",null)," ",c().createElement("a",{target:"_blank",href:"zh-CN"===k.auth.locale?"https://docs-cn.nocobase.com/handbook/data-source-manager":"https://docs.nocobase.com/handbook/data-source-manager",rel:"noreferrer"},x("View documentation",{ns:y.A7})))})}].filter(Boolean).concat(v(s.types.keys()).map(function(e){var t=s.types.get(e);return{key:e,label:p(null==t?void 0:t.label)}}))}},c().createElement(a.Button,{type:"primary",icon:c().createElement(d.PlusOutlined,null)},x("Add new")," ",c().createElement(d.DownOutlined,null))),c().createElement(o.SchemaComponent,{scope:{createOnly:!1,useTestConnectionAction:f.useTestConnectionAction,dialect:C,useDialectDataSource:function(e){var t=v(s.types.keys()).map(function(e){var t=s.types.get(e);return{value:t.name,label:p(t.label)}});e.dataSource=t}},schema:t})))},x=n("505");function A(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 C(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{!i&&null!=o.return&&o.return()}finally{if(c)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return A(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 A(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.")}()}var k=function(){var e=(0,o.useRecord)(),t=S((0,i.useState)({}),2),n=t[0],a=t[1],s=(0,o.usePlugin)(l.default),p=(0,o.useCompile)(),d=S((0,i.useState)(!1),2),f=d[0],m=d[1],b=(0,u.useTranslation)().t,v=(0,o.useDataSourceManager)();return c().createElement("div",null,c().createElement(o.ActionContext.Provider,{value:{visible:f,setVisible:m}},"main"!==e.key&&c().createElement("a",{onClick:function(){m(!0);var t,n,o,i=s.types.get(e.type);a({type:"object",properties:(t={},n=(0,r.uid)(),o={type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:e},title:p("{{t('Edit')}}")+" - "+p(e.displayName),properties:{body:{type:"void","x-component":i.DataSourceSettingsForm},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},testConnectiion:{title:'{{ t("Test Connection",{ ns: "'.concat(y.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==i?void 0:i.disableTestConnection},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}}}}},n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o,t)})}},b("Edit")),c().createElement(o.SchemaComponent,{scope:{createOnly:!0,useUpdateAction:function(){var e=(0,x.useField)(),t=(0,x.useForm)(),n=(0,o.useActionContext)(),r=(0,o.useResourceActionContext)().refresh,a=(0,o.useResourceContext)().resource,i=(0,o.useRecord)().key;return{run:function(){var o;return(o=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,function(o){switch(o.label){case 0:return[4,t.submit()];case 1:o.sent(),e.data=e.data||{},e.data.loading=!0,o.label=2;case 2:return o.trys.push([2,5,6,7]),[4,a.update({filterByTk:i,values:t.values})];case 3:return o.sent(),n.setVisible(!1),v.getDataSource(i).setOptions(t.values),v.getDataSource(i).reload(),[4,t.reset()];case 4:return o.sent(),r(),[3,7];case 5:return console.log(o.sent()),[3,7];case 6:return e.data.loading=!1,[7];case 7:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){C(a,n,r,i,c,"next",e)}function c(e){C(a,n,r,i,c,"throw",e)}i(void 0)})})()}}}},schema:n})))},w=n("964"),D=n("128"),E=function(e){var t=e.key,n=e.type;return"/admin/settings/data-source-manager/".concat(t,"/collections?type=").concat(n)};function T(){var e,t,n=(e=["\n .ant-btn-link {\n &:hover {\n color: rgba(0, 0, 0, 0.25) !important;\n }\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return T=function(){return n},n}var P=function(){var e=(0,o.useRecord)(),t=(0,D.useNavigate)(),n=(0,u.useTranslation)().t;return c().createElement("div",{className:e.enabled?void 0:(0,w.css)(T())},c().createElement(a.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:function(){t(E(e))},role:"button","aria-label":"".concat(null==e?void 0:e.key,"-Configure")},n("Configure")))};function O(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 j(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function _(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){j(a,r,o,i,c,"next",e)}function c(e){j(a,r,o,i,c,"throw",e)}i(void 0)})}}function I(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return O(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 O(e,t)}}(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,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var R=function(){var e=(0,u.useTranslation)().t,t=(0,o.usePlugin)(l.default),n=I(t.types.keys()).map(function(n){var r=t.types.get(n);return{value:n,label:e(null==r?void 0:r.label)}}).concat([{value:"main",label:e("Main")}]),d=(0,o.useDataSourceManager)(),f=c().useRef([]);(0,i.useEffect)(function(){return function(){d.getDataSources().forEach(function(e){f.current.includes(e.key)&&e.reload()})}},[f]);var y=(0,i.useCallback)(function(e){d.removeDataSources(e)},[d]),m=(0,i.useCallback)(function(e){d.addDataSource(p.F,e),f.current=I(f.current).concat([e.key])},[]);return c().createElement(a.Card,{bordered:!1},c().createElement(o.SchemaComponent,{components:{CreateDatabaseConnectAction:g,EditDatabaseConnectionAction:k,ViewDatabaseConnectionAction:P},scope:{useNewId:function(e){return"".concat(e).concat((0,r.uid)())},types:n,useRefreshActionProps:function(){var e=(0,o.useResourceActionContext)();return{onClick:function(){return _(function(){var t,n,r,o,a;return F(this,function(i){switch(i.label){case 0:if(!(null==(r=null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data.filter(function(e){return"loaded"!==e.status}))?void 0:r.length))return[3,2];return o=d.getDataSources(),a=r.map(function(e){return e.key}),[4,Promise.all(o.filter(function(e){return a.includes(e.key)}).map(function(e){return e.reload()}))];case 1:i.sent(),i.label=2;case 2:return null==e||null===(n=e.refresh)||void 0===n||n.call(e),[2]}})})()}}},useDestroyAction:function(){var e=(0,o.useResourceActionContext)().refresh,t=(0,o.useResourceContext)().resource,n=(0,o.useRecord)().key;return{run:function(){return _(function(){return F(this,function(r){switch(r.label){case 0:return[4,t.destroy({filterByTk:n})];case 1:return r.sent(),y([n]),e(),[2]}})})()}}},dataSourceDeleteCallback:y,dataSourceCreateCallback:m,useIsAbleDelete:function(e){var t=(0,o.useRecord)().key;e.visible="main"!==t}},schema:s.j}))}},212:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return f}});var r=n(505),o=n(721),a=n(238),i=n(772),c=n(573);function u(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){u(a,r,o,i,c,"next",e)}function c(e){u(a,r,o,i,c,"throw",e)}i(void 0)})}}function s(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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}function p(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var d=function(e){var t=(0,r.useForm)(),n=(0,i.useActionContext)(),c=(0,i.useAPIClient)(),u=(0,a.useTranslation)().t,d=(0,r.useField)();return d.data=d.data||{},{run:function(){return l(function(){var r,a;return p(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,6]),d.data.loading=!0,[4,c.resource("databaseServers").create({values:s({},t.values)})];case 3:return r=i.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return i.sent(),null==e||e(null==r?void 0:r.data),o.message.success(u("Saved successfully")),[3,6];case 5:return a=i.sent(),d.data.loading=!1,console.log(a),[3,6];case 6:return[2]}})})()}}},f=function(){var e=(0,r.useForm)(),t=(0,i.useAPIClient)(),n=(0,a.useTranslation)().t,u=(0,r.useField)();return u.data=u.data||{},{run:function(){return l(function(){var r;return p(this,function(a){switch(a.label){case 0:return[4,e.submit()];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),u.data.loading=!0,[4,t.resource("dataSources").testConnection({values:s({},e.values)})];case 3:return a.sent(),u.data.loading=!1,o.message.success(n("Connection successful",{ns:c.A7})),[3,5];case 4:return r=a.sent(),u.data.loading=!1,console.log(r),[3,5];case 5:return[2]}})})()}}}},421:function(e,t,n){n.d(t,{$:function(){return u},j:function(){return s}});var r,o,a,i=n(875),c=n(573),u=[{value:"loading",label:'{{t("Loading",{ns:"'.concat(c.A7,'"})}}'),color:"orange"},{value:"loading-failed",label:'{{t("Failed",{ns:"'.concat(c.A7,'"})}}'),color:"red"},{value:"loaded",label:'{{t("Loaded",{ns:"'.concat(c.A7,'"})}}'),color:"green"},{value:"reloading",label:'{{t("Reloading",{ns:"'.concat(c.A7,'"})}}'),color:"orange"}],l={name:"collections-"+(0,i.uid)(),fields:[{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Data source name",{ ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Data source display name",{ ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Type", { ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Select",enum:"{{types}}"}},{type:"string",name:"status",interface:"select",uiSchema:{title:'{{t("Status", { ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Select",enum:u}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]};var s={type:"object",properties:(r={},o=(0,i.uid)(),a={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:l,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:l},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"},actionCallback:"{{ dataSourceDeleteCallback }}"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateDatabaseConnectAction","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{key:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},displayName:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{},properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"ViewDatabaseConnectionAction","x-component-props":{type:"primary"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditDatabaseConnectionAction","x-component-props":{type:"primary"},"x-reactions":["{{useIsAbleDelete($self)}}"]},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{useDestroyAction}}"},"x-reactions":["{{useIsAbleDelete($self)}}"]}}}}}}}}},o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,r)}}}]);
@@ -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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["630"],{994:function(e,t,n){n.r(t),n.d(t,{CurrentRolesContext:function(){return ei},DataSourcePermissionManager:function(){return el}});var r,o,a,c,i=n("875"),l=n("772"),u=n("721"),s=n("156"),p=n.n(s),m=n("60"),d=n("238");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 y(e,t,n,r,o,a,c){try{var i=e[a](c),l=i.value}catch(e){n(e);return}i.done?t(l):Promise.resolve(l).then(r,o)}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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}var v=(0,s.createContext)(null);v.displayName="PermissionContext";var x=function(e){var t,n,r,o,a=(0,l.useAPIClient)(),c=(0,l.useRecord)(),i=(0,d.useTranslation)().t,m=(0,s.useContext)(ei),x=m.snippets;null==x||x.forEach(function(e){m[e]=!0});var g=(t=(0,s.useState)(m),n=2,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 a=[],c=!0,i=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);c=!0);}catch(e){i=!0,r=e}finally{try{!c&&null!=o.return&&o.return()}finally{if(i)throw r}}return a}}(t,2)||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)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),h=g[0],O=g[1];return(0,s.useEffect)(function(){O(m)},[m]),p().createElement(v.Provider,{value:{currentDataSource:c,currentRecord:h,update:(o=(r=function(e,t){return function(e,t){var n,r,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}(this,function(e){switch(e.label){case 0:return[4,a.request({url:"dataSources/".concat(c.key,"/roles:update"),data:t.values,method:"post",params:{filterByTk:t.values.roleName}})];case 1:return e.sent(),O(b({},h,t.values)),u.message.success(i("Saved successfully")),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function c(e){y(a,n,o,c,i,"next",e)}function i(e){y(a,n,o,c,i,"throw",e)}c(void 0)})}),function(e,t){return o.apply(this,arguments)})}},e.children)},g=function(e){var t=(0,s.useContext)(ei),n=(0,l.useRecord)();return p().createElement(l.RecordContext_deprecated.Provider,{value:b({},t)},p().createElement(l.SchemaComponentOptions,{scope:{dataSourceKey:n.key}},e.children))},h=n("505");function O(e,t,n,r,o,a,c){try{var i=e[a](c),l=i.value}catch(e){n(e);return}i.done?t(l):Promise.resolve(l).then(r,o)}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C={type:"void","x-decorator":"RoleRecordProvider",properties:{block:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"dataSourcesCollections",targetKey:"name",filterTargetKey:"name",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Collection display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Collection name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Resource type")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Collection")}}',value:"collection",color:"green"},{label:'{{t("Association")}}',value:"association",color:"blue"}]}},{type:"string",name:"usingConfig",interface:"input",uiSchema:{title:'{{t("Permission policy")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Individual")}}',value:"resourceAction",color:"orange"},{label:'{{t("General")}}',value:"strategy",color:"default"}]}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}}]},association:{sourceKey:"name",targetKey:"name"},resourceName:"roles.dataSourcesCollections",request:{resource:"roles.dataSourcesCollections",action:"list",params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:"{{dataSourceKey}}"},sort:["sort"],appends:["fields"]}}},properties:(S(c={},(0,i.uid)(),{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}}),S(c,"table1",{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column0:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{usingConfig:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,n,r=(0,l.useRecord)(),o=(0,l.useActionContext)().visible,a=(0,s.useContext)(v).currentDataSource;var c=(0,l.useRequest)({resource:"roles.dataSourceResources",resourceOf:r.roleName,action:"get",params:{appends:["actions","actions.scope"],filterByTk:r.name,filter:{dataSourceKey:a.key,name:r.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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}({},e),n=(n={manual:!0},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t));return(0,s.useEffect)(function(){if(!r.exists){e.onSuccess({data:{}});return}o&&c.run()},[o,r.exists]),c}},title:'{{t("Configure permission")}}',properties:{usingActionsConfig:{title:'{{t("Permission policy")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:!1,enum:[{value:!1,label:'{{t("General")}}'},{value:!0,label:'{{t("Individual")}}'}],"x-reactions":{target:"actions",fulfill:{state:{hidden:"{{!$self.value}}"}}}},actions:{"x-component":"RolesResourcesActions","x-decorator":"FormItem"},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:function(){var e=(0,h.useForm)(),t=(0,l.useAPIClient)(),n=(0,l.useRecord)(),r=(0,l.useActionContext)(),o=(0,l.useResourceActionContext)().refresh,a=(0,s.useContext)(v).currentDataSource;return{run:function(){var c;return(c=function(){return function(e,t){var n,r,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}(this,function(c){switch(c.label){case 0:var i,l;return[4,t.resource("roles.dataSourceResources",n.roleName)[n.exists?"update":"create"]({filterByTk:n.name,filter:{dataSourceKey:a.key,name:n.name},values:(i=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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}({},e.values),l=null!=(l={name:n.name,dataSourceKey:a.key})?l:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(l)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(l)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(l,e))}),i)})];case 1:return c.sent(),r.setVisible(!1),o(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=c.apply(e,t);function a(e){O(o,n,r,a,i,"next",e)}function i(e){O(o,n,r,a,i,"throw",e)}a(void 0)})})()}}}}}}}}}}}}}}}}}),c)}}},P={name:"dataSources",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"number","x-component":"Input",required:!0}}]},w=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:P,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,showAnonymous:!0,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:P},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"PermissionProvider",title:'{{t("Configure permissions")}}',properties:{tabs1:{type:"void","x-component":"Tabs","x-component-props":{},properties: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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}({tab1:{type:"void",title:'{{t("General action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{role:{"x-component":"RoleConfigure"}}},tab2:{type:"void",title:'{{t("Action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{roleCollectionsSchema:C}}},e)}}}}}}}}}}}}}}}},j=(0,s.createContext)([]);j.displayName="AvailableActionsContext";var A=function(e){var t=(0,l.useRequest)({resource:"availableActions",action:"list"}),n=t.data;return t.loading?p().createElement(u.Spin,null):p().createElement(j.Provider,{value:null==n?void 0:n.data},e.children)},E=function(){return(0,s.useContext)(j)},k={designable:!1},R=function(){var e=(0,l.useRecord)(),t=(0,l.usePlugin)(m.default);return p().createElement("div",null,p().createElement(l.SchemaComponentContext.Provider,{value:k},p().createElement(A,null,p().createElement(l.SchemaComponent,{schema:w(t.getExtendedTabs()),components:{SettingCenterPermissionProvider:l.SettingCenterPermissionProvider,PermissionProvider:x},scope:{dataSourceKey:e.key}}))))},T=n("563");function D(e,t,n,r,o,a,c){try{var i=e[a](c),l=i.value}catch(e){n(e);return}i.done?t(l):Promise.resolve(l).then(r,o)}var F=function(){var e=(0,s.useContext)(v).update,t=(0,d.useTranslation)().t,n=(0,l.useRecord)().key;return p().createElement(l.SchemaComponent,{schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:function(e){var t=(0,l.useAPIClient)(),r=(0,s.useContext)(ei);return(0,l.useRequest)(function(){return t.resource("dataSources/".concat(n,"/roles")).get({filterByTk:r.name}).then(function(e){var t,n,r=null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data;return null===(n=r.snippets)||void 0===n||n.forEach(function(e){r[e]=!0}),{data:r}})},e)},effects:function(){var t,n;(0,T.onFieldChange)("*",(n=(t=function(t,n){return function(e,t){var n,r,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}(this,function(r){switch(r.label){case 0:if(!n.modified)return[2];return[4,e(t,n)];case 1:return r.sent(),[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function c(e){D(a,r,o,c,i,"next",e)}function i(e){D(a,r,o,c,i,"throw",e)}c(void 0)})}),function(e,t){return n.apply(this,arguments)}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},I=n("632"),N=n("467"),K=n("202");function B(){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 B=function(){return n},n}var V=(0,K.createStyles)(function(e){return(0,e.css)(B())});function M(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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}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 q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return{name:"dataSources/".concat(e,"/rolesResourcesScopes"),fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]}},z=function(){var e=(0,s.useContext)(ee).name,t=(0,l.useFormBlockContext)();return(0,s.useEffect)(function(){t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},$=function(e){var t=((0,l.useCollectionRecord)().data||{}).id,n=_(M({},e),{disabled:[1,2].includes(t)});return p().createElement(l.Action.Link,n)},L=function(e){var t=((0,l.useCollectionRecord)().data||{}).id,n=_(M({},e,(0,l.useDestroyActionProps)()),{disabled:[1,2].includes(t)});return p().createElement(l.Action.Link,n)},G=function(e){var t=q(e);return{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:t,resource:"dataSources/".concat(e,"/rolesResourcesScopes"),action:"list",params:{pageSize:20},useParams:function(){return{filter:{$or:[{resourceName:(0,s.useContext)(ee).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:"dataSources/".concat(e,"/rolesResourcesScopes"),collection:t},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":z,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":(0,l.withDynamicSchemaProps)(function(e){return p().createElement(l.FlagProvider,{isVariableParsedInOtherContext:!0},p().createElement(l.Filter,e))}),"x-use-component-props":function(){var e=(0,s.useContext)(ee);return{options:(0,l.useFilterFieldOptions)(e.fields)}},"x-component-props":{dynamicComponent:l.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":$,"x-component-props":{openMode:"drawer",icon:"EditOutlined"},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:"dataSources/".concat(e,"/rolesResourcesScopes"),collection:t,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":(0,l.withDynamicSchemaProps)(function(e){return p().createElement(l.FlagProvider,{isVariableParsedInOtherContext:!0},p().createElement(l.Filter,e))}),"x-use-component-props":function(){var e=(0,s.useContext)(ee);return{options:(0,l.useFilterFieldOptions)(e.fields)}},"x-component-props":{dynamicComponent:l.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-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-component":L}}}}}}}}},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 U(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 W=(0,s.createContext)(null);W.displayName="RolesResourcesScopesSelectedRowKeysContext";var H=function(e){var t,n,r=(t=(0,s.useState)([]),n=2,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 a=[],c=!0,i=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);c=!0);}catch(e){i=!0,r=e}finally{try{!c&&null!=o.return&&o.return()}finally{if(i)throw r}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return U(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 U(e,t)}}(t,n)||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];return p().createElement(W.Provider,{value:[o,a]},e.children)},J=function(e){var t,n=(0,s.useMemo)(function(){return(0,T.createForm)({values:{scope:e.value}})},[]),r=G(((null===(t=(0,l.useCollectionRecord)())||void 0===t?void 0:t.parentRecord.data)||{}).key);return p().createElement(l.FormProvider,{form:n},p().createElement(l.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:H},scope:{onChange:function(t){var n;null==e||null===(n=e.onChange)||void 0===n||n.call(e,t)}},schema:r}))};function Q(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 X(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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}function Y(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 Z=function(e){var t,n={};return null==e||null===(t=e.forEach)||void 0===t||t.call(e,function(e){e.name&&(n[e.name]=e,n[e.name].scope=(0,N.isEmpty)(e.scope)?null:e.scope)}),n},ee=(0,s.createContext)({});ee.displayName="RoleResourceCollectionContext";var et=(0,h.connect)(function(e){var t,n=V().styles,r=function(t){var n=t.map(function(e){return Y(X({},e),{scope:(0,N.isEmpty)(e.scope)?null:e.scope})});e.onChange(n)},o=(0,l.useRecord)(),a=E(),c=o.fields,i=(0,l.useCompile)(),s=(0,d.useTranslation)().t,m=Z((0,h.useField)().value||[]),f=function(e,t){var n,r=null==m?void 0:m[e];return!!r&&(null==r?void 0:null===(n=r.fields)||void 0===n?void 0:n.includes(t))},y=a.filter(function(e){return e.allowConfigureFields}),b=null==c?void 0:c.map(function(e){var t=X({},e),n=!0,r=!1,o=void 0;try{for(var a,c=y[Symbol.iterator]();!(n=(a=c.next()).done);n=!0){var i=a.value;t[i.name]=f(i.name,e.name)}}catch(e){r=!0,o=e}finally{try{!n&&null!=c.return&&c.return()}finally{if(r)throw o}}return t}),v=function(e){if(m[e])delete m[e];else{var t;m[e]={name:e,fields:null==c?void 0:null===(t=c.map)||void 0===t?void 0:t.call(c,function(e){return e.name})}}r(Object.values(m))},x=function(e,t){m[e]||v(e),m[e].scope=t,r(Object.values(m))},g={},O=!0,S=!1,C=void 0;try{for(var P,w=y[Symbol.iterator]();!(O=(P=w.next()).done);O=!0){var j,A,k=P.value;g[k.name]=(null==c?void 0:c.length)===(null==m?void 0:null===(A=m[k.name])||void 0===A?void 0:null===(j=A.fields)||void 0===j?void 0:j.length)}}catch(e){S=!0,C=e}finally{try{!O&&null!=w.return&&w.return()}finally{if(S)throw C}}return p().createElement("div",null,p().createElement(ee.Provider,{value:o},p().createElement(I.FormLayout,{layout:"vertical"},p().createElement(I.FormItem,{label:s("Action permission")},p().createElement(u.Table,{className:n,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:s("Action display name"),render:function(e){return i(e)}},{dataIndex:"onNewRecord",title:s("Action type"),render:function(e){return e?p().createElement(u.Tag,{color:"green"},s("Action on new records")):p().createElement(u.Tag,{color:"geekblue"},s("Action on existing records"))}},{dataIndex:"enabled",title:s("Allow"),render:function(e,t){return p().createElement(u.Checkbox,{checked:e,onChange:function(){v(t.name)}})}},{dataIndex:"scope",title:s("Data scope"),render:function(e,t){return!t.onNewRecord&&p().createElement(J,{value:e,onChange:function(e){x(t.name,e)}})}}],dataSource:null==a?void 0:a.map(function(e){var t=!1,n=null;return m[e.name]&&(t=!0,!e.onNewRecord&&(n=m[e.name].scope)),Y(X({},e),{enabled:t,scope:n})})})),p().createElement(I.FormItem,{label:s("Field permission")},p().createElement(u.Table,{className:n,pagination:!1,dataSource:b,columns:[{dataIndex:["uiSchema","title"],title:s("Field display name"),render:function(e,t){return i(e)||t.name}}].concat(function(e){if(Array.isArray(e))return Q(e)}(t=y.map(function(e){var t=null==g?void 0:g[e.name];return{dataIndex:e.name,title:p().createElement(p().Fragment,null,p().createElement(u.Checkbox,{checked:t,onChange:function(){var n,o=m[e.name]||{name:e.name};t?o.fields=[]:o.fields=null==c?void 0:null===(n=c.map)||void 0===n?void 0:n.call(c,function(e){return e.name}),m[e.name]=o,r(Object.values(m))}}),i(e.displayName)),render:function(t,n){return p().createElement(u.Checkbox,{checked:t,onChange:function(){var o=m[e.name]||{name:e.name},a=o.fields||[];if(t){var c=a.indexOf(n.name);a.splice(c,1)}else a.push(n.name);o.fields=a,m[e.name]=o,r(Object.values(m))}})}}}))||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 Q(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 Q(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.")}())})))))});function en(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 er=function(e){if(!e)return{};var t,n={};return null==e||null===(t=e.forEach)||void 0===t||t.call(e,function(e){var t,r,o=(t=e.split(":"),r=2,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 a=[],c=!0,i=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);c=!0);}catch(e){i=!0,r=e}finally{try{!c&&null!=o.return&&o.return()}finally{if(i)throw r}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return en(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 en(e,t)}}(t,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=o[0],c=o[1];n[a]=c||"all"}),n},eo=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},ea=(0,h.connect)(function(e){var t=e.onChange,n=E(),r=(0,l.useCompile)(),o=(0,d.useTranslation)().t,a=er((0,h.useField)().value);return p().createElement("div",null,p().createElement(u.Table,{size:"small",pagination:!1,rowKey:"name",columns:[{dataIndex:"displayName",title:o("Action display name"),render:function(e){return r(e)}},{dataIndex:"onNewRecord",title:o("Action type"),render:function(e){return e?p().createElement(u.Tag,{color:"green"},o("Action on new records")):p().createElement(u.Tag,{color:"geekblue"},o("Action on existing records"))}},{dataIndex:"enabled",title:o("Allow"),render:function(e,n){return p().createElement(u.Checkbox,{checked:e,onChange:function(r){e?delete a[n.name]:a[n.name]="all",t(eo(a))}})}},{dataIndex:"scope",title:o("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:o("All records"),value:"all"},{label:o("Own records"),value:"own"}],onChange:function(e){a[n.name]=e,t(eo(a))}})}}],dataSource:null==n?void 0:n.map(function(e){var t,n,r="all",o=!1;return a[e.name]&&(o=!0,r=a[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,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}({},e),n=(n={enabled:o,scope:r},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t})}))});var ec={type:"object",properties:(r={},o=(0,i.uid)(),a={"x-component":"DataSourceTable"},o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,r)},ei=(0,s.createContext)({});ei.displayName="CurrentRolesContext";var el=function(e){var t=e.role;return p().createElement(u.Card,{"data-testid":"acl-pane-card",bordered:!1},p().createElement(ei.Provider,{value:t},p().createElement(l.SchemaComponent,{components:{MenuConfigure:l.MenuConfigure,RoleConfigure:F,RolesResourcesActions:et,DataSourceTable:R,StrategyActions:ea,SettingsCenterConfigure:l.SettingsCenterConfigure,SettingCenterProvider:l.SettingCenterProvider,ResourceActionProvider:l.ResourceActionProvider,RoleRecordProvider:g},schema:ec})))}}}]);
@@ -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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["927"],{947:function(e,t,n){n.r(t),n.d(t,{DataSourceContext:function(){return l},DatabaseConnectionProvider:function(){return u}});var o=n(772),r=n(156),a=n.n(r),c=n(212);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}var l=(0,r.createContext)(null);l.displayName="DataSourceContext";var u=function(e){var t,n,u=(t=(0,r.useState)(null),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],c=!0,i=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);c=!0);}catch(e){i=!0,o=e}finally{try{!c&&null!=r.return&&r.return()}finally{if(i)throw o}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return i(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 i(e,t)}}(t,n)||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=u[0],p=u[1];return a().createElement(l.Provider,{value:{dataSource:s,setDataSource:p}},a().createElement(o.SchemaComponentOptions,{scope:c,components:{}},e.children))}},580:function(e,t,n){n.r(t),n.d(t,{BreadcumbTitle:function(){return d}});var o=n(482),r=n(772),a=n(721),c=n(156),i=n.n(c),l=n(128),u=n(947),s=n(573),p=n(421),d=function(){var e=(0,r.useApp)(),t=(0,l.useParams)().name,n=(0,r.useCompile)(),d=(0,r.useDataSourceManager)(),m=(d.getDataSource(t)||{}).displayName,y=(0,c.useContext)(u.DataSourceContext).dataSource,f=(0,c.useMemo)(function(){return y&&(null==y?void 0:y.name)===t?y:d.getDataSource(t)},[y,t]),b=(0,c.useMemo)(function(){var t=null==f?void 0:f.status,o=p.$.find(function(e){return e.value===t}),r=[{title:i().createElement(l.Link,{to:e.pluginSettingsManager.getRoutePath(s.A7)},(0,s.KQ)("Data source manager"))}];return f&&r.push({title:i().createElement(a.Space,null,i().createElement("span",null,n(m)),t&&i().createElement(a.Tag,{key:t,color:null==o?void 0:o.color},n(null==o?void 0:o.label)))}),r},[f]);return i().createElement(a.Breadcrumb,{separator:i().createElement(o.RightOutlined,null),items:b})}},212:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return m}});var o=n(505),r=n(721),a=n(238),c=n(772),i=n(573);function l(e,t,n,o,r,a,c){try{var i=e[a](c),l=i.value}catch(e){n(e);return}i.done?t(l):Promise.resolve(l).then(o,r)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function c(e){l(a,o,r,c,i,"next",e)}function i(e){l(a,o,r,c,i,"throw",e)}c(void 0)})}}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o,r,a;o=e,r=t,a=n[t],r in o?Object.defineProperty(o,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[r]=a})}return e}function p(e,t){var n,o,r,a,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,o=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){c.label=a[1];break}if(6===a[0]&&c.label<r[1]){c.label=r[1],r=a;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(a);break}r[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var d=function(e){var t=(0,o.useForm)(),n=(0,c.useActionContext)(),i=(0,c.useAPIClient)(),l=(0,a.useTranslation)().t,d=(0,o.useField)();return d.data=d.data||{},{run:function(){return u(function(){var o,a;return p(this,function(c){switch(c.label){case 0:return[4,t.submit()];case 1:c.sent(),c.label=2;case 2:return c.trys.push([2,5,,6]),d.data.loading=!0,[4,i.resource("databaseServers").create({values:s({},t.values)})];case 3:return o=c.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return c.sent(),null==e||e(null==o?void 0:o.data),r.message.success(l("Saved successfully")),[3,6];case 5:return a=c.sent(),d.data.loading=!1,console.log(a),[3,6];case 6:return[2]}})})()}}},m=function(){var e=(0,o.useForm)(),t=(0,c.useAPIClient)(),n=(0,a.useTranslation)().t,l=(0,o.useField)();return l.data=l.data||{},{run:function(){return u(function(){var o;return p(this,function(a){switch(a.label){case 0:return[4,e.submit()];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),l.data.loading=!0,[4,t.resource("dataSources").testConnection({values:s({},e.values)})];case 3:return a.sent(),l.data.loading=!1,r.message.success(n("Connection successful",{ns:i.A7})),[3,5];case 4:return o=a.sent(),l.data.loading=!1,console.log(o),[3,5];case 5:return[2]}})})()}}}},421:function(e,t,n){n.d(t,{$:function(){return l},j:function(){return s}});var o,r,a,c=n(875),i=n(573),l=[{value:"loading",label:'{{t("Loading",{ns:"'.concat(i.A7,'"})}}'),color:"orange"},{value:"loading-failed",label:'{{t("Failed",{ns:"'.concat(i.A7,'"})}}'),color:"red"},{value:"loaded",label:'{{t("Loaded",{ns:"'.concat(i.A7,'"})}}'),color:"green"},{value:"reloading",label:'{{t("Reloading",{ns:"'.concat(i.A7,'"})}}'),color:"orange"}],u={name:"collections-"+(0,c.uid)(),fields:[{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Data source name",{ ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Data source display name",{ ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Type", { ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Select",enum:"{{types}}"}},{type:"string",name:"status",interface:"select",uiSchema:{title:'{{t("Status", { ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Select",enum:l}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]};var s={type:"object",properties:(o={},r=(0,c.uid)(),a={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:u,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:u},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"},actionCallback:"{{ dataSourceDeleteCallback }}"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateDatabaseConnectAction","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{key:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},displayName:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{},properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"ViewDatabaseConnectionAction","x-component-props":{type:"primary"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditDatabaseConnectionAction","x-component-props":{type:"primary"},"x-reactions":["{{useIsAbleDelete($self)}}"]},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{useDestroyAction}}"},"x-reactions":["{{useIsAbleDelete($self)}}"]}}}}}}}}},r in o?Object.defineProperty(o,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[r]=a,o)}}}]);
@@ -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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["721"],{947:function(e,t,n){n.r(t),n.d(t,{DataSourceContext:function(){return s},DatabaseConnectionProvider:function(){return l}});var r=n(772),a=n(156),o=n.n(a),u=n(212);function c(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 s=(0,a.createContext)(null);s.displayName="DataSourceContext";var l=function(e){var t,n,l=(t=(0,a.useState)(null),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],u=!0,c=!1;try{for(a=a.call(e);!(u=(n=a.next()).done)&&(o.push(n.value),!t||o.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{!u&&null!=a.return&&a.return()}finally{if(c)throw r}}return o}}(t,2)||function(e,t){if(e){if("string"==typeof e)return c(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 c(e,t)}}(t,n)||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=l[0],f=l[1];return o().createElement(s.Provider,{value:{dataSource:i,setDataSource:f}},o().createElement(r.SchemaComponentOptions,{scope:u,components:{}},e.children))}},212:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return b}});var r=n(505),a=n(721),o=n(238),u=n(772),c=n(573);function s(e,t,n,r,a,o,u){try{var c=e[o](u),s=c.value}catch(e){n(e);return}c.done?t(s):Promise.resolve(s).then(r,a)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function u(e){s(o,r,a,u,c,"next",e)}function c(e){s(o,r,a,u,c,"throw",e)}u(void 0)})}}function i(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,a,o;r=e,a=t,o=n[t],a in r?Object.defineProperty(r,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[a]=o})}return e}function f(e,t){var n,r,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){u.label=o[1];break}if(6===o[0]&&u.label<a[1]){u.label=a[1],a=o;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(o);break}a[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var d=function(e){var t=(0,r.useForm)(),n=(0,u.useActionContext)(),c=(0,u.useAPIClient)(),s=(0,o.useTranslation)().t,d=(0,r.useField)();return d.data=d.data||{},{run:function(){return l(function(){var r,o;return f(this,function(u){switch(u.label){case 0:return[4,t.submit()];case 1:u.sent(),u.label=2;case 2:return u.trys.push([2,5,,6]),d.data.loading=!0,[4,c.resource("databaseServers").create({values:i({},t.values)})];case 3:return r=u.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return u.sent(),null==e||e(null==r?void 0:r.data),a.message.success(s("Saved successfully")),[3,6];case 5:return o=u.sent(),d.data.loading=!1,console.log(o),[3,6];case 6:return[2]}})})()}}},b=function(){var e=(0,r.useForm)(),t=(0,u.useAPIClient)(),n=(0,o.useTranslation)().t,s=(0,r.useField)();return s.data=s.data||{},{run:function(){return l(function(){var r;return f(this,function(o){switch(o.label){case 0:return[4,e.submit()];case 1:o.sent(),o.label=2;case 2:return o.trys.push([2,4,,5]),s.data.loading=!0,[4,t.resource("dataSources").testConnection({values:i({},e.values)})];case 3:return o.sent(),s.data.loading=!1,a.message.success(n("Connection successful",{ns:c.A7})),[3,5];case 4:return r=o.sent(),s.data.loading=!1,console.log(r),[3,5];case 5:return[2]}})})()}}}}}]);
@@ -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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["518"],{865:function(e,t,r){r.r(t),r.d(t,{CollectionMainProvider:function(){return i}});var n=r(156),a=r.n(n),o=r(772),u=r(128);function l(e,t,r,n,a,o,u){try{var l=e[o](u),i=l.value}catch(e){r(e);return}l.done?t(i):Promise.resolve(i).then(n,a)}var i=function(e){var t,r=(0,o.useAPIClient)(),i={url:"collectionCategories:list",params:{paginate:!1,sort:["sort"]}},c=(0,o.useRequest)(i);var s=(0,n.useCallback)((t=function(){var e;return function(e,t){var r,n,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){u.label=o[1];break}if(6===o[0]&&u.label<a[1]){u.label=a[1],a=o;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(o);break}a[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}(this,function(t){switch(t.label){case 0:return[4,r.request(i)];case 1:return e=t.sent().data,c.mutate(e),[2,(null==e?void 0:e.data)||[]]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function u(e){l(o,n,a,u,i,"next",e)}function i(e){l(o,n,a,u,i,"throw",e)}u(void 0)})}),[c]);return a().createElement(o.CollectionCategoriesProvider,{service:c,refreshCategory:s},a().createElement(u.Outlet,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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["833"],{227:function(e,t,n){n.d(t,{E:function(){return s}});var r=n(482),i=n(772),a=n(505),l=n(721),o=n(156),c=n.n(o),u=n(286),s=function(e){var t=(0,i.useCollectionRecordData)()||{},n=(0,i.useCompile)();return(0,a.useField)().editable?c().createElement(i.Input,e):(null==t?void 0:t.filterTargetKey)?n(t.title):c().createElement("div",{style:{display:"inline"}},c().createElement(l.Popover,{trigger:["click"],content:c().createElement(u.L,{size:"small",style:{width:"20em"}})},c().createElement(r.ExclamationCircleTwoTone,{style:{marginRight:"0.3em"},twoToneColor:"#faad14"})),n(t.title))}},648:function(e,t,n){n.d(t,{a:function(){return u}});var r=n(772),i=n(721),a=n(156),l=n.n(a),o=n(128),c=n(286),u=function(e){var t=e.collectionName,n=(0,r.useApp)(),u=(0,o.useParams)().name,s=void 0===u?"main":u,f=(0,a.useMemo)(function(){return n.getCollectionManager(s).getCollection(t)},[n,s,t]);return!(null==f?void 0:f.filterTargetKey)&&l().createElement(i.Alert,{style:{marginBottom:16},type:"warning",message:l().createElement(c.L,null)})}},286:function(e,t,n){n.d(t,{L:function(){return m}});var r=n(772),i=n(721),a=n(156),l=n.n(a),o=n(128),c=n(573),u=n(550);function s(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 f(e,t,n,r,i,a,l){try{var o=e[a](l),c=o.value}catch(e){n(e);return}o.done?t(c):Promise.resolve(c).then(r,i)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],l=!0,o=!1;try{for(i=i.call(e);!(l=(n=i.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){o=!0,r=e}finally{try{!l&&null!=i.return&&i.return()}finally{if(o)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(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 s(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.")}()}var m=function(e){var t,n=e.size,s=e.style,m=(0,r.useAPIClient)(),p=(0,o.useParams)().name,y=void 0===p?"main":p,h=(0,r.useCollectionRecordData)(),b=(0,r.useApp)(),g=d((0,a.useState)(),2),v=g[0],w=g[1],x=d((0,a.useState)(),2),E=x[0],S=x[1],C=(0,r.useCompile)(),A=(0,a.useMemo)(function(){return b.getCollectionManager(y).getCollection(h.name)},[b,y,h.name]),I=(0,a.useMemo)(function(){return b.getCollectionManager(y).getCollectionFields(h.name).filter(function(e){if(!e.interface)return!1;var t=b.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(e.interface);return(null==t?!!void 0:!!t.titleUsable)||!1}).map(function(e){var t;return{label:C(null===(t=e.uiSchema)||void 0===t?void 0:t.title),value:e.name}})},[b,C,y,h.name]),O=(0,r.useResourceActionContext)().refresh,k=(0,a.useContext)(u.I),F=(0,c.EL)().t;return l().createElement("div",{style: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,i,a;r=e,i=t,a=n[t],i in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a})}return e}({},s)},F("If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection."),"small"===n?l().createElement("br",null):" ",l().createElement(i.Space.Compact,{style:{marginTop:5}},l().createElement(i.Select,{onChange:function(e,t){console.log(e,t),w(e),S(t.map(function(e){return e.label}).join(","))},placeholder:F("Select field"),size:"small",options:I,mode:"multiple",style:{width:"200px"}}),l().createElement(i.Popconfirm,{placement:"bottom",title:l().createElement("div",{style:{width:"15em"}},E?F('Are you sure you want to set the "{{title}}" field as a record unique key? This setting cannot be changed after it\'s been set.',{title:E}):F("Please select a field.")),onConfirm:(t=function(){var e;return function(e,t){var n,r,i,a,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(i=(i=l.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){l.label=a[1];break}if(6===a[0]&&l.label<i[1]){l.label=i[1],i=a;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(a);break}i[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}(this,function(t){switch(t.label){case 0:if(!v)return[2];if("main"!==y)return[3,2];return[4,m.request({url:"collections:update?filterByTk=".concat(h.name),method:"post",data:{filterTargetKey:v}})];case 1:return t.sent(),[3,4];case 2:return[4,m.request({url:"dataSources/".concat(y,"/collections:update?filterByTk=").concat(h.name),method:"post",data:{filterTargetKey:v}})];case 3:t.sent(),t.label=4;case 4:return null==k||null===(e=k.refresh)||void 0===e||e.call(k),O(),[4,b.dataSourceManager.getDataSource(y).reload()];case 5:return t.sent(),A.setOption("filterTargetKey",v),[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,i){var a=t.apply(e,n);function l(e){f(a,r,i,l,o,"next",e)}function o(e){f(a,r,i,l,o,"throw",e)}l(void 0)})})},l().createElement(i.Button,{type:"primary",size:"small"},F("OK")))))}},550:function(e,t,n){n.d(t,{f:function(){return D},I:function(){return I}});var r=n("964"),i=n("563"),a=n("505"),l=n("772"),o=n("721"),c=n("156"),u=n.n(c),s=n("238"),f=n("648");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,i,a,l){try{var o=e[a](l),c=o.value}catch(e){n(e);return}o.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function l(e){m(a,r,i,l,o,"next",e)}function o(e){m(a,r,i,l,o,"throw",e)}l(void 0)})}}function y(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,i,a;r=e,i=t,a=n[t],i in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a})}return e}function h(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 b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a=[],l=!0,o=!1;try{for(i=i.call(e);!(l=(n=i.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){o=!0,r=e}finally{try{!l&&null!=i.return&&i.return()}finally{if(o)throw r}}return a}}(e,t)||v(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 g(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function v(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 w(e,t){var n,r,i,a,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(i=(i=l.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){l.label=a[1];break}if(6===a[0]&&l.label<i[1]){l.label=i[1],i=a;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(a);break}i[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}function x(){var e=g(["\n .ant-table {\n margin-left: -16px !important;\n }\n"]);return x=function(){return e},e}function E(){var e=g(["\n tr {\n display: flex;\n }\n td,\n th {\n flex: 2.3;\n width: 0;\n &:nth-child(5) {\n flex: 1.2;\n }\n &:last-child {\n flex: 1.5;\n }\n }\n .ant-table-selection-column,\n .ant-table-row-expand-icon-cell {\n flex-basis: 50px !important;\n min-width: 50px;\n flex: 0;\n }\n"]);return E=function(){return e},e}function S(){var e=g(["\n font-weight: 500;\n "]);return S=function(){return e},e}function C(){var e=g(["\n justify-content: flex-end;\n display: flex;\n margin-bottom: 16px;\n "]);return C=function(){return e},e}var A={association:{sourceKey:"name",targetKey:"name"},collection:{name:"fields",fields:[{type:"string",name:"type",interface:"input",uiSchema:{title:'{{ t("Storage type") }}',type:"string","x-component":"Select",enum:[{label:"String",value:"string"}],required:!0}},{type:"string",name:"interface",interface:"input",uiSchema:{title:'{{ t("Field interface") }}',type:"string","x-component":"Select",enum:"{{interfaces}}"}},{type:"string",name:"title",interface:"input",uiSchema:{title:'{{ t("Field display name") }}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Field name") }}',type:"string","x-component":"Input"}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input.TextArea"}}]},request:{resource:"collections.fields",action:"list",params:{paginate:!1,filter:{$or:[{"interface.$not":null},{"options.source.$notEmpty":!0}]},sort:["sort"]}}},I=(0,c.createContext)(null),O=function(e){return u().createElement(I.Provider,{value:(0,l.useResourceActionContext)()},u().createElement(l.ResourceActionProvider,A,e.children))},k=(0,r.css)(x()),F=(0,r.css)(E()),P="Default title for each record",T=function(e){var t=(0,l.useCompile)(),n=(0,l.useCollectionManager_deprecated)().getInterface,r=(0,s.useTranslation)().t,i=(0,l.useResourceActionContext)().setState,a=(e.collectionResource||{}).targetKey,f=(0,l.useRecord)(),d=b(u().useState(null),2),m=d[0],g=d[1],v=(0,l.useCollectionManager_deprecated)(),x=v.refreshCM,E=v.isTitleField,S=v.getTemplate,C=f[a],A=f.titleField,O=S(f.template),F=(0,l.useAPIClient)(),T=(0,c.useContext)(I),j=[{dataIndex:["uiSchema","title"],title:r("Field display name"),render:function(e){return u().createElement("div",{style:{marginLeft:7}},t(e))}},{dataIndex:"name",title:r("Field name")},{dataIndex:"interface",title:r("Field interface"),render:function(e){var r;return u().createElement(o.Tag,null,t(null===(r=n(e))||void 0===r?void 0:r.title))}},{dataIndex:"titleField",title:r("Title field"),render:function(t,n){var i,a=(i=p(function(t){var i;return w(this,function(a){switch(a.label){case 0:return g(n),[4,F.request({url:"collections:update?filterByTk=".concat(C),method:"post",data:{titleField:t?n.name:"id"}})];case 1:return a.sent(),null==T||null===(i=T.refresh)||void 0===i||i.call(T),[4,e.refreshAsync()];case 2:return a.sent(),g(null),x(),o.message.success(r("Saved successfully")),[2]}})}),function(e){return i.apply(this,arguments)});return E(n)?u().createElement(o.Tooltip,{title:r(P),placement:"right",overlayInnerStyle:{textAlign:"center"}},u().createElement(o.Switch,{"aria-label":"switch-title-field-".concat(n.name),size:"small",loading:n.name===(null==m?void 0:m.name),checked:n.name===(A||"id"),onChange:a})):null}},{dataIndex:"description",title:r("Descriptio "),render:function(e){return u().createElement(l.Input.ReadPretty,{value:e,ellipsis:!0})}},{dataIndex:"actions",title:r("Actions"),render:function(e,t){var n={confirm:{title:r("Delete record"),content:r("Are you sure you want to delete it?")},useAction:l.useDestroyActionAndRefreshCM,disabled:(0,l.isDeleteButtonDisabled)(t)||(null==O?void 0:O.forbidDeletion),title:r("Delete")};return u().createElement(l.RecordProvider,{record:t,parent:f},u().createElement(o.Space,{size:"middle"},u().createElement(l.EditCollectionField,{role:"button","aria-label":"edit-button-".concat(t.name),type:"primary"}),u().createElement(l.Action.Link,n)))}}];return u().createElement(o.Table,{rowKey:"name",columns:j,showHeader:!1,pagination:!1,dataSource:e.fields,rowSelection:{type:"checkbox",getCheckboxProps:function(e){return{"aria-label":"checkbox-".concat(e.name)}},onChange:function(e){i(function(t){return h(y({},t),{selectedRowKeys:e})})}},className:k})},j=function(e){var t=(0,l.useCompile)(),n=(0,l.useCollectionManager_deprecated)().getInterface,r=(e.collectionResource||{}).targetKey,i=(0,l.useRecord)(),a=b(u().useState(null),2),f=a[0],d=a[1],m=(0,s.useTranslation)().t,y=(0,l.useCollectionManager_deprecated)(),h=y.refreshCM,g=y.isTitleField,v=i[r],x=i.titleField,E=i.name,S=(0,c.useContext)(I),C=(0,l.useAPIClient)(),A=[{dataIndex:["uiSchema","rawTitle"],title:m("Field display name"),render:function(e){return u().createElement("div",{style:{marginLeft:1}},t(e))}},{dataIndex:"name",title:m("Field name")},{dataIndex:"interface",title:m("Field interface"),render:function(e){var r;return u().createElement(o.Tag,null,t(null===(r=n(e))||void 0===r?void 0:r.title))}},{dataIndex:"titleField",title:m("Title field"),render:function(t,n){var r,i=(r=p(function(t){var r;return w(this,function(i){switch(i.label){case 0:return d(n),[4,C.request({url:"collections:update?filterByTk=".concat(v),method:"post",data:{titleField:t?n.name:"id"}})];case 1:return i.sent(),null==S||null===(r=S.refresh)||void 0===r||r.call(S),[4,e.refreshAsync()];case 2:return i.sent(),d(null),h(),o.message.success(m("Saved successfully")),[2]}})}),function(e){return r.apply(this,arguments)});return g(n)?u().createElement(o.Tooltip,{title:m(P),placement:"right",overlayInnerStyle:{textAlign:"center"}},u().createElement(o.Switch,{size:"small",loading:n.name===(null==f?void 0:f.name),checked:n.name===(x||"id"),onChange:i})):null}},{dataIndex:"actions",title:m("Actions"),render:function(e,t){return u().createElement(l.RecordProvider,{record:t,parent:i},u().createElement(o.Space,null,u().createElement(l.OverridingCollectionField,{type:"primary",currentCollection:E}),u().createElement(l.ViewCollectionField,{type:"primary"})))}}];return u().createElement(o.Table,{rowKey:"name",columns:A,showHeader:!1,pagination:!1,dataSource:e.fields.filter(function(e){return e.interface})})},R=function(){var e,t=(0,l.useCompile)(),n=(0,a.useField)(),m=(0,l.useRecord)(),p=m.name,b=m.template,g=((0,l.useCurrentAppInfo)()||{data:{database:{}}}).data.database,w=(0,l.useCollectionManager_deprecated)(),x=w.getInterface,E=w.getInheritCollections,A=w.getCollection,I=w.getTemplate,O=(0,c.useMemo)(function(){return(0,i.createForm)()},[]),k=(0,l.useAttach)(O.createArrayField(h(y({},n.props),{basePath:""}))),P=(0,s.useTranslation)().t,R=(0,l.useResourceContext)(),D=(0,c.useContext)(l.ResourceActionContext),M=D.refreshAsync,K=D.data,_=I(b),q=E(p),z=[{dataIndex:"title",title:P("Field display name"),render:function(e){return u().createElement("div",{className:(0,r.css)(S())},e)}},{dataIndex:"name",title:P("Field name")},{dataIndex:"interface",title:P("Field interface")},{dataIndex:"titleField",title:P("Title field")},{dataIndex:"description",title:P("Description")},{dataIndex:"actions",title:P("Actions")}],B=(null==K?void 0:K.data)||[],L={pf:[],association:[],general:[],system:[]};B.forEach(function(e){if(e.primaryKey||e.isForeignKey)L.pf.push(e);else if(e.interface){var t=x(e.interface);(null==t?void 0:t.group)==="systemInfo"?L.system.push(e):(null==t?void 0:t.group)==="relation"?L.association.push(e):L.general.push(e)}});var N=[{key:"pf",title:P("PK & FK fields"),fields:L.pf},{key:"association",title:P("Association fields"),fields:L.association},{key:"general",title:P("General fields"),fields:L.general},{key:"system",title:P("System fields"),fields:L.system}];N.push.apply(N,function(e){if(Array.isArray(e))return d(e)}(e=q.map(function(e){var n=A(e);if(!!n)return{key:e,title:"".concat(P("Inherited fields")," - ")+t(null==n?void 0:n.title),inherit:!0,fields:(null==n?void 0:n.fields)||[]}}).filter(Boolean))||function(e){if("undefined"!=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.")}());var $=(0,c.useMemo)(function(){return{useAction:function(){return(0,l.useBulkDestroyActionAndRefreshCM)(!0)},title:P("Delete"),icon:"DeleteOutlined",disabled:null==_?void 0:_.forbidDeletion,confirm:{title:P("Delete record"),content:P("Are you sure you want to delete it?")}}},[P]);return u().createElement(a.FormContext.Provider,{value:O},u().createElement(a.FieldContext.Provider,{value:k},u().createElement(f.a,{collectionName:p}),u().createElement(o.Space,{align:"end",className:(0,r.css)(C())},u().createElement(l.Action,$),u().createElement(l.SyncFieldsAction,{type:"primary"}),u().createElement(l.SyncSQLFieldsAction,{refreshCMList:M}),u().createElement(l.SchemaComponent,{schema:{type:"object",properties:y({},_.configureActions)}}),u().createElement(l.AddCollectionField,{type:"primary",database:g})),u().createElement(o.Table,{rowKey:"key",columns:z,dataSource:N.filter(function(e){return e.fields.length}),pagination:!1,className:F,expandable:{defaultExpandAllRows:!0,defaultExpandedRowKeys:N.map(function(e){return e.key}),expandedRowRender:function(e){return e.inherit?u().createElement(j,{fields:e.fields,collectionResource:R,refreshAsync:M}):u().createElement(T,{fields:e.fields,collectionResource:R,refreshAsync:M})}}})))},D=function(){return u().createElement(O,null,u().createElement(R,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_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["542"],{185:function(e,t,n){n.r(t),n.d(t,{MainDataSourceManager:function(){return em}});var r,o,i,a,l=n("875"),c=n("156"),u=n.n(c),s=n("772"),p=n("563"),d=n("505"),f=n("229"),m=n("584"),y=n("238"),b=n("550"),v=n("721"),h=n("227");function g(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}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}var x=function(e){return d.Schema.compile(e,{t:s.i18n.t})},A={type:"object",properties:{block1:{type:"void","x-collection":"collections","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"collections",filterTargetKey:"name",targetKey:"name",sortable:!0,fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{ t("Collection display name") }}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Collection name") }}',type:"string","x-component":"Input",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'}},{type:"string",name:"template",interface:"input",uiSchema:{title:'{{ t("Collection Template") }}',type:"string","x-component":"Input"}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}},{type:"hasMany",name:"inherits",interface:"select",uiSchema:{title:'{{ t("Inherits") }}',type:"string","x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input"}}]},dragSort:!0,request:{resource:"collections",action:"list",params:{pageSize:50,sort:"sort",filter:{"hidden.$isFalsy":!0},appends:["category"]}}},properties:{tabs:{type:"void","x-component":"ConfigurationTabs"}}}}},S={type:"object",properties:(C(a={},(0,l.uid)(),{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button",isBulk:!0}},create:{type:"void",title:'{{ t("Create collection") }}',"x-component":"AddCollection","x-component-props":{type:"primary"}}}}),C(a,(0,l.uid)(),{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction:function(){var e=(0,s.useAPIClient)(),t=(0,y.useTranslation)().t;return{move:function(n,r){var o;return(o=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:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(o){switch(o.label){case 0:return[4,e.resource("collections").move({sourceId:n.name,targetId:r.name})];case 1:return o.sent(),v.message.success(t("Saved successfully"),.2),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){g(i,n,r,a,l,"next",e)}function l(e){g(i,n,r,a,l,"throw",e)}a(void 0)})})()}}}},properties:{column1:{type:"void",title:'{{t("Collection display name")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{"x-component":h.E,"x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Collection template")}}',properties:{template:{"x-component":s.CollectionTemplateTag,"x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-visible":"categoryVisible",title:'{{t("Collection category")}}',properties:{category:{"x-component":s.CollectionCategory,"x-read-pretty":!0}}},column5:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{"x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column6:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("Configure fields") }}',"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{destroyOnClose:!0,width:"70%"},"x-reactions":function(e){var t=e.path.segments[1],n=e.path.segments[0],r=e.form.getValuesIn("".concat(n,".").concat(t));r&&(e.title="".concat(x(r.title)," - ").concat(x('{{ t("Configure fields") }}')))},properties:{collectionFieldSchema:{type:"void","x-component":"CollectionFields"}}}}},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"EditCollection","x-component-props":{role:"button","aria-label":'{{ "edit-button-" + $record.name }}',type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button","aria-label":'{{ "delete-button-" + $record.name }}',type:"primary",className:"nb-action-link"}}}}}}}}),a)},w={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateCategry }}",style:{marginLeft:"8px"}}}}}}}}},O={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}};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 P(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){P(i,r,o,a,l,"next",e)}function l(e){P(i,r,o,a,l,"throw",e)}a(void 0)})}}function F(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:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var T=function(e,t){return function(n,r){n.loading=!0,e(n,r,t).then(f.action.bound(function(e){n.dataSource=e,n.loading=!1})).catch(console.error)}},D=function(){var e,t,n=(e=(0,c.useState)([]),t=2,function(e){if(Array.isArray(e))return e}(e)||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,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,2)||function(e,t){if(e){if("string"==typeof e)return E(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 E(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.")}());return[n[0],n[1]]},k=function(){var e=(0,s.useRecord)(),t=(0,d.useForm)();return{run:function(){return j(function(){var n,r,o,i;return F(this,function(a){return i=null===(o=t.values)||void 0===o?void 0:null===(r=o.children)||void 0===r?void 0:null===(n=r.slice)||void 0===n?void 0:n.call(r),t.setValuesIn("children",i.filter(function(t){return t.name!==e.name})),[2]})})()}}},I=function(){return{run:function(){return j(function(){return F(this,function(e){return[2]})})()}}},M=function(){var e=(0,s.useRecord)(),t=(0,s.useCollectionManager_deprecated)().getCollectionFields;return e.__parent&&"subTable"===e.__parent.interface?(0,c.useContext)(s.DataSourceContext_deprecated).dataSource:t(e.collectionName||e.name)},R=function(e){return"".concat(e||"").concat((0,l.uid)())},V=function(){var e,t,n,r,o,i=(0,y.useTranslation)().t,a=(0,s.useCollectionManager_deprecated)(),l=a.interfaces,p=a.getCollections,f=a.getCollection,v=((0,s.useCurrentAppInfo)()||{data:{database:{}}}).data.database,h=(0,c.useContext)(s.CollectionCategoriesContext),g=(0,s.useAPIClient)(),C=g.resource("dbViews"),x=(0,s.useCompile)();(0,d.useForm)();var S=(0,s.useApp)();var w=(e=j(function(e,t,n){var r,o,i;return F(this,function(a){return o=t.targetScope,i=(null===(r=e.props)||void 0===r?void 0:r.name)==="inherits",[2,p().filter(function(t){if(null==n?void 0:n.includes(t.template))return!1;if(t.autoCreate&&t.isThrough||i&&"view"===t.template||"target"===e.props.name&&Array.isArray(t.filterTargetKey)&&t.filterTargetKey.length>1)return!1;var r,a=!(null==o?void 0:o.template)||o.template.includes(t.template),l=!(null==o?void 0:o[null===(r=e.props)||void 0===r?void 0:r.name])||o[e.props.name].includes(t.name);return a&&l}).map(function(e){return{label:x(e.title),value:e.name}})]})}),function(t,n,r){return e.apply(this,arguments)});var O=(t=j(function(){return F(this,function(e){return[2,h.data.map(function(e){return{label:x(e.name),value:e.id}})]})}),function(){return t.apply(this,arguments)});var E=(n=j(function(){return F(this,function(e){return[2,C.list().then(function(e){var t,n=e.data;return null==n?void 0:null===(t=n.data)||void 0===t?void 0:t.map(function(e){var t=e.schema;return{label:t?"".concat(t,".").concat(x(e.name)):e.name,value:t?"".concat(t,"_").concat(e.name):e.name}})})]})}),function(){return n.apply(this,arguments)});var P=(r=j(function(e){var t,n,r;return F(this,function(o){return n=(t=e.form.values).name,r=t.fields,[2,Promise.resolve({data:(f(n)||{}).fields||r}).then(function(e){var t;return null===(t=e.data.filter(function(e){return!!e.interface&&(!!S.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(e.interface).titleUsable||!1)}))||void 0===t?void 0:t.map(function(e){var t;return{label:x(null===(t=e.uiSchema)||void 0===t?void 0:t.title)||e.name,value:e.name}})})]})}),function(e){return r.apply(this,arguments)});var V=(o=j(function(){return F(this,function(e){return[2,g.resource("storages").list().then(function(e){var t,n=e.data;return null==n?void 0:null===(t=n.data)||void 0===t?void 0:t.map(function(e){return{label:i(x(e.title)),value:e.name}})})]})}),function(){return o.apply(this,arguments)}),_=(0,c.useContext)(s.SchemaComponentContext),$=(0,c.useMemo)(function(){var e,t;return e=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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},_),t=(t={designable:!1},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},[_]);return u().createElement(s.SchemaComponentContext.Provider,{value:$},u().createElement(s.SchemaComponent,{schema:A,components:{AddSubFieldAction:s.AddSubFieldAction,EditSubFieldAction:s.EditSubFieldAction,FieldSummary:s.FieldSummary,TemplateSummay:s.TemplateSummary,CollectionFields:b.f},scope:{loadFilterTargetKeys:P,useDestroySubField:k,useBulkDestroySubField:I,useSelectedRowKeys:D,useAsyncDataSource:T,loadCollections:w,loadCategories:O,loadDBViews:E,loadStorages:V,useCurrentFields:M,useNewId:R,useCancelAction:s.useCancelAction,interfaces:l,enableInherits:(null==v?void 0:v.dialect)==="postgres",isPG:(null==v?void 0:v.dialect)==="postgres",getPickerFormat:m.getPickerFormat}}))},_=n("482"),$=n("948"),K=n("467"),q=n.n(K);function B(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 N(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function G(e){return 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,l,"next",e)}function l(e){N(i,r,o,a,l,"throw",e)}a(void 0)})}}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(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){L(e,t,n[t])})}return e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||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,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return B(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 B(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 Q(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:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function Z(e){var t=(0,$.useDraggable)({id:e.id,data:e.data}),n=t.attributes,r=t.listeners,o=t.setNodeRef;return u().createElement("div",U({ref:o},r,n),u().createElement("div",null,e.children))}function H(e){var t=(0,$.useDroppable)({id:e.id,data:e.data}),n=t.isOver,r=t.setNodeRef;return u().createElement("div",{ref:r,style:n?{color:"green"}:void 0},e.children)}var J=(0,d.observer)(function(e){var t=e.item;return u().createElement(H,{id:t.id.toString(),data:t},u().createElement("div",null,u().createElement(Z,{id:t.id.toString(),data:t},u().createElement(W,{item:t}))))},{displayName:"TabTitle"}),W=function(e){var t=e.item,n=(0,y.useTranslation)().t,r=(0,s.useCompile)();return u().createElement(v.Space,null,u().createElement(v.Badge,{color:t.color}),n(r(t.name)))},X=(0,d.observer)(function(e){var t,n=z((0,c.useState)(null),2),r=n[0],o=n[1],i=(0,c.useContext)(s.CollectionCategoriesContext).refresh,a=(0,s.useResourceActionContext)().refresh,l=(0,s.useAPIClient)();var p=(t=G(function(e){var t,n;return Q(this,function(r){switch(r.label){case 0:if(t=e.active,n=e.over,setTimeout(function(){o(null)}),!(n&&n.id!==t.id))return[3,4];return[4,l.resource("collectionCategories").move({sourceId:t.id,targetId:n.id})];case 1:return r.sent(),[4,i()];case 2:return r.sent(),[4,a()];case 3:r.sent(),r.label=4;case 4:return[2]}})}),function(e){return t.apply(this,arguments)}),d=(0,$.useSensor)($.MouseSensor,{activationConstraint:{distance:10}}),f=(0,$.useSensors)(d);return u().createElement($.DndContext,{sensors:f,onDragEnd:p,onDragStart:function(e){var t;o(null===(t=e.active)||void 0===t?void 0:t.data.current)}},e.children,u().createElement($.DragOverlay,null,r?u().createElement("span",{style:{whiteSpace:"nowrap"}},u().createElement(W,{item:r})):null))},{displayName:"DndProvider"}),Y=function(){var e,t=(0,y.useTranslation)().t,n=(0,c.useContext)(s.CollectionCategoriesContext),r=n.data,o=n.refresh,i=(0,s.useResourceActionContext)(),a=i.refresh,p=i.run,f=i.defaultRequest,m=i.setState,h=z((0,c.useState)({tab:"all"}),2),g=h[0],C=h[1],x=z((0,c.useState)(g.tab),2),A=x[0],w=x[1],O=(0,s.useCompile)(),E=(0,s.useAPIClient)(),P=v.App.useApp().modal,j=(0,c.useMemo)(function(){if(!r)return[];var e=r.sort(function(e,t){return t.sort-e.sort}).concat().map(function(e){var t,n;return t=U({},e),n=(n={schema:S},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t});return e.find(function(e){return"all"===e.id})||e.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:S}),e},[r]);(0,c.useEffect)(function(){"all"!==g.tab&&F(g.tab)},[]);var F=function(e){if(C({tab:e}),w((0,l.uid)()),"all"!==e){var t,n={$and:[null==f?void 0:null===(t=f.params)||void 0===t?void 0:t.filter,{"category.id":e}]};p({filter:n}),null==m||m({category:[+e],params:[{filter:n}]})}else p(),null==m||m({category:[],params:[]})},T=function(e){P.confirm({title:O("{{t('Delete category')}}"),content:O("{{t('Are you sure you want to delete it?')}}"),onOk:G(function(){return Q(this,function(t){switch(t.label){case 0:return[4,E.resource("collectionCategories").destroy({filter:{id:e}})];case 1:return t.sent(),e===+g.tab&&C({tab:"all"}),[4,o()];case 2:return t.sent(),[4,a()];case 3:return t.sent(),[2]}})})})};var D=(e=G(function(){return Q(this,function(e){return[2,r.map(function(e){return{label:t(O(e.name)),value:e.id}})]})}),function(){return e.apply(this,arguments)}),k=q().memoize(function(e){return{items:[{key:"edit",label:u().createElement(s.SchemaComponent,{schema:{type:"void",properties:L({},(0,l.uid)(),{"x-component":"EditCategory","x-component-props":{item:e}})}})},{key:"delete",label:O("{{t('Delete category')}}"),onClick:function(){return T(e.id)}}]}});return r?u().createElement(X,null,u().createElement(v.Tabs,{addIcon:u().createElement(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:F,defaultActiveKey:g.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:j.map(function(e){return{label:"all"!==e.id?u().createElement("div",{"data-no-dnd":"true"},u().createElement(J,{item:e})):O(e.name),key:String(e.id),closable:e.closable,closeIcon:u().createElement(v.Dropdown,{menu:k(e)},u().createElement(_.MenuOutlined,{role:"button","aria-label":O(e.name),style:{padding:8,margin:"-8px"}})),children:u().createElement(v.Card,{bordered:!1},u().createElement(s.SchemaComponentOptions,{components:{CollectionFields:b.f},inherit:!0,scope:{loadCategories:D,categoryVisible:"all"===e.id,categoryId:e.id}},u().createElement(d.RecursionField,{name:A,schema:e.schema,onlyRenderProperties:!0})))}})})):null};function ee(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 et(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function en(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var er=function(){var e=(0,d.useForm)(),t=(0,s.useActionContext)(),n=(0,c.useContext)(s.CollectionCategoriesContext).refresh,r=(0,s.useAPIClient)();return{run:function(){var o;return(o=function(){var o;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:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(i){switch(i.label){case 0:return[4,e.submit()];case 1:return i.sent(),o=(0,K.cloneDeep)(e.values),[4,r.resource("collectionCategories").create({values:en({},o)})];case 2:return i.sent(),t.setVisible(!1),[4,e.reset()];case 3:return i.sent(),[4,n()];case 4:return i.sent(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){et(i,n,r,a,l,"next",e)}function l(e){et(i,n,r,a,l,"throw",e)}a(void 0)})})()}}},eo=function(e){return u().createElement(ei,e)},ei=function(e){var t,n,r=e.scope,o=e.getContainer,i=e.children;var a=(t=(0,c.useState)(!1),n=2,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,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return ee(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 ee(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=a[0],p=a[1],d=(0,y.useTranslation)().t;return u().createElement(s.ActionContextProvider,{value:{visible:l,setVisible:p}},u().createElement("div",{onClick:function(){return p(!0)},title:d("Add category")},i||u().createElement(_.PlusOutlined,null)),u().createElement(s.SchemaComponent,{schema:w,components:{CollectionCategory:s.CollectionCategory,CollectionTemplateTag:s.CollectionTemplateTag},scope:en({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateCategry:er},r)}))};function ea(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 el(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function ec(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var eu=function(){var e=(0,d.useForm)(),t=(0,s.useActionContext)(),n=(0,c.useContext)(s.CollectionCategoriesContext).refresh,r=(0,s.useResourceActionContext)().refresh,o=(0,s.useAPIClient)(),i=(0,s.useRecord)().id;return{run:function(){var a;return(a=function(){var a;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:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(l){switch(l.label){case 0:return[4,e.submit()];case 1:return l.sent(),a=(0,K.cloneDeep)(e.values),[4,o.resource("collectionCategories").update({filter:{id:i},values:ec({},a)})];case 2:return l.sent(),t.setVisible(!1),[4,e.reset()];case 3:return l.sent(),[4,n()];case 4:return l.sent(),[4,r()];case 5:return l.sent(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=a.apply(e,t);function i(e){el(o,n,r,i,l,"next",e)}function l(e){el(o,n,r,i,l,"throw",e)}i(void 0)})})()}}},es=function(e){var t,n,r=(0,s.useRecord)();var o=(0,s.useRequest)(function(){return Promise.resolve({data:(0,K.cloneDeep)(r)})},(t=ec({},e),n=(n={manual:!0},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)),i=(0,s.useActionContext)();return(0,c.useEffect)(function(){i.visible&&o.run()},[i.visible]),o},ep=function(e){return u().createElement(ed,e)},ed=function(e){var t,n,r=e.scope,o=e.getContainer,i=e.item,a=e.children;var l=(t=(0,c.useState)(!1),n=2,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,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return ea(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 ea(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=l[0],d=l[1],f=(0,s.useCompile)();return u().createElement(s.RecordProvider,{record:i},u().createElement(s.ActionContextProvider,{value:{visible:p,setVisible:d}},u().createElement(u().Fragment,null,a||u().createElement("span",{onClick:function(){return d(!0)}},f('{{ t("Edit category") }}'))),u().createElement(s.SchemaComponent,{schema:O,scope:ec({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:eu,useValuesFromRecord:es},r)})))};(0,p.registerValidateFormats)({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});var ef={type:"object",properties:(r={},o=(0,l.uid)(),i={"x-component":"ConfigurationTable"},o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,r)},em=function(){return u().createElement(s.SchemaComponent,{schema:ef,components:{CollectionCategoriesProvider:s.CollectionCategoriesProvider,ConfigurationTable:V,ConfigurationTabs:Y,AddFieldAction:s.AddFieldAction,AddCollectionField:s.AddCollectionField,AddCollection:s.AddCollection,AddCollectionAction:s.AddCollectionAction,AddCategoryAction:ei,AddCategory:eo,EditCollection:s.EditCollection,EditCollectionAction:s.EditCollectionAction,DeleteCollection:s.DeleteCollection,DeleteCollectionAction:s.DeleteCollectionAction,EditFieldAction:s.EditFieldAction,EditCollectionField:s.EditCollectionField,OverridingCollectionField:s.OverridingCollectionField,OverridingFieldAction:s.OverridingFieldAction,ViewCollectionField:s.ViewCollectionField,ViewFieldAction:s.ViewFieldAction,EditCategory:ep,EditCategoryAction:ed,SyncFieldsAction:s.SyncFieldsAction,SyncFieldsActionCom:s.SyncFieldsActionCom,SyncSQLFieldsAction:s.SyncSQLFieldsAction}})}}}]);