@blocklet/ui-react 2.9.19 → 2.9.21
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/es/ComponentInstaller/index.d.ts +6 -2
- package/es/ComponentInstaller/index.js +6 -0
- package/es/ComponentInstaller/use-component-installed.d.ts +2 -2
- package/es/ComponentInstaller/use-component-installed.js +6 -4
- package/es/UserCenter/components/user-center.d.ts +2 -1
- package/es/UserCenter/components/user-center.js +8 -4
- package/lib/ComponentInstaller/index.d.ts +6 -2
- package/lib/ComponentInstaller/index.js +6 -0
- package/lib/ComponentInstaller/use-component-installed.d.ts +2 -2
- package/lib/ComponentInstaller/use-component-installed.js +9 -7
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +10 -6
- package/package.json +6 -5
- package/src/ComponentInstaller/index.jsx +7 -0
- package/src/ComponentInstaller/use-component-installed.js +6 -4
- package/src/UserCenter/components/user-center.tsx +9 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default ComponentInstaller;
|
|
2
|
-
declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, roles, }: {
|
|
2
|
+
declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, disabled, roles, }: {
|
|
3
3
|
warnIcon: any;
|
|
4
4
|
did: any;
|
|
5
5
|
noPermissionMute: any;
|
|
@@ -9,10 +9,12 @@ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstall
|
|
|
9
9
|
closeByOutSize: any;
|
|
10
10
|
onClose: any;
|
|
11
11
|
fallback: any;
|
|
12
|
+
disabled: any;
|
|
12
13
|
roles?: string[] | undefined;
|
|
13
|
-
}):
|
|
14
|
+
}): any;
|
|
14
15
|
declare namespace ComponentInstaller {
|
|
15
16
|
namespace propTypes {
|
|
17
|
+
let disabled: any;
|
|
16
18
|
let warnIcon: any;
|
|
17
19
|
let did: any;
|
|
18
20
|
let noPermissionMute: any;
|
|
@@ -25,6 +27,8 @@ declare namespace ComponentInstaller {
|
|
|
25
27
|
let roles: any;
|
|
26
28
|
}
|
|
27
29
|
namespace defaultProps {
|
|
30
|
+
let disabled_1: boolean;
|
|
31
|
+
export { disabled_1 as disabled };
|
|
28
32
|
let warnIcon_1: null;
|
|
29
33
|
export { warnIcon_1 as warnIcon };
|
|
30
34
|
let noPermissionMute_1: boolean;
|
|
@@ -21,6 +21,7 @@ function ComponentInstaller({
|
|
|
21
21
|
closeByOutSize,
|
|
22
22
|
onClose,
|
|
23
23
|
fallback,
|
|
24
|
+
disabled,
|
|
24
25
|
roles = ["owner", "admin"]
|
|
25
26
|
}) {
|
|
26
27
|
const { locale } = useLocaleContext();
|
|
@@ -46,6 +47,9 @@ function ComponentInstaller({
|
|
|
46
47
|
window.location.reload();
|
|
47
48
|
};
|
|
48
49
|
const size = 60;
|
|
50
|
+
if (disabled) {
|
|
51
|
+
return children;
|
|
52
|
+
}
|
|
49
53
|
return /* @__PURE__ */ jsx(SessionPermission, { session: sessionCtx?.session, roles, children: ({ hasPermission }) => {
|
|
50
54
|
if (installed) {
|
|
51
55
|
return children;
|
|
@@ -274,6 +278,7 @@ function ComponentInstaller({
|
|
|
274
278
|
} });
|
|
275
279
|
}
|
|
276
280
|
ComponentInstaller.propTypes = {
|
|
281
|
+
disabled: PropTypes.bool,
|
|
277
282
|
warnIcon: PropTypes.node,
|
|
278
283
|
did: PropTypes.string.isRequired,
|
|
279
284
|
noPermissionMute: PropTypes.bool,
|
|
@@ -286,6 +291,7 @@ ComponentInstaller.propTypes = {
|
|
|
286
291
|
roles: PropTypes.array
|
|
287
292
|
};
|
|
288
293
|
ComponentInstaller.defaultProps = {
|
|
294
|
+
disabled: false,
|
|
289
295
|
warnIcon: null,
|
|
290
296
|
noPermissionMute: false,
|
|
291
297
|
onInstalled: null,
|
|
@@ -6,8 +6,8 @@ declare function useComponentInstalled({ did, onInstalled, onError }: {
|
|
|
6
6
|
}): {
|
|
7
7
|
optionalComponent: any;
|
|
8
8
|
installed: any;
|
|
9
|
-
installUrl:
|
|
10
|
-
storeUrl:
|
|
9
|
+
installUrl: any;
|
|
10
|
+
storeUrl: any;
|
|
11
11
|
installStatus: string;
|
|
12
12
|
setInstallStatus: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
13
13
|
installStatusDone: boolean;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
|
|
2
2
|
import { useMemo, useRef, useState, useEffect } from 'react';
|
|
3
|
+
import urlJoin from 'url-join';
|
|
3
4
|
|
|
4
5
|
function useComponentInstalled({ did, onInstalled, onError }) {
|
|
5
|
-
const
|
|
6
|
+
const [installStatus, setInstallStatus] = useState('');
|
|
6
7
|
const onInstalledRef = useRef({ onInstalled, onError });
|
|
7
8
|
onInstalledRef.current = { onInstalled, onError };
|
|
8
9
|
|
|
10
|
+
const { optionalComponents, componentMountPoints } = window.blocklet;
|
|
11
|
+
|
|
9
12
|
const optionalComponent = useMemo(() => {
|
|
10
13
|
if (!optionalComponents || !optionalComponents.length) {
|
|
11
14
|
return null;
|
|
@@ -22,9 +25,8 @@ function useComponentInstalled({ did, onInstalled, onError }) {
|
|
|
22
25
|
return (componentMountPoints || []).find((item) => item.did === did);
|
|
23
26
|
}, [optionalComponent, componentMountPoints, did]);
|
|
24
27
|
|
|
25
|
-
const installUrl =
|
|
26
|
-
const storeUrl = optionalComponent ?
|
|
27
|
-
const [installStatus, setInstallStatus] = useState('');
|
|
28
|
+
const installUrl = urlJoin(window.blocklet.appUrl, AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
|
|
29
|
+
const storeUrl = optionalComponent ? urlJoin(optionalComponent.meta.homepage, 'blocklets', did) : '';
|
|
28
30
|
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
const handle = (event) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PaperProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, }: {
|
|
3
|
+
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, }: {
|
|
4
4
|
readonly children: any;
|
|
5
5
|
readonly currentTab: string;
|
|
6
6
|
readonly contentProps?: PaperProps;
|
|
@@ -9,4 +9,5 @@ export default function UserCenter({ children, currentTab, contentProps, disable
|
|
|
9
9
|
readonly hideFooter?: boolean;
|
|
10
10
|
readonly headerProps?: object;
|
|
11
11
|
readonly footerProps?: object;
|
|
12
|
+
readonly userDid?: string;
|
|
12
13
|
}): import("react").JSX.Element | null;
|
|
@@ -28,7 +28,8 @@ export default function UserCenter({
|
|
|
28
28
|
autoPopupSetting = false,
|
|
29
29
|
hideFooter = false,
|
|
30
30
|
headerProps = {},
|
|
31
|
-
footerProps = {}
|
|
31
|
+
footerProps = {},
|
|
32
|
+
userDid
|
|
32
33
|
}) {
|
|
33
34
|
const { locale } = useLocaleContext();
|
|
34
35
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -37,6 +38,9 @@ export default function UserCenter({
|
|
|
37
38
|
const sessionCtx = useContext(SessionContext);
|
|
38
39
|
const session = sessionCtx?.session;
|
|
39
40
|
const currentDid = useCreation(() => {
|
|
41
|
+
if (userDid) {
|
|
42
|
+
return userDid;
|
|
43
|
+
}
|
|
40
44
|
const currentUrl = window.location.href;
|
|
41
45
|
const query = getQuery(currentUrl);
|
|
42
46
|
if (query?.did) {
|
|
@@ -46,7 +50,7 @@ export default function UserCenter({
|
|
|
46
50
|
return query.did;
|
|
47
51
|
}
|
|
48
52
|
return session?.user?.did;
|
|
49
|
-
}, [session?.user?.did]);
|
|
53
|
+
}, [session?.user?.did, userDid]);
|
|
50
54
|
const isMyself = useCreation(() => {
|
|
51
55
|
if (session?.user) {
|
|
52
56
|
return currentDid === session?.user?.did;
|
|
@@ -251,11 +255,11 @@ export default function UserCenter({
|
|
|
251
255
|
) : null,
|
|
252
256
|
isMyself ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
253
257
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
254
|
-
/* @__PURE__ */ jsx(Typography, { variant: "
|
|
258
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontWeight: 600, mb: 1.5 }, children: t("passport") }),
|
|
255
259
|
/* @__PURE__ */ jsx(Passport, { user: userState.data })
|
|
256
260
|
] }),
|
|
257
261
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
258
|
-
/* @__PURE__ */ jsx(Typography, { variant: "
|
|
262
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontWeight: 600, mb: 1.5 }, children: t("userInfo") }),
|
|
259
263
|
/* @__PURE__ */ jsx(
|
|
260
264
|
UserInfo,
|
|
261
265
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default ComponentInstaller;
|
|
2
|
-
declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, roles, }: {
|
|
2
|
+
declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, disabled, roles, }: {
|
|
3
3
|
warnIcon: any;
|
|
4
4
|
did: any;
|
|
5
5
|
noPermissionMute: any;
|
|
@@ -9,10 +9,12 @@ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstall
|
|
|
9
9
|
closeByOutSize: any;
|
|
10
10
|
onClose: any;
|
|
11
11
|
fallback: any;
|
|
12
|
+
disabled: any;
|
|
12
13
|
roles?: string[] | undefined;
|
|
13
|
-
}):
|
|
14
|
+
}): any;
|
|
14
15
|
declare namespace ComponentInstaller {
|
|
15
16
|
namespace propTypes {
|
|
17
|
+
let disabled: any;
|
|
16
18
|
let warnIcon: any;
|
|
17
19
|
let did: any;
|
|
18
20
|
let noPermissionMute: any;
|
|
@@ -25,6 +27,8 @@ declare namespace ComponentInstaller {
|
|
|
25
27
|
let roles: any;
|
|
26
28
|
}
|
|
27
29
|
namespace defaultProps {
|
|
30
|
+
let disabled_1: boolean;
|
|
31
|
+
export { disabled_1 as disabled };
|
|
28
32
|
let warnIcon_1: null;
|
|
29
33
|
export { warnIcon_1 as warnIcon };
|
|
30
34
|
let noPermissionMute_1: boolean;
|
|
@@ -28,6 +28,7 @@ function ComponentInstaller({
|
|
|
28
28
|
closeByOutSize,
|
|
29
29
|
onClose,
|
|
30
30
|
fallback,
|
|
31
|
+
disabled,
|
|
31
32
|
roles = ["owner", "admin"]
|
|
32
33
|
}) {
|
|
33
34
|
const {
|
|
@@ -63,6 +64,9 @@ function ComponentInstaller({
|
|
|
63
64
|
window.location.reload();
|
|
64
65
|
};
|
|
65
66
|
const size = 60;
|
|
67
|
+
if (disabled) {
|
|
68
|
+
return children;
|
|
69
|
+
}
|
|
66
70
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_SessionPermission.default, {
|
|
67
71
|
session: sessionCtx?.session,
|
|
68
72
|
roles,
|
|
@@ -357,6 +361,7 @@ function ComponentInstaller({
|
|
|
357
361
|
});
|
|
358
362
|
}
|
|
359
363
|
ComponentInstaller.propTypes = {
|
|
364
|
+
disabled: _propTypes.default.bool,
|
|
360
365
|
warnIcon: _propTypes.default.node,
|
|
361
366
|
did: _propTypes.default.string.isRequired,
|
|
362
367
|
noPermissionMute: _propTypes.default.bool,
|
|
@@ -369,6 +374,7 @@ ComponentInstaller.propTypes = {
|
|
|
369
374
|
roles: _propTypes.default.array
|
|
370
375
|
};
|
|
371
376
|
ComponentInstaller.defaultProps = {
|
|
377
|
+
disabled: false,
|
|
372
378
|
warnIcon: null,
|
|
373
379
|
noPermissionMute: false,
|
|
374
380
|
onInstalled: null,
|
|
@@ -6,8 +6,8 @@ declare function useComponentInstalled({ did, onInstalled, onError }: {
|
|
|
6
6
|
}): {
|
|
7
7
|
optionalComponent: any;
|
|
8
8
|
installed: any;
|
|
9
|
-
installUrl:
|
|
10
|
-
storeUrl:
|
|
9
|
+
installUrl: any;
|
|
10
|
+
storeUrl: any;
|
|
11
11
|
installStatus: string;
|
|
12
12
|
setInstallStatus: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
13
13
|
installStatusDone: boolean;
|
|
@@ -6,15 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var _constant = require("@arcblock/did-connect/lib/constant");
|
|
8
8
|
var _react = require("react");
|
|
9
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
11
|
function useComponentInstalled({
|
|
10
12
|
did,
|
|
11
13
|
onInstalled,
|
|
12
14
|
onError
|
|
13
15
|
}) {
|
|
14
|
-
const
|
|
15
|
-
optionalComponents,
|
|
16
|
-
componentMountPoints
|
|
17
|
-
} = window.blocklet;
|
|
16
|
+
const [installStatus, setInstallStatus] = (0, _react.useState)('');
|
|
18
17
|
const onInstalledRef = (0, _react.useRef)({
|
|
19
18
|
onInstalled,
|
|
20
19
|
onError
|
|
@@ -23,6 +22,10 @@ function useComponentInstalled({
|
|
|
23
22
|
onInstalled,
|
|
24
23
|
onError
|
|
25
24
|
};
|
|
25
|
+
const {
|
|
26
|
+
optionalComponents,
|
|
27
|
+
componentMountPoints
|
|
28
|
+
} = window.blocklet;
|
|
26
29
|
const optionalComponent = (0, _react.useMemo)(() => {
|
|
27
30
|
if (!optionalComponents || !optionalComponents.length) {
|
|
28
31
|
return null;
|
|
@@ -37,9 +40,8 @@ function useComponentInstalled({
|
|
|
37
40
|
}
|
|
38
41
|
return (componentMountPoints || []).find(item => item.did === did);
|
|
39
42
|
}, [optionalComponent, componentMountPoints, did]);
|
|
40
|
-
const installUrl =
|
|
41
|
-
const storeUrl = optionalComponent ?
|
|
42
|
-
const [installStatus, setInstallStatus] = (0, _react.useState)('');
|
|
43
|
+
const installUrl = (0, _urlJoin.default)(window.blocklet.appUrl, _constant.AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
|
|
44
|
+
const storeUrl = optionalComponent ? (0, _urlJoin.default)(optionalComponent.meta.homepage, 'blocklets', did) : '';
|
|
43
45
|
(0, _react.useEffect)(() => {
|
|
44
46
|
const handle = event => {
|
|
45
47
|
if (event.origin !== window.blocklet.appUrl) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PaperProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, }: {
|
|
3
|
+
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, }: {
|
|
4
4
|
readonly children: any;
|
|
5
5
|
readonly currentTab: string;
|
|
6
6
|
readonly contentProps?: PaperProps;
|
|
@@ -9,4 +9,5 @@ export default function UserCenter({ children, currentTab, contentProps, disable
|
|
|
9
9
|
readonly hideFooter?: boolean;
|
|
10
10
|
readonly headerProps?: object;
|
|
11
11
|
readonly footerProps?: object;
|
|
12
|
+
readonly userDid?: string;
|
|
12
13
|
}): import("react").JSX.Element | null;
|
|
@@ -35,7 +35,8 @@ function UserCenter({
|
|
|
35
35
|
autoPopupSetting = false,
|
|
36
36
|
hideFooter = false,
|
|
37
37
|
headerProps = {},
|
|
38
|
-
footerProps = {}
|
|
38
|
+
footerProps = {},
|
|
39
|
+
userDid
|
|
39
40
|
}) {
|
|
40
41
|
const {
|
|
41
42
|
locale
|
|
@@ -46,6 +47,9 @@ function UserCenter({
|
|
|
46
47
|
const sessionCtx = (0, _react.useContext)(_Session.SessionContext);
|
|
47
48
|
const session = sessionCtx?.session;
|
|
48
49
|
const currentDid = (0, _ahooks.useCreation)(() => {
|
|
50
|
+
if (userDid) {
|
|
51
|
+
return userDid;
|
|
52
|
+
}
|
|
49
53
|
const currentUrl = window.location.href;
|
|
50
54
|
const query = (0, _ufo.getQuery)(currentUrl);
|
|
51
55
|
if (query?.did) {
|
|
@@ -55,7 +59,7 @@ function UserCenter({
|
|
|
55
59
|
return query.did;
|
|
56
60
|
}
|
|
57
61
|
return session?.user?.did;
|
|
58
|
-
}, [session?.user?.did]);
|
|
62
|
+
}, [session?.user?.did, userDid]);
|
|
59
63
|
const isMyself = (0, _ahooks.useCreation)(() => {
|
|
60
64
|
if (session?.user) {
|
|
61
65
|
return currentDid === session?.user?.did;
|
|
@@ -266,9 +270,9 @@ function UserCenter({
|
|
|
266
270
|
}) : null, isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
267
271
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
268
272
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
269
|
-
variant: "
|
|
273
|
+
variant: "h6",
|
|
270
274
|
sx: {
|
|
271
|
-
fontWeight:
|
|
275
|
+
fontWeight: 600,
|
|
272
276
|
mb: 1.5
|
|
273
277
|
},
|
|
274
278
|
children: t("passport")
|
|
@@ -277,9 +281,9 @@ function UserCenter({
|
|
|
277
281
|
})]
|
|
278
282
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
279
283
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
280
|
-
variant: "
|
|
284
|
+
variant: "h6",
|
|
281
285
|
sx: {
|
|
282
|
-
fontWeight:
|
|
286
|
+
fontWeight: 600,
|
|
283
287
|
mb: 1.5
|
|
284
288
|
},
|
|
285
289
|
children: t("userInfo")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.21",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@abtnode/constant": "1.16.23-beta-aeb9f5bd",
|
|
66
|
-
"@arcblock/did-connect": "^2.9.
|
|
67
|
-
"@arcblock/ux": "^2.9.
|
|
66
|
+
"@arcblock/did-connect": "^2.9.21",
|
|
67
|
+
"@arcblock/ux": "^2.9.21",
|
|
68
68
|
"@blocklet/js-sdk": "1.16.23-beta-aeb9f5bd",
|
|
69
69
|
"@emotion/react": "^11.10.4",
|
|
70
70
|
"@emotion/styled": "^11.10.4",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
81
|
"react-error-boundary": "^3.1.4",
|
|
82
82
|
"react-placeholder": "^4.1.0",
|
|
83
|
-
"ufo": "^1.3.2"
|
|
83
|
+
"ufo": "^1.3.2",
|
|
84
|
+
"url-join": "^4.0.1"
|
|
84
85
|
},
|
|
85
86
|
"peerDependencies": {
|
|
86
87
|
"react": ">=18.1.0"
|
|
@@ -98,5 +99,5 @@
|
|
|
98
99
|
"jest": "^28.1.3",
|
|
99
100
|
"unbuild": "^2.0.0"
|
|
100
101
|
},
|
|
101
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "800e32d5197a96b1b0a7dcf08f0bf11132c301e9"
|
|
102
103
|
}
|
|
@@ -21,6 +21,7 @@ function ComponentInstaller({
|
|
|
21
21
|
closeByOutSize,
|
|
22
22
|
onClose,
|
|
23
23
|
fallback,
|
|
24
|
+
disabled,
|
|
24
25
|
roles = ['owner', 'admin'],
|
|
25
26
|
}) {
|
|
26
27
|
const { locale } = useLocaleContext();
|
|
@@ -53,6 +54,10 @@ function ComponentInstaller({
|
|
|
53
54
|
|
|
54
55
|
const size = 60;
|
|
55
56
|
|
|
57
|
+
if (disabled) {
|
|
58
|
+
return children;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
return (
|
|
57
62
|
<SessionPermission session={sessionCtx?.session} roles={roles}>
|
|
58
63
|
{({ hasPermission }) => {
|
|
@@ -279,6 +284,7 @@ function ComponentInstaller({
|
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
ComponentInstaller.propTypes = {
|
|
287
|
+
disabled: PropTypes.bool,
|
|
282
288
|
warnIcon: PropTypes.node,
|
|
283
289
|
did: PropTypes.string.isRequired,
|
|
284
290
|
noPermissionMute: PropTypes.bool,
|
|
@@ -292,6 +298,7 @@ ComponentInstaller.propTypes = {
|
|
|
292
298
|
};
|
|
293
299
|
|
|
294
300
|
ComponentInstaller.defaultProps = {
|
|
301
|
+
disabled: false,
|
|
295
302
|
warnIcon: null,
|
|
296
303
|
noPermissionMute: false,
|
|
297
304
|
onInstalled: null,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
|
|
2
2
|
import { useMemo, useRef, useState, useEffect } from 'react';
|
|
3
|
+
import urlJoin from 'url-join';
|
|
3
4
|
|
|
4
5
|
function useComponentInstalled({ did, onInstalled, onError }) {
|
|
5
|
-
const
|
|
6
|
+
const [installStatus, setInstallStatus] = useState('');
|
|
6
7
|
const onInstalledRef = useRef({ onInstalled, onError });
|
|
7
8
|
onInstalledRef.current = { onInstalled, onError };
|
|
8
9
|
|
|
10
|
+
const { optionalComponents, componentMountPoints } = window.blocklet;
|
|
11
|
+
|
|
9
12
|
const optionalComponent = useMemo(() => {
|
|
10
13
|
if (!optionalComponents || !optionalComponents.length) {
|
|
11
14
|
return null;
|
|
@@ -22,9 +25,8 @@ function useComponentInstalled({ did, onInstalled, onError }) {
|
|
|
22
25
|
return (componentMountPoints || []).find((item) => item.did === did);
|
|
23
26
|
}, [optionalComponent, componentMountPoints, did]);
|
|
24
27
|
|
|
25
|
-
const installUrl =
|
|
26
|
-
const storeUrl = optionalComponent ?
|
|
27
|
-
const [installStatus, setInstallStatus] = useState('');
|
|
28
|
+
const installUrl = urlJoin(window.blocklet.appUrl, AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
|
|
29
|
+
const storeUrl = optionalComponent ? urlJoin(optionalComponent.meta.homepage, 'blocklets', did) : '';
|
|
28
30
|
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
const handle = (event) => {
|
|
@@ -36,6 +36,7 @@ export default function UserCenter({
|
|
|
36
36
|
hideFooter = false,
|
|
37
37
|
headerProps = {},
|
|
38
38
|
footerProps = {},
|
|
39
|
+
userDid,
|
|
39
40
|
}: {
|
|
40
41
|
readonly children: any;
|
|
41
42
|
readonly currentTab: string;
|
|
@@ -45,6 +46,7 @@ export default function UserCenter({
|
|
|
45
46
|
readonly hideFooter?: boolean;
|
|
46
47
|
readonly headerProps?: object;
|
|
47
48
|
readonly footerProps?: object;
|
|
49
|
+
readonly userDid?: string;
|
|
48
50
|
}) {
|
|
49
51
|
const { locale } = useLocaleContext();
|
|
50
52
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -54,6 +56,10 @@ export default function UserCenter({
|
|
|
54
56
|
const session = sessionCtx?.session;
|
|
55
57
|
|
|
56
58
|
const currentDid = useCreation(() => {
|
|
59
|
+
if (userDid) {
|
|
60
|
+
return userDid;
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
const currentUrl = window.location.href;
|
|
58
64
|
const query = getQuery(currentUrl);
|
|
59
65
|
if (query?.did) {
|
|
@@ -63,7 +69,7 @@ export default function UserCenter({
|
|
|
63
69
|
return query.did;
|
|
64
70
|
}
|
|
65
71
|
return session?.user?.did;
|
|
66
|
-
}, [session?.user?.did]);
|
|
72
|
+
}, [session?.user?.did, userDid]);
|
|
67
73
|
|
|
68
74
|
const isMyself = useCreation(() => {
|
|
69
75
|
if (session?.user) {
|
|
@@ -284,13 +290,13 @@ export default function UserCenter({
|
|
|
284
290
|
{isMyself ? (
|
|
285
291
|
<>
|
|
286
292
|
<Box>
|
|
287
|
-
<Typography variant="
|
|
293
|
+
<Typography variant="h6" sx={{ fontWeight: 600, mb: 1.5 }}>
|
|
288
294
|
{t('passport')}
|
|
289
295
|
</Typography>
|
|
290
296
|
<Passport user={userState.data} />
|
|
291
297
|
</Box>
|
|
292
298
|
<Box>
|
|
293
|
-
<Typography variant="
|
|
299
|
+
<Typography variant="h6" sx={{ fontWeight: 600, mb: 1.5 }}>
|
|
294
300
|
{t('userInfo')}
|
|
295
301
|
</Typography>
|
|
296
302
|
<UserInfo
|