@nocobase/plugin-multi-app-share-collection 1.9.0-beta.8 → 2.0.0-alpha.2

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.
@@ -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"),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}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-multi-app-manager/client"),require("@nocobase/utils/client"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-multi-app-share-collection",["react","@formily/react","@nocobase/client","@nocobase/plugin-multi-app-manager/client","@nocobase/utils/client","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-multi-app-share-collection"]=t(require("react"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-multi-app-manager/client"),require("@nocobase/utils/client"),require("antd"),require("react-i18next")):e["@nocobase/plugin-multi-app-share-collection"]=t(e.react,e["@formily/react"],e["@nocobase/client"],e["@nocobase/plugin-multi-app-manager/client"],e["@nocobase/utils/client"],e.antd,e["react-i18next"])}(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=n},801:function(e){e.exports=r},584:function(e){e.exports=o},721:function(e){e.exports=a},156:function(t){t.exports=e},238:function(e){e.exports=i}},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}()});
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@formily/react": "2.3.0",
12
- "@nocobase/client": "1.9.0-beta.8",
13
- "@nocobase/plugin-multi-app-manager": "1.9.0-beta.8",
11
+ "@formily/react": "2.3.7",
12
+ "@nocobase/client": "2.0.0-alpha.2",
13
+ "@nocobase/plugin-multi-app-manager": "2.0.0-alpha.2",
14
14
  "antd": "5.24.2",
15
15
  "react": "18.2.0",
16
- "@nocobase/utils": "1.9.0-beta.8",
16
+ "@nocobase/utils": "2.0.0-alpha.2",
17
17
  "react-i18next": "11.18.6",
18
- "@nocobase/database": "1.9.0-beta.8",
19
- "@nocobase/server": "1.9.0-beta.8",
18
+ "@nocobase/database": "2.0.0-alpha.2",
19
+ "@nocobase/server": "2.0.0-alpha.2",
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.9.0-beta.8",
7
+ "version": "2.0.0-alpha.2",
8
8
  "main": "./dist/server/index.js",
9
9
  "devDependencies": {
10
10
  "@formily/react": "2.x",
@@ -13,17 +13,17 @@
13
13
  "react-i18next": "^11.15.1"
14
14
  },
15
15
  "peerDependencies": {
16
- "@nocobase/client": "1.x",
17
- "@nocobase/database": "1.x",
18
- "@nocobase/plugin-data-source-main": "1.x",
19
- "@nocobase/plugin-error-handler": "1.x",
20
- "@nocobase/plugin-multi-app-manager": "1.x",
21
- "@nocobase/plugin-users": "1.x",
22
- "@nocobase/server": "1.x",
23
- "@nocobase/test": "1.x",
24
- "@nocobase/utils": "1.x"
16
+ "@nocobase/client": "2.x",
17
+ "@nocobase/database": "2.x",
18
+ "@nocobase/plugin-data-source-main": "2.x",
19
+ "@nocobase/plugin-error-handler": "2.x",
20
+ "@nocobase/plugin-multi-app-manager": "2.x",
21
+ "@nocobase/plugin-users": "2.x",
22
+ "@nocobase/server": "2.x",
23
+ "@nocobase/test": "2.x",
24
+ "@nocobase/utils": "2.x"
25
25
  },
26
- "gitHead": "f3d4f3d1ba7adbf4d4c60e656c23da45565769c8",
26
+ "gitHead": "1322f486b248bef53ed8c8f42f0a39dfd02125fd",
27
27
  "keywords": [
28
28
  "System management"
29
29
  ]