@nocobase/plugin-multi-app-share-collection 0.13.0-alpha.3 → 0.13.0-alpha.5
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/dist/client/index.js +4 -496
- package/dist/index.js +37 -16
- package/dist/locale/es-ES.js +22 -4
- package/dist/locale/pt-BR.js +22 -4
- package/dist/locale/zh-CN.js +22 -4
- package/dist/server/collections/applications.js +24 -7
- package/dist/server/collections/collections.js +24 -7
- package/dist/server/index.js +33 -11
- package/dist/server/migrations/20230319111111-update-apps-collections.js +26 -9
- package/dist/server/plugin.js +55 -30
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,510 +1,18 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@nocobase/client"), require("react"), require("@formily/react"), require("@nocobase/plugin-multi-app-manager/client"), require("antd"), require("@nocobase/utils/client"), require("react-i18next")) : typeof define === "function" && define.amd ? define(["exports", "@nocobase/client", "react", "@formily/react", "@nocobase/plugin-multi-app-manager/client", "antd", "@nocobase/utils/client", "react-i18next"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-multi-app-share-collection"] = {}, global["@nocobase/client"], global.react, global["@formily/react"], global["@nocobase/plugin-multi-app-manager"], global.antd, global["@nocobase/utils"], global["react-i18next"]));
|
|
3
|
-
})(this, function(exports2, client, require$$0, react, client$2, antd, client$1, reactI18next) {
|
|
4
|
-
"use strict";
|
|
5
|
-
var jsxRuntime = { exports: {} };
|
|
6
|
-
var reactJsxRuntime_production_min = {};
|
|
7
|
-
/**
|
|
8
|
-
* @license React
|
|
9
|
-
* react-jsx-runtime.production.min.js
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/
|
|
16
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
17
|
-
function q(c, a, g) {
|
|
18
|
-
var b, d = {}, e = null, h = null;
|
|
19
|
-
void 0 !== g && (e = "" + g);
|
|
20
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
21
|
-
void 0 !== a.ref && (h = a.ref);
|
|
22
|
-
for (b in a)
|
|
23
|
-
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
24
|
-
if (c && c.defaultProps)
|
|
25
|
-
for (b in a = c.defaultProps, a)
|
|
26
|
-
void 0 === d[b] && (d[b] = a[b]);
|
|
27
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
28
|
-
}
|
|
29
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
30
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
31
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
32
|
-
{
|
|
33
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
34
|
-
}
|
|
35
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
36
|
-
const excludeCollections = ["users", "roles", "applications"];
|
|
37
|
-
const useCollectionsGraph = ({ removed = [] }) => {
|
|
38
|
-
const { collections } = client.useCollectionManager();
|
|
39
|
-
const findAddable = require$$0.useCallback(
|
|
40
|
-
(name) => {
|
|
41
|
-
return client$1.CollectionsGraph.connectedNodes({
|
|
42
|
-
collections,
|
|
43
|
-
nodes: [name],
|
|
44
|
-
excludes: excludeCollections
|
|
45
|
-
}).filter((name2) => removed.includes(name2));
|
|
46
|
-
},
|
|
47
|
-
[removed]
|
|
48
|
-
);
|
|
49
|
-
const findRemovable = require$$0.useCallback(
|
|
50
|
-
(name) => {
|
|
51
|
-
return client$1.CollectionsGraph.connectedNodes({
|
|
52
|
-
collections,
|
|
53
|
-
nodes: [name],
|
|
54
|
-
excludes: excludeCollections,
|
|
55
|
-
direction: "reverse"
|
|
56
|
-
}).filter((name2) => !removed.includes(name2));
|
|
57
|
-
},
|
|
58
|
-
[removed]
|
|
59
|
-
);
|
|
60
|
-
return {
|
|
61
|
-
findAddable,
|
|
62
|
-
findRemovable
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const useCollections = () => {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
const record = client.useRecord();
|
|
68
|
-
const [selected, setSelected] = require$$0.useState([]);
|
|
69
|
-
const res1 = client.useRequest(
|
|
70
|
-
{
|
|
71
|
-
url: `applications/${record.name}/collectionBlacklist:list`,
|
|
72
|
-
params: {
|
|
73
|
-
paginate: false,
|
|
74
|
-
params: {
|
|
75
|
-
fields: ["name"]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
onSuccess(data) {
|
|
81
|
-
var _a2;
|
|
82
|
-
setSelected((_a2 = data.data) == null ? void 0 : _a2.map((data2) => data2.name));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
const res2 = client.useRequest({
|
|
87
|
-
url: `collections`,
|
|
88
|
-
params: {
|
|
89
|
-
fields: ["name", "title", "hidden", "category.name", "category.color", "category.sort"],
|
|
90
|
-
sort: "sort",
|
|
91
|
-
paginate: false
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const res3 = client.useRequest({
|
|
95
|
-
url: `collectionCategories`,
|
|
96
|
-
params: {
|
|
97
|
-
sort: "sort",
|
|
98
|
-
paginate: false
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
loading: res1.loading || res2.loading || res3.loading,
|
|
103
|
-
collections: (((_a = res2.data) == null ? void 0 : _a.data) || []).filter((item) => !item.hidden && !excludeCollections.includes(item.name)),
|
|
104
|
-
removed: selected,
|
|
105
|
-
setSelected,
|
|
106
|
-
categories: (((_b = res3.data) == null ? void 0 : _b.data) || []).map((cat) => ({ label: cat.name, value: cat.name }))
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
const includes = (text, s) => {
|
|
110
|
-
const values = Array.isArray(s) ? s : [s];
|
|
111
|
-
for (const val of values) {
|
|
112
|
-
if (text.toLowerCase().includes(val)) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
const useRemovedDataSource = ({ collections, removed }) => {
|
|
119
|
-
const [filter, setFilter] = require$$0.useState({ name: "", category: [] });
|
|
120
|
-
const dataSource = require$$0.useMemo(() => {
|
|
121
|
-
return collections.filter((collection) => {
|
|
122
|
-
const { name, title, category = [] } = collection;
|
|
123
|
-
const results = [removed.includes(collection.name)];
|
|
124
|
-
if (filter.name) {
|
|
125
|
-
results.push(includes(name, filter.name) || includes(title, filter.name));
|
|
126
|
-
}
|
|
127
|
-
if (filter.category.length > 0) {
|
|
128
|
-
results.push(category.some((item) => includes(item.name, filter.category)));
|
|
129
|
-
}
|
|
130
|
-
return !results.includes(false);
|
|
131
|
-
});
|
|
132
|
-
}, [collections, removed, filter]);
|
|
133
|
-
const setNameFilter = require$$0.useMemo(
|
|
134
|
-
() => client$1.lodash.debounce((name) => {
|
|
135
|
-
setFilter({
|
|
136
|
-
...filter,
|
|
137
|
-
name
|
|
138
|
-
});
|
|
139
|
-
}, 300),
|
|
140
|
-
[]
|
|
141
|
-
);
|
|
142
|
-
return {
|
|
143
|
-
dataSource,
|
|
144
|
-
setNameFilter,
|
|
145
|
-
setCategoryFilter: (category) => {
|
|
146
|
-
setFilter({
|
|
147
|
-
...filter,
|
|
148
|
-
category
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
const useAddedDataSource = ({ collections, removed }) => {
|
|
154
|
-
const [filter, setFilter] = require$$0.useState({ name: "", category: [] });
|
|
155
|
-
const dataSource = collections.filter((collection) => {
|
|
156
|
-
const { name, title, category = [] } = collection;
|
|
157
|
-
const results = [!removed.includes(collection.name)];
|
|
158
|
-
if (filter.name) {
|
|
159
|
-
results.push(includes(name, filter.name) || includes(title, filter.name));
|
|
160
|
-
}
|
|
161
|
-
if (filter.category.length > 0) {
|
|
162
|
-
results.push(category.some((item) => includes(item.name, filter.category)));
|
|
163
|
-
}
|
|
164
|
-
return !results.includes(false);
|
|
165
|
-
});
|
|
166
|
-
const setNameFilter = require$$0.useMemo(
|
|
167
|
-
() => client$1.lodash.debounce((name) => {
|
|
168
|
-
setFilter({
|
|
169
|
-
...filter,
|
|
170
|
-
name
|
|
171
|
-
});
|
|
172
|
-
}, 300),
|
|
173
|
-
[]
|
|
174
|
-
);
|
|
175
|
-
return {
|
|
176
|
-
dataSource,
|
|
177
|
-
setNameFilter,
|
|
178
|
-
setCategoryFilter: (category) => {
|
|
179
|
-
setFilter({
|
|
180
|
-
...filter,
|
|
181
|
-
category
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
const TableTransfer = react.connect((props) => {
|
|
187
|
-
const { onChange } = props;
|
|
188
|
-
const { loading, collections, categories, removed, setSelected } = useCollections();
|
|
189
|
-
const [selectedRowKeys1, setSelectedRowKeys1] = require$$0.useState([]);
|
|
190
|
-
const [selectedRowKeys2, setSelectedRowKeys2] = require$$0.useState([]);
|
|
191
|
-
const { findAddable, findRemovable } = useCollectionsGraph({ removed });
|
|
192
|
-
const addedDataSource = useAddedDataSource({ collections, removed });
|
|
193
|
-
const removedDataSource = useRemovedDataSource({ collections, removed });
|
|
194
|
-
const { t } = reactI18next.useTranslation("multi-app-share-collection");
|
|
195
|
-
const { modal } = antd.App.useApp();
|
|
196
|
-
const { token } = client.useToken();
|
|
197
|
-
const columns = require$$0.useMemo(
|
|
198
|
-
() => [
|
|
199
|
-
{
|
|
200
|
-
title: t("Collection display name"),
|
|
201
|
-
dataIndex: "title"
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
title: t("Collection name"),
|
|
205
|
-
dataIndex: "name"
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
title: t("Collection category"),
|
|
209
|
-
dataIndex: "category",
|
|
210
|
-
render: (categories2) => categories2.map((category) => /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tag, { color: category.color, children: category.name }, category.name))
|
|
211
|
-
}
|
|
212
|
-
],
|
|
213
|
-
[]
|
|
214
|
-
);
|
|
215
|
-
if (loading) {
|
|
216
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {});
|
|
217
|
-
}
|
|
218
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
219
|
-
antd.Row,
|
|
220
|
-
{
|
|
221
|
-
gutter: 24,
|
|
222
|
-
className: client.css`
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("@nocobase/plugin-multi-app-manager/client"),require("antd"),require("@nocobase/utils/client"),require("react"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","@nocobase/plugin-multi-app-manager/client","antd","@nocobase/utils/client","react","react-i18next"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o["@nocobase/plugin-multi-app-share-collection"]={},o["@nocobase/client"],o.jsxRuntime,o["@formily/react"],o["@nocobase/plugin-multi-app-manager"],o.antd,o["@nocobase/utils"],o.react,o["react-i18next"]))})(this,function(o,t,e,M,y,r,C,d,S){"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 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={}))te.call(t,e)&&B(o,e,t[e]);if(O)for(var e of O(t))oe.call(t,e)&&B(o,e,t[e]);return o},q=(o,t)=>$(o,ee(t));var G=(o,t,e)=>new Promise((M,y)=>{var r=S=>{try{d(e.next(S))}catch(v){y(v)}},C=S=>{try{d(e.throw(S))}catch(v){y(v)}},d=S=>S.done?M(S.value):Promise.resolve(S.value).then(r,C);d((e=e.apply(o,t)).next())});const v=["users","roles","applications"],E=({removed:n=[]})=>{const{collections:a}=t.useCollectionManager(),s=d.useCallback(m=>C.CollectionsGraph.connectedNodes({collections:a,nodes:[m],excludes:v}).filter(c=>n.includes(c)),[n]),i=d.useCallback(m=>C.CollectionsGraph.connectedNodes({collections:a,nodes:[m],excludes:v,direction:"reverse"}).filter(c=>!n.includes(c)),[n]);return{findAddable:s,findRemovable:i}},W=()=>{var l,b;const n=t.useRecord(),[a,s]=d.useState([]),i=t.useRequest({url:`applications/${n.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}}),c=t.useRequest({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:i.loading||m.loading||c.loading,collections:(((l=m.data)==null?void 0:l.data)||[]).filter(h=>!h.hidden&&!v.includes(h.name)),removed:a,setSelected:s,categories:(((b=c.data)==null?void 0:b.data)||[]).map(h=>({label:h.name,value:h.name}))}},F=(n,a)=>{const s=Array.isArray(a)?a:[a];for(const i of s)if(n.toLowerCase().includes(i))return!0;return!1},_=({collections:n,removed:a})=>{const[s,i]=d.useState({name:"",category:[]}),m=d.useMemo(()=>n.filter(l=>{const{name:b,title:h,category:w=[]}=l,f=[a.includes(l.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(T=>F(T.name,s.category))),!f.includes(!1)}),[n,a,s]),c=d.useMemo(()=>C.lodash.debounce(l=>{i(q(k({},s),{name:l}))},300),[]);return{dataSource:m,setNameFilter:c,setCategoryFilter:l=>{i(q(k({},s),{category:l}))}}},U=({collections:n,removed:a})=>{const[s,i]=d.useState({name:"",category:[]}),m=n.filter(l=>{const{name:b,title:h,category:w=[]}=l,f=[!a.includes(l.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(T=>F(T.name,s.category))),!f.includes(!1)}),c=d.useMemo(()=>C.lodash.debounce(l=>{i(q(k({},s),{name:l}))},300),[]);return{dataSource:m,setNameFilter:c,setCategoryFilter:l=>{i(q(k({},s),{category:l}))}}},V=M.connect(n=>{const{onChange:a}=n,{loading:s,collections:i,categories:m,removed:c,setSelected:l}=W(),[b,h]=d.useState([]),[w,f]=d.useState([]),{findAddable:T,findRemovable:Y}=E({removed:c}),K=U({collections:i,removed:c}),j=_({collections:i,removed:c}),{t:g}=S.useTranslation("multi-app-share-collection"),{modal:L}=r.App.useApp(),{token:z}=t.useToken(),I=d.useMemo(()=>[{title:g("Collection display name"),dataIndex:"title"},{title:g("Collection name"),dataIndex:"name"},{title:g("Collection category"),dataIndex:"category",render:u=>u.map(p=>e.jsx(r.Tag,{color:p.color,children:p.name},p.name))}],[]);return s?e.jsx(r.Spin,{}):e.jsx("div",{children:e.jsxs(r.Row,{gutter:24,className:t.css`
|
|
223
2
|
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
224
3
|
background: #e6f7ff;
|
|
225
4
|
cursor: pointer;
|
|
226
5
|
}
|
|
227
|
-
`,
|
|
228
|
-
children: [
|
|
229
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Col, { span: 12, children: [
|
|
230
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
231
|
-
"div",
|
|
232
|
-
{
|
|
233
|
-
className: client.css`
|
|
6
|
+
`,children:[e.jsxs(r.Col,{span:12,children:[e.jsxs("div",{className:t.css`
|
|
234
7
|
display: flex;
|
|
235
8
|
justify-content: space-between;
|
|
236
9
|
align-items: center;
|
|
237
10
|
width: 100%;
|
|
238
11
|
margin-bottom: 8px;
|
|
239
|
-
`,
|
|
240
|
-
children: [
|
|
241
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { style: { fontSize: token.fontSizeLG, color: token.colorText }, children: t("Unshared collections") }),
|
|
242
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Input.Group, { compact: true, style: { width: 360 }, children: [
|
|
243
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
244
|
-
antd.Select,
|
|
245
|
-
{
|
|
246
|
-
popupMatchSelectWidth: false,
|
|
247
|
-
onChange: (value) => {
|
|
248
|
-
removedDataSource.setCategoryFilter(value);
|
|
249
|
-
},
|
|
250
|
-
mode: "multiple",
|
|
251
|
-
style: { width: "35%" },
|
|
252
|
-
size: "middle",
|
|
253
|
-
placeholder: t("All categories"),
|
|
254
|
-
options: categories,
|
|
255
|
-
allowClear: true
|
|
256
|
-
}
|
|
257
|
-
),
|
|
258
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
259
|
-
antd.Input,
|
|
260
|
-
{
|
|
261
|
-
onChange: (e) => removedDataSource.setNameFilter(e.target.value),
|
|
262
|
-
style: { width: "65%" },
|
|
263
|
-
placeholder: t("Enter name or title..."),
|
|
264
|
-
allowClear: true
|
|
265
|
-
}
|
|
266
|
-
)
|
|
267
|
-
] })
|
|
268
|
-
]
|
|
269
|
-
}
|
|
270
|
-
),
|
|
271
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
272
|
-
antd.Table,
|
|
273
|
-
{
|
|
274
|
-
bordered: true,
|
|
275
|
-
rowKey: "name",
|
|
276
|
-
rowSelection: {
|
|
277
|
-
type: "checkbox",
|
|
278
|
-
selectedRowKeys: selectedRowKeys1,
|
|
279
|
-
onChange(selectedRowKeys) {
|
|
280
|
-
const values = removed.filter((s) => !selectedRowKeys.includes(s));
|
|
281
|
-
setSelected(values);
|
|
282
|
-
onChange(values);
|
|
283
|
-
setSelectedRowKeys1([]);
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
pagination: false,
|
|
287
|
-
size: "small",
|
|
288
|
-
columns,
|
|
289
|
-
dataSource: removedDataSource.dataSource,
|
|
290
|
-
scroll: { y: "calc(100vh - 260px)" },
|
|
291
|
-
onRow: ({ name, disabled }) => ({
|
|
292
|
-
onClick: () => {
|
|
293
|
-
if (disabled)
|
|
294
|
-
return;
|
|
295
|
-
const adding = findAddable(name);
|
|
296
|
-
const change = () => {
|
|
297
|
-
const values = removed.filter((s) => !adding.includes(s));
|
|
298
|
-
setSelected(values);
|
|
299
|
-
onChange(values);
|
|
300
|
-
};
|
|
301
|
-
if (adding.length === 1) {
|
|
302
|
-
return change();
|
|
303
|
-
}
|
|
304
|
-
modal.confirm({
|
|
305
|
-
title: t("Are you sure to add the following collections?"),
|
|
306
|
-
width: "60%",
|
|
307
|
-
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
308
|
-
antd.Table,
|
|
309
|
-
{
|
|
310
|
-
size: "small",
|
|
311
|
-
columns,
|
|
312
|
-
dataSource: collections.filter((collection) => adding.includes(collection.name)),
|
|
313
|
-
pagination: false,
|
|
314
|
-
scroll: { y: "60vh" }
|
|
315
|
-
}
|
|
316
|
-
) }),
|
|
317
|
-
onOk() {
|
|
318
|
-
change();
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
}
|
|
324
|
-
)
|
|
325
|
-
] }),
|
|
326
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Col, { span: 12, children: [
|
|
327
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
328
|
-
"div",
|
|
329
|
-
{
|
|
330
|
-
className: client.css`
|
|
12
|
+
`,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Unshared collections")}),e.jsxs(r.Input.Group,{compact:!0,style:{width:360},children:[e.jsx(r.Select,{popupMatchSelectWidth:!1,onChange:u=>{j.setCategoryFilter(u)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(r.Input,{onChange:u=>j.setNameFilter(u.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:b,onChange(u){const p=c.filter(x=>!u.includes(x));l(p),a(p),h([])}},pagination:!1,size:"small",columns:I,dataSource:j.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:u,disabled:p})=>({onClick:()=>{if(p)return;const x=T(u),A=()=>{const N=c.filter(Z=>!x.includes(Z));l(N),a(N)};if(x.length===1)return A();L.confirm({title:g("Are you sure to add the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(r.Table,{size:"small",columns:I,dataSource:i.filter(N=>x.includes(N.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){A()}})}})})]}),e.jsxs(r.Col,{span:12,children:[e.jsxs("div",{className:t.css`
|
|
331
13
|
display: flex;
|
|
332
14
|
justify-content: space-between;
|
|
333
15
|
align-items: center;
|
|
334
16
|
width: 100%;
|
|
335
17
|
margin-bottom: 8px;
|
|
336
|
-
`,
|
|
337
|
-
children: [
|
|
338
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { style: { fontSize: token.fontSizeLG, color: token.colorText }, children: t("Shared collections") }),
|
|
339
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Input.Group, { compact: true, style: { width: 360 }, children: [
|
|
340
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
341
|
-
antd.Select,
|
|
342
|
-
{
|
|
343
|
-
popupMatchSelectWidth: false,
|
|
344
|
-
onChange: (value) => {
|
|
345
|
-
addedDataSource.setCategoryFilter(value);
|
|
346
|
-
},
|
|
347
|
-
mode: "multiple",
|
|
348
|
-
style: { width: "35%" },
|
|
349
|
-
size: "middle",
|
|
350
|
-
placeholder: t("All categories"),
|
|
351
|
-
options: categories,
|
|
352
|
-
allowClear: true
|
|
353
|
-
}
|
|
354
|
-
),
|
|
355
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
356
|
-
antd.Input,
|
|
357
|
-
{
|
|
358
|
-
onChange: (e) => addedDataSource.setNameFilter(e.target.value),
|
|
359
|
-
style: { width: "65%" },
|
|
360
|
-
placeholder: t("Enter name or title..."),
|
|
361
|
-
allowClear: true
|
|
362
|
-
}
|
|
363
|
-
)
|
|
364
|
-
] })
|
|
365
|
-
]
|
|
366
|
-
}
|
|
367
|
-
),
|
|
368
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
369
|
-
antd.Table,
|
|
370
|
-
{
|
|
371
|
-
bordered: true,
|
|
372
|
-
rowKey: "name",
|
|
373
|
-
rowSelection: {
|
|
374
|
-
type: "checkbox",
|
|
375
|
-
selectedRowKeys: selectedRowKeys2,
|
|
376
|
-
onChange(selectedRowKeys) {
|
|
377
|
-
const values = client$1.lodash.uniq(removed.concat(selectedRowKeys));
|
|
378
|
-
setSelected(values);
|
|
379
|
-
onChange(values);
|
|
380
|
-
setSelectedRowKeys2([]);
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
pagination: false,
|
|
384
|
-
size: "small",
|
|
385
|
-
columns,
|
|
386
|
-
dataSource: addedDataSource.dataSource,
|
|
387
|
-
scroll: { y: "calc(100vh - 260px)" },
|
|
388
|
-
onRow: ({ name }) => ({
|
|
389
|
-
onClick: () => {
|
|
390
|
-
const removing = findRemovable(name);
|
|
391
|
-
const change = () => {
|
|
392
|
-
removed.push(...removing);
|
|
393
|
-
const values = client$1.lodash.uniq([...removed]);
|
|
394
|
-
setSelected(values);
|
|
395
|
-
onChange(values);
|
|
396
|
-
};
|
|
397
|
-
if (removing.length === 1) {
|
|
398
|
-
return change();
|
|
399
|
-
}
|
|
400
|
-
modal.confirm({
|
|
401
|
-
title: t("Are you sure to remove the following collections?"),
|
|
402
|
-
width: "60%",
|
|
403
|
-
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
404
|
-
antd.Table,
|
|
405
|
-
{
|
|
406
|
-
size: "small",
|
|
407
|
-
columns,
|
|
408
|
-
dataSource: collections.filter((collection) => removing.includes(collection.name)),
|
|
409
|
-
pagination: false,
|
|
410
|
-
scroll: { y: "60vh" }
|
|
411
|
-
}
|
|
412
|
-
) }),
|
|
413
|
-
onOk() {
|
|
414
|
-
change();
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
})
|
|
419
|
-
}
|
|
420
|
-
)
|
|
421
|
-
] })
|
|
422
|
-
]
|
|
423
|
-
}
|
|
424
|
-
) });
|
|
425
|
-
});
|
|
426
|
-
const i18nText = (text) => {
|
|
427
|
-
return `{{t("${text}", { ns: 'multi-app-share-collection' })}}`;
|
|
428
|
-
};
|
|
429
|
-
const useShareCollectionAction = () => {
|
|
430
|
-
const form = react.useForm();
|
|
431
|
-
const ctx = client.useActionContext();
|
|
432
|
-
const api = client.useAPIClient();
|
|
433
|
-
const record = client.useRecord();
|
|
434
|
-
return {
|
|
435
|
-
async run() {
|
|
436
|
-
console.log(form.values.names);
|
|
437
|
-
await api.request({
|
|
438
|
-
url: `applications/${record.name}/collectionBlacklist`,
|
|
439
|
-
data: form.values.names,
|
|
440
|
-
method: "post"
|
|
441
|
-
});
|
|
442
|
-
ctx.setVisible(false);
|
|
443
|
-
form.reset();
|
|
444
|
-
antd.message.success("Saved successfully");
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
};
|
|
448
|
-
const updateSchema = client$2.tableActionColumnSchema.properties.update;
|
|
449
|
-
const deleteSchema = client$2.tableActionColumnSchema.properties.delete;
|
|
450
|
-
delete client$2.tableActionColumnSchema.properties.update;
|
|
451
|
-
delete client$2.tableActionColumnSchema.properties.delete;
|
|
452
|
-
client$2.tableActionColumnSchema.properties["collection"] = {
|
|
453
|
-
type: "void",
|
|
454
|
-
title: i18nText("Share collections"),
|
|
455
|
-
"x-component": "Action.Link",
|
|
456
|
-
"x-component-props": {},
|
|
457
|
-
properties: {
|
|
458
|
-
drawer: {
|
|
459
|
-
type: "void",
|
|
460
|
-
"x-component": "Action.Drawer",
|
|
461
|
-
"x-component-props": {
|
|
462
|
-
width: "95vw"
|
|
463
|
-
},
|
|
464
|
-
"x-decorator": "Form",
|
|
465
|
-
title: i18nText("Share collections"),
|
|
466
|
-
properties: {
|
|
467
|
-
names: {
|
|
468
|
-
type: "array",
|
|
469
|
-
"x-component": TableTransfer,
|
|
470
|
-
"x-decorator": "FormItem"
|
|
471
|
-
},
|
|
472
|
-
footer: {
|
|
473
|
-
type: "void",
|
|
474
|
-
"x-component": "Action.Drawer.Footer",
|
|
475
|
-
properties: {
|
|
476
|
-
cancel: {
|
|
477
|
-
title: '{{t("Cancel")}}',
|
|
478
|
-
"x-component": "Action",
|
|
479
|
-
"x-component-props": {
|
|
480
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
481
|
-
}
|
|
482
|
-
},
|
|
483
|
-
submit: {
|
|
484
|
-
title: '{{t("Submit")}}',
|
|
485
|
-
"x-component": "Action",
|
|
486
|
-
"x-component-props": {
|
|
487
|
-
type: "primary",
|
|
488
|
-
useAction: useShareCollectionAction
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
client$2.tableActionColumnSchema.properties.update = updateSchema;
|
|
498
|
-
client$2.tableActionColumnSchema.properties.delete = deleteSchema;
|
|
499
|
-
const MultiAppShareCollectionProvider = (props) => {
|
|
500
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
|
|
501
|
-
};
|
|
502
|
-
class MultiAppShareCollectionPlugin extends client.Plugin {
|
|
503
|
-
async load() {
|
|
504
|
-
this.app.use(MultiAppShareCollectionProvider);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
exports2.MultiAppShareCollectionPlugin = MultiAppShareCollectionPlugin;
|
|
508
|
-
exports2.default = MultiAppShareCollectionPlugin;
|
|
509
|
-
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
510
|
-
});
|
|
18
|
+
`,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Shared collections")}),e.jsxs(r.Input.Group,{compact:!0,style:{width:360},children:[e.jsx(r.Select,{popupMatchSelectWidth:!1,onChange:u=>{K.setCategoryFilter(u)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(r.Input,{onChange:u=>K.setNameFilter(u.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:w,onChange(u){const p=C.lodash.uniq(c.concat(u));l(p),a(p),f([])}},pagination:!1,size:"small",columns:I,dataSource:K.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:u})=>({onClick:()=>{const p=Y(u),x=()=>{c.push(...p);const A=C.lodash.uniq([...c]);l(A),a(A)};if(p.length===1)return x();L.confirm({title:g("Are you sure to remove the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(r.Table,{size:"small",columns:I,dataSource:i.filter(A=>p.includes(A.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){x()}})}})})]})]})})}),D=n=>`{{t("${n}", { ns: 'multi-app-share-collection' })}}`,H=()=>{const n=M.useForm(),a=t.useActionContext(),s=t.useAPIClient(),i=t.useRecord();return{run(){return G(this,null,function*(){console.log(n.values.names),yield s.request({url:`applications/${i.name}/collectionBlacklist`,data:n.values.names,method:"post"}),a.setVisible(!1),n.reset(),r.message.success("Saved successfully")})}}},J=y.tableActionColumnSchema.properties.update,Q=y.tableActionColumnSchema.properties.delete;delete y.tableActionColumnSchema.properties.update,delete y.tableActionColumnSchema.properties.delete,y.tableActionColumnSchema.properties.collection={type:"void",title:D("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:D("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}}}}}}}},y.tableActionColumnSchema.properties.update=J,y.tableActionColumnSchema.properties.delete=Q;const X=n=>e.jsx(e.Fragment,{children:n.children});class P extends t.Plugin{load(){return G(this,null,function*(){this.app.use(X)})}}o.MultiAppShareCollectionPlugin=P,o.default=P,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => import_server.default
|
|
12
32
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
35
|
+
var import_server = __toESM(require("./server"));
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
...require("./server")
|
|
18
39
|
});
|
package/dist/locale/es-ES.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var es_ES_exports = {};
|
|
19
|
+
__export(es_ES_exports, {
|
|
20
|
+
default: () => es_ES_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(es_ES_exports);
|
|
3
23
|
var es_ES_default = {
|
|
4
24
|
"Share collections": "Tablas compartidas",
|
|
5
25
|
"Unshared collections": "Tablas no compartidas",
|
|
@@ -12,5 +32,3 @@ var es_ES_default = {
|
|
|
12
32
|
"Collection name": "Nombre de la tabla",
|
|
13
33
|
"Collection category": "Categor\xEDa de tabla"
|
|
14
34
|
};
|
|
15
|
-
|
|
16
|
-
module.exports = es_ES_default;
|
package/dist/locale/pt-BR.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var pt_BR_exports = {};
|
|
19
|
+
__export(pt_BR_exports, {
|
|
20
|
+
default: () => pt_BR_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pt_BR_exports);
|
|
3
23
|
var pt_BR_default = {
|
|
4
24
|
"Share collections": "Compartilhar tabelas",
|
|
5
25
|
"Unshared collections": "Tabelas n\xE3o compartilhadas",
|
|
@@ -12,5 +32,3 @@ var pt_BR_default = {
|
|
|
12
32
|
"Collection name": "Nome da tabela",
|
|
13
33
|
"Collection category": "Categoria da tabela"
|
|
14
34
|
};
|
|
15
|
-
|
|
16
|
-
module.exports = pt_BR_default;
|
package/dist/locale/zh-CN.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var zh_CN_exports = {};
|
|
19
|
+
__export(zh_CN_exports, {
|
|
20
|
+
default: () => zh_CN_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(zh_CN_exports);
|
|
3
23
|
var zh_CN_default = {
|
|
4
24
|
"Share collections": "\u5171\u4EAB\u6570\u636E\u8868",
|
|
5
25
|
"Unshared collections": "\u672A\u5171\u4EAB\u7684\u6570\u636E\u8868",
|
|
@@ -12,5 +32,3 @@ var zh_CN_default = {
|
|
|
12
32
|
"Collection name": "\u6807\u8BC6",
|
|
13
33
|
"Collection category": "\u5206\u7C7B"
|
|
14
34
|
};
|
|
15
|
-
|
|
16
|
-
module.exports = zh_CN_default;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var applications_exports = {};
|
|
19
|
+
__export(applications_exports, {
|
|
20
|
+
default: () => applications_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(applications_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var applications_default = (0, import_database.extendCollection)({
|
|
6
25
|
name: "applications",
|
|
7
26
|
fields: [
|
|
8
27
|
{
|
|
@@ -17,5 +36,3 @@ var applications_default = database.extendCollection({
|
|
|
17
36
|
}
|
|
18
37
|
]
|
|
19
38
|
});
|
|
20
|
-
|
|
21
|
-
module.exports = applications_default;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var collections_exports = {};
|
|
19
|
+
__export(collections_exports, {
|
|
20
|
+
default: () => collections_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(collections_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var collections_default = (0, import_database.extendCollection)({
|
|
6
25
|
name: "collections",
|
|
7
26
|
fields: [
|
|
8
27
|
{
|
|
@@ -17,5 +36,3 @@ var collections_default = database.extendCollection({
|
|
|
17
36
|
}
|
|
18
37
|
]
|
|
19
38
|
});
|
|
20
|
-
|
|
21
|
-
module.exports = collections_default;
|
package/dist/server/index.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
default: () => import_plugin.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(server_exports);
|
|
33
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var update_apps_collections_exports = {};
|
|
19
|
+
__export(update_apps_collections_exports, {
|
|
20
|
+
default: () => update_apps_collections_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(update_apps_collections_exports);
|
|
23
|
+
var import_server = require("@nocobase/server");
|
|
24
|
+
var import_utils = require("@nocobase/utils");
|
|
25
|
+
class update_apps_collections_default extends import_server.Migration {
|
|
7
26
|
async up() {
|
|
8
27
|
const result = await this.app.version.satisfies("<0.9.3-alpha.1");
|
|
9
28
|
if (!result) {
|
|
@@ -36,7 +55,7 @@ class update_apps_collections_default extends server.Migration {
|
|
|
36
55
|
const blackListCollections = allCollections.filter(
|
|
37
56
|
(collection) => !syncedCollections.has(collection) && !["users", "roles"].includes(collection)
|
|
38
57
|
);
|
|
39
|
-
const connectedCollections =
|
|
58
|
+
const connectedCollections = import_utils.CollectionsGraph.connectedNodes({
|
|
40
59
|
collections: collectionsData,
|
|
41
60
|
nodes: blackListCollections,
|
|
42
61
|
direction: "reverse"
|
|
@@ -62,5 +81,3 @@ class update_apps_collections_default extends server.Migration {
|
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
}
|
|
65
|
-
|
|
66
|
-
module.exports = update_apps_collections_default;
|
package/dist/server/plugin.js
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var plugin_exports = {};
|
|
29
|
+
__export(plugin_exports, {
|
|
30
|
+
MultiAppShareCollectionPlugin: () => MultiAppShareCollectionPlugin,
|
|
31
|
+
default: () => plugin_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
var import_plugin_multi_app_manager = __toESM(require("@nocobase/plugin-multi-app-manager"));
|
|
35
|
+
var import_server = require("@nocobase/server");
|
|
36
|
+
var import_lodash = __toESM(require("lodash"));
|
|
37
|
+
var import_path = require("path");
|
|
15
38
|
const subAppFilteredPlugins = ["multi-app-share-collection", "multi-app-manager"];
|
|
16
|
-
|
|
39
|
+
const unSyncPlugins = ["localization-management"];
|
|
40
|
+
class SubAppPlugin extends import_server.Plugin {
|
|
17
41
|
beforeLoad() {
|
|
18
42
|
const mainApp = this.options.mainApp;
|
|
19
43
|
const subApp = this.app;
|
|
@@ -96,7 +120,7 @@ class SubAppPlugin extends server.Plugin {
|
|
|
96
120
|
});
|
|
97
121
|
}
|
|
98
122
|
}
|
|
99
|
-
class MultiAppShareCollectionPlugin extends
|
|
123
|
+
class MultiAppShareCollectionPlugin extends import_server.Plugin {
|
|
100
124
|
afterAdd() {
|
|
101
125
|
}
|
|
102
126
|
async beforeEnable() {
|
|
@@ -113,15 +137,15 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
113
137
|
throw new Error("multi-app-share-collection plugin only support postgres");
|
|
114
138
|
}
|
|
115
139
|
const traverseSubApps = async (callback, options) => {
|
|
116
|
-
if (
|
|
140
|
+
if (import_lodash.default.get(options, "loadFromDatabase")) {
|
|
117
141
|
for (const application of await this.app.db.getCollection("applications").repository.find()) {
|
|
118
142
|
const appName = application.get("name");
|
|
119
|
-
const subApp = await
|
|
143
|
+
const subApp = await import_server.AppSupervisor.getInstance().getApp(appName);
|
|
120
144
|
await callback(subApp);
|
|
121
145
|
}
|
|
122
146
|
return;
|
|
123
147
|
}
|
|
124
|
-
const subApps = [...
|
|
148
|
+
const subApps = [...import_server.AppSupervisor.getInstance().subApps()];
|
|
125
149
|
for (const subApp of subApps) {
|
|
126
150
|
await callback(subApp);
|
|
127
151
|
}
|
|
@@ -132,8 +156,8 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
132
156
|
app.plugin(SubAppPlugin, { name: "sub-app", mainApp });
|
|
133
157
|
}
|
|
134
158
|
}
|
|
135
|
-
if (
|
|
136
|
-
|
|
159
|
+
if (import_server.AppSupervisor.getInstance().listeners("afterAppAdded").filter((f) => f.name == addPluginToSubApp.name).length == 0) {
|
|
160
|
+
import_server.AppSupervisor.getInstance().on("afterAppAdded", addPluginToSubApp);
|
|
137
161
|
}
|
|
138
162
|
this.app.db.on("users.afterCreateWithAssociations", async (model, options) => {
|
|
139
163
|
await traverseSubApps(async (subApp) => {
|
|
@@ -163,7 +187,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
163
187
|
});
|
|
164
188
|
this.app.on("afterEnablePlugin", (pluginNames) => {
|
|
165
189
|
traverseSubApps((subApp) => {
|
|
166
|
-
for (const pluginName of
|
|
190
|
+
for (const pluginName of import_lodash.default.castArray(pluginNames)) {
|
|
167
191
|
if (subAppFilteredPlugins.includes(pluginName))
|
|
168
192
|
return;
|
|
169
193
|
subApp.runAsCLI(["pm", "enable", pluginName], { from: "user" });
|
|
@@ -172,7 +196,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
172
196
|
});
|
|
173
197
|
this.app.on("afterDisablePlugin", (pluginNames) => {
|
|
174
198
|
traverseSubApps((subApp) => {
|
|
175
|
-
for (const pluginName of
|
|
199
|
+
for (const pluginName of import_lodash.default.castArray(pluginNames)) {
|
|
176
200
|
if (subAppFilteredPlugins.includes(pluginName))
|
|
177
201
|
return;
|
|
178
202
|
subApp.runAsCLI(["pm", "disable", pluginName], { from: "user" });
|
|
@@ -180,7 +204,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
180
204
|
});
|
|
181
205
|
});
|
|
182
206
|
this.app.db.on(`afterRemoveCollection`, (collection) => {
|
|
183
|
-
const subApps = [...
|
|
207
|
+
const subApps = [...import_server.AppSupervisor.getInstance().subApps()];
|
|
184
208
|
for (const subApp of subApps) {
|
|
185
209
|
subApp.db.removeCollection(collection.name);
|
|
186
210
|
}
|
|
@@ -193,7 +217,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
193
217
|
return;
|
|
194
218
|
}
|
|
195
219
|
await this.db.import({
|
|
196
|
-
directory:
|
|
220
|
+
directory: (0, import_path.resolve)(__dirname, "collections")
|
|
197
221
|
});
|
|
198
222
|
this.app.resourcer.registerActionHandlers({
|
|
199
223
|
"applications:shareCollections": async (ctx, next) => {
|
|
@@ -206,7 +230,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
206
230
|
}
|
|
207
231
|
});
|
|
208
232
|
multiAppManager.setAppOptionsFactory((appName, mainApp) => {
|
|
209
|
-
const mainAppDbConfig =
|
|
233
|
+
const mainAppDbConfig = import_plugin_multi_app_manager.default.getDatabaseConfig(mainApp);
|
|
210
234
|
const databaseOptions = {
|
|
211
235
|
...mainAppDbConfig,
|
|
212
236
|
schema: appName
|
|
@@ -215,7 +239,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
215
239
|
(name) => name !== "multi-app-manager" && name !== "multi-app-share-collection"
|
|
216
240
|
);
|
|
217
241
|
return {
|
|
218
|
-
database:
|
|
242
|
+
database: import_lodash.default.merge(databaseOptions, {
|
|
219
243
|
dialectOptions: {
|
|
220
244
|
application_name: `nocobase.${appName}`
|
|
221
245
|
}
|
|
@@ -246,6 +270,7 @@ class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
|
246
270
|
}
|
|
247
271
|
}
|
|
248
272
|
var plugin_default = MultiAppShareCollectionPlugin;
|
|
249
|
-
|
|
250
|
-
exports
|
|
251
|
-
|
|
273
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
274
|
+
0 && (module.exports = {
|
|
275
|
+
MultiAppShareCollectionPlugin
|
|
276
|
+
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "多应用数据共享",
|
|
5
5
|
"description": "multi app share collection",
|
|
6
6
|
"description.zh-CN": "多应用数据共享",
|
|
7
|
-
"version": "0.13.0-alpha.
|
|
7
|
+
"version": "0.13.0-alpha.5",
|
|
8
8
|
"main": "./dist/server/index.js",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@formily/react": "2.x",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@nocobase/test": "0.x",
|
|
24
24
|
"@nocobase/utils": "0.x"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "9eabe607b4a20c356fdb2fd95e40fa476986dcb0"
|
|
27
27
|
}
|