@abtnode/ux 1.8.39 → 1.8.41
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/lib/blocklet/access/config-access.js +5 -1
- package/lib/blocklet/access/index.js +1 -0
- package/lib/blocklet/avatar.js +6 -15
- package/lib/blocklet/component/add.js +1 -2
- package/lib/blocklet/component/navigation/locale-tabs.js +218 -0
- package/lib/blocklet/component/navigation/navigation-actions.js +103 -0
- package/lib/blocklet/component/navigation/navigation-dialog.js +613 -0
- package/lib/blocklet/component/navigation/navigation-preview.js +101 -0
- package/lib/blocklet/component/navigation/simple-select.js +129 -0
- package/lib/blocklet/component/sortable-tree.js +124 -0
- package/lib/blocklet/config-navigation.js +320 -0
- package/lib/blocklet/configuration.js +1 -2
- package/lib/blocklet/preferences/index.js +3 -0
- package/lib/hooks/blocklet.js +13 -1
- package/lib/hooks/use-avatar.js +36 -0
- package/lib/hooks/use-navigation.js +364 -0
- package/lib/locales/en.js +24 -1
- package/lib/locales/zh.js +24 -1
- package/lib/team/members/passports.js +3 -3
- package/lib/team/passports/color.js +1 -2
- package/lib/team/passports/index.js +5 -4
- package/lib/util/locales.js +28 -0
- package/package.json +21 -13
|
@@ -86,6 +86,7 @@ function BlockletPreferences(_ref) {
|
|
|
86
86
|
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
87
87
|
display: "flex",
|
|
88
88
|
alignItems: "center",
|
|
89
|
+
"data-cy": "configuration-tab-general",
|
|
89
90
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TuneRounded.default, {
|
|
90
91
|
sx: {
|
|
91
92
|
fontSize: 24
|
|
@@ -105,6 +106,7 @@ function BlockletPreferences(_ref) {
|
|
|
105
106
|
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
106
107
|
display: "flex",
|
|
107
108
|
alignItems: "center",
|
|
109
|
+
"data-cy": "configuration-tab-access",
|
|
108
110
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Key.default, {
|
|
109
111
|
sx: {
|
|
110
112
|
fontSize: 24
|
|
@@ -124,6 +126,7 @@ function BlockletPreferences(_ref) {
|
|
|
124
126
|
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
125
127
|
display: "flex",
|
|
126
128
|
alignItems: "center",
|
|
129
|
+
"data-cy": "configuration-tab-preference",
|
|
127
130
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
128
131
|
ml: -2,
|
|
129
132
|
style: {
|
package/lib/hooks/blocklet.js
CHANGED
|
@@ -137,6 +137,17 @@ function useBlocklet(_ref) {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
+
const configNavigations = async value => {
|
|
141
|
+
const {
|
|
142
|
+
blocklet: data
|
|
143
|
+
} = await client.configNavigations({
|
|
144
|
+
input: {
|
|
145
|
+
did,
|
|
146
|
+
navigations: value
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
setBlocklet(data);
|
|
150
|
+
};
|
|
140
151
|
(0, _react.useEffect)(() => {
|
|
141
152
|
if (domainListStr && !disableSubscription) {
|
|
142
153
|
refreshDomainStatus();
|
|
@@ -181,7 +192,8 @@ function useBlocklet(_ref) {
|
|
|
181
192
|
actions: {
|
|
182
193
|
refreshBlocklet,
|
|
183
194
|
refreshDomainStatus,
|
|
184
|
-
setBlocklet
|
|
195
|
+
setBlocklet,
|
|
196
|
+
configNavigations
|
|
185
197
|
}
|
|
186
198
|
};
|
|
187
199
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useAvatar;
|
|
7
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
8
|
+
var _constant = require("@abtnode/constant");
|
|
9
|
+
var _node = require("../contexts/node");
|
|
10
|
+
var _util = require("../util");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function useAvatar(_ref) {
|
|
13
|
+
var _blocklet$meta;
|
|
14
|
+
let {
|
|
15
|
+
blocklet,
|
|
16
|
+
ancestors = []
|
|
17
|
+
} = _ref;
|
|
18
|
+
const node = (0, _node.useNodeContext)();
|
|
19
|
+
const {
|
|
20
|
+
inService
|
|
21
|
+
} = node;
|
|
22
|
+
const search = "?version=".concat(blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.version);
|
|
23
|
+
let logoUrl = inService ? (0, _urlJoin.default)(_util.APP_PREFIX, _constant.WELLKNOWN_SERVICE_PATH_PREFIX, '/blocklet/logo', search) : (0, _urlJoin.default)(node.prefix, 'blocklet.png');
|
|
24
|
+
if (blocklet.source === 'registry' && blocklet.deployedFrom && blocklet.meta.logo) {
|
|
25
|
+
logoUrl = (0, _urlJoin.default)(blocklet.deployedFrom, (0, _util.formatRegistryLogoPath)(blocklet.meta.bundleDid, blocklet.meta.logo), search);
|
|
26
|
+
} else {
|
|
27
|
+
const prefix = window.env.apiPrefix || '/';
|
|
28
|
+
const components = ancestors.concat(blocklet);
|
|
29
|
+
const list = inService ? components.slice(1) : components;
|
|
30
|
+
logoUrl = (0, _urlJoin.default)(prefix, "/blocklet/logo".concat(list.map(x => "/".concat(x.meta.did)).join('')), search);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
logoUrl,
|
|
34
|
+
inService
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useNavigation;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
9
|
+
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
10
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
11
|
+
var _omitBy = _interopRequireDefault(require("lodash/omitBy"));
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _nanoid = require("nanoid");
|
|
14
|
+
var _material = require("@mui/material");
|
|
15
|
+
var _parseNavigationFromBlocklet = require("@blocklet/meta/lib/parse-navigation-from-blocklet");
|
|
16
|
+
var _constant = require("@abtnode/constant");
|
|
17
|
+
var _blocklet = require("../contexts/blocklet");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
+
const BASE_LINK = '/';
|
|
24
|
+
const DEFAULT_SECTION = 'header';
|
|
25
|
+
// 默认注入的数据
|
|
26
|
+
// 需要指定一些内置的 id
|
|
27
|
+
const injectNavigationData = {
|
|
28
|
+
sessionManager: [{
|
|
29
|
+
id: '/sessionManager',
|
|
30
|
+
title: {
|
|
31
|
+
en: 'Manage',
|
|
32
|
+
zh: '管理'
|
|
33
|
+
},
|
|
34
|
+
section: ['sessionManager'],
|
|
35
|
+
icon: 'ion:settings-outline',
|
|
36
|
+
link: "".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/admin"),
|
|
37
|
+
role: ['owner', 'admin'],
|
|
38
|
+
from: 'tmpl'
|
|
39
|
+
}],
|
|
40
|
+
dashboard: [{
|
|
41
|
+
id: '/access',
|
|
42
|
+
title: {
|
|
43
|
+
en: 'Access',
|
|
44
|
+
zh: '访问控制'
|
|
45
|
+
},
|
|
46
|
+
role: ['owner', 'admin', 'member'],
|
|
47
|
+
section: ['dashboard'],
|
|
48
|
+
link: '',
|
|
49
|
+
from: 'tmpl',
|
|
50
|
+
items: [{
|
|
51
|
+
id: 'member',
|
|
52
|
+
title: {
|
|
53
|
+
en: 'Members',
|
|
54
|
+
zh: '成员'
|
|
55
|
+
},
|
|
56
|
+
icon: 'ant-design:user-outlined',
|
|
57
|
+
link: "".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/admin/members"),
|
|
58
|
+
from: 'tmpl'
|
|
59
|
+
}, {
|
|
60
|
+
id: 'passport',
|
|
61
|
+
title: {
|
|
62
|
+
en: 'Passport',
|
|
63
|
+
zh: '通行证'
|
|
64
|
+
},
|
|
65
|
+
icon: 'icon-park-outline:passport',
|
|
66
|
+
link: "".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/admin/passports"),
|
|
67
|
+
from: 'tmpl'
|
|
68
|
+
}]
|
|
69
|
+
}, {
|
|
70
|
+
id: '/dashboard',
|
|
71
|
+
title: 'Blocklet',
|
|
72
|
+
role: ['owner', 'admin'],
|
|
73
|
+
section: ['dashboard'],
|
|
74
|
+
link: '',
|
|
75
|
+
from: 'tmpl',
|
|
76
|
+
items: [{
|
|
77
|
+
id: 'dashboard',
|
|
78
|
+
title: {
|
|
79
|
+
en: 'Dashboard',
|
|
80
|
+
zh: '仪表盘'
|
|
81
|
+
},
|
|
82
|
+
icon: 'ant-design:dashboard-outlined',
|
|
83
|
+
link: "".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/admin"),
|
|
84
|
+
from: 'tmpl'
|
|
85
|
+
}]
|
|
86
|
+
}]
|
|
87
|
+
};
|
|
88
|
+
function isSameNavigation(a, b) {
|
|
89
|
+
if (a.section && b.section) {
|
|
90
|
+
return a.section === b.section && a.id === b.id;
|
|
91
|
+
}
|
|
92
|
+
return a.id === b.id;
|
|
93
|
+
}
|
|
94
|
+
function hackBuiltinLink(treeList) {
|
|
95
|
+
const copyData = (0, _cloneDeep.default)(treeList);
|
|
96
|
+
(0, _parseNavigationFromBlocklet.deepWalk)(copyData, item => {
|
|
97
|
+
if (item.from === 'tmpl') {
|
|
98
|
+
item.link = '/';
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: 'items'
|
|
102
|
+
});
|
|
103
|
+
return copyData;
|
|
104
|
+
}
|
|
105
|
+
function useNavigation() {
|
|
106
|
+
const {
|
|
107
|
+
blocklet,
|
|
108
|
+
actions
|
|
109
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
110
|
+
const {
|
|
111
|
+
navigationList,
|
|
112
|
+
components,
|
|
113
|
+
builtinList
|
|
114
|
+
} = (0, _parseNavigationFromBlocklet.parseNavigation)(blocklet, {
|
|
115
|
+
beforeProcess(rawList) {
|
|
116
|
+
const copyList = (0, _cloneDeep.default)(rawList);
|
|
117
|
+
// 注入默认的 dashboard 菜单
|
|
118
|
+
injectNavigationData.dashboard.forEach(item => {
|
|
119
|
+
if (!copyList.some(x => x.id === item.id)) {
|
|
120
|
+
copyList.push(item);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// 注入默认的 sessionManager 菜单
|
|
124
|
+
if (!copyList.some(x => x.id && (x.section || []).includes('sessionManager'))) {
|
|
125
|
+
copyList.push(...injectNavigationData.sessionManager);
|
|
126
|
+
}
|
|
127
|
+
return copyList;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const state = (0, _ahooks.useReactive)({
|
|
131
|
+
rawNavigation: (0, _cloneDeep.default)(navigationList),
|
|
132
|
+
activeSection: DEFAULT_SECTION,
|
|
133
|
+
components
|
|
134
|
+
});
|
|
135
|
+
const navigation = (0, _react.useMemo)(() => {
|
|
136
|
+
return (0, _parseNavigationFromBlocklet.nestNavigationList)(state.rawNavigation);
|
|
137
|
+
}, [state.rawNavigation]);
|
|
138
|
+
const treeNavigation = (0, _react.useMemo)(() => {
|
|
139
|
+
const rawData = (0, _parseNavigationFromBlocklet.filterNavigation)(state.rawNavigation, components);
|
|
140
|
+
const navigationWithLink = hackBuiltinLink((0, _parseNavigationFromBlocklet.joinLink)(rawData, components));
|
|
141
|
+
return navigationWithLink;
|
|
142
|
+
}, [components, state.rawNavigation]);
|
|
143
|
+
function getNavigationFullLink(navigationItem) {
|
|
144
|
+
if (!navigationItem.id) return '';
|
|
145
|
+
const fullList = (0, _parseNavigationFromBlocklet.flatternNavigation)((0, _parseNavigationFromBlocklet.joinLink)(navigation, components));
|
|
146
|
+
const findItem = fullList.find(item => item.id === navigationItem.id);
|
|
147
|
+
// eslint-disable-next-line react/prop-types
|
|
148
|
+
function Uninstalled(_ref) {
|
|
149
|
+
let {
|
|
150
|
+
name
|
|
151
|
+
} = _ref;
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
153
|
+
label: "Uninstalled: ".concat(name),
|
|
154
|
+
color: "error",
|
|
155
|
+
size: "small",
|
|
156
|
+
variant: "outlined",
|
|
157
|
+
sx: {
|
|
158
|
+
fontSize: 10,
|
|
159
|
+
height: 20
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (findItem !== null && findItem !== void 0 && findItem.component) {
|
|
164
|
+
if (!components.some(x => x.name === findItem.component)) {
|
|
165
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Uninstalled, {
|
|
166
|
+
name: findItem.component
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
} else if (findItem.parent) {
|
|
170
|
+
const parent = fullList.find(x => x.id === findItem.parent);
|
|
171
|
+
if (parent !== null && parent !== void 0 && parent.component) {
|
|
172
|
+
if (!components.some(x => x.name === parent.component)) {
|
|
173
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Uninstalled, {
|
|
174
|
+
name: parent.component
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return findItem === null || findItem === void 0 ? void 0 : findItem.link;
|
|
180
|
+
}
|
|
181
|
+
function updateActiveSection(activeSection) {
|
|
182
|
+
state.activeSection = activeSection;
|
|
183
|
+
}
|
|
184
|
+
function updateNavigationTree(tree) {
|
|
185
|
+
const list = [];
|
|
186
|
+
(0, _parseNavigationFromBlocklet.deepWalk)(tree, (treeItem, parent) => {
|
|
187
|
+
const tmpData = _objectSpread(_objectSpread({}, (0, _omit.default)(treeItem, ['children', 'expand'])), {}, {
|
|
188
|
+
parent: parent === null || parent === void 0 ? void 0 : parent.id
|
|
189
|
+
});
|
|
190
|
+
list.push(tmpData);
|
|
191
|
+
});
|
|
192
|
+
const unchangedNavigation = state.rawNavigation.filter(item => {
|
|
193
|
+
if (!state.activeSection) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
const findItem = list.find(v => isSameNavigation(v, item));
|
|
197
|
+
if (findItem) {
|
|
198
|
+
return !(0, _parseNavigationFromBlocklet.isMatchSection)(findItem.section, state.activeSection);
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
});
|
|
202
|
+
state.rawNavigation = [...unchangedNavigation, ...list];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 更新导航的一个节点
|
|
206
|
+
* @param {object} itemData 更新的数据
|
|
207
|
+
*/
|
|
208
|
+
function updateNavigationItem(itemData) {
|
|
209
|
+
_saveNavigationChange([itemData]);
|
|
210
|
+
}
|
|
211
|
+
function _saveNavigationChange() {
|
|
212
|
+
let changed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
213
|
+
const updatedNavigation = state.rawNavigation.map(item => {
|
|
214
|
+
const findChanged = changed.find(changeItem => isSameNavigation(_objectSpread(_objectSpread({}, changeItem), {}, {
|
|
215
|
+
section: state.activeSection
|
|
216
|
+
}), item));
|
|
217
|
+
if (findChanged) {
|
|
218
|
+
return _objectSpread(_objectSpread({}, item), findChanged);
|
|
219
|
+
}
|
|
220
|
+
return item;
|
|
221
|
+
});
|
|
222
|
+
state.rawNavigation = updatedNavigation;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 删除一个导航节点
|
|
226
|
+
* @param {string} id 导航的 ID
|
|
227
|
+
*/
|
|
228
|
+
function delNavigationItem(id) {
|
|
229
|
+
const relatedNavigationId = state.rawNavigation.filter(item => item.id === id || item.parent === id).map(item => item.id);
|
|
230
|
+
state.rawNavigation = state.rawNavigation.filter(item => !relatedNavigationId.includes(item.id));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 增加一个导航节点
|
|
234
|
+
* @param {object} params 导航数据
|
|
235
|
+
*/
|
|
236
|
+
function addNavigationItem() {
|
|
237
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
238
|
+
const data = _objectSpread(_objectSpread({}, params), {}, {
|
|
239
|
+
// 新增的数据使用随机生成的 nanoid (A-Za-z0-9_-)
|
|
240
|
+
id: (0, _nanoid.nanoid)(),
|
|
241
|
+
section: state.activeSection,
|
|
242
|
+
visible: true
|
|
243
|
+
});
|
|
244
|
+
state.rawNavigation = [...state.rawNavigation, data];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 将树状结构转换为数据库存储的导航结构
|
|
249
|
+
* @param {array} tree 树状结构
|
|
250
|
+
* @returns array
|
|
251
|
+
*/
|
|
252
|
+
// eslint-disable-next-line no-unused-vars
|
|
253
|
+
function tree2navigation(tree) {
|
|
254
|
+
const list = tree.map(item => {
|
|
255
|
+
const items = item.children || [];
|
|
256
|
+
return {
|
|
257
|
+
title: item.title,
|
|
258
|
+
icon: item.icon,
|
|
259
|
+
link: item.link,
|
|
260
|
+
items: tree2navigation(items),
|
|
261
|
+
section: item.section,
|
|
262
|
+
visible: item.visible,
|
|
263
|
+
parent: item.parent,
|
|
264
|
+
component: item.component,
|
|
265
|
+
role: item.role,
|
|
266
|
+
from: item.from,
|
|
267
|
+
id: item.id
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
return list;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* 将数据库中的导航数据转换为树状结构
|
|
274
|
+
* @param {array} list 数据库中导航的结构
|
|
275
|
+
* @param {string} baseLink 当前 tree 的 base
|
|
276
|
+
* @returns 树状结构
|
|
277
|
+
*/
|
|
278
|
+
function navigation2tree(list) {
|
|
279
|
+
let baseLink = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : BASE_LINK;
|
|
280
|
+
const tree = list.map(item => {
|
|
281
|
+
const findComponent = components.find(componentItem => componentItem.name === item.component);
|
|
282
|
+
const base = (findComponent === null || findComponent === void 0 ? void 0 : findComponent.link) || baseLink;
|
|
283
|
+
const children = item.items || [];
|
|
284
|
+
const {
|
|
285
|
+
link
|
|
286
|
+
} = item;
|
|
287
|
+
return {
|
|
288
|
+
title: item.title,
|
|
289
|
+
subtitle: getNavigationFullLink(item),
|
|
290
|
+
link,
|
|
291
|
+
icon: item.icon,
|
|
292
|
+
children: navigation2tree(children, link || BASE_LINK),
|
|
293
|
+
section: item.section,
|
|
294
|
+
visible: item.visible,
|
|
295
|
+
parent: item.parent,
|
|
296
|
+
component: item.component,
|
|
297
|
+
id: item.id,
|
|
298
|
+
role: item.role,
|
|
299
|
+
from: item.from,
|
|
300
|
+
__base: base
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
return tree;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 获取指定区块的导航数据
|
|
308
|
+
* @param {string} section 导航所属区块
|
|
309
|
+
* @returns 在指定导航区块内的导航数据
|
|
310
|
+
*/
|
|
311
|
+
function getNavigation(section) {
|
|
312
|
+
const copyNavigation = (0, _cloneDeep.default)(navigation);
|
|
313
|
+
const filteredSectionNavigation = copyNavigation.filter(item => {
|
|
314
|
+
return (0, _parseNavigationFromBlocklet.isMatchSection)(item.section, section);
|
|
315
|
+
});
|
|
316
|
+
return navigation2tree(filteredSectionNavigation);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 将导航数据保存到后端
|
|
321
|
+
* @param {array} list 需要保存的导航数据
|
|
322
|
+
*/
|
|
323
|
+
async function saveNavigationList(list) {
|
|
324
|
+
const data = list.map(item => {
|
|
325
|
+
return (0, _omitBy.default)(item, _isNil.default);
|
|
326
|
+
});
|
|
327
|
+
const formartedData = data.map(item => {
|
|
328
|
+
const tempData = _objectSpread({}, item);
|
|
329
|
+
if (tempData.role && Array.isArray(tempData.role)) {
|
|
330
|
+
tempData.role = JSON.stringify(tempData.role);
|
|
331
|
+
}
|
|
332
|
+
if (tempData.section && Array.isArray(tempData.section)) {
|
|
333
|
+
tempData.section = JSON.stringify(tempData.section);
|
|
334
|
+
}
|
|
335
|
+
if (tempData.title && tempData.title instanceof Object) {
|
|
336
|
+
tempData.title = JSON.stringify(tempData.title);
|
|
337
|
+
}
|
|
338
|
+
if (tempData.link && tempData.link instanceof Object) {
|
|
339
|
+
tempData.link = JSON.stringify(tempData.link);
|
|
340
|
+
}
|
|
341
|
+
return tempData;
|
|
342
|
+
});
|
|
343
|
+
// .filter((item) => item.from !== ' tmpl');
|
|
344
|
+
await actions.configNavigations(formartedData);
|
|
345
|
+
}
|
|
346
|
+
async function resetNavigation() {
|
|
347
|
+
await saveNavigationList([]);
|
|
348
|
+
state.rawNavigation = (0, _cloneDeep.default)(builtinList);
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
state,
|
|
352
|
+
navigation: treeNavigation,
|
|
353
|
+
components,
|
|
354
|
+
getNavigationFullLink,
|
|
355
|
+
updateActiveSection,
|
|
356
|
+
updateNavigationItem,
|
|
357
|
+
delNavigationItem,
|
|
358
|
+
addNavigationItem,
|
|
359
|
+
updateNavigationTree,
|
|
360
|
+
getNavigation,
|
|
361
|
+
saveNavigationList,
|
|
362
|
+
resetNavigation
|
|
363
|
+
};
|
|
364
|
+
}
|
package/lib/locales/en.js
CHANGED
|
@@ -100,6 +100,7 @@ module.exports = {
|
|
|
100
100
|
components: 'Components',
|
|
101
101
|
config: 'Configure',
|
|
102
102
|
configuration: 'Configuration',
|
|
103
|
+
configNavigation: 'Navigation',
|
|
103
104
|
configSuccess: 'Config successfully',
|
|
104
105
|
confirm: 'Confirm',
|
|
105
106
|
console: 'Console',
|
|
@@ -504,7 +505,7 @@ module.exports = {
|
|
|
504
505
|
routingEngine: 'Routing Engine',
|
|
505
506
|
ownerNftURL: 'Owner NFT',
|
|
506
507
|
expirationLeft: 'Expiration Left',
|
|
507
|
-
|
|
508
|
+
renew: 'Renew'
|
|
508
509
|
},
|
|
509
510
|
store: {
|
|
510
511
|
nameSort: 'Name',
|
|
@@ -1110,5 +1111,27 @@ module.exports = {
|
|
|
1110
1111
|
confirm: 'Confirm on your DID Wallet',
|
|
1111
1112
|
success: 'You are successfully connected'
|
|
1112
1113
|
}
|
|
1114
|
+
},
|
|
1115
|
+
navigation: {
|
|
1116
|
+
navigation: 'Navigation',
|
|
1117
|
+
form: {
|
|
1118
|
+
title: 'Title',
|
|
1119
|
+
titlePlaceholder: 'Please input navigation title',
|
|
1120
|
+
titleTooLong: 'Title length should small than {len}',
|
|
1121
|
+
icon: 'Navigation Icon',
|
|
1122
|
+
iconPlaceholder: 'Please input navigation icon',
|
|
1123
|
+
invalidIcon: 'Icon is invalid',
|
|
1124
|
+
findMoreIcon: 'Find more icons',
|
|
1125
|
+
link: 'Link',
|
|
1126
|
+
linkPlaceholder: 'Please input navigation link',
|
|
1127
|
+
invalidLink: 'Link is invalid',
|
|
1128
|
+
component: 'Component',
|
|
1129
|
+
componentPlaceholder: 'Please select navigation component',
|
|
1130
|
+
role: 'Role',
|
|
1131
|
+
rolePlaceholder: 'Please select navigation role',
|
|
1132
|
+
locale: 'Locale',
|
|
1133
|
+
localePlaceholder: 'Please input locale need to add',
|
|
1134
|
+
localeExists: '{value} is already exists'
|
|
1135
|
+
}
|
|
1113
1136
|
}
|
|
1114
1137
|
};
|
package/lib/locales/zh.js
CHANGED
|
@@ -104,6 +104,7 @@ module.exports = {
|
|
|
104
104
|
components: '组件',
|
|
105
105
|
config: '配置',
|
|
106
106
|
configuration: '配置',
|
|
107
|
+
configNavigation: '导航',
|
|
107
108
|
configSuccess: '设置成功',
|
|
108
109
|
confirm: '确认',
|
|
109
110
|
console: '控制台',
|
|
@@ -512,7 +513,7 @@ module.exports = {
|
|
|
512
513
|
routingEngine: '路由引擎',
|
|
513
514
|
ownerNftURL: '所有者 NFT',
|
|
514
515
|
expirationLeft: '有效期还剩',
|
|
515
|
-
|
|
516
|
+
renew: '续期'
|
|
516
517
|
},
|
|
517
518
|
store: {
|
|
518
519
|
nameSort: '名称',
|
|
@@ -1115,5 +1116,27 @@ module.exports = {
|
|
|
1115
1116
|
confirm: '在您的 DID 钱包上确认',
|
|
1116
1117
|
success: '连接成功'
|
|
1117
1118
|
}
|
|
1119
|
+
},
|
|
1120
|
+
navigation: {
|
|
1121
|
+
navigation: '导航',
|
|
1122
|
+
form: {
|
|
1123
|
+
title: '标题',
|
|
1124
|
+
titlePlaceholder: '请输入导航标题',
|
|
1125
|
+
titleTooLong: '标题最长为 {len}',
|
|
1126
|
+
icon: '图标',
|
|
1127
|
+
iconPlaceholder: '请输入导航图标',
|
|
1128
|
+
invalidIcon: '导航图标不存在',
|
|
1129
|
+
findMoreIcon: '找到更多图标',
|
|
1130
|
+
link: '链接',
|
|
1131
|
+
linkPlaceholder: '请输入导航链接',
|
|
1132
|
+
invalidLink: '链接格式不正确',
|
|
1133
|
+
component: '组件',
|
|
1134
|
+
componentPlaceholder: '请选择导航所属的组件',
|
|
1135
|
+
role: '角色',
|
|
1136
|
+
rolePlaceholder: '请选择导航可见的角色',
|
|
1137
|
+
locale: '语言',
|
|
1138
|
+
localePlaceholder: '请输入要添加的多语言标识符',
|
|
1139
|
+
localeExists: '{value} 已经存在'
|
|
1140
|
+
}
|
|
1118
1141
|
}
|
|
1119
1142
|
};
|
|
@@ -77,8 +77,7 @@ function Passports(_ref2) {
|
|
|
77
77
|
t
|
|
78
78
|
} = (0, _context.useLocaleContext)();
|
|
79
79
|
const {
|
|
80
|
-
session
|
|
81
|
-
inService
|
|
80
|
+
session
|
|
82
81
|
} = (0, _session.useSessionContext)();
|
|
83
82
|
const {
|
|
84
83
|
roles,
|
|
@@ -91,7 +90,8 @@ function Passports(_ref2) {
|
|
|
91
90
|
blocklet
|
|
92
91
|
} = (0, _team.useTeamContext)();
|
|
93
92
|
const {
|
|
94
|
-
api
|
|
93
|
+
api,
|
|
94
|
+
inService
|
|
95
95
|
} = (0, _node.useNodeContext)();
|
|
96
96
|
const {
|
|
97
97
|
enqueueSnackbar
|
|
@@ -37,7 +37,6 @@ function PassportList() {
|
|
|
37
37
|
} = (0, _react.useContext)(_context.LocaleContext);
|
|
38
38
|
const {
|
|
39
39
|
api,
|
|
40
|
-
info: nodeInfo,
|
|
41
40
|
inService
|
|
42
41
|
} = (0, _node.useNodeContext)();
|
|
43
42
|
const {
|
|
@@ -47,7 +46,8 @@ function PassportList() {
|
|
|
47
46
|
teamName,
|
|
48
47
|
refresh: refreshTeam,
|
|
49
48
|
enablePassportIssuance,
|
|
50
|
-
passportColor
|
|
49
|
+
passportColor,
|
|
50
|
+
isNodeTeam
|
|
51
51
|
} = (0, _team.useTeamContext)();
|
|
52
52
|
const [showCreate, setShowCreate] = (0, _react.useState)(false);
|
|
53
53
|
const [updateForm, setUpdateForm] = (0, _react.useState)(false);
|
|
@@ -118,8 +118,9 @@ function PassportList() {
|
|
|
118
118
|
})]
|
|
119
119
|
})]
|
|
120
120
|
})
|
|
121
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, {
|
|
121
|
+
}), !isNodeTeam && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, {
|
|
122
122
|
onClick: () => setShowColor(true),
|
|
123
|
+
"data-cy": "config-passport-color",
|
|
123
124
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
124
125
|
children: t('team.passport.configColor')
|
|
125
126
|
})
|
|
@@ -138,7 +139,7 @@ function PassportList() {
|
|
|
138
139
|
}
|
|
139
140
|
}), t('team.passport.trustedPassportIssuers')]
|
|
140
141
|
})
|
|
141
|
-
}),
|
|
142
|
+
}), !isNodeTeam && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
142
143
|
style: {
|
|
143
144
|
marginLeft: 16
|
|
144
145
|
},
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// https://www.maigoo.com/top/393790.html
|
|
8
|
+
// https://zh.wikipedia.org/zh-my/ISO_639-1代码表
|
|
9
|
+
var _default = {
|
|
10
|
+
en: 'English',
|
|
11
|
+
zh: '中文',
|
|
12
|
+
fr: 'Français',
|
|
13
|
+
// 法语
|
|
14
|
+
ru: 'Russian',
|
|
15
|
+
// 俄语
|
|
16
|
+
ar: 'العربية',
|
|
17
|
+
// 阿拉伯语
|
|
18
|
+
es: 'Español',
|
|
19
|
+
// 西班牙语
|
|
20
|
+
de: 'Deutsch',
|
|
21
|
+
// 德语
|
|
22
|
+
pt: 'Português do Brasil',
|
|
23
|
+
// 葡萄牙语
|
|
24
|
+
ja: '日本語',
|
|
25
|
+
// 日语
|
|
26
|
+
hi: 'हिन्दी' // 印地语
|
|
27
|
+
};
|
|
28
|
+
exports.default = _default;
|