@nocobase/plugin-data-source-manager 1.8.0-alpha.1 → 1.8.0-alpha.11

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([["47"],{473: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(611);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=(t=(0,r.useState)(null),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),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,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=n[0],s=n[1];return a().createElement(l.Provider,{value:{dataSource:u,setDataSource:s}},a().createElement(o.SchemaComponentOptions,{scope:c,components:{}},e.children))}},36: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(473),s=n(748),p=n(933),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})}},611:function(e,t,n){n.r(t),n.d(t,{addDatasourceCollections:function(){return b},useCreateDatabaseServer:function(){return m},useLoadCollections:function(){return f},useTestConnectionAction:function(){return y}});var o,r=n(505),a=n(721),c=n(238),i=n(772),l=n(748);function u(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 s(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function c(e){u(a,o,r,c,i,"next",e)}function i(e){u(a,o,r,c,i,"throw",e)}c(void 0)})}}function p(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;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function d(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){var l=[a,i];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return c.label++,{value:l[1],done:!1};case 5:c.label++,o=l[1],l=[0];continue;case 7:l=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){c=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){c.label=l[1];break}if(6===l[0]&&c.label<r[1]){c.label=r[1],r=l;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(l);break}r[2]&&c.ops.pop(),c.trys.pop();continue}l=t.call(e,c)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var m=function(e){var t=(0,r.useForm)(),n=(0,i.useActionContext)(),o=(0,i.useAPIClient)(),l=(0,c.useTranslation)().t,u=(0,r.useField)();return u.data=u.data||{},{run:function(){return s(function(){var r,c;return d(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]),u.data.loading=!0,[4,o.resource("databaseServers").create({values:p({},t.values)})];case 3:return r=i.sent().data,u.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return i.sent(),null==e||e(null==r?void 0:r.data),a.message.success(l("Saved successfully")),[3,6];case 5:return c=i.sent(),u.data.loading=!1,console.log(c),[3,6];case 6:return[2]}})})()}}},y=function(){var e=(0,r.useForm)(),t=(0,i.useAPIClient)(),n=(0,c.useTranslation)().t,o=(0,r.useField)();return o.data=o.data||{},{run:function(){return s(function(){var r;return d(this,function(c){switch(c.label){case 0:return[4,e.submit()];case 1:c.sent(),c.label=2;case 2:return c.trys.push([2,4,,5]),o.data.loading=!0,[4,t.resource("dataSources").testConnection({values:p({},e.values)})];case 3:return c.sent(),o.data.loading=!1,a.message.success(n("Connection successful",{ns:l.A7})),[3,5];case 4:return r=c.sent(),o.data.loading=!1,console.log(r),[3,5];case 5:return[2]}})})()}}},f=function(){var e,t=(0,i.useAPIClient)();return e=s(function(e){return d(this,function(n){switch(n.label){case 0:return[4,t.request({url:"dataSources/".concat(e,"/collections:all"),method:"get"})];case 1:return[2,n.sent().data]}})}),function(t){return e.apply(this,arguments)}},b=(o=s(function(e,t,n){var o,r,a,c,i,l,u,s,p,m,y;return d(this,function(d){switch(d.label){case 0:if(o="dataSources/".concat(t,"/collections:add"),r=n.collections,a=n.dbOptions,!r.length)return[3,2];c=[],i=!0,l=!1,u=void 0;try{for(s=r[Symbol.iterator]();!(i=(p=s.next()).done);i=!0)y=(m=p.value).name,m.selected&&c.push(y)}catch(e){l=!0,u=e}finally{try{i||null==s.return||s.return()}finally{if(l)throw u}}return[4,e.request({url:o,method:"post",data:{dbOptions:a,collections:c}})];case 1:d.sent(),d.label=2;case 2:return[2]}})}),function(e,t,n){return o.apply(this,arguments)})},933:function(e,t,n){n.d(t,{$:function(){return l},j:function(){return s}});var o,r,a,c=n(875),i=n(748),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"}}]},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([["252"],{259:function(e,t,n){n.r(t),n.d(t,{DatabaseConnectionManagerPane:function(){return U}});var r=n(875),o=n(772),a=n(721),l=n(156),i=n.n(l),c=n(238),u=n(636),s=n(933),p=n(864),d=n(482),f=n(611),m=n(748),y=n(505);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 v(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function g(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 C(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(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.")}()}var x=(0,y.observer)(function(e){var t,n,r,c,u,s=(0,o.useAPIClient)(),p=C((0,l.useState)(!1),2),f=p[0],m=p[1],y=C((0,l.useState)(""),2),b=y[0],x=y[1],A=C((0,l.useState)([]),2),S=A[0],w=A[1],k=C((0,l.useState)(new Map),2),E=k[0],D=k[1],O=C((0,l.useState)(!1),2),T=O[0],P=O[1],j=(0,l.useRef)(),I=e.NAMESPACE,M=e.t,q=(null==(r=e.formValues)||null==(n=r.options)?void 0:n.addAllCollections)===void 0||(null==(u=e.formValues)||null==(c=u.options)?void 0:c.addAllCollections),F=C((0,l.useState)(q),2),V=F[0],_=F[1];(0,l.useMemo)(function(){return b.trim()?S.filter(function(e){var t;return null==(t=e.name)?void 0:t.toLowerCase().includes(b.toLowerCase())}):S},[S,b]);var R=(0,l.useMemo)(function(){var t=e.value&&e.value.length>0?e.value:S;return b.trim()?t.filter(function(e){var t;return null==(t=e.name)?void 0:t.toLowerCase().includes(b.toLowerCase())}):t},[e.value,S,b]),$=(0,l.useMemo)(function(){return e.value&&e.value.length>0?e.value:S},[e.value,S]),L=(0,l.useMemo)(function(){return R.map(function(e){return g(h({},e),{selected:E.get(e.name)||e.required||T})})},[R,E,T]);(0,l.useEffect)(function(){if($.length>0){var e=new Map;$.forEach(function(t){t.selected&&e.set(t.name,!0)}),D(e),P(!1)}},[$.length]);var N=(0,l.useCallback)(function(t){_(t),e.formSetValues&&e.formSetValues("options.addAllCollections",t)},[e.formSetValues]),B=(0,l.useCallback)((t=function(){var t,n,r,o,l,i,c,u,p;return function(e,t){var n,r,o,a,l={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){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(d){switch(d.label){case 0:if(t=e.dataSourceKey,n=e.formValues,r=e.onChange,o=e.from,l=(null==n?void 0:n.options)||{},i=M("is required"),"oracle"!==n.type){if(!t)return a.message.error(M("Data source name",{ns:I})+i),[2];if(!l.host)return a.message.error(M("Host",{ns:I})+i),[2];if(!l.port)return a.message.error(M("Port",{ns:I})+i),[2];if(!l.database)return a.message.error(M("Database",{ns:I})+i),[2];if(!l.username)return a.message.error(M("Username",{ns:I})+i),[2]}m(!0),d.label=1;case 1:return d.trys.push([1,3,4,5]),c={isFirst:"create"===o,dbOptions:g(h({},l),{type:n.type||"mysql"})},[4,s.request({url:"dataSources/".concat(t,"/collections:all"),method:"get",params:c})];case 2:return w(p=((null==(u=d.sent())?void 0:u.data)||{}).data||[]),r&&r(p),e.field&&e.field.form&&e.field.form.setValuesIn("collections",p),[3,5];case 3:return console.error("Error loading collections:",d.sent()),a.message.error(M("Failed to load collections",{ns:I})),[3,5];case 4:return m(!1),[7];case 5:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function l(e){v(a,r,o,l,i,"next",e)}function i(e){v(a,r,o,l,i,"throw",e)}l(void 0)})}),[e.dataSourceKey,e.formValues,e.options,e.from,s,M,I]),z=(0,l.useCallback)(function(e){j.current&&clearTimeout(j.current),j.current=setTimeout(function(){x(e)},300)},[]);(0,l.useEffect)(function(){return function(){j.current&&clearTimeout(j.current)}},[]);var U=(0,l.useMemo)(function(){var e=$.filter(function(e){return E.get(e.name)||e.required}).length,t=L.filter(function(e){return!e.required}),n=L.filter(function(e){return e.selected||e.required}).length;return{isAllSelected:t.length>0&&n===L.length,isIndeterminate:n>0&&n<L.length,selectedCount:e,isAtLimit:e>=100}},[L,$,E]),G=U.isAllSelected,K=U.isIndeterminate,H=U.selectedCount,W=U.isAtLimit,J=(0,l.useCallback)(function(t){if(t){var n=$.filter(function(e){return E.get(e.name)||e.required}).length,r=R.filter(function(e){return!e.required&&!E.get(e.name)}).length;if(n>=100)return;r>100-n&&a.message.warning(M("Maximum selection limit exceeded. To ensure system performance, you can select up to {{limit}} collections.",{ns:I,limit:100}))}P(t);var o=function(){var n,r=new Map(E),o=0,a=100-$.filter(function(e){return E.get(e.name)||e.required}).length;R.forEach(function(e){!e.required&&(t?o<a&&!E.get(e.name)&&(r.set(e.name,!0),o++):r.delete(e.name))}),D(r);var l=$.map(function(e){return g(h({},e),{selected:r.get(e.name)||e.required||!1})});null==(n=e.onChange)||n.call(e,l),P(!1)};if("undefined"!=typeof MessageChannel){var l=new MessageChannel;l.port2.onmessage=function(){return o()},l.port1.postMessage(null)}else setTimeout(o,0)},[R,$,E,e.onChange,M,I]),Q=(0,l.useCallback)(function(t,n){var r=L[t];if(r&&r.selected!==n){if(n){var o=$.filter(function(e){return E.get(e.name)||e.required}).length;if(o>=100)return;o+1===100&&a.message.warning(M("Maximum selection limit reached. To ensure system performance, you can select up to {{limit}} collections at once.",{ns:I,limit:100}))}var l=new Map(E);n?l.set(r.name,!0):(l.delete(r.name),P(!1)),D(l),setTimeout(function(){var t,n=$.map(function(e){return g(h({},e),{selected:l.get(e.name)||e.required||!1})});null==(t=e.onChange)||t.call(e,n)},0)}},[L,$,E,e.onChange,M,I]),X=(0,l.useCallback)(function(e){z(e)},[z]),Y=(0,l.useCallback)(function(){x(""),j.current&&clearTimeout(j.current)},[]),Z=(0,l.useCallback)(function(){D(new Map),P(!1);var t,n=$.map(function(e){return g(h({},e),{selected:e.required||!1})});null==(t=e.onChange)||t.call(e,n)},[$,e.onChange]),ee=(0,l.useMemo)(function(){var e=i().memo(function(e){var t=e.selected,n=e.required,r=e.index,o=e.onChange,l=(e.name,e.disabled);return i().createElement(a.Checkbox,{checked:n||t,disabled:n||l,onChange:function(e){return o(r,e.target.checked)}})}),t=i().memo(function(e){var t=e.text;return i().createElement("span",{style:{paddingLeft:"40px"}},t)}),n=[{title:i().createElement("div",{style:{textAlign:"center"}},M("Display name",{ns:I})),dataIndex:"name",key:"name",align:"left",width:"50%",render:function(e){return i().createElement(t,{text:e})}}];if(!V){var r=H>=90,o=$.filter(function(e){return E.get(e.name)||e.required}).length,l=L.filter(function(e){return!e.selected&&!e.required}).length;n.push({title:i().createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4}},i().createElement(a.Checkbox,{checked:G,indeterminate:K,disabled:W&&!G&&!(o+l<=100),onChange:function(e){return J(e.target.checked)}}),i().createElement("span",{style:r?{color:"#ff7a00"}:{}},M("Add",{ns:I})," (",H,"/",$.length,")"),H>0&&i().createElement(a.Tooltip,{title:M("Reset selection",{ns:I})},i().createElement(a.Button,{type:"text",size:"small",icon:i().createElement(d.ClearOutlined,null),onClick:Z,style:{padding:"0 4px",height:"16px",minWidth:"16px",fontSize:"12px",color:"#666"}}))),dataIndex:"selected",key:"selected",align:"center",width:"30%",render:function(t,n,r){var o=W&&!t&&!n.required;return i().createElement(e,{selected:t,required:n.required,index:r,name:n.name,disabled:o,onChange:Q})}})}return n},[M,G,K,J,Q,V,I,H,$.length,W,E,L,Z]);return i().createElement("div",null,i().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"8px 0"}},i().createElement("div",null,i().createElement(a.Checkbox,{checked:V,onChange:function(e){return N(e.target.checked)}},M("Add all collections",{ns:I}))),i().createElement(a.Input.Search,{placeholder:M("Search collection name",{ns:I}),allowClear:!0,style:{width:250},onSearch:X,onChange:function(e){return X(e.target.value)},onClear:Y}),i().createElement(a.Button,{icon:i().createElement(d.ReloadOutlined,null),onClick:function(){return B()},loading:f},M("Load Collections",{ns:I}))),i().createElement(a.Table,{columns:ee,dataSource:L,loading:f,pagination:!1,scroll:{x:V?300:550,y:400},virtual:!0,bordered:!0,rowKey:"name",size:"small"}))}),A=function(e){var t=e.NAMESPACE,n=e.t;return{CollectionsTable:function(e){return i().createElement(x,g(h({},e),{NAMESPACE:t,t:n}))},createCollectionsSchema:function(e,n){return{type:"array",title:'{{t("Collections",{ ns: "'.concat(t,'" })}}'),"x-decorator":"FormItem","x-component":"CollectionsTable","x-component-props":{from:e,loadCollections:n,formValues:"{{$form.values}}",options:"{{$form.values.options}}",formSetValues:"{{$form.setValuesIn}}"},"x-reactions":[{dependencies:["..key","..options","..addAllCollections"],fulfill:{schema:{"x-component-props.dataSourceKey":"{{$deps[0]}}","x-component-props.options":"{{$deps[1]}}","x-component-props.addAllCollectionsValue":"{{$deps[2]}}"}}},{dependencies:["..key"],fulfill:{run:"\n if ($deps[0] && from === 'edit' && loadCollections) {\n (async () => {\n const {data} = await loadCollections($deps[0]);\n $self.value = data || [];\n $form.setValuesIn('collections', data || []);\n })();\n }\n "}}]}},Text:(0,y.observer)(function(e){return i().createElement("span",null,e.value)}),addAllCollectionsSchema:{type:"boolean","x-component":"Checkbox","x-display":"hidden",default:!0}}};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 w(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||E(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 k(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||E(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 E(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)}}var D=function(){var e=w((0,l.useState)({}),2),t=e[0],n=e[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),y=w((0,l.useState)(!1),2),b=y[0],v=y[1],h=(0,c.useTranslation)().t,g=w((0,l.useState)(null),2),C=g[0],x=g[1],S=(0,o.useAPIClient)(),E=(0,f.useLoadCollections)();return i().createElement("div",null,i().createElement(o.ActionContext.Provider,{value:{visible:b,setVisible:v}},i().createElement(a.Dropdown,{menu:{onClick:function(e){if("__empty__"!==e.key){var t,o,a,l=s.types.get(e.key);x(e.key),v(!0),n({type:"object",properties:(t={},o=(0,r.uid)(),a={type:"void","x-component":"Action.Drawer","x-component-props":{width:650},"x-decorator":"Form","x-decorator-props":{initialValue:{type:e.key,key:"d_".concat((0,r.uid)())}},title:p("{{t('Add new')}}")+" - "+p(l.label),properties:{body:{type:"void","x-component":l.DataSourceSettingsForm.bind(null,{CollectionsTableField:A,loadCollections:E,from:"create"})},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{testConnection:{title:'{{ t("Test Connection",{ ns: "'.concat(m.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==l?void 0:l.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:i().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:i().createElement(i().Fragment,null,h("No external data source plugin installed",{ns:m.A7}),i().createElement("br",null)," ",i().createElement("a",{target:"_blank",href:"zh-CN"===S.auth.locale?"https://docs-cn.nocobase.com/handbook/data-source-manager":"https://docs.nocobase.com/handbook/data-source-manager",rel:"noreferrer"},h("View documentation",{ns:m.A7})))})}].filter(Boolean).concat(k(s.types.keys()).map(function(e){var t=s.types.get(e);return{key:e,label:p(null==t?void 0:t.label)}}))}},i().createElement(a.Button,{type:"primary",icon:i().createElement(d.PlusOutlined,null)},h("Add new")," ",i().createElement(d.DownOutlined,null))),i().createElement(o.SchemaComponent,{scope:{createOnly:!1,useTestConnectionAction:f.useTestConnectionAction,dialect:C,useDialectDataSource:function(e){e.dataSource=k(s.types.keys()).map(function(e){var t=s.types.get(e);return{value:t.name,label:p(t.label)}})}},schema:t})))},O=n(467),T=n.n(O);function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function I(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(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 P(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(){var e=(0,o.useRecord)(),t=I((0,l.useState)({}),2),n=t[0],a=t[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),d=I((0,l.useState)(!1),2),b=d[0],v=d[1],h=(0,c.useTranslation)().t,g=(0,o.useDataSourceManager)(),C=(0,f.useLoadCollections)(),x=(0,o.useAPIClient)();return i().createElement("div",null,i().createElement(o.ActionContext.Provider,{value:{visible:b,setVisible:v}},"main"!==e.key&&i().createElement("a",{onClick:function(){v(!0);var t,n,o,l=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},"x-component-props":{width:650},title:p("{{t('Edit')}}")+" - "+p(e.displayName),properties:{body:{type:"void","x-component":l.DataSourceSettingsForm.bind(null,{CollectionsTableField:A,loadCollections:C,from:"edit"})},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(m.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==l?void 0:l.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)})}},h("Edit")),i().createElement(o.SchemaComponent,{scope:{createOnly:!0,useUpdateAction:function(){var e=(0,y.useField)(),t=(0,y.useForm)(),n=(0,o.useActionContext)(),r=(0,o.useResourceActionContext)().refresh,a=(0,o.useResourceContext)().resource,l=(0,o.useRecord)().key;return{run:function(){var o;return(o=function(){var o;return function(e,t){var n,r,o,a,l={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){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:i.sent(),e.data=e.data||{},e.data.loading=!0,i.label=2;case 2:return i.trys.push([2,7,8,9]),[4,a.update({filterByTk:l,values:T().omit(t.values,"collections")})];case 3:if(i.sent(),o=t.values.collections||[],t.values.addAllCollections)return[3,5];return[4,(0,f.addDatasourceCollections)(x,l,{collections:o,dbOptions:t.values.options})];case 4:i.sent(),i.label=5;case 5:return delete t.values.collections,n.setVisible(!1),g.getDataSource(l).setOptions(t.values),g.getDataSource(l).reload(),[4,t.reset()];case 6:return i.sent(),r(),[3,9];case 7:return console.log(i.sent()),[3,9];case 8:return e.data.loading=!1,[7];case 9:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function l(e){j(a,n,r,l,i,"next",e)}function i(e){j(a,n,r,l,i,"throw",e)}l(void 0)})})()}}},loadCollections:C},schema:n})))},q=n(964),F=n(128),V=function(e){var t=e.key,n=e.type;return"/admin/settings/data-source-manager/".concat(t,"/collections?type=").concat(n)};function _(){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 _=function(){return n},n}var R=function(){var e=(0,o.useRecord)(),t=(0,F.useNavigate)(),n=(0,c.useTranslation)().t;return i().createElement("div",{className:e.enabled?void 0:(0,q.css)(_())},i().createElement(a.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:function(){t(V(e))},role:"button","aria-label":"".concat(null==e?void 0:e.key,"-Configure")},n("Configure")))};function $(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 L(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function N(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){L(a,r,o,l,i,"next",e)}function i(e){L(a,r,o,l,i,"throw",e)}l(void 0)})}}function B(e){return function(e){if(Array.isArray(e))return $(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 $(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(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 z(e,t){var n,r,o,a,l={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){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var U=function(){var e,t=(0,c.useTranslation)().t,n=(0,o.usePlugin)(u.default),d=(0,o.useDataSourceManager)(),m=(0,o.useAPIClient)(),y=B(n.types.keys()).map(function(e){var r=n.types.get(e);return{value:e,label:t(null==r?void 0:r.label)}}).concat([{value:"main",label:t("Main")}]),b=i().useRef([]);(0,l.useEffect)(function(){return function(){d.getDataSources().forEach(function(e){b.current.includes(e.key)&&e.reload()})}},[b]);var v=(0,l.useCallback)(function(e){d.removeDataSources(e)},[d]),h=(0,l.useCallback)((e=N(function(e,t){var n;return z(this,function(r){switch(r.label){case 0:if(null==(n=e.options)?void 0:n.addAllCollections)return[3,2];return[4,(0,f.addDatasourceCollections)(m,e.key,{collections:t,dbOptions:e.options})];case 1:r.sent(),r.label=2;case 2:return d.addDataSource(p.F,e),b.current=B(b.current).concat([e.key]),[2]}})}),function(t,n){return e.apply(this,arguments)}),[m,d]);return i().createElement(a.Card,{bordered:!1},i().createElement(o.SchemaComponent,{components:{CreateDatabaseConnectAction:D,EditDatabaseConnectionAction:M,ViewDatabaseConnectionAction:R},scope:{useNewId:function(e){return"".concat(e).concat((0,r.uid)())},types:y,useRefreshActionProps:function(){var e=(0,o.useResourceActionContext)();return{onClick:function(){return N(function(){var t,n,r,o,a;return z(this,function(l){switch(l.label){case 0:if(!(null==(r=null==e||null==(t=e.data)?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:l.sent(),l.label=2;case 2:return null==e||null==(n=e.refresh)||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 N(function(){return z(this,function(r){switch(r.label){case 0:return[4,t.destroy({filterByTk:n})];case 1:return r.sent(),v([n]),e(),[2]}})})()}}},dataSourceDeleteCallback:v,dataSourceCreateCallback:h,useIsAbleDelete:function(e){e.visible="main"!==(0,o.useRecord)().key}},schema:s.j}))}},611:function(e,t,n){n.r(t),n.d(t,{addDatasourceCollections:function(){return b},useCreateDatabaseServer:function(){return f},useLoadCollections:function(){return y},useTestConnectionAction:function(){return m}});var r,o=n(505),a=n(721),l=n(238),i=n(772),c=n(748);function u(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){u(a,r,o,l,i,"next",e)}function i(e){u(a,r,o,l,i,"throw",e)}l(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function d(e,t){var n,r,o,a,l={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){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var f=function(e){var t=(0,o.useForm)(),n=(0,i.useActionContext)(),r=(0,i.useAPIClient)(),c=(0,l.useTranslation)().t,u=(0,o.useField)();return u.data=u.data||{},{run:function(){return s(function(){var o,l;return d(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]),u.data.loading=!0,[4,r.resource("databaseServers").create({values:p({},t.values)})];case 3:return o=i.sent().data,u.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return i.sent(),null==e||e(null==o?void 0:o.data),a.message.success(c("Saved successfully")),[3,6];case 5:return l=i.sent(),u.data.loading=!1,console.log(l),[3,6];case 6:return[2]}})})()}}},m=function(){var e=(0,o.useForm)(),t=(0,i.useAPIClient)(),n=(0,l.useTranslation)().t,r=(0,o.useField)();return r.data=r.data||{},{run:function(){return s(function(){var o;return d(this,function(l){switch(l.label){case 0:return[4,e.submit()];case 1:l.sent(),l.label=2;case 2:return l.trys.push([2,4,,5]),r.data.loading=!0,[4,t.resource("dataSources").testConnection({values:p({},e.values)})];case 3:return l.sent(),r.data.loading=!1,a.message.success(n("Connection successful",{ns:c.A7})),[3,5];case 4:return o=l.sent(),r.data.loading=!1,console.log(o),[3,5];case 5:return[2]}})})()}}},y=function(){var e,t=(0,i.useAPIClient)();return e=s(function(e){return d(this,function(n){switch(n.label){case 0:return[4,t.request({url:"dataSources/".concat(e,"/collections:all"),method:"get"})];case 1:return[2,n.sent().data]}})}),function(t){return e.apply(this,arguments)}},b=(r=s(function(e,t,n){var r,o,a,l,i,c,u,s,p,f,m;return d(this,function(d){switch(d.label){case 0:if(r="dataSources/".concat(t,"/collections:add"),o=n.collections,a=n.dbOptions,!o.length)return[3,2];l=[],i=!0,c=!1,u=void 0;try{for(s=o[Symbol.iterator]();!(i=(p=s.next()).done);i=!0)m=(f=p.value).name,f.selected&&l.push(m)}catch(e){c=!0,u=e}finally{try{i||null==s.return||s.return()}finally{if(c)throw u}}return[4,e.request({url:r,method:"post",data:{dbOptions:a,collections:l}})];case 1:d.sent(),d.label=2;case 2:return[2]}})}),function(e,t,n){return r.apply(this,arguments)})},933:function(e,t,n){n.d(t,{$:function(){return c},j:function(){return s}});var r,o,a,l=n(875),i=n(748),c=[{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,l.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:c}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},s={type:"object",properties:(r={},o=(0,l.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)}}"]}}}}}}}}},o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,r)}}}]);
@@ -0,0 +1,52 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React from 'react';
10
+ export declare const CollectionsTableField: (props: {
11
+ NAMESPACE: string;
12
+ t: (key: string, options?: any) => string;
13
+ }) => {
14
+ CollectionsTable: (props: any) => React.JSX.Element;
15
+ createCollectionsSchema: (from: string, loadCollections: any) => {
16
+ type: string;
17
+ title: string;
18
+ 'x-decorator': string;
19
+ 'x-component': string;
20
+ 'x-component-props': {
21
+ from: string;
22
+ loadCollections: any;
23
+ formValues: string;
24
+ options: string;
25
+ formSetValues: string;
26
+ };
27
+ 'x-reactions': ({
28
+ dependencies: string[];
29
+ fulfill: {
30
+ schema: {
31
+ 'x-component-props.dataSourceKey': string;
32
+ 'x-component-props.options': string;
33
+ 'x-component-props.addAllCollectionsValue': string;
34
+ };
35
+ run?: undefined;
36
+ };
37
+ } | {
38
+ dependencies: string[];
39
+ fulfill: {
40
+ run: string;
41
+ schema?: undefined;
42
+ };
43
+ })[];
44
+ };
45
+ Text: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
46
+ addAllCollectionsSchema: {
47
+ type: string;
48
+ 'x-component': string;
49
+ 'x-display': string;
50
+ default: boolean;
51
+ };
52
+ };