@nocobase/plugin-multi-app-share-collection 0.10.1-alpha.1 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/MultiAppShareCollectionProvider.d.ts +2 -0
- package/lib/client/MultiAppShareCollectionProvider.js +122 -0
- package/lib/client/TableTransfer.d.ts +1 -1
- package/lib/client/TableTransfer.js +10 -31
- package/lib/client/index.d.ts +5 -3
- package/lib/client/index.js +11 -106
- package/lib/server/plugin.js +5 -5
- package/package.json +27 -7
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/MultiAppShareCollectionProvider.tsx +86 -0
- package/src/client/TableTransfer.tsx +15 -13
- package/src/client/index.tsx +8 -84
- package/src/server/plugin.ts +1 -1
package/client.d.ts
CHANGED
package/client.js
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
4
|
-
|
|
5
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
|
-
|
|
7
|
-
var _index = _interopRequireWildcard(require("./lib/client"));
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
var _exportNames = {};
|
|
13
|
-
Object.defineProperty(exports, "default", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _index.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Object.keys(_index).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _index[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _index[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
1
|
+
module.exports = require('./lib/client/index.js');
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MultiAppShareCollectionProvider = void 0;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = require("@formily/react");
|
|
9
|
+
_react = function _react() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _client() {
|
|
15
|
+
const data = require("@nocobase/client");
|
|
16
|
+
_client = function _client() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _client2() {
|
|
22
|
+
const data = require("@nocobase/plugin-multi-app-manager/client");
|
|
23
|
+
_client2 = function _client2() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _antd() {
|
|
29
|
+
const data = require("antd");
|
|
30
|
+
_antd = function _antd() {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _react2() {
|
|
36
|
+
const data = _interopRequireDefault(require("react"));
|
|
37
|
+
_react2 = function _react2() {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
var _TableTransfer = require("./TableTransfer");
|
|
43
|
+
var _utils = require("./utils");
|
|
44
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
46
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
47
|
+
const useShareCollectionAction = () => {
|
|
48
|
+
const form = (0, _react().useForm)();
|
|
49
|
+
const ctx = (0, _client().useActionContext)();
|
|
50
|
+
const api = (0, _client().useAPIClient)();
|
|
51
|
+
const record = (0, _client().useRecord)();
|
|
52
|
+
return {
|
|
53
|
+
run() {
|
|
54
|
+
return _asyncToGenerator(function* () {
|
|
55
|
+
console.log(form.values.names);
|
|
56
|
+
yield api.request({
|
|
57
|
+
url: `applications/${record.name}/collectionBlacklist`,
|
|
58
|
+
data: form.values.names,
|
|
59
|
+
method: 'post'
|
|
60
|
+
});
|
|
61
|
+
ctx.setVisible(false);
|
|
62
|
+
form.reset();
|
|
63
|
+
_antd().message.success('Saved successfully');
|
|
64
|
+
})();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const updateSchema = _client2().tableActionColumnSchema.properties.update;
|
|
69
|
+
const deleteSchema = _client2().tableActionColumnSchema.properties.delete;
|
|
70
|
+
delete _client2().tableActionColumnSchema.properties.update;
|
|
71
|
+
delete _client2().tableActionColumnSchema.properties.delete;
|
|
72
|
+
_client2().tableActionColumnSchema.properties['collection'] = {
|
|
73
|
+
type: 'void',
|
|
74
|
+
title: (0, _utils.i18nText)('Share collections'),
|
|
75
|
+
'x-component': 'Action.Link',
|
|
76
|
+
'x-component-props': {},
|
|
77
|
+
properties: {
|
|
78
|
+
drawer: {
|
|
79
|
+
type: 'void',
|
|
80
|
+
'x-component': 'Action.Drawer',
|
|
81
|
+
'x-component-props': {
|
|
82
|
+
width: '95vw'
|
|
83
|
+
},
|
|
84
|
+
'x-decorator': 'Form',
|
|
85
|
+
title: (0, _utils.i18nText)('Share collections'),
|
|
86
|
+
properties: {
|
|
87
|
+
names: {
|
|
88
|
+
type: 'array',
|
|
89
|
+
'x-component': _TableTransfer.TableTransfer,
|
|
90
|
+
'x-decorator': 'FormItem'
|
|
91
|
+
},
|
|
92
|
+
footer: {
|
|
93
|
+
type: 'void',
|
|
94
|
+
'x-component': 'Action.Drawer.Footer',
|
|
95
|
+
properties: {
|
|
96
|
+
cancel: {
|
|
97
|
+
title: '{{t("Cancel")}}',
|
|
98
|
+
'x-component': 'Action',
|
|
99
|
+
'x-component-props': {
|
|
100
|
+
useAction: '{{ cm.useCancelAction }}'
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
submit: {
|
|
104
|
+
title: '{{t("Submit")}}',
|
|
105
|
+
'x-component': 'Action',
|
|
106
|
+
'x-component-props': {
|
|
107
|
+
type: 'primary',
|
|
108
|
+
useAction: useShareCollectionAction
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
_client2().tableActionColumnSchema.properties.update = updateSchema;
|
|
118
|
+
_client2().tableActionColumnSchema.properties.delete = deleteSchema;
|
|
119
|
+
const MultiAppShareCollectionProvider = props => {
|
|
120
|
+
return _react2().default.createElement(_react2().default.Fragment, null, props.children);
|
|
121
|
+
};
|
|
122
|
+
exports.MultiAppShareCollectionProvider = MultiAppShareCollectionProvider;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const TableTransfer: React.ForwardRefExoticComponent<
|
|
2
|
+
export declare const TableTransfer: React.ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
3
3
|
export default TableTransfer;
|
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.TableTransfer = void 0;
|
|
7
|
-
function _css() {
|
|
8
|
-
const data = require("@emotion/css");
|
|
9
|
-
_css = function _css() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _react() {
|
|
15
8
|
const data = require("@formily/react");
|
|
16
9
|
_react = function _react() {
|
|
@@ -39,20 +32,6 @@ function _antd() {
|
|
|
39
32
|
};
|
|
40
33
|
return data;
|
|
41
34
|
}
|
|
42
|
-
function _debounce() {
|
|
43
|
-
const data = _interopRequireDefault(require("lodash/debounce"));
|
|
44
|
-
_debounce = function _debounce() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
function _uniq() {
|
|
50
|
-
const data = _interopRequireDefault(require("lodash/uniq"));
|
|
51
|
-
_uniq = function _uniq() {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
35
|
function _react2() {
|
|
57
36
|
const data = _interopRequireWildcard(require("react"));
|
|
58
37
|
_react2 = function _react2() {
|
|
@@ -69,7 +48,6 @@ function _reactI18next() {
|
|
|
69
48
|
}
|
|
70
49
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
71
50
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
72
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
73
51
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
74
52
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
75
53
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -200,7 +178,7 @@ const useRemovedDataSource = ({
|
|
|
200
178
|
return !results.includes(false);
|
|
201
179
|
});
|
|
202
180
|
}, [collections, removed, filter]);
|
|
203
|
-
const setNameFilter = (0, _react2().useMemo)(() => (
|
|
181
|
+
const setNameFilter = (0, _react2().useMemo)(() => _client2().lodash.debounce(name => {
|
|
204
182
|
setFilter(_objectSpread(_objectSpread({}, filter), {}, {
|
|
205
183
|
name
|
|
206
184
|
}));
|
|
@@ -240,7 +218,7 @@ const useAddedDataSource = ({
|
|
|
240
218
|
}
|
|
241
219
|
return !results.includes(false);
|
|
242
220
|
});
|
|
243
|
-
const setNameFilter = (0, _react2().useMemo)(() => (
|
|
221
|
+
const setNameFilter = (0, _react2().useMemo)(() => _client2().lodash.debounce(name => {
|
|
244
222
|
setFilter(_objectSpread(_objectSpread({}, filter), {}, {
|
|
245
223
|
name
|
|
246
224
|
}));
|
|
@@ -296,6 +274,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
296
274
|
title: t('Collection category'),
|
|
297
275
|
dataIndex: 'category',
|
|
298
276
|
render: categories => categories.map(category => _react2().default.createElement(_antd().Tag, {
|
|
277
|
+
key: category.name,
|
|
299
278
|
color: category.color
|
|
300
279
|
}, category.name))
|
|
301
280
|
}], []);
|
|
@@ -304,7 +283,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
304
283
|
}
|
|
305
284
|
return _react2().default.createElement("div", null, _react2().default.createElement(_antd().Row, {
|
|
306
285
|
gutter: 24,
|
|
307
|
-
className: (0,
|
|
286
|
+
className: (0, _client().css)`
|
|
308
287
|
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
309
288
|
background: #e6f7ff;
|
|
310
289
|
cursor: pointer;
|
|
@@ -313,7 +292,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
313
292
|
}, _react2().default.createElement(_antd().Col, {
|
|
314
293
|
span: 12
|
|
315
294
|
}, _react2().default.createElement("div", {
|
|
316
|
-
className: (0,
|
|
295
|
+
className: (0, _client().css)`
|
|
317
296
|
display: flex;
|
|
318
297
|
justify-content: space-between;
|
|
319
298
|
align-items: center;
|
|
@@ -330,7 +309,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
330
309
|
width: 360
|
|
331
310
|
}
|
|
332
311
|
}, _react2().default.createElement(_antd().Select, {
|
|
333
|
-
|
|
312
|
+
popupMatchSelectWidth: false,
|
|
334
313
|
onChange: value => {
|
|
335
314
|
removedDataSource.setCategoryFilter(value);
|
|
336
315
|
},
|
|
@@ -406,7 +385,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
406
385
|
})), _react2().default.createElement(_antd().Col, {
|
|
407
386
|
span: 12
|
|
408
387
|
}, _react2().default.createElement("div", {
|
|
409
|
-
className: (0,
|
|
388
|
+
className: (0, _client().css)`
|
|
410
389
|
display: flex;
|
|
411
390
|
justify-content: space-between;
|
|
412
391
|
align-items: center;
|
|
@@ -423,7 +402,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
423
402
|
width: 360
|
|
424
403
|
}
|
|
425
404
|
}, _react2().default.createElement(_antd().Select, {
|
|
426
|
-
|
|
405
|
+
popupMatchSelectWidth: false,
|
|
427
406
|
onChange: value => {
|
|
428
407
|
addedDataSource.setCategoryFilter(value);
|
|
429
408
|
},
|
|
@@ -449,7 +428,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
449
428
|
type: 'checkbox',
|
|
450
429
|
selectedRowKeys: selectedRowKeys2,
|
|
451
430
|
onChange(selectedRowKeys) {
|
|
452
|
-
const values = (
|
|
431
|
+
const values = _client2().lodash.uniq(removed.concat(selectedRowKeys));
|
|
453
432
|
setSelected(values);
|
|
454
433
|
onChange(values);
|
|
455
434
|
setSelectedRowKeys2([]);
|
|
@@ -470,7 +449,7 @@ const TableTransfer = (0, _react().connect)(props => {
|
|
|
470
449
|
const removing = findRemovable(name);
|
|
471
450
|
const change = () => {
|
|
472
451
|
removed.push(...removing);
|
|
473
|
-
const values = (
|
|
452
|
+
const values = _client2().lodash.uniq([...removed]);
|
|
474
453
|
setSelected(values);
|
|
475
454
|
onChange(values);
|
|
476
455
|
};
|
package/lib/client/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare
|
|
3
|
-
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
export declare class MultiAppShareCollectionPlugin extends Plugin {
|
|
3
|
+
load(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export default MultiAppShareCollectionPlugin;
|
package/lib/client/index.js
CHANGED
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
function _react() {
|
|
8
|
-
const data = require("@formily/react");
|
|
9
|
-
_react = function _react() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
6
|
+
exports.default = exports.MultiAppShareCollectionPlugin = void 0;
|
|
14
7
|
function _client() {
|
|
15
8
|
const data = require("@nocobase/client");
|
|
16
9
|
_client = function _client() {
|
|
@@ -18,105 +11,17 @@ function _client() {
|
|
|
18
11
|
};
|
|
19
12
|
return data;
|
|
20
13
|
}
|
|
21
|
-
|
|
22
|
-
const data = require("@nocobase/plugin-multi-app-manager/client");
|
|
23
|
-
_client2 = function _client2() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _antd() {
|
|
29
|
-
const data = require("antd");
|
|
30
|
-
_antd = function _antd() {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _react2() {
|
|
36
|
-
const data = _interopRequireDefault(require("react"));
|
|
37
|
-
_react2 = function _react2() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
var _TableTransfer = require("./TableTransfer");
|
|
43
|
-
var _utils = require("./utils");
|
|
44
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
var _MultiAppShareCollectionProvider = require("./MultiAppShareCollectionProvider");
|
|
45
15
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
46
16
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
run() {
|
|
54
|
-
return _asyncToGenerator(function* () {
|
|
55
|
-
console.log(form.values.names);
|
|
56
|
-
yield api.request({
|
|
57
|
-
url: `applications/${record.name}/collectionBlacklist`,
|
|
58
|
-
data: form.values.names,
|
|
59
|
-
method: 'post'
|
|
60
|
-
});
|
|
61
|
-
ctx.setVisible(false);
|
|
62
|
-
form.reset();
|
|
63
|
-
_antd().message.success('Saved successfully');
|
|
64
|
-
})();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const updateSchema = _client2().tableActionColumnSchema.properties.update;
|
|
69
|
-
const deleteSchema = _client2().tableActionColumnSchema.properties.delete;
|
|
70
|
-
delete _client2().tableActionColumnSchema.properties.update;
|
|
71
|
-
delete _client2().tableActionColumnSchema.properties.delete;
|
|
72
|
-
_client2().tableActionColumnSchema.properties['collection'] = {
|
|
73
|
-
type: 'void',
|
|
74
|
-
title: (0, _utils.i18nText)('Share collections'),
|
|
75
|
-
'x-component': 'Action.Link',
|
|
76
|
-
'x-component-props': {},
|
|
77
|
-
properties: {
|
|
78
|
-
drawer: {
|
|
79
|
-
type: 'void',
|
|
80
|
-
'x-component': 'Action.Drawer',
|
|
81
|
-
'x-component-props': {
|
|
82
|
-
width: '95vw'
|
|
83
|
-
},
|
|
84
|
-
'x-decorator': 'Form',
|
|
85
|
-
title: (0, _utils.i18nText)('Share collections'),
|
|
86
|
-
properties: {
|
|
87
|
-
names: {
|
|
88
|
-
type: 'array',
|
|
89
|
-
'x-component': _TableTransfer.TableTransfer,
|
|
90
|
-
'x-decorator': 'FormItem'
|
|
91
|
-
},
|
|
92
|
-
footer: {
|
|
93
|
-
type: 'void',
|
|
94
|
-
'x-component': 'Action.Drawer.Footer',
|
|
95
|
-
properties: {
|
|
96
|
-
cancel: {
|
|
97
|
-
title: '{{t("Cancel")}}',
|
|
98
|
-
'x-component': 'Action',
|
|
99
|
-
'x-component-props': {
|
|
100
|
-
useAction: '{{ cm.useCancelAction }}'
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
submit: {
|
|
104
|
-
title: '{{t("Submit")}}',
|
|
105
|
-
'x-component': 'Action',
|
|
106
|
-
'x-component-props': {
|
|
107
|
-
type: 'primary',
|
|
108
|
-
useAction: useShareCollectionAction
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
17
|
+
class MultiAppShareCollectionPlugin extends _client().Plugin {
|
|
18
|
+
load() {
|
|
19
|
+
var _this = this;
|
|
20
|
+
return _asyncToGenerator(function* () {
|
|
21
|
+
_this.app.use(_MultiAppShareCollectionProvider.MultiAppShareCollectionProvider);
|
|
22
|
+
})();
|
|
115
23
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var _default = props => {
|
|
120
|
-
return _react2().default.createElement(_react2().default.Fragment, null, props.children);
|
|
121
|
-
};
|
|
24
|
+
}
|
|
25
|
+
exports.MultiAppShareCollectionPlugin = MultiAppShareCollectionPlugin;
|
|
26
|
+
var _default = MultiAppShareCollectionPlugin;
|
|
122
27
|
exports.default = _default;
|
package/lib/server/plugin.js
CHANGED
|
@@ -18,9 +18,9 @@ function _server() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const data =
|
|
23
|
-
|
|
21
|
+
function _utils() {
|
|
22
|
+
const data = require("@nocobase/utils");
|
|
23
|
+
_utils = function _utils() {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
@@ -152,7 +152,7 @@ class MultiAppShareCollectionPlugin extends _server().Plugin {
|
|
|
152
152
|
}
|
|
153
153
|
const traverseSubApps = /*#__PURE__*/function () {
|
|
154
154
|
var _ref3 = _asyncToGenerator(function* (callback, options) {
|
|
155
|
-
if (
|
|
155
|
+
if (_utils().lodash.get(options, 'loadFromDatabase')) {
|
|
156
156
|
var _iterator2 = _createForOfIteratorHelper(yield _this2.app.db.getCollection('applications').repository.find()),
|
|
157
157
|
_step2;
|
|
158
158
|
try {
|
|
@@ -372,7 +372,7 @@ class MultiAppShareCollectionPlugin extends _server().Plugin {
|
|
|
372
372
|
});
|
|
373
373
|
const plugins = [...mainApp.pm.getPlugins().keys()].filter(name => name !== 'multi-app-manager' && name !== 'multi-app-share-collection');
|
|
374
374
|
return {
|
|
375
|
-
database:
|
|
375
|
+
database: _utils().lodash.merge(databaseOptions, {
|
|
376
376
|
dialectOptions: {
|
|
377
377
|
application_name: `nocobase.${appName}`
|
|
378
378
|
}
|
package/package.json
CHANGED
|
@@ -4,13 +4,33 @@
|
|
|
4
4
|
"displayName.zh-CN": "多应用数据共享",
|
|
5
5
|
"description": "multi app share collection",
|
|
6
6
|
"description.zh-CN": "多应用数据共享",
|
|
7
|
-
"version": "0.
|
|
8
|
-
"main": "lib/server/index.js",
|
|
7
|
+
"version": "0.11.0-alpha.1",
|
|
8
|
+
"main": "./lib/server/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib",
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"README.zh-CN.md",
|
|
14
|
+
"CHANGELOG.md",
|
|
15
|
+
"server.js",
|
|
16
|
+
"server.d.ts",
|
|
17
|
+
"client.js",
|
|
18
|
+
"client.d.ts"
|
|
19
|
+
],
|
|
9
20
|
"devDependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"@nocobase/
|
|
12
|
-
"@nocobase/
|
|
13
|
-
"@nocobase/
|
|
21
|
+
"@formily/react": "2.2.26",
|
|
22
|
+
"@nocobase/client": "0.11.0-alpha.1",
|
|
23
|
+
"@nocobase/database": "0.11.0-alpha.1",
|
|
24
|
+
"@nocobase/plugin-collection-manager": "0.11.0-alpha.1",
|
|
25
|
+
"@nocobase/plugin-error-handler": "0.11.0-alpha.1",
|
|
26
|
+
"@nocobase/plugin-multi-app-manager": "0.11.0-alpha.1",
|
|
27
|
+
"@nocobase/plugin-users": "0.11.0-alpha.1",
|
|
28
|
+
"@nocobase/server": "0.11.0-alpha.1",
|
|
29
|
+
"@nocobase/test": "0.11.0-alpha.1",
|
|
30
|
+
"@nocobase/utils": "0.11.0-alpha.1",
|
|
31
|
+
"antd": "^5.6.4",
|
|
32
|
+
"react": "18.x",
|
|
33
|
+
"react-i18next": "^11.15.1"
|
|
14
34
|
},
|
|
15
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
|
|
16
36
|
}
|
package/server.d.ts
CHANGED
package/server.js
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
4
|
-
|
|
5
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
|
-
|
|
7
|
-
var _index = _interopRequireWildcard(require("./lib/server"));
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
var _exportNames = {};
|
|
13
|
-
Object.defineProperty(exports, "default", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _index.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Object.keys(_index).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _index[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _index[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
1
|
+
module.exports = require('./lib/server/index.js');
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useForm } from '@formily/react';
|
|
2
|
+
import { useActionContext, useAPIClient, useRecord } from '@nocobase/client';
|
|
3
|
+
import { tableActionColumnSchema } from '@nocobase/plugin-multi-app-manager/client';
|
|
4
|
+
import { message } from 'antd';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { TableTransfer } from './TableTransfer';
|
|
7
|
+
import { i18nText } from './utils';
|
|
8
|
+
|
|
9
|
+
const useShareCollectionAction = () => {
|
|
10
|
+
const form = useForm();
|
|
11
|
+
const ctx = useActionContext();
|
|
12
|
+
const api = useAPIClient();
|
|
13
|
+
const record = useRecord();
|
|
14
|
+
return {
|
|
15
|
+
async run() {
|
|
16
|
+
console.log(form.values.names);
|
|
17
|
+
await api.request({
|
|
18
|
+
url: `applications/${record.name}/collectionBlacklist`,
|
|
19
|
+
data: form.values.names,
|
|
20
|
+
method: 'post',
|
|
21
|
+
});
|
|
22
|
+
ctx.setVisible(false);
|
|
23
|
+
form.reset();
|
|
24
|
+
message.success('Saved successfully');
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const updateSchema = tableActionColumnSchema.properties.update;
|
|
30
|
+
const deleteSchema = tableActionColumnSchema.properties.delete;
|
|
31
|
+
|
|
32
|
+
delete tableActionColumnSchema.properties.update;
|
|
33
|
+
delete tableActionColumnSchema.properties.delete;
|
|
34
|
+
|
|
35
|
+
tableActionColumnSchema.properties['collection'] = {
|
|
36
|
+
type: 'void',
|
|
37
|
+
title: i18nText('Share collections'),
|
|
38
|
+
'x-component': 'Action.Link',
|
|
39
|
+
'x-component-props': {},
|
|
40
|
+
properties: {
|
|
41
|
+
drawer: {
|
|
42
|
+
type: 'void',
|
|
43
|
+
'x-component': 'Action.Drawer',
|
|
44
|
+
'x-component-props': {
|
|
45
|
+
width: '95vw',
|
|
46
|
+
},
|
|
47
|
+
'x-decorator': 'Form',
|
|
48
|
+
title: i18nText('Share collections'),
|
|
49
|
+
properties: {
|
|
50
|
+
names: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
'x-component': TableTransfer,
|
|
53
|
+
'x-decorator': 'FormItem',
|
|
54
|
+
},
|
|
55
|
+
footer: {
|
|
56
|
+
type: 'void',
|
|
57
|
+
'x-component': 'Action.Drawer.Footer',
|
|
58
|
+
properties: {
|
|
59
|
+
cancel: {
|
|
60
|
+
title: '{{t("Cancel")}}',
|
|
61
|
+
'x-component': 'Action',
|
|
62
|
+
'x-component-props': {
|
|
63
|
+
useAction: '{{ cm.useCancelAction }}',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
submit: {
|
|
67
|
+
title: '{{t("Submit")}}',
|
|
68
|
+
'x-component': 'Action',
|
|
69
|
+
'x-component-props': {
|
|
70
|
+
type: 'primary',
|
|
71
|
+
useAction: useShareCollectionAction,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
tableActionColumnSchema.properties.update = updateSchema;
|
|
82
|
+
tableActionColumnSchema.properties.delete = deleteSchema;
|
|
83
|
+
|
|
84
|
+
export const MultiAppShareCollectionProvider = (props) => {
|
|
85
|
+
return <>{props.children}</>;
|
|
86
|
+
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { css } from '@emotion/css';
|
|
2
1
|
import { connect } from '@formily/react';
|
|
3
|
-
import { useCollectionManager, useRecord, useRequest } from '@nocobase/client';
|
|
4
|
-
import { CollectionsGraph } from '@nocobase/utils/client';
|
|
2
|
+
import { css, useCollectionManager, useRecord, useRequest } from '@nocobase/client';
|
|
3
|
+
import { CollectionsGraph, lodash } from '@nocobase/utils/client';
|
|
5
4
|
import { Col, Input, Modal, Row, Select, Spin, Table, Tag } from 'antd';
|
|
6
|
-
import debounce from 'lodash/debounce';
|
|
7
|
-
import uniq from 'lodash/uniq';
|
|
8
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
9
6
|
import { useTranslation } from 'react-i18next';
|
|
10
7
|
|
|
@@ -116,7 +113,7 @@ const useRemovedDataSource = ({ collections, removed }) => {
|
|
|
116
113
|
}, [collections, removed, filter]);
|
|
117
114
|
const setNameFilter = useMemo(
|
|
118
115
|
() =>
|
|
119
|
-
debounce((name) => {
|
|
116
|
+
lodash.debounce((name) => {
|
|
120
117
|
setFilter({
|
|
121
118
|
...filter,
|
|
122
119
|
name,
|
|
@@ -151,7 +148,7 @@ const useAddedDataSource = ({ collections, removed }) => {
|
|
|
151
148
|
});
|
|
152
149
|
const setNameFilter = useMemo(
|
|
153
150
|
() =>
|
|
154
|
-
debounce((name) => {
|
|
151
|
+
lodash.debounce((name) => {
|
|
155
152
|
setFilter({
|
|
156
153
|
...filter,
|
|
157
154
|
name,
|
|
@@ -193,7 +190,12 @@ export const TableTransfer = connect((props) => {
|
|
|
193
190
|
{
|
|
194
191
|
title: t('Collection category'),
|
|
195
192
|
dataIndex: 'category',
|
|
196
|
-
render: (categories) =>
|
|
193
|
+
render: (categories) =>
|
|
194
|
+
categories.map((category) => (
|
|
195
|
+
<Tag key={category.name} color={category.color}>
|
|
196
|
+
{category.name}
|
|
197
|
+
</Tag>
|
|
198
|
+
)),
|
|
197
199
|
},
|
|
198
200
|
],
|
|
199
201
|
[],
|
|
@@ -225,7 +227,7 @@ export const TableTransfer = connect((props) => {
|
|
|
225
227
|
<strong style={{ fontSize: 16 }}>{t('Unshared collections')}</strong>
|
|
226
228
|
<Input.Group compact style={{ width: 360 }}>
|
|
227
229
|
<Select
|
|
228
|
-
|
|
230
|
+
popupMatchSelectWidth={false}
|
|
229
231
|
onChange={(value) => {
|
|
230
232
|
removedDataSource.setCategoryFilter(value);
|
|
231
233
|
}}
|
|
@@ -263,7 +265,7 @@ export const TableTransfer = connect((props) => {
|
|
|
263
265
|
// dataSource={collections.filter((collection) => removed.includes(collection.name))}
|
|
264
266
|
dataSource={removedDataSource.dataSource}
|
|
265
267
|
scroll={{ y: 'calc(100vh - 260px)' }}
|
|
266
|
-
onRow={({ name, disabled }) => ({
|
|
268
|
+
onRow={({ name, disabled }: any) => ({
|
|
267
269
|
onClick: () => {
|
|
268
270
|
if (disabled) return;
|
|
269
271
|
const adding = findAddable(name);
|
|
@@ -310,7 +312,7 @@ export const TableTransfer = connect((props) => {
|
|
|
310
312
|
<strong style={{ fontSize: 16 }}>{t('Shared collections')}</strong>
|
|
311
313
|
<Input.Group compact style={{ width: 360 }}>
|
|
312
314
|
<Select
|
|
313
|
-
|
|
315
|
+
popupMatchSelectWidth={false}
|
|
314
316
|
onChange={(value) => {
|
|
315
317
|
addedDataSource.setCategoryFilter(value);
|
|
316
318
|
}}
|
|
@@ -336,7 +338,7 @@ export const TableTransfer = connect((props) => {
|
|
|
336
338
|
type: 'checkbox',
|
|
337
339
|
selectedRowKeys: selectedRowKeys2,
|
|
338
340
|
onChange(selectedRowKeys) {
|
|
339
|
-
const values = uniq(removed.concat(selectedRowKeys));
|
|
341
|
+
const values = lodash.uniq(removed.concat(selectedRowKeys));
|
|
340
342
|
setSelected(values);
|
|
341
343
|
onChange(values);
|
|
342
344
|
setSelectedRowKeys2([]);
|
|
@@ -353,7 +355,7 @@ export const TableTransfer = connect((props) => {
|
|
|
353
355
|
const removing = findRemovable(name);
|
|
354
356
|
const change = () => {
|
|
355
357
|
removed.push(...removing);
|
|
356
|
-
const values = uniq([...removed]);
|
|
358
|
+
const values = lodash.uniq([...removed]);
|
|
357
359
|
setSelected(values);
|
|
358
360
|
onChange(values);
|
|
359
361
|
};
|
package/src/client/index.tsx
CHANGED
|
@@ -1,86 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { tableActionColumnSchema } from '@nocobase/plugin-multi-app-manager/client';
|
|
4
|
-
import { message } from 'antd';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { TableTransfer } from './TableTransfer';
|
|
7
|
-
import { i18nText } from './utils';
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
import { MultiAppShareCollectionProvider } from './MultiAppShareCollectionProvider';
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
async run() {
|
|
16
|
-
console.log(form.values.names);
|
|
17
|
-
await api.request({
|
|
18
|
-
url: `applications/${record.name}/collectionBlacklist`,
|
|
19
|
-
data: form.values.names,
|
|
20
|
-
method: 'post',
|
|
21
|
-
});
|
|
22
|
-
ctx.setVisible(false);
|
|
23
|
-
form.reset();
|
|
24
|
-
message.success('Saved successfully');
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
};
|
|
4
|
+
export class MultiAppShareCollectionPlugin extends Plugin {
|
|
5
|
+
async load() {
|
|
6
|
+
this.app.use(MultiAppShareCollectionProvider);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
28
9
|
|
|
29
|
-
|
|
30
|
-
const deleteSchema = tableActionColumnSchema.properties.delete;
|
|
31
|
-
|
|
32
|
-
delete tableActionColumnSchema.properties.update;
|
|
33
|
-
delete tableActionColumnSchema.properties.delete;
|
|
34
|
-
|
|
35
|
-
tableActionColumnSchema.properties['collection'] = {
|
|
36
|
-
type: 'void',
|
|
37
|
-
title: i18nText('Share collections'),
|
|
38
|
-
'x-component': 'Action.Link',
|
|
39
|
-
'x-component-props': {},
|
|
40
|
-
properties: {
|
|
41
|
-
drawer: {
|
|
42
|
-
type: 'void',
|
|
43
|
-
'x-component': 'Action.Drawer',
|
|
44
|
-
'x-component-props': {
|
|
45
|
-
width: '95vw',
|
|
46
|
-
},
|
|
47
|
-
'x-decorator': 'Form',
|
|
48
|
-
title: i18nText('Share collections'),
|
|
49
|
-
properties: {
|
|
50
|
-
names: {
|
|
51
|
-
type: 'array',
|
|
52
|
-
'x-component': TableTransfer,
|
|
53
|
-
'x-decorator': 'FormItem',
|
|
54
|
-
},
|
|
55
|
-
footer: {
|
|
56
|
-
type: 'void',
|
|
57
|
-
'x-component': 'Action.Drawer.Footer',
|
|
58
|
-
properties: {
|
|
59
|
-
cancel: {
|
|
60
|
-
title: '{{t("Cancel")}}',
|
|
61
|
-
'x-component': 'Action',
|
|
62
|
-
'x-component-props': {
|
|
63
|
-
useAction: '{{ cm.useCancelAction }}',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
submit: {
|
|
67
|
-
title: '{{t("Submit")}}',
|
|
68
|
-
'x-component': 'Action',
|
|
69
|
-
'x-component-props': {
|
|
70
|
-
type: 'primary',
|
|
71
|
-
useAction: useShareCollectionAction,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
tableActionColumnSchema.properties.update = updateSchema;
|
|
82
|
-
tableActionColumnSchema.properties.delete = deleteSchema;
|
|
83
|
-
|
|
84
|
-
export default (props) => {
|
|
85
|
-
return <>{props.children}</>;
|
|
86
|
-
};
|
|
10
|
+
export default MultiAppShareCollectionPlugin;
|
package/src/server/plugin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PluginMultiAppManager from '@nocobase/plugin-multi-app-manager';
|
|
2
2
|
import { Application, Plugin } from '@nocobase/server';
|
|
3
|
-
import lodash from '
|
|
3
|
+
import { lodash } from '@nocobase/utils';
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
|
|
6
6
|
const subAppFilteredPlugins = ['multi-app-share-collection', 'multi-app-manager'];
|