@nocobase/plugin-graph-collection-manager 0.9.0-alpha.1 → 0.9.1-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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # graph-collection-manager
2
+
3
+ English | [中文](./README.zh-CN.md)
4
+
5
+ ## 安装激活
6
+
7
+ ```bash
8
+ yarn pm enable graph-collection-manager
9
+ ```
10
+
11
+ ## 使用方法
@@ -0,0 +1,11 @@
1
+ # graph-collection-manager
2
+
3
+ [English](./README.md) | 中文
4
+
5
+ ## 安装激活
6
+
7
+ ```bash
8
+ yarn pm enable graph-collection-manager
9
+ ```
10
+
11
+ ## 使用方法
@@ -25,19 +25,9 @@ function _react() {
25
25
  return data;
26
26
  }
27
27
 
28
- function _reactI18next() {
29
- const data = require("react-i18next");
30
-
31
- _reactI18next = function _reactI18next() {
32
- return data;
33
- };
34
-
35
- return data;
36
- }
37
-
38
28
  var _GraphCollectionShortcut = require("./GraphCollectionShortcut");
39
29
 
40
- var _locale = require("./locale");
30
+ var _utils = require("./utils");
41
31
 
42
32
  const _excluded = ["routes", "components"];
43
33
 
@@ -61,16 +51,13 @@ const GraphCollectionProvider = _react().default.memo(props => {
61
51
  const _useContext = (0, _react().useContext)(_client().RouteSwitchContext),
62
52
  routes = _useContext.routes,
63
53
  components = _useContext.components,
64
- others = _objectWithoutProperties(_useContext, _excluded);
65
-
66
- _client().i18n.addResources('en-US', 'graphPositions', _locale.enUS);
67
-
68
- _client().i18n.addResources('ja-JP', 'graphPositions', _locale.jaJP);
54
+ others = _objectWithoutProperties(_useContext, _excluded); // i18n.addResources('en-US', 'graphPositions', enUS);
55
+ // i18n.addResources('ja-JP', 'graphPositions', jaJP);
56
+ // i18n.addResources('zh-CN', 'graphPositions', zhCN);
69
57
 
70
- _client().i18n.addResources('zh-CN', 'graphPositions', _locale.zhCN);
71
58
 
72
- const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
73
- t = _useTranslation.t;
59
+ const _useGCMTranslation = (0, _utils.useGCMTranslation)(),
60
+ t = _useGCMTranslation.t;
74
61
 
75
62
  const items = (0, _react().useContext)(_client().SettingsCenterContext);
76
63
  items['collection-manager']['tabs']['graph'] = {
@@ -15,6 +15,16 @@ function _icons() {
15
15
  return data;
16
16
  }
17
17
 
18
+ function _css() {
19
+ const data = require("@emotion/css");
20
+
21
+ _css = function _css() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
18
28
  function _shared() {
19
29
  const data = require("@formily/shared");
20
30
 
@@ -45,26 +55,6 @@ function _react() {
45
55
  return data;
46
56
  }
47
57
 
48
- function _css() {
49
- const data = require("@emotion/css");
50
-
51
- _css = function _css() {
52
- return data;
53
- };
54
-
55
- return data;
56
- }
57
-
58
- function _reactI18next() {
59
- const data = require("react-i18next");
60
-
61
- _reactI18next = function _reactI18next() {
62
- return data;
63
- };
64
-
65
- return data;
66
- }
67
-
68
58
  function _reactRouterDom() {
69
59
  const data = require("react-router-dom");
70
60
 
@@ -79,6 +69,8 @@ var _actionHooks = require("./action-hooks");
79
69
 
80
70
  var _GraphDrawPage = require("./GraphDrawPage");
81
71
 
72
+ var _utils = require("./utils");
73
+
82
74
  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); }
83
75
 
84
76
  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; }
@@ -220,8 +212,8 @@ const GraphCollectionPane = () => {
220
212
  exports.GraphCollectionPane = GraphCollectionPane;
221
213
 
222
214
  const GraphCollectionShortcut = () => {
223
- const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
224
- t = _useTranslation.t;
215
+ const _useGCMTranslation = (0, _utils.useGCMTranslation)(),
216
+ t = _useGCMTranslation.t;
225
217
 
226
218
  const history = (0, _reactRouterDom().useHistory)();
227
219
  return _react().default.createElement(_client().PluginManager.Toolbar.Item, {
@@ -107,28 +107,18 @@ function _react2() {
107
107
  return data;
108
108
  }
109
109
 
110
- function _reactI18next() {
111
- const data = require("react-i18next");
112
-
113
- _reactI18next = function _reactI18next() {
114
- return data;
115
- };
116
-
117
- return data;
118
- }
119
-
120
110
  var _actionHooks = require("./action-hooks");
121
111
 
122
112
  var _AddCollectionAction = require("./components/AddCollectionAction");
123
113
 
124
114
  var _Entity = _interopRequireDefault(require("./components/Entity"));
125
115
 
116
+ var _ViewNode = require("./components/ViewNode");
117
+
126
118
  var _style = require("./style");
127
119
 
128
120
  var _utils = require("./utils");
129
121
 
130
- var _ViewNode = require("./components/ViewNode");
131
-
132
122
  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); }
133
123
 
134
124
  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; }
@@ -557,8 +547,8 @@ const GraphDrawPage = _react2().default.memo(() => {
557
547
  const api = (0, _client().useAPIClient)();
558
548
  const compile = (0, _client().useCompile)();
559
549
 
560
- const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
561
- t = _useTranslation.t;
550
+ const _useGCMTranslation = (0, _utils.useGCMTranslation)(),
551
+ t = _useGCMTranslation.t;
562
552
 
563
553
  const _useState = (0, _react2().useState)([]),
564
554
  _useState2 = _slicedToArray(_useState, 2),
@@ -643,7 +633,6 @@ const GraphDrawPage = _react2().default.memo(() => {
643
633
  const refreshGM = /*#__PURE__*/function () {
644
634
  var _ref4 = _asyncToGenerator(function* () {
645
635
  const data = yield refreshCM();
646
- console.log(data);
647
636
  targetGraph.collections = data;
648
637
  targetGraph.updatePositionAction = useUpdatePositionAction;
649
638
  const currentNodes = targetGraph.getNodes();
@@ -760,7 +749,7 @@ const GraphDrawPage = _react2().default.memo(() => {
760
749
  inherit: true,
761
750
  scope: scope,
762
751
  components: components
763
- }, _react2().default.createElement(_client().CollectionManagerProvider, {
752
+ }, _react2().default.createElement(_client().CollectionCategroriesProvider, null, _react2().default.createElement(_client().CollectionManagerProvider, {
764
753
  collections: (_targetGraph2 = targetGraph) === null || _targetGraph2 === void 0 ? void 0 : _targetGraph2.collections,
765
754
  refreshCM: refreshGM,
766
755
  interfaces: ctx.interfaces
@@ -772,7 +761,7 @@ const GraphDrawPage = _react2().default.memo(() => {
772
761
  node: node,
773
762
  setTargetNode: setTargetNode,
774
763
  targetGraph: targetGraph
775
- }))))));
764
+ })))))));
776
765
  },
777
766
  ports: {
778
767
  groups: {
@@ -47,16 +47,6 @@ function _client() {
47
47
  return data;
48
48
  }
49
49
 
50
- function _reactI18next() {
51
- const data = require("react-i18next");
52
-
53
- _reactI18next = function _reactI18next() {
54
- return data;
55
- };
56
-
57
- return data;
58
- }
59
-
60
50
  function _antd() {
61
51
  const data = require("antd");
62
52
 
@@ -67,20 +57,20 @@ function _antd() {
67
57
  return data;
68
58
  }
69
59
 
70
- function _react() {
71
- const data = _interopRequireWildcard(require("react"));
60
+ function _lodash() {
61
+ const data = require("lodash");
72
62
 
73
- _react = function _react() {
63
+ _lodash = function _lodash() {
74
64
  return data;
75
65
  };
76
66
 
77
67
  return data;
78
68
  }
79
69
 
80
- function _lodash() {
81
- const data = require("lodash");
70
+ function _react() {
71
+ const data = _interopRequireWildcard(require("react"));
82
72
 
83
- _lodash = function _lodash() {
73
+ _react = function _react() {
84
74
  return data;
85
75
  };
86
76
 
@@ -91,20 +81,22 @@ var _actionHooks = require("../action-hooks");
91
81
 
92
82
  var _style = require("../style");
93
83
 
94
- var _FieldSummary = require("./FieldSummary");
84
+ var _utils = require("../utils");
95
85
 
96
86
  var _AddFieldAction = require("./AddFieldAction");
97
87
 
98
88
  var _CollectionNodeProvder = require("./CollectionNodeProvder");
99
89
 
90
+ var _EditCollectionAction = require("./EditCollectionAction");
91
+
100
92
  var _EditFieldAction = require("./EditFieldAction");
101
93
 
94
+ var _FieldSummary = require("./FieldSummary");
95
+
102
96
  var _OverrideFieldAction = require("./OverrideFieldAction");
103
97
 
104
98
  var _ViewFieldAction = require("./ViewFieldAction");
105
99
 
106
- var _EditCollectionAction = require("./EditCollectionAction");
107
-
108
100
  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); }
109
101
 
110
102
  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; }
@@ -144,10 +136,12 @@ const Entity = props => {
144
136
  id = node.id;
145
137
  const database = (0, _client().useCurrentAppInfo)();
146
138
  const collectionData = (0, _react().useRef)();
139
+ const categoryData = (0, _react().useContext)(_client().CollectionCategroriesContext);
147
140
  collectionData.current = _objectSpread(_objectSpread({}, item), {}, {
148
141
  title,
149
142
  inherits: item.inherits && new Proxy(item.inherits, {})
150
143
  });
144
+ const category = item.category;
151
145
  const compile = (0, _client().useCompile)();
152
146
 
153
147
  const loadCollections = /*#__PURE__*/function () {
@@ -165,6 +159,19 @@ const Entity = props => {
165
159
  };
166
160
  }();
167
161
 
162
+ const loadCategories = /*#__PURE__*/function () {
163
+ var _ref2 = _asyncToGenerator(function* () {
164
+ return categoryData.data.map(item => ({
165
+ label: compile(item.name),
166
+ value: item.id
167
+ }));
168
+ });
169
+
170
+ return function loadCategories() {
171
+ return _ref2.apply(this, arguments);
172
+ };
173
+ }();
174
+
168
175
  const portsProps = {
169
176
  targetGraph,
170
177
  collectionData,
@@ -178,10 +185,22 @@ const Entity = props => {
178
185
  boxShadow: attrs === null || attrs === void 0 ? void 0 : attrs.boxShadow,
179
186
  border: select ? '2px dashed #f5a20a' : 0
180
187
  }
181
- }, _react().default.createElement("div", {
188
+ }, category.map((v, index) => {
189
+ return _react().default.createElement(_antd().Badge.Ribbon, {
190
+ color: v.color,
191
+ style: {
192
+ width: '103%',
193
+ height: '3px',
194
+ marginTop: index * 5 - 8,
195
+ borderRadius: 0
196
+ },
197
+ placement: "start"
198
+ });
199
+ }), _react().default.createElement("div", {
182
200
  className: _style.headClass,
183
201
  style: {
184
- background: (attrs === null || attrs === void 0 ? void 0 : attrs.hightLight) ? '#1890ff' : null
202
+ background: (attrs === null || attrs === void 0 ? void 0 : attrs.hightLight) ? '#1890ff' : null,
203
+ paddingTop: category.length * 3
185
204
  }
186
205
  }, _react().default.createElement("span", {
187
206
  className: _style.tableNameClass
@@ -197,6 +216,7 @@ const Entity = props => {
197
216
  useUpdateCollectionActionAndRefreshCM: _actionHooks.useUpdateCollectionActionAndRefreshCM,
198
217
  useCancelAction: _actionHooks.useCancelAction,
199
218
  loadCollections,
219
+ loadCategories,
200
220
  useAsyncDataSource: _actionHooks.useAsyncDataSource,
201
221
  Action: _client().Action,
202
222
  DeleteOutlined: _icons().DeleteOutlined,
@@ -284,8 +304,8 @@ const PortsCom = _react().default.memo(({
284
304
  collapse = _useState2[0],
285
305
  setCollapse = _useState2[1];
286
306
 
287
- const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
288
- t = _useTranslation.t;
307
+ const _useGCMTranslation = (0, _utils.useGCMTranslation)(),
308
+ t = _useGCMTranslation.t;
289
309
 
290
310
  const compile = (0, _client().useCompile)();
291
311
  const portsData = (0, _lodash().groupBy)(ports.items, v => {
@@ -143,7 +143,7 @@ const entityContainer = (0, _css().css)`
143
143
  `;
144
144
  exports.entityContainer = entityContainer;
145
145
  const headClass = (0, _css().css)`
146
- height: 40px;
146
+ height: 50px;
147
147
  font-size: 14px;
148
148
  font-weight: 500;
149
149
  display: flex;
@@ -1,3 +1,4 @@
1
+ export declare const useGCMTranslation: () => import("react-i18next").UseTranslationResponse<"graph-collection-manager", undefined>;
1
2
  export declare const getInheritCollections: (collections: any, name: any) => any[];
2
3
  export declare const getChildrenCollections: (collections: any, name: any) => any[];
3
4
  export declare const formatData: (data: any) => {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getInheritCollections = exports.getDiffNode = exports.getDiffEdge = exports.getChildrenCollections = exports.formatPortData = exports.formatInheritEdgeData = exports.formatData = void 0;
6
+ exports.useGCMTranslation = exports.getInheritCollections = exports.getDiffNode = exports.getDiffEdge = exports.getChildrenCollections = exports.formatPortData = exports.formatInheritEdgeData = exports.formatData = void 0;
7
7
 
8
8
  function _lodash() {
9
9
  const data = require("lodash");
@@ -15,6 +15,16 @@ function _lodash() {
15
15
  return data;
16
16
  }
17
17
 
18
+ function _reactI18next() {
19
+ const data = require("react-i18next");
20
+
21
+ _reactI18next = function _reactI18next() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
18
28
  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; }
19
29
 
20
30
  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; }
@@ -26,6 +36,12 @@ const shape = {
26
36
  EDGE: 'edge'
27
37
  };
28
38
 
39
+ const useGCMTranslation = () => {
40
+ return (0, _reactI18next().useTranslation)('graph-collection-manager');
41
+ };
42
+
43
+ exports.useGCMTranslation = useGCMTranslation;
44
+
29
45
  const getInheritCollections = (collections, name) => {
30
46
  const parents = [];
31
47
 
@@ -16,6 +16,8 @@ function _database() {
16
16
  }
17
17
 
18
18
  var _default = (0, _database().defineCollection)({
19
+ namespace: 'graph-collection-manager',
20
+ duplicator: 'required',
19
21
  name: 'graphPositions',
20
22
  fields: [{
21
23
  type: 'string',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-graph-collection-manager",
3
- "version": "0.9.0-alpha.1",
3
+ "version": "0.9.1-alpha.1",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
@@ -11,8 +11,8 @@
11
11
  "dagre": "^0.8.5"
12
12
  },
13
13
  "devDependencies": {
14
- "@nocobase/client": "0.9.0-alpha.1",
15
- "@nocobase/test": "0.9.0-alpha.1"
14
+ "@nocobase/client": "0.9.1-alpha.1",
15
+ "@nocobase/test": "0.9.1-alpha.1"
16
16
  },
17
- "gitHead": "d84c2a47c42c2ffec4fbf317d53268952fbd58d7"
17
+ "gitHead": "56cb184b00dc383b853015d525bf6e79dea92169"
18
18
  }