@tachybase/plugin-multi-app-share-collection 1.3.22 → 1.3.24

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.
@@ -1,4 +1,4 @@
1
- (function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/module-multi-app/client"),require("@tachybase/schema"),require("antd"),require("react"),require("@tego/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/module-multi-app/client","@tachybase/schema","antd","react","@tego/client","react-i18next"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o["@tachybase/plugin-multi-app-share-collection"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-multi-app"],o["@tachybase/schema"],o.antd,o.react,o["@tego/client"],o["react-i18next"]))})(this,function(o,t,e,S,T,c,p,g,C){"use strict";var R=Object.defineProperty,$=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var _=(o,t,e)=>t in o?R(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,q=(o,t)=>{for(var e in t||(t={}))te.call(t,e)&&_(o,e,t[e]);if(O)for(var e of O(t))oe.call(t,e)&&_(o,e,t[e]);return o},M=(o,t)=>$(o,ee(t));var D=(o,t,e)=>new Promise((S,T)=>{var c=C=>{try{g(e.next(C))}catch(v){T(v)}},p=C=>{try{g(e.throw(C))}catch(v){T(v)}},g=C=>C.done?S(C.value):Promise.resolve(C.value).then(c,p);g((e=e.apply(o,t)).next())});const v=["users","roles","applications"],B=({removed:a=[]})=>{const{collections:l}=t.useCollectionManager_deprecated(),s=p.useCallback(m=>g.CollectionsGraph.connectedNodes({collections:l,nodes:[m],excludes:v}).filter(r=>a.includes(r)),[a]),i=p.useCallback(m=>g.CollectionsGraph.connectedNodes({collections:l,nodes:[m],excludes:v,direction:"reverse"}).filter(r=>!a.includes(r)),[a]);return{findAddable:s,findRemovable:i}},E=()=>{var n,b;const a=t.useRecord(),[l,s]=p.useState([]),i=t.useRequest({url:`applications/${a.name}/collectionBlacklist:list`,params:{paginate:!1,params:{fields:["name"]}}},{onSuccess(h){var w;s((w=h.data)==null?void 0:w.map(f=>f.name))}}),m=t.useRequest({url:"collections",params:{fields:["name","title","hidden","category.name","category.color","category.sort"],sort:"sort",paginate:!1}}),r=t.useRequest({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:i.loading||m.loading||r.loading,collections:(((n=m.data)==null?void 0:n.data)||[]).filter(h=>!h.hidden&&!v.includes(h.name)),removed:l,setSelected:s,categories:(((b=r.data)==null?void 0:b.data)||[]).map(h=>({label:h.name,value:h.name}))}},F=(a,l)=>{const s=Array.isArray(l)?l:[l];for(const i of s)if(a.toLowerCase().includes(i))return!0;return!1},W=({collections:a,removed:l})=>{const[s,i]=p.useState({name:"",category:[]}),m=p.useMemo(()=>a.filter(n=>{const{name:b,title:h,category:w=[]}=n,f=[l.includes(n.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(k=>F(k.name,s.category))),!f.includes(!1)}),[a,l,s]),r=p.useMemo(()=>g.lodash.debounce(n=>{i(M(q({},s),{name:n}))},300),[]);return{dataSource:m,setNameFilter:r,setCategoryFilter:n=>{i(M(q({},s),{category:n}))}}},U=({collections:a,removed:l})=>{const[s,i]=p.useState({name:"",category:[]}),m=a.filter(n=>{const{name:b,title:h,category:w=[]}=n,f=[!l.includes(n.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(k=>F(k.name,s.category))),!f.includes(!1)}),r=p.useMemo(()=>g.lodash.debounce(n=>{i(M(q({},s),{name:n}))},300),[]);return{dataSource:m,setNameFilter:r,setCategoryFilter:n=>{i(M(q({},s),{category:n}))}}},V=T.connect(a=>{const{onChange:l}=a,{loading:s,collections:i,categories:m,removed:r,setSelected:n}=E(),[b,h]=p.useState([]),[w,f]=p.useState([]),{findAddable:k,findRemovable:Y}=B({removed:r}),j=U({collections:i,removed:r}),I=W({collections:i,removed:r}),{t:y}=C.useTranslation("multi-app-share-collection"),{modal:L}=c.App.useApp(),{token:z}=t.useToken(),N=p.useMemo(()=>[{title:y("Collection display name"),dataIndex:"title"},{title:y("Collection name"),dataIndex:"name"},{title:y("Collection category"),dataIndex:"category",render:d=>d.map(u=>e.jsx(c.Tag,{color:u.color,children:u.name},u.name))}],[]);return s?e.jsx(c.Spin,{}):e.jsx("div",{children:e.jsxs(c.Row,{gutter:24,className:t.css`
1
+ (function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/module-multi-app/client"),require("@tachybase/schema"),require("antd"),require("react"),require("@tego/client"),require("lodash"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/module-multi-app/client","@tachybase/schema","antd","react","@tego/client","lodash","react-i18next"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o["@tachybase/plugin-multi-app-share-collection"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-multi-app"],o["@tachybase/schema"],o.antd,o.react,o["@tego/client"],o.lodash,o["react-i18next"]))})(this,function(o,t,e,S,q,c,p,v,f,F){"use strict";var R=Object.defineProperty,ee=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var B=(o,t,e)=>t in o?R(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,k=(o,t)=>{for(var e in t||(t={}))oe.call(t,e)&&B(o,e,t[e]);if(_)for(var e of _(t))se.call(t,e)&&B(o,e,t[e]);return o},M=(o,t)=>ee(o,te(t));var P=(o,t,e)=>new Promise((S,q)=>{var c=f=>{try{v(e.next(f))}catch(F){q(F)}},p=f=>{try{v(e.throw(f))}catch(F){q(F)}},v=f=>f.done?S(f.value):Promise.resolve(f.value).then(c,p);v((e=e.apply(o,t)).next())});const j=["users","roles","applications"],E=({removed:n=[]})=>{const{collections:l}=t.useCollectionManager_deprecated(),s=p.useCallback(m=>v.CollectionsGraph.connectedNodes({collections:l,nodes:[m],excludes:j}).filter(r=>n.includes(r)),[n]),i=p.useCallback(m=>v.CollectionsGraph.connectedNodes({collections:l,nodes:[m],excludes:j,direction:"reverse"}).filter(r=>!n.includes(r)),[n]);return{findAddable:s,findRemovable:i}},W=()=>{var a,C;const n=t.useRecord(),[l,s]=p.useState([]),i=t.useRequest({url:`applications/${n.name}/collectionBlacklist:list`,params:{paginate:!1,params:{fields:["name"]}}},{onSuccess(h){var b;s((b=h.data)==null?void 0:b.map(y=>y.name))}}),m=t.useRequest({url:"collections",params:{fields:["name","title","hidden","category.name","category.color","category.sort"],sort:"sort",paginate:!1}}),r=t.useRequest({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:i.loading||m.loading||r.loading,collections:(((a=m.data)==null?void 0:a.data)||[]).filter(h=>!h.hidden&&!j.includes(h.name)),removed:l,setSelected:s,categories:(((C=r.data)==null?void 0:C.data)||[]).map(h=>({label:h.name,value:h.name}))}},A=(n,l)=>{const s=Array.isArray(l)?l:[l];for(const i of s)if(n.toLowerCase().includes(i))return!0;return!1},U=({collections:n,removed:l})=>{const[s,i]=p.useState({name:"",category:[]}),m=p.useMemo(()=>n.filter(a=>{const{name:C,title:h,category:b=[]}=a,y=[l.includes(a.name)];return s.name&&y.push(A(C,s.name)||A(h,s.name)),s.category.length>0&&y.push(b.some(T=>A(T.name,s.category))),!y.includes(!1)}),[n,l,s]),r=p.useMemo(()=>f.debounce(a=>{i(M(k({},s),{name:a}))},300),[]);return{dataSource:m,setNameFilter:r,setCategoryFilter:a=>{i(M(k({},s),{category:a}))}}},V=({collections:n,removed:l})=>{const[s,i]=p.useState({name:"",category:[]}),m=n.filter(a=>{const{name:C,title:h,category:b=[]}=a,y=[!l.includes(a.name)];return s.name&&y.push(A(C,s.name)||A(h,s.name)),s.category.length>0&&y.push(b.some(T=>A(T.name,s.category))),!y.includes(!1)}),r=p.useMemo(()=>f.debounce(a=>{i(M(k({},s),{name:a}))},300),[]);return{dataSource:m,setNameFilter:r,setCategoryFilter:a=>{i(M(k({},s),{category:a}))}}},H=q.connect(n=>{const{onChange:l}=n,{loading:s,collections:i,categories:m,removed:r,setSelected:a}=W(),[C,h]=p.useState([]),[b,y]=p.useState([]),{findAddable:T,findRemovable:Z}=E({removed:r}),I=V({collections:i,removed:r}),D=U({collections:i,removed:r}),{t:g}=F.useTranslation("multi-app-share-collection"),{modal:O}=c.App.useApp(),{token:z}=t.useToken(),N=p.useMemo(()=>[{title:g("Collection display name"),dataIndex:"title"},{title:g("Collection name"),dataIndex:"name"},{title:g("Collection category"),dataIndex:"category",render:d=>d.map(u=>e.jsx(c.Tag,{color:u.color,children:u.name},u.name))}],[]);return s?e.jsx(c.Spin,{}):e.jsx("div",{children:e.jsxs(c.Row,{gutter:24,className:t.css`
2
2
  .ant-table-tbody > tr.ant-table-row:hover > td {
3
3
  background: #e6f7ff;
4
4
  cursor: pointer;
@@ -9,10 +9,10 @@
9
9
  align-items: center;
10
10
  width: 100%;
11
11
  margin-bottom: 8px;
12
- `,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:y("Unshared collections")}),e.jsxs(c.Space.Compact,{style:{width:360},children:[e.jsx(c.Select,{popupMatchSelectWidth:!1,onChange:d=>{I.setCategoryFilter(d)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:y("All categories"),options:m,allowClear:!0}),e.jsx(c.Input,{onChange:d=>I.setNameFilter(d.target.value),style:{width:"65%"},placeholder:y("Enter name or title..."),allowClear:!0})]})]}),e.jsx(c.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:b,onChange(d){const u=r.filter(x=>!d.includes(x));n(u),l(u),h([])}},pagination:!1,size:"small",columns:N,dataSource:I.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:d,disabled:u})=>({onClick:()=>{if(u)return;const x=k(d),A=()=>{const K=r.filter(Z=>!x.includes(Z));n(K),l(K)};if(x.length===1)return A();L.confirm({title:y("Are you sure to add the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(c.Table,{size:"small",columns:N,dataSource:i.filter(K=>x.includes(K.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){A()}})}})})]}),e.jsxs(c.Col,{span:12,children:[e.jsxs("div",{className:t.css`
12
+ `,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Unshared collections")}),e.jsxs(c.Space.Compact,{style:{width:360},children:[e.jsx(c.Select,{popupMatchSelectWidth:!1,onChange:d=>{D.setCategoryFilter(d)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(c.Input,{onChange:d=>D.setNameFilter(d.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(c.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:C,onChange(d){const u=r.filter(w=>!d.includes(w));a(u),l(u),h([])}},pagination:!1,size:"small",columns:N,dataSource:D.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:d,disabled:u})=>({onClick:()=>{if(u)return;const w=T(d),x=()=>{const K=r.filter($=>!w.includes($));a(K),l(K)};if(w.length===1)return x();O.confirm({title:g("Are you sure to add the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(c.Table,{size:"small",columns:N,dataSource:i.filter(K=>w.includes(K.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){x()}})}})})]}),e.jsxs(c.Col,{span:12,children:[e.jsxs("div",{className:t.css`
13
13
  display: flex;
14
14
  justify-content: space-between;
15
15
  align-items: center;
16
16
  width: 100%;
17
17
  margin-bottom: 8px;
18
- `,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:y("Shared collections")}),e.jsxs(c.Space.Compact,{style:{width:360},children:[e.jsx(c.Select,{popupMatchSelectWidth:!1,onChange:d=>{j.setCategoryFilter(d)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:y("All categories"),options:m,allowClear:!0}),e.jsx(c.Input,{onChange:d=>j.setNameFilter(d.target.value),style:{width:"65%"},placeholder:y("Enter name or title..."),allowClear:!0})]})]}),e.jsx(c.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:w,onChange(d){const u=g.lodash.uniq(r.concat(d));n(u),l(u),f([])}},pagination:!1,size:"small",columns:N,dataSource:j.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:d})=>({onClick:()=>{const u=Y(d),x=()=>{r.push(...u);const A=g.lodash.uniq([...r]);n(A),l(A)};if(u.length===1)return x();L.confirm({title:y("Are you sure to remove the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(c.Table,{size:"small",columns:N,dataSource:i.filter(A=>u.includes(A.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){x()}})}})})]})]})})}),P=a=>`{{t("${a}", { ns: 'multi-app-share-collection' })}}`,H=()=>{const a=T.useForm(),l=t.useActionContext(),s=t.useAPIClient(),i=t.useRecord();return{run(){return D(this,null,function*(){console.log(a.values.names),yield s.request({url:`applications/${i.name}/collectionBlacklist`,data:a.values.names,method:"post"}),l.setVisible(!1),a.reset(),c.message.success("Saved successfully")})}}},J=S.tableActionColumnSchema.properties.update,Q=S.tableActionColumnSchema.properties.delete;delete S.tableActionColumnSchema.properties.update,delete S.tableActionColumnSchema.properties.delete,S.tableActionColumnSchema.properties.collection={type:"void",title:P("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:P("Share collections"),properties:{names:{type:"array","x-component":V,"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:H}}}}}}}},S.tableActionColumnSchema.properties.update=J,S.tableActionColumnSchema.properties.delete=Q;const X=a=>e.jsx(e.Fragment,{children:a.children});class G extends t.Plugin{load(){return D(this,null,function*(){this.app.use(X)})}}o.MultiAppShareCollectionPlugin=G,o.default=G,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
18
+ `,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Shared collections")}),e.jsxs(c.Space.Compact,{style:{width:360},children:[e.jsx(c.Select,{popupMatchSelectWidth:!1,onChange:d=>{I.setCategoryFilter(d)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(c.Input,{onChange:d=>I.setNameFilter(d.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(c.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:b,onChange(d){const u=f.uniq(r.concat(d));a(u),l(u),y([])}},pagination:!1,size:"small",columns:N,dataSource:I.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:d})=>({onClick:()=>{const u=Z(d),w=()=>{r.push(...u);const x=f.uniq([...r]);a(x),l(x)};if(u.length===1)return w();O.confirm({title:g("Are you sure to remove the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(c.Table,{size:"small",columns:N,dataSource:i.filter(x=>u.includes(x.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){w()}})}})})]})]})})}),G=n=>`{{t("${n}", { ns: 'multi-app-share-collection' })}}`,J=()=>{const n=q.useForm(),l=t.useActionContext(),s=t.useAPIClient(),i=t.useRecord();return{run(){return P(this,null,function*(){console.log(n.values.names),yield s.request({url:`applications/${i.name}/collectionBlacklist`,data:n.values.names,method:"post"}),l.setVisible(!1),n.reset(),c.message.success("Saved successfully")})}}},Q=S.tableActionColumnSchema.properties.update,X=S.tableActionColumnSchema.properties.delete;delete S.tableActionColumnSchema.properties.update,delete S.tableActionColumnSchema.properties.delete,S.tableActionColumnSchema.properties.collection={type:"void",title:G("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:G("Share collections"),properties:{names:{type:"array","x-component":H,"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:J}}}}}}}},S.tableActionColumnSchema.properties.update=Q,S.tableActionColumnSchema.properties.delete=X;const Y=n=>e.jsx(e.Fragment,{children:n.children});class L extends t.Plugin{load(){return P(this,null,function*(){this.app.use(Y)})}}o.MultiAppShareCollectionPlugin=L,o.default=L,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,11 +1,11 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.22",
4
- "@tachybase/module-multi-app": "1.3.22",
5
- "@tachybase/schema": "1.3.39",
3
+ "@tachybase/client": "1.3.24",
4
+ "@tachybase/module-multi-app": "1.3.24",
5
+ "@tachybase/schema": "1.3.49",
6
6
  "antd": "5.22.5",
7
- "@tego/client": "1.3.39",
7
+ "@tego/client": "1.3.49",
8
+ "lodash": "4.17.21",
8
9
  "react-i18next": "15.2.0",
9
- "@tego/server": "1.3.39",
10
- "lodash": "4.17.21"
10
+ "@tego/server": "1.3.49"
11
11
  };
@@ -245,7 +245,6 @@ class MultiAppShareCollectionPlugin extends import_server.Plugin {
245
245
  "header.x-app"
246
246
  ]
247
247
  }
248
- // pmSock: resolve(process.cwd(), 'storage', `${appName}.sock`),
249
248
  };
250
249
  });
251
250
  multiAppManager.setAppDbCreator(async (app) => {
package/package.json CHANGED
@@ -1,29 +1,25 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-multi-app-share-collection",
3
3
  "displayName": "Multi-app share collection",
4
- "version": "1.3.22",
4
+ "version": "1.3.24",
5
5
  "description": "Multi-app share collection",
6
6
  "keywords": [
7
7
  "System management"
8
8
  ],
9
9
  "main": "./dist/server/index.js",
10
- "dependencies": {},
11
10
  "devDependencies": {
12
- "@tachybase/schema": "^1.3.39",
13
- "@tachybase/test": "^1.3.39",
14
- "@tego/client": "^1.3.39",
15
- "@tego/server": "^1.3.39",
11
+ "@tachybase/schema": "^1.3.49",
12
+ "@tachybase/test": "^1.3.49",
13
+ "@tego/client": "^1.3.49",
14
+ "@tego/server": "^1.3.49",
15
+ "@types/lodash": "^4.17.20",
16
16
  "antd": "5.22.5",
17
17
  "lodash": "4.17.21",
18
18
  "react": "18.3.1",
19
19
  "react-i18next": "15.2.0",
20
- "@tachybase/client": "1.3.22",
21
- "@tachybase/module-collection": "1.3.22",
22
- "@tachybase/module-multi-app": "1.3.22",
23
- "@tachybase/module-error-handler": "1.3.22",
24
- "@tachybase/module-user": "1.3.22"
20
+ "@tachybase/client": "1.3.24",
21
+ "@tachybase/module-multi-app": "1.3.24"
25
22
  },
26
23
  "description.zh-CN": "多应用数据共享",
27
- "displayName.zh-CN": "多应用数据共享",
28
- "scripts": {}
24
+ "displayName.zh-CN": "多应用数据共享"
29
25
  }