@abtnode/ux 1.8.41 → 1.8.43

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.
@@ -147,23 +147,28 @@ const NavigationDialog = /*#__PURE__*/(0, _react.forwardRef)(function Navigation
147
147
  const selectedOption = (0, _react.useMemo)(() => {
148
148
  const parentData = rawNavigations.find(item => {
149
149
  if (watchComponent) {
150
- return item.component === watchComponent;
150
+ const findComponent = components.find(x => x.name === watchComponent);
151
+ return findComponent.did === item.id;
151
152
  }
152
153
  return item.id === watchParent;
153
154
  });
154
155
  return parentData;
155
- }, [rawNavigations, watchComponent, watchParent]);
156
+ }, [components, rawNavigations, watchComponent, watchParent]);
156
157
  const linkPrefix = (0, _react.useMemo)(() => {
157
158
  if (selectedOption !== null && selectedOption !== void 0 && selectedOption.component) {
158
159
  const findComponent = components.find(item => item.name === selectedOption.component);
159
160
  const {
160
161
  link
161
162
  } = findComponent || {};
162
- const stringLink = (0, _isObject.default)(link) ? link[locale] : link;
163
- return (0, _index.withoutTrailingSlash)((0, _urlJoin.default)(stringLink, selectedOption.link || '/'));
163
+ const stringLink = (0, _isObject.default)(link) ? link[state.locale] : link;
164
+ if (watchComponent) {
165
+ return (0, _index.withoutTrailingSlash)(stringLink);
166
+ }
167
+ const selectedLink = (0, _isObject.default)(selectedOption.link) ? selectedOption.link[state.locale] : selectedOption.link;
168
+ return (0, _index.withoutTrailingSlash)((0, _urlJoin.default)(stringLink, selectedLink || '/'));
164
169
  }
165
170
  return null;
166
- }, [components, locale, selectedOption]);
171
+ }, [components, state.locale, selectedOption, watchComponent]);
167
172
  const autocompleteOptions = (0, _react.useMemo)(() => {
168
173
  const {
169
174
  component
@@ -46,6 +46,7 @@ function NavigationPreview(_ref) {
46
46
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
47
47
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dashboard.default, {
48
48
  meta: blockletInfo,
49
+ invalidPathFallback: () => {},
49
50
  headerProps: {
50
51
  style: {
51
52
  display: 'none'
@@ -8,10 +8,11 @@ var _react = require("react");
8
8
  var _material = require("@mui/material");
9
9
  var _lab = require("@mui/lab");
10
10
  var _react2 = require("@iconify/react");
11
- var _Session = require("@arcblock/did-connect/lib/Session");
12
11
  var _notistack = require("notistack");
13
12
  var _ahooks = require("ahooks");
14
13
  var _Dialog = require("@arcblock/ux/lib/Dialog");
14
+ var _context = require("@arcblock/ux/lib/Locale/context");
15
+ var _Session = require("@arcblock/did-connect/lib/Session");
15
16
  var _sortableTree = _interopRequireDefault(require("./component/sortable-tree"));
16
17
  var _navigationDialog = _interopRequireDefault(require("./component/navigation/navigation-dialog"));
17
18
  var _navigationActions = _interopRequireDefault(require("./component/navigation/navigation-actions"));
@@ -19,6 +20,7 @@ var _useNavigation = _interopRequireDefault(require("../hooks/use-navigation"));
19
20
  var _blocklet = require("../contexts/blocklet");
20
21
  var _navigationPreview = _interopRequireDefault(require("./component/navigation/navigation-preview"));
21
22
  var _team = require("../contexts/team");
23
+ var _util = require("../util");
22
24
  var _jsxRuntime = require("react/jsx-runtime");
23
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
26
  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; }
@@ -32,11 +34,29 @@ const mockSession = {
32
34
  switchProfile: () => {},
33
35
  switchPassport: () => {}
34
36
  };
37
+ const navigationTypeMap = {
38
+ header: 'Header',
39
+ footer: 'Footer',
40
+ bottom: 'Footer Link',
41
+ social: 'Footer Social',
42
+ dashboard: 'Dashboard',
43
+ sessionManager: 'SessionManager'
44
+ };
35
45
  function ConfigNavigation() {
46
+ const {
47
+ t
48
+ } = (0, _context.useLocaleContext)();
36
49
  const [showTree, setShowTree] = (0, _react.useState)(false);
37
50
  const {
38
51
  blocklet
39
52
  } = (0, _blocklet.useBlockletContext)();
53
+ const refNavigationDialog = (0, _react.useRef)(null);
54
+ const {
55
+ roles
56
+ } = (0, _team.useTeamContext)();
57
+ const {
58
+ enqueueSnackbar
59
+ } = (0, _notistack.useSnackbar)();
40
60
  const pageState = (0, _ahooks.useReactive)({
41
61
  saveLoading: false,
42
62
  resetLoading: false,
@@ -49,21 +69,6 @@ function ConfigNavigation() {
49
69
  setShowTree(false);
50
70
  };
51
71
  }, []);
52
- const navigationTypeMap = {
53
- header: 'Header',
54
- footer: 'Footer',
55
- bottom: 'Footer Link',
56
- social: 'Footer Social',
57
- dashboard: 'Dashboard',
58
- sessionManager: 'SessionManager'
59
- };
60
- const refNavigationDialog = (0, _react.useRef)(null);
61
- const {
62
- roles
63
- } = (0, _team.useTeamContext)();
64
- const {
65
- enqueueSnackbar
66
- } = (0, _notistack.useSnackbar)();
67
72
  const {
68
73
  state: navigationState,
69
74
  navigation,
@@ -112,10 +117,22 @@ function ConfigNavigation() {
112
117
  enqueueSnackbar('保存成功', {
113
118
  variant: 'success'
114
119
  });
120
+ } catch (e) {
121
+ enqueueSnackbar( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
122
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
123
+ variant: "subtitle2",
124
+ children: t('navigation.actionFailed')
125
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
126
+ variant: "body1",
127
+ children: (0, _util.formatError)(e) || e.error
128
+ })]
129
+ }), {
130
+ variant: 'error'
131
+ });
115
132
  } finally {
116
133
  pageState.saveLoading = false;
117
134
  }
118
- }, [enqueueSnackbar, navigationState.rawNavigation, pageState, saveNavigationList]);
135
+ }, [enqueueSnackbar, navigationState.rawNavigation, pageState, saveNavigationList, t]);
119
136
  const handleResetNavigation = (0, _react.useCallback)(async () => {
120
137
  try {
121
138
  pageState.resetLoading = true;
@@ -123,10 +140,22 @@ function ConfigNavigation() {
123
140
  enqueueSnackbar('重置成功', {
124
141
  variant: 'success'
125
142
  });
143
+ } catch (e) {
144
+ enqueueSnackbar( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
145
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
146
+ variant: "subtitle2",
147
+ children: t('navigation.actionFailed')
148
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
149
+ variant: "body1",
150
+ children: (0, _util.formatError)(e) || e.error
151
+ })]
152
+ }), {
153
+ variant: 'error'
154
+ });
126
155
  } finally {
127
156
  pageState.resetLoading = false;
128
157
  }
129
- }, [enqueueSnackbar, pageState, resetNavigation]);
158
+ }, [enqueueSnackbar, pageState, resetNavigation, t]);
130
159
  const sessionCtxValue = (0, _react.useMemo)(() => {
131
160
  return {
132
161
  session: _objectSpread(_objectSpread({}, mockSession), {}, {
@@ -91,17 +91,6 @@ function isSameNavigation(a, b) {
91
91
  }
92
92
  return a.id === b.id;
93
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
94
  function useNavigation() {
106
95
  const {
107
96
  blocklet,
@@ -137,8 +126,8 @@ function useNavigation() {
137
126
  }, [state.rawNavigation]);
138
127
  const treeNavigation = (0, _react.useMemo)(() => {
139
128
  const rawData = (0, _parseNavigationFromBlocklet.filterNavigation)(state.rawNavigation, components);
140
- const navigationWithLink = hackBuiltinLink((0, _parseNavigationFromBlocklet.joinLink)(rawData, components));
141
- return navigationWithLink;
129
+ const navigationWithLink = (0, _parseNavigationFromBlocklet.joinLink)(rawData, components);
130
+ return (0, _parseNavigationFromBlocklet.cleanOrphanNavigation)(navigationWithLink);
142
131
  }, [components, state.rawNavigation]);
143
132
  function getNavigationFullLink(navigationItem) {
144
133
  if (!navigationItem.id) return '';
package/lib/locales/en.js CHANGED
@@ -505,7 +505,8 @@ module.exports = {
505
505
  routingEngine: 'Routing Engine',
506
506
  ownerNftURL: 'Owner NFT',
507
507
  expirationLeft: 'Expiration Left',
508
- renew: 'Renew'
508
+ renew: 'Renew',
509
+ startFromCrashTip: 'Blocklet Server did not exit normally last time, please manually start the blocklets that needs to be run.'
509
510
  },
510
511
  store: {
511
512
  nameSort: 'Name',
@@ -1114,6 +1115,7 @@ module.exports = {
1114
1115
  },
1115
1116
  navigation: {
1116
1117
  navigation: 'Navigation',
1118
+ actionFailed: 'Action Failed',
1117
1119
  form: {
1118
1120
  title: 'Title',
1119
1121
  titlePlaceholder: 'Please input navigation title',
package/lib/locales/zh.js CHANGED
@@ -513,7 +513,8 @@ module.exports = {
513
513
  routingEngine: '路由引擎',
514
514
  ownerNftURL: '所有者 NFT',
515
515
  expirationLeft: '有效期还剩',
516
- renew: '续期'
516
+ renew: '续期',
517
+ startFromCrashTip: 'Blocklet Server 上次未正常退出,请手动启动需要运行的 blocklet.'
517
518
  },
518
519
  store: {
519
520
  nameSort: '名称',
@@ -1119,6 +1120,7 @@ module.exports = {
1119
1120
  },
1120
1121
  navigation: {
1121
1122
  navigation: '导航',
1123
+ actionFailed: '操作失败',
1122
1124
  form: {
1123
1125
  title: '标题',
1124
1126
  titlePlaceholder: '请输入导航标题',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.41",
6
+ "version": "1.8.43",
7
7
  "description": "UX components shared across abtnode packages",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -21,19 +21,19 @@
21
21
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@abtnode/auth": "1.8.41",
25
- "@abtnode/constant": "1.8.41",
26
- "@abtnode/util": "1.8.41",
27
- "@arcblock/did-connect": "^2.4.55",
24
+ "@abtnode/auth": "1.8.43",
25
+ "@abtnode/constant": "1.8.43",
26
+ "@abtnode/util": "1.8.43",
27
+ "@arcblock/did-connect": "^2.4.57",
28
28
  "@arcblock/did-motif": "^1.1.10",
29
- "@arcblock/icons": "^2.4.55",
30
- "@arcblock/terminal": "^2.4.55",
31
- "@arcblock/ux": "^2.4.55",
32
- "@blocklet/constant": "1.8.41",
33
- "@blocklet/launcher-layout": "^1.9.15",
34
- "@blocklet/list": "^0.10.38",
35
- "@blocklet/meta": "1.8.41",
36
- "@blocklet/ui-react": "^2.4.55",
29
+ "@arcblock/icons": "^2.4.57",
30
+ "@arcblock/terminal": "^2.4.57",
31
+ "@arcblock/ux": "^2.4.57",
32
+ "@blocklet/constant": "1.8.43",
33
+ "@blocklet/launcher-layout": "^1.9.20",
34
+ "@blocklet/list": "^0.10.42",
35
+ "@blocklet/meta": "1.8.43",
36
+ "@blocklet/ui-react": "^2.4.57",
37
37
  "@emotion/react": "^11.10.4",
38
38
  "@emotion/styled": "^11.10.4",
39
39
  "@iconify/react": "^4.0.0",
@@ -84,5 +84,5 @@
84
84
  "@babel/preset-react": "^7.18.6",
85
85
  "babel-plugin-inline-react-svg": "^1.1.2"
86
86
  },
87
- "gitHead": "bdc6b7c45ec5c59b83b2ef4ac088dc2eae9f4dea"
87
+ "gitHead": "5c6b7b09f6252a83523594aead6c722bf4ba0d0c"
88
88
  }