@nocobase/plugin-multi-app-share-collection 1.7.0-beta.9 → 1.8.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Updated Date: February 20, 2025
1
+ Updated Date: April 1, 2025
2
2
 
3
3
  NocoBase License Agreement
4
4
 
@@ -88,7 +88,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
88
88
 
89
89
  6.6 Can sell plugins developed for Software in the Marketplace.
90
90
 
91
- 6.7 The User with an Enterprise Edition License can sell Upper Layer Application to their clients.
91
+ 6.7 The User with a Professional or Enterprise Edition License can sell Upper Layer Application to their clients.
92
92
 
93
93
  6.8 Not restricted by the AGPL-3.0 agreement.
94
94
 
@@ -106,9 +106,9 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
106
106
 
107
107
  7.4 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS products to the public using the original or modified Software.
108
108
 
109
- 7.5 It is not allowed for the User withot an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
109
+ 7.5 It is not allowed for the User withot a Professional or Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
110
110
 
111
- 7.6 It is not allowed for the User with an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
111
+ 7.6 It is not allowed for the User with a Professional or Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
112
112
 
113
113
  7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
114
114
 
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/react"),require("@nocobase/utils/client"),require("@nocobase/plugin-multi-app-manager/client"),require("@nocobase/client"),require("react"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-multi-app-share-collection",["react-i18next","@formily/react","@nocobase/utils/client","@nocobase/plugin-multi-app-manager/client","@nocobase/client","react","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-multi-app-share-collection"]=t(require("react-i18next"),require("@formily/react"),require("@nocobase/utils/client"),require("@nocobase/plugin-multi-app-manager/client"),require("@nocobase/client"),require("react"),require("antd")):e["@nocobase/plugin-multi-app-share-collection"]=t(e["react-i18next"],e["@formily/react"],e["@nocobase/utils/client"],e["@nocobase/plugin-multi-app-manager/client"],e["@nocobase/client"],e.react,e.antd)}(self,function(e,t,n,r,o,a,i){return function(){"use strict";var c={505:function(e){e.exports=t},772:function(e){e.exports=o},801:function(e){e.exports=r},584:function(e){e.exports=n},721:function(e){e.exports=i},156:function(e){e.exports=a},238:function(t){t.exports=e}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};u.r(s),u.d(s,{PluginMultiAppShareCollectionClient:function(){return H},default:function(){return J}});var f=u("772"),p=u("505"),d=u("801"),m=u("721"),y=u("156"),b=u.n(y),h=u("584"),v=u("238");function g(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){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 S(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 x(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)||j(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 O(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function C(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(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 j(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}function A(){var e=O(["\n .ant-table-tbody > tr.ant-table-row:hover > td {\n background: #e6f7ff;\n cursor: pointer;\n }\n "]);return A=function(){return e},e}function E(){var e=O(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n margin-bottom: 8px;\n "]);return E=function(){return e},e}function P(){var e=O(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n margin-bottom: 8px;\n "]);return P=function(){return e},e}var k=["users","roles","applications"],q=function(e){var t=e.removed,n=void 0===t?[]:t,r=(0,f.useCollectionManager_deprecated)().collections;return{findAddable:(0,y.useCallback)(function(e){return h.CollectionsGraph.connectedNodes({collections:r,nodes:[e],excludes:k}).filter(function(e){return n.includes(e)})},[n]),findRemovable:(0,y.useCallback)(function(e){return h.CollectionsGraph.connectedNodes({collections:r,nodes:[e],excludes:k,direction:"reverse"}).filter(function(e){return!n.includes(e)})},[n])}},T=function(){var e,t,n=(0,f.useRecord)(),r=x((0,y.useState)([]),2),o=r[0],a=r[1],i=(0,f.useRequest)({url:"applications/".concat(n.name,"/collectionBlacklist:list"),params:{paginate:!1,params:{fields:["name"]}}},{onSuccess:function(e){var t;a(null===(t=e.data)||void 0===t?void 0:t.map(function(e){return e.name}))}}),c=(0,f.useRequest)({url:"collections",params:{fields:["name","title","hidden","category.name","category.color","category.sort"],sort:"sort",paginate:!1}}),l=(0,f.useRequest)({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:i.loading||c.loading||l.loading,collections:((null===(e=c.data)||void 0===e?void 0:e.data)||[]).filter(function(e){return!e.hidden&&!k.includes(e.name)}),removed:o,setSelected:a,categories:((null===(t=l.data)||void 0===t?void 0:t.data)||[]).map(function(e){return{label:e.name,value:e.name}})}},R=function(e,t){var n=Array.isArray(t)?t:[t],r=!0,o=!1,a=void 0;try{for(var i,c=n[Symbol.iterator]();!(r=(i=c.next()).done);r=!0){var l=i.value;if(e.toLowerCase().includes(l))return!0}}catch(e){o=!0,a=e}finally{try{!r&&null!=c.return&&c.return()}finally{if(o)throw a}}return!1},F=function(e){var t=e.collections,n=e.removed,r=x((0,y.useState)({name:"",category:[]}),2),o=r[0],a=r[1];return{dataSource:(0,y.useMemo)(function(){return t.filter(function(e){var t=e.name,r=e.title,a=e.category,i=[n.includes(e.name)];return o.name&&i.push(R(t,o.name)||R(r,o.name)),o.category.length>0&&i.push((void 0===a?[]:a).some(function(e){return R(e.name,o.category)})),!i.includes(!1)})},[t,n,o]),setNameFilter:(0,y.useMemo)(function(){return h.lodash.debounce(function(e){a(S(w({},o),{name:e}))},300)},[]),setCategoryFilter:function(e){a(S(w({},o),{category:e}))}}},I=function(e){var t=e.collections,n=e.removed,r=x((0,y.useState)({name:"",category:[]}),2),o=r[0],a=r[1];return{dataSource:t.filter(function(e){var t=e.name,r=e.title,a=e.category,i=[!n.includes(e.name)];return o.name&&i.push(R(t,o.name)||R(r,o.name)),o.category.length>0&&i.push((void 0===a?[]:a).some(function(e){return R(e.name,o.category)})),!i.includes(!1)}),setNameFilter:(0,y.useMemo)(function(){return h.lodash.debounce(function(e){a(S(w({},o),{name:e}))},300)},[]),setCategoryFilter:function(e){a(S(w({},o),{category:e}))}}},M=(0,p.connect)(function(e){var t=e.onChange,n=T(),r=n.loading,o=n.collections,a=n.categories,i=n.removed,c=n.setSelected,l=x((0,y.useState)([]),2),u=l[0],s=l[1],p=x((0,y.useState)([]),2),d=p[0],g=p[1],w=q({removed:i}),S=w.findAddable,O=w.findRemovable,j=I({collections:o,removed:i}),k=F({collections:o,removed:i}),R=(0,v.useTranslation)("multi-app-share-collection").t,M=m.App.useApp().modal,_=(0,f.useToken)().token,z=(0,y.useMemo)(function(){return[{title:R("Collection display name"),dataIndex:"title"},{title:R("Collection name"),dataIndex:"name"},{title:R("Collection category"),dataIndex:"category",render:function(e){return e.map(function(e){return b().createElement(m.Tag,{key:e.name,color:e.color},e.name)})}}]},[]);return r?b().createElement(m.Spin,null):b().createElement("div",null,b().createElement(m.Row,{gutter:24,className:(0,f.css)(A())},b().createElement(m.Col,{span:12},b().createElement("div",{className:(0,f.css)(E())},b().createElement("strong",{style:{fontSize:_.fontSizeLG,color:_.colorText}},R("Unshared collections")),b().createElement(m.Input.Group,{compact:!0,style:{width:360}},b().createElement(m.Select,{popupMatchSelectWidth:!1,onChange:function(e){k.setCategoryFilter(e)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:R("All categories"),options:a,allowClear:!0}),b().createElement(m.Input,{onChange:function(e){return k.setNameFilter(e.target.value)},style:{width:"65%"},placeholder:R("Enter name or title..."),allowClear:!0}))),b().createElement(m.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:u,onChange:function(e){var n=i.filter(function(t){return!e.includes(t)});c(n),t(n),s([])}},pagination:!1,size:"small",columns:z,dataSource:k.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:function(e){var n=e.name,r=e.disabled;return{onClick:function(){if(!r){var e=S(n),a=function(){var n=i.filter(function(t){return!e.includes(t)});c(n),t(n)};if(1===e.length)return a();M.confirm({title:R("Are you sure to add the following collections?"),width:"60%",content:b().createElement("div",null,b().createElement(m.Table,{size:"small",columns:z,dataSource:o.filter(function(t){return e.includes(t.name)}),pagination:!1,scroll:{y:"60vh"}})),onOk:function(){a()}})}}}}})),b().createElement(m.Col,{span:12},b().createElement("div",{className:(0,f.css)(P())},b().createElement("strong",{style:{fontSize:_.fontSizeLG,color:_.colorText}},R("Shared collections")),b().createElement(m.Input.Group,{compact:!0,style:{width:360}},b().createElement(m.Select,{popupMatchSelectWidth:!1,onChange:function(e){j.setCategoryFilter(e)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:R("All categories"),options:a,allowClear:!0}),b().createElement(m.Input,{onChange:function(e){return j.setNameFilter(e.target.value)},style:{width:"65%"},placeholder:R("Enter name or title..."),allowClear:!0}))),b().createElement(m.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:d,onChange:function(e){var n=h.lodash.uniq(i.concat(e));c(n),t(n),g([])}},pagination:!1,size:"small",columns:z,dataSource:j.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:function(e){var n=e.name;return{onClick:function(){var e=O(n),r=function(){i.push.apply(i,C(e));var n=h.lodash.uniq(C(i));c(n),t(n)};if(1===e.length)return r();M.confirm({title:R("Are you sure to remove the following collections?"),width:"60%",content:b().createElement("div",null,b().createElement(m.Table,{size:"small",columns:z,dataSource:o.filter(function(t){return e.includes(t.name)}),pagination:!1,scroll:{y:"60vh"}})),onOk:function(){r()}})}}}}))))}),_=function(e){return'{{t("'.concat(e,"\", { ns: 'multi-app-share-collection' })}}")};function z(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}var N=d.tableActionColumnSchema.properties.update,G=d.tableActionColumnSchema.properties.delete;delete d.tableActionColumnSchema.properties.update,delete d.tableActionColumnSchema.properties.delete,d.tableActionColumnSchema.properties.collection={type:"void",title:_("Share collections"),"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{width:"95vw"},"x-decorator":"Form",title:_("Share collections"),properties:{names:{type:"array","x-component":M,"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,p.useForm)(),t=(0,f.useActionContext)(),n=(0,f.useAPIClient)(),r=(0,f.useRecord)();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 console.log(e.values.names),[4,n.request({url:"applications/".concat(r.name,"/collectionBlacklist"),data:e.values.names,method:"post"})];case 1:return o.sent(),t.setVisible(!1),e.reset(),m.message.success("Saved successfully"),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){z(a,n,r,i,c,"next",e)}function c(e){z(a,n,r,i,c,"throw",e)}i(void 0)})})()}}}}}}}}}}},d.tableActionColumnSchema.properties.update=N,d.tableActionColumnSchema.properties.delete=G;var D=function(e){return b().createElement(b().Fragment,null,e.children)};function B(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function K(e,t,n){return(K=$()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&W(o,n.prototype),o}).apply(null,arguments)}function L(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function W(e,t){return(W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function V(e){var t="function"==typeof Map?new Map:void 0;return(V=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return K(e,arguments,U(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),W(r,e)})(e)}function $(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return($=function(){return!!e})()}var H=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=U(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,$()?Reflect.construct(t,n||[],U(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&W(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=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(e){return t.app.use(D),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){B(a,r,o,i,c,"next",e)}function c(e){B(a,r,o,i,c,"throw",e)}i(void 0)})})()}}],L(t.prototype,n),o}(V(f.Plugin)),J=H;return s}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-i18next"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/utils/client"),require("@nocobase/plugin-multi-app-manager/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-multi-app-share-collection",["react","react-i18next","@formily/react","@nocobase/client","@nocobase/utils/client","@nocobase/plugin-multi-app-manager/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-multi-app-share-collection"]=t(require("react"),require("react-i18next"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/utils/client"),require("@nocobase/plugin-multi-app-manager/client"),require("antd")):e["@nocobase/plugin-multi-app-share-collection"]=t(e.react,e["react-i18next"],e["@formily/react"],e["@nocobase/client"],e["@nocobase/utils/client"],e["@nocobase/plugin-multi-app-manager/client"],e.antd)}(self,function(e,t,n,r,o,a,i){return function(){"use strict";var c={505:function(e){e.exports=n},772:function(e){e.exports=r},801:function(e){e.exports=a},584:function(e){e.exports=o},721:function(e){e.exports=i},156:function(t){t.exports=e},238:function(e){e.exports=t}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return!function(){u.r(s),u.d(s,{PluginMultiAppShareCollectionClient:function(){return N},default:function(){return G}});var e=u(772),t=u(505),n=u(801),r=u(721),o=u(156),a=u.n(o),i=u(584),c=u(238);function l(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){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 p(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 d(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)||b(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 m(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function y(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(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 b(e,t){if(e){if("string"==typeof e)return l(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 l(e,t)}}function h(){var e=m(["\n .ant-table-tbody > tr.ant-table-row:hover > td {\n background: #e6f7ff;\n cursor: pointer;\n }\n "]);return h=function(){return e},e}function v(){var e=m(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n margin-bottom: 8px;\n "]);return v=function(){return e},e}function g(){var e=m(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n margin-bottom: 8px;\n "]);return g=function(){return e},e}var w=["users","roles","applications"],S=function(t){var n=t.removed,r=void 0===n?[]:n,a=(0,e.useCollectionManager_deprecated)().collections;return{findAddable:(0,o.useCallback)(function(e){return i.CollectionsGraph.connectedNodes({collections:a,nodes:[e],excludes:w}).filter(function(e){return r.includes(e)})},[r]),findRemovable:(0,o.useCallback)(function(e){return i.CollectionsGraph.connectedNodes({collections:a,nodes:[e],excludes:w,direction:"reverse"}).filter(function(e){return!r.includes(e)})},[r])}},x=function(){var t,n,r=(0,e.useRecord)(),a=d((0,o.useState)([]),2),i=a[0],c=a[1],l=(0,e.useRequest)({url:"applications/".concat(r.name,"/collectionBlacklist:list"),params:{paginate:!1,params:{fields:["name"]}}},{onSuccess:function(e){var t;c(null==(t=e.data)?void 0:t.map(function(e){return e.name}))}}),u=(0,e.useRequest)({url:"collections",params:{fields:["name","title","hidden","category.name","category.color","category.sort"],sort:"sort",paginate:!1}}),s=(0,e.useRequest)({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:l.loading||u.loading||s.loading,collections:((null==(t=u.data)?void 0:t.data)||[]).filter(function(e){return!e.hidden&&!w.includes(e.name)}),removed:i,setSelected:c,categories:((null==(n=s.data)?void 0:n.data)||[]).map(function(e){return{label:e.name,value:e.name}})}},O=function(e,t){var n=Array.isArray(t)?t:[t],r=!0,o=!1,a=void 0;try{for(var i,c=n[Symbol.iterator]();!(r=(i=c.next()).done);r=!0){var l=i.value;if(e.toLowerCase().includes(l))return!0}}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return!1},C=function(e){var t=e.collections,n=e.removed,r=d((0,o.useState)({name:"",category:[]}),2),a=r[0],c=r[1];return{dataSource:(0,o.useMemo)(function(){return t.filter(function(e){var t=e.name,r=e.title,o=e.category,i=[n.includes(e.name)];return a.name&&i.push(O(t,a.name)||O(r,a.name)),a.category.length>0&&i.push((void 0===o?[]:o).some(function(e){return O(e.name,a.category)})),!i.includes(!1)})},[t,n,a]),setNameFilter:(0,o.useMemo)(function(){return i.lodash.debounce(function(e){c(p(f({},a),{name:e}))},300)},[]),setCategoryFilter:function(e){c(p(f({},a),{category:e}))}}},j=function(e){var t=e.collections,n=e.removed,r=d((0,o.useState)({name:"",category:[]}),2),a=r[0],c=r[1];return{dataSource:t.filter(function(e){var t=e.name,r=e.title,o=e.category,i=[!n.includes(e.name)];return a.name&&i.push(O(t,a.name)||O(r,a.name)),a.category.length>0&&i.push((void 0===o?[]:o).some(function(e){return O(e.name,a.category)})),!i.includes(!1)}),setNameFilter:(0,o.useMemo)(function(){return i.lodash.debounce(function(e){c(p(f({},a),{name:e}))},300)},[]),setCategoryFilter:function(e){c(p(f({},a),{category:e}))}}},A=(0,t.connect)(function(t){var n=t.onChange,l=x(),u=l.loading,s=l.collections,f=l.categories,p=l.removed,m=l.setSelected,b=d((0,o.useState)([]),2),w=b[0],O=b[1],A=d((0,o.useState)([]),2),E=A[0],P=A[1],k=S({removed:p}),q=k.findAddable,T=k.findRemovable,R=j({collections:s,removed:p}),F=C({collections:s,removed:p}),I=(0,c.useTranslation)("multi-app-share-collection").t,M=r.App.useApp().modal,_=(0,e.useToken)().token,z=(0,o.useMemo)(function(){return[{title:I("Collection display name"),dataIndex:"title"},{title:I("Collection name"),dataIndex:"name"},{title:I("Collection category"),dataIndex:"category",render:function(e){return e.map(function(e){return a().createElement(r.Tag,{key:e.name,color:e.color},e.name)})}}]},[]);return u?a().createElement(r.Spin,null):a().createElement("div",null,a().createElement(r.Row,{gutter:24,className:(0,e.css)(h())},a().createElement(r.Col,{span:12},a().createElement("div",{className:(0,e.css)(v())},a().createElement("strong",{style:{fontSize:_.fontSizeLG,color:_.colorText}},I("Unshared collections")),a().createElement(r.Input.Group,{compact:!0,style:{width:360}},a().createElement(r.Select,{popupMatchSelectWidth:!1,onChange:function(e){F.setCategoryFilter(e)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:I("All categories"),options:f,allowClear:!0}),a().createElement(r.Input,{onChange:function(e){return F.setNameFilter(e.target.value)},style:{width:"65%"},placeholder:I("Enter name or title..."),allowClear:!0}))),a().createElement(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:w,onChange:function(e){var t=p.filter(function(t){return!e.includes(t)});m(t),n(t),O([])}},pagination:!1,size:"small",columns:z,dataSource:F.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:function(e){var t=e.name,o=e.disabled;return{onClick:function(){if(!o){var e=q(t),i=function(){var t=p.filter(function(t){return!e.includes(t)});m(t),n(t)};if(1===e.length)return i();M.confirm({title:I("Are you sure to add the following collections?"),width:"60%",content:a().createElement("div",null,a().createElement(r.Table,{size:"small",columns:z,dataSource:s.filter(function(t){return e.includes(t.name)}),pagination:!1,scroll:{y:"60vh"}})),onOk:function(){i()}})}}}}})),a().createElement(r.Col,{span:12},a().createElement("div",{className:(0,e.css)(g())},a().createElement("strong",{style:{fontSize:_.fontSizeLG,color:_.colorText}},I("Shared collections")),a().createElement(r.Input.Group,{compact:!0,style:{width:360}},a().createElement(r.Select,{popupMatchSelectWidth:!1,onChange:function(e){R.setCategoryFilter(e)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:I("All categories"),options:f,allowClear:!0}),a().createElement(r.Input,{onChange:function(e){return R.setNameFilter(e.target.value)},style:{width:"65%"},placeholder:I("Enter name or title..."),allowClear:!0}))),a().createElement(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:E,onChange:function(e){var t=i.lodash.uniq(p.concat(e));m(t),n(t),P([])}},pagination:!1,size:"small",columns:z,dataSource:R.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:function(e){var t=e.name;return{onClick:function(){var e=T(t),o=function(){p.push.apply(p,y(e));var t=i.lodash.uniq(y(p));m(t),n(t)};if(1===e.length)return o();M.confirm({title:I("Are you sure to remove the following collections?"),width:"60%",content:a().createElement("div",null,a().createElement(r.Table,{size:"small",columns:z,dataSource:s.filter(function(t){return e.includes(t.name)}),pagination:!1,scroll:{y:"60vh"}})),onOk:function(){o()}})}}}}))))}),E=function(e){return'{{t("'.concat(e,"\", { ns: 'multi-app-share-collection' })}}")};function P(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}var k=n.tableActionColumnSchema.properties.update,q=n.tableActionColumnSchema.properties.delete;delete n.tableActionColumnSchema.properties.update,delete n.tableActionColumnSchema.properties.delete,n.tableActionColumnSchema.properties.collection={type:"void",title:E("Share collections"),"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{width:"95vw"},"x-decorator":"Form",title:E("Share collections"),properties:{names:{type:"array","x-component":A,"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 n=(0,t.useForm)(),o=(0,e.useActionContext)(),a=(0,e.useAPIClient)(),i=(0,e.useRecord)();return{run:function(){var e;return(e=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){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){switch(e.label){case 0:return console.log(n.values.names),[4,a.request({url:"applications/".concat(i.name,"/collectionBlacklist"),data:n.values.names,method:"post"})];case 1:return e.sent(),o.setVisible(!1),n.reset(),r.message.success("Saved successfully"),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){P(a,r,o,i,c,"next",e)}function c(e){P(a,r,o,i,c,"throw",e)}i(void 0)})})()}}}}}}}}}}},n.tableActionColumnSchema.properties.update=k,n.tableActionColumnSchema.properties.delete=q;var T=function(e){return a().createElement(a().Fragment,null,e.children)};function R(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function F(e,t,n){return(F=z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&M(o,n.prototype),o}).apply(null,arguments)}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t="function"==typeof Map?new Map:void 0;return(_=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return F(e,arguments,I(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),M(n,e)})(e)}function z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(z=function(){return!!e})()}var N=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=I(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,z()?Reflect.construct(e,t||[],I(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&M(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=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){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(T),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){R(a,r,o,i,c,"next",e)}function c(e){R(a,r,o,i,c,"throw",e)}i(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(_(e.Plugin)),G=N}(),s}()});
@@ -9,13 +9,13 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.0",
12
- "@nocobase/client": "1.7.0-beta.9",
13
- "@nocobase/plugin-multi-app-manager": "1.7.0-beta.9",
12
+ "@nocobase/client": "1.8.0-alpha.1",
13
+ "@nocobase/plugin-multi-app-manager": "1.8.0-alpha.1",
14
14
  "antd": "5.24.2",
15
15
  "react": "18.2.0",
16
- "@nocobase/utils": "1.7.0-beta.9",
16
+ "@nocobase/utils": "1.8.0-alpha.1",
17
17
  "react-i18next": "11.18.6",
18
- "@nocobase/database": "1.7.0-beta.9",
19
- "@nocobase/server": "1.7.0-beta.9",
18
+ "@nocobase/database": "1.8.0-alpha.1",
19
+ "@nocobase/server": "1.8.0-alpha.1",
20
20
  "lodash": "4.17.21"
21
21
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "多应用数据表共享",
5
5
  "description": "",
6
6
  "description.zh-CN": "",
7
- "version": "1.7.0-beta.9",
7
+ "version": "1.8.0-alpha.1",
8
8
  "main": "./dist/server/index.js",
9
9
  "devDependencies": {
10
10
  "@formily/react": "2.x",
@@ -23,7 +23,7 @@
23
23
  "@nocobase/test": "1.x",
24
24
  "@nocobase/utils": "1.x"
25
25
  },
26
- "gitHead": "7013a5080f3695d7750ab21005c90d2172c16480",
26
+ "gitHead": "bc81ea73ed91b18dfb7cfad0f353b825881b4cc7",
27
27
  "keywords": [
28
28
  "System management"
29
29
  ]