@blocklet/ui-react 2.4.48 → 2.4.49

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.
@@ -25,7 +25,7 @@ var _headerAddons2 = _interopRequireDefault(require("../common/header-addons"));
25
25
 
26
26
  var _jsxRuntime = require("react/jsx-runtime");
27
27
 
28
- const _excluded = ["meta", "fallbackUrl", "invalidPathFallback", "headerAddons", "sessionManagerProps"];
28
+ const _excluded = ["meta", "fallbackUrl", "invalidPathFallback", "headerAddons", "sessionManagerProps", "links"];
29
29
 
30
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
31
 
@@ -51,7 +51,8 @@ function Dashboard(_ref) {
51
51
  fallbackUrl,
52
52
  invalidPathFallback,
53
53
  headerAddons,
54
- sessionManagerProps
54
+ sessionManagerProps,
55
+ links
55
56
  } = _ref,
56
57
  rest = _objectWithoutProperties(_ref, _excluded);
57
58
 
@@ -106,7 +107,8 @@ function Dashboard(_ref) {
106
107
  flattened,
107
108
  matchedIndex
108
109
  };
109
- }, [formattedBlocklet, locale, userRole]); // 页面初始化时, 如果当前用户没有权限访问任何导航菜单 (比如登录时未提供 VC 导致无权限), 则跳转到 fallbackUrl
110
+ }, [formattedBlocklet, locale, userRole]);
111
+ const allLinks = typeof links === 'function' ? links(localizedNav) : [...localizedNav, ...links]; // 页面初始化时, 如果当前用户没有权限访问任何导航菜单 (比如登录时未提供 VC 导致无权限), 则跳转到 fallbackUrl
110
112
  // 未认证 (user 为空) 时不做处理, 这种情况的页面跳转逻辑一般由应用自行处理
111
113
 
112
114
  (0, _react.useLayoutEffect)(() => {
@@ -149,7 +151,7 @@ function Dashboard(_ref) {
149
151
  fullWidth: true,
150
152
  sidebarWidth: 128,
151
153
  legacy: false,
152
- links: localizedNav
154
+ links: allLinks
153
155
  }, rest), {}, {
154
156
  headerProps: _objectSpread({
155
157
  homeLink: _blocklets.publicPath,
@@ -169,7 +171,8 @@ Dashboard.propTypes = {
169
171
  // 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
170
172
  invalidPathFallback: _propTypes.default.func,
171
173
  headerAddons: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
172
- sessionManagerProps: _types.sessionManagerProps
174
+ sessionManagerProps: _types.sessionManagerProps,
175
+ links: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func])
173
176
  };
174
177
  Dashboard.defaultProps = {
175
178
  meta: {},
@@ -182,7 +185,8 @@ Dashboard.defaultProps = {
182
185
  onLogout: () => {
183
186
  window.location.href = _blocklets.publicPath;
184
187
  }
185
- }
188
+ },
189
+ links: []
186
190
  };
187
191
  var _default = Dashboard;
188
192
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.4.48",
3
+ "version": "2.4.49",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -30,8 +30,8 @@
30
30
  "url": "https://github.com/ArcBlock/ux/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@arcblock/did-connect": "^2.4.48",
34
- "@arcblock/ux": "^2.4.48",
33
+ "@arcblock/did-connect": "^2.4.49",
34
+ "@arcblock/ux": "^2.4.49",
35
35
  "@emotion/react": "^11.10.4",
36
36
  "@emotion/styled": "^11.10.4",
37
37
  "@iconify/iconify": "^2.2.1",
@@ -53,5 +53,5 @@
53
53
  "eslint-plugin-react-hooks": "^4.6.0",
54
54
  "jest": "^28.1.3"
55
55
  },
56
- "gitHead": "7ba461919bba281ba700a2388e4419676b647a01"
56
+ "gitHead": "81c74068803edad783cc931fc1de7a6ad6c85022"
57
57
  }
@@ -13,7 +13,7 @@ import HeaderAddons from '../common/header-addons';
13
13
  * 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
14
14
  */
15
15
  // eslint-disable-next-line no-shadow
16
- function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps, ...rest }) {
16
+ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps, links, ...rest }) {
17
17
  const sessionCtx = useContext(SessionContext);
18
18
  const user = sessionCtx?.session?.user;
19
19
  const userRole = user?.role;
@@ -53,6 +53,8 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
53
53
  return { localizedNav, flattened, matchedIndex };
54
54
  }, [formattedBlocklet, locale, userRole]);
55
55
 
56
+ const allLinks = typeof links === 'function' ? links(localizedNav) : [...localizedNav, ...links];
57
+
56
58
  // 页面初始化时, 如果当前用户没有权限访问任何导航菜单 (比如登录时未提供 VC 导致无权限), 则跳转到 fallbackUrl
57
59
  // 未认证 (user 为空) 时不做处理, 这种情况的页面跳转逻辑一般由应用自行处理
58
60
  useLayoutEffect(() => {
@@ -92,7 +94,7 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
92
94
  fullWidth
93
95
  sidebarWidth={128}
94
96
  legacy={false}
95
- links={localizedNav}
97
+ links={allLinks}
96
98
  {...rest}
97
99
  headerProps={{
98
100
  homeLink: publicPath,
@@ -112,6 +114,7 @@ Dashboard.propTypes = {
112
114
  invalidPathFallback: PropTypes.func,
113
115
  headerAddons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
114
116
  sessionManagerProps,
117
+ links: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
115
118
  };
116
119
 
117
120
  Dashboard.defaultProps = {
@@ -126,6 +129,7 @@ Dashboard.defaultProps = {
126
129
  window.location.href = publicPath;
127
130
  },
128
131
  },
132
+ links: [],
129
133
  };
130
134
 
131
135
  export default Dashboard;