@blocklet/ui-react 2.9.51 → 2.9.53
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/@types/index.d.ts +3 -5
- package/es/Dashboard/index.d.ts +5 -6
- package/es/Dashboard/index.js +5 -5
- package/es/Footer/index.js +2 -2
- package/es/Header/index.js +5 -5
- package/es/UserCenter/components/notification.js +1 -1
- package/es/UserCenter/components/passport.js +1 -2
- package/es/UserCenter/components/privacy.js +1 -1
- package/es/UserCenter/components/settings.js +9 -1
- package/es/UserCenter/components/storage/connect-to.d.ts +1 -1
- package/es/UserCenter/components/storage/connect-to.js +9 -3
- package/es/UserCenter/components/storage/connected.d.ts +1 -1
- package/es/UserCenter/components/storage/connected.js +5 -2
- package/es/UserCenter/components/storage/delete.d.ts +1 -1
- package/es/UserCenter/components/storage/delete.js +4 -1
- package/es/UserCenter/components/storage/index.js +4 -2
- package/es/UserCenter/components/storage/item.js +7 -12
- package/es/UserCenter/components/user-center.d.ts +2 -2
- package/es/UserCenter/components/user-center.js +15 -6
- package/es/UserCenter/libs/locales.d.ts +54 -0
- package/es/UserCenter/libs/locales.js +56 -2
- package/es/UserSessions/components/user-session-info.d.ts +6 -0
- package/es/UserSessions/components/user-session-info.js +58 -0
- package/es/UserSessions/components/user-sessions.d.ts +9 -0
- package/es/UserSessions/components/user-sessions.js +255 -0
- package/es/UserSessions/index.d.ts +1 -0
- package/es/UserSessions/index.js +1 -0
- package/es/UserSessions/libs/locales.d.ts +52 -0
- package/es/UserSessions/libs/locales.js +52 -0
- package/es/UserSessions/libs/utils.d.ts +2 -0
- package/es/UserSessions/libs/utils.js +73 -0
- package/es/blocklets.js +6 -6
- package/es/common/header-addons.d.ts +3 -4
- package/es/common/header-addons.js +4 -4
- package/es/contexts/config-user-space.js +2 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/types.d.ts +2 -2
- package/es/types.js +2 -2
- package/lib/@types/index.d.ts +3 -5
- package/lib/Dashboard/index.d.ts +5 -6
- package/lib/Dashboard/index.js +4 -4
- package/lib/Footer/index.js +1 -1
- package/lib/Header/index.js +4 -4
- package/lib/UserCenter/components/notification.js +1 -1
- package/lib/UserCenter/components/passport.js +1 -2
- package/lib/UserCenter/components/privacy.js +1 -1
- package/lib/UserCenter/components/settings.js +10 -1
- package/lib/UserCenter/components/storage/connect-to.d.ts +1 -1
- package/lib/UserCenter/components/storage/connect-to.js +3 -3
- package/lib/UserCenter/components/storage/connected.d.ts +1 -1
- package/lib/UserCenter/components/storage/connected.js +1 -1
- package/lib/UserCenter/components/storage/delete.d.ts +1 -1
- package/lib/UserCenter/components/storage/index.js +22 -17
- package/lib/UserCenter/components/storage/item.js +1 -13
- package/lib/UserCenter/components/user-center.d.ts +2 -2
- package/lib/UserCenter/components/user-center.js +20 -10
- package/lib/UserCenter/libs/locales.d.ts +54 -0
- package/lib/UserCenter/libs/locales.js +56 -2
- package/lib/UserSessions/components/user-session-info.d.ts +6 -0
- package/lib/UserSessions/components/user-session-info.js +68 -0
- package/lib/UserSessions/components/user-sessions.d.ts +9 -0
- package/lib/UserSessions/components/user-sessions.js +282 -0
- package/lib/UserSessions/index.d.ts +1 -0
- package/lib/UserSessions/index.js +13 -0
- package/lib/UserSessions/libs/locales.d.ts +52 -0
- package/lib/UserSessions/libs/locales.js +58 -0
- package/lib/UserSessions/libs/utils.d.ts +2 -0
- package/lib/UserSessions/libs/utils.js +80 -0
- package/lib/blocklets.js +6 -6
- package/lib/common/header-addons.d.ts +3 -4
- package/lib/common/header-addons.js +3 -3
- package/lib/contexts/config-user-space.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/types.d.ts +2 -2
- package/lib/types.js +3 -3
- package/package.json +14 -6
- package/src/@types/index.ts +3 -5
- package/src/Dashboard/index.jsx +7 -3
- package/src/Footer/index.jsx +2 -2
- package/src/Header/index.jsx +5 -3
- package/src/Icon/index.jsx +1 -0
- package/src/UserCenter/components/notification.tsx +2 -2
- package/src/UserCenter/components/passport.tsx +1 -2
- package/src/UserCenter/components/privacy.tsx +1 -1
- package/src/UserCenter/components/settings.tsx +15 -2
- package/src/UserCenter/components/storage/connect-to.tsx +17 -11
- package/src/UserCenter/components/storage/connected.tsx +9 -3
- package/src/UserCenter/components/storage/delete.tsx +8 -2
- package/src/UserCenter/components/storage/index.tsx +17 -13
- package/src/UserCenter/components/storage/item.tsx +8 -15
- package/src/UserCenter/components/storage/preview-nft.tsx +1 -1
- package/src/UserCenter/components/user-center.tsx +21 -14
- package/src/UserCenter/components/webhook-item.tsx +1 -1
- package/src/UserCenter/libs/locales.ts +54 -0
- package/src/UserSessions/components/user-session-info.tsx +52 -0
- package/src/UserSessions/components/user-sessions.tsx +276 -0
- package/src/UserSessions/index.tsx +1 -0
- package/src/UserSessions/libs/locales.ts +52 -0
- package/src/UserSessions/libs/utils.ts +82 -0
- package/src/blocklets.js +6 -6
- package/src/common/header-addons.jsx +2 -2
- package/src/contexts/config-user-space.tsx +12 -11
- package/src/index.ts +1 -0
- package/src/{UserCenter/libs → libs}/client.ts +1 -0
- package/src/libs/spaces.tsx +2 -2
- package/src/types.js +2 -2
- /package/es/{UserCenter/libs → libs}/client.d.ts +0 -0
- /package/es/{UserCenter/libs → libs}/client.js +0 -0
- /package/lib/{UserCenter/libs → libs}/client.d.ts +0 -0
- /package/lib/{UserCenter/libs → libs}/client.js +0 -0
package/es/@types/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Axios } from 'axios';
|
|
2
|
+
import type { UserPublicInfo } from '@blocklet/js-sdk';
|
|
2
3
|
export type SessionContext = {
|
|
3
4
|
session: Session;
|
|
4
5
|
api: Axios;
|
|
5
6
|
};
|
|
6
|
-
export type User = {
|
|
7
|
-
did: string;
|
|
8
|
-
fullName: string;
|
|
7
|
+
export type User = UserPublicInfo & {
|
|
9
8
|
role: string;
|
|
10
|
-
avatar: string;
|
|
11
9
|
email?: string;
|
|
12
10
|
phone?: string;
|
|
13
11
|
sourceProvider?: string;
|
|
@@ -15,7 +13,7 @@ export type User = {
|
|
|
15
13
|
lastLoginIp?: string;
|
|
16
14
|
createdAt?: string;
|
|
17
15
|
passports?: any[];
|
|
18
|
-
didSpace
|
|
16
|
+
didSpace?: Record<string, any>;
|
|
19
17
|
};
|
|
20
18
|
export type UserCenterTab = {
|
|
21
19
|
value: string;
|
package/es/Dashboard/index.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ declare function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddon
|
|
|
13
13
|
}): import("react").JSX.Element | null;
|
|
14
14
|
declare namespace Dashboard {
|
|
15
15
|
namespace propTypes {
|
|
16
|
-
export {
|
|
16
|
+
export { BlockletMetaProps as meta };
|
|
17
17
|
export let fallbackUrl: any;
|
|
18
18
|
export let invalidPathFallback: any;
|
|
19
19
|
export let headerAddons: any;
|
|
20
|
-
export { sessionManagerProps };
|
|
20
|
+
export { SessionManagerProps as sessionManagerProps };
|
|
21
21
|
export let links: any;
|
|
22
22
|
}
|
|
23
23
|
namespace defaultProps {
|
|
@@ -27,15 +27,14 @@ declare namespace Dashboard {
|
|
|
27
27
|
export { invalidPathFallback_1 as invalidPathFallback };
|
|
28
28
|
let headerAddons_1: undefined;
|
|
29
29
|
export { headerAddons_1 as headerAddons };
|
|
30
|
-
export namespace
|
|
30
|
+
export namespace sessionManagerProps {
|
|
31
31
|
let showRole: boolean;
|
|
32
32
|
function onLogout(): void;
|
|
33
33
|
}
|
|
34
|
-
export { sessionManagerProps_1 as sessionManagerProps };
|
|
35
34
|
let links_1: never[];
|
|
36
35
|
export { links_1 as links };
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
38
|
+
import { BlockletMetaProps } from '../types';
|
|
39
|
+
import { SessionManagerProps } from '../types';
|
|
41
40
|
import { publicPath } from '../blocklets';
|
package/es/Dashboard/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
6
6
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
7
|
import UxDashboard from "@arcblock/ux/lib/Layout/dashboard";
|
|
8
|
-
import {
|
|
8
|
+
import { BlockletMetaProps, SessionManagerProps } from "../types.js";
|
|
9
9
|
import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
10
10
|
import { publicPath, formatBlockletInfo, getLocalizedNavigation, filterNavByRole } from "../blocklets.js";
|
|
11
11
|
import HeaderAddons from "../common/header-addons.js";
|
|
12
12
|
import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
|
|
13
|
-
function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps
|
|
13
|
+
function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessionManagerProps, links, ...rest }) {
|
|
14
14
|
useWalletHiddenTopbar();
|
|
15
15
|
const sessionCtx = useContext(SessionContext);
|
|
16
16
|
const user = sessionCtx?.session?.user;
|
|
@@ -71,7 +71,7 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
71
71
|
{
|
|
72
72
|
formattedBlocklet,
|
|
73
73
|
addons: headerAddons,
|
|
74
|
-
sessionManagerProps
|
|
74
|
+
sessionManagerProps
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
return /* @__PURE__ */ jsx(
|
|
@@ -93,13 +93,13 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
Dashboard.propTypes = {
|
|
96
|
-
meta:
|
|
96
|
+
meta: BlockletMetaProps,
|
|
97
97
|
// 如果当前用户没有权限访问任何导航菜单, 则自动跳转到 fallbackUrl, 默认值为 publicPath, 设置为 null 表示禁用自动跳转
|
|
98
98
|
fallbackUrl: PropTypes.string,
|
|
99
99
|
// 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
|
|
100
100
|
invalidPathFallback: PropTypes.func,
|
|
101
101
|
headerAddons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
102
|
-
sessionManagerProps,
|
|
102
|
+
sessionManagerProps: SessionManagerProps,
|
|
103
103
|
links: PropTypes.oneOfType([PropTypes.array, PropTypes.func])
|
|
104
104
|
};
|
|
105
105
|
Dashboard.defaultProps = {
|
package/es/Footer/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import OverridableThemeProvider from "../common/overridable-theme-provider.js";
|
|
|
11
11
|
import InternalFooter from "./internal-footer.js";
|
|
12
12
|
import { mapRecursive } from "../utils.js";
|
|
13
13
|
import { formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
14
|
-
import {
|
|
14
|
+
import { BlockletMetaProps } from "../types.js";
|
|
15
15
|
function Footer({ meta, theme: themeOverrides, ...rest }) {
|
|
16
16
|
const { locale } = useLocaleContext() || {};
|
|
17
17
|
const formattedBlocklet = useMemo(() => {
|
|
@@ -62,7 +62,7 @@ function Footer({ meta, theme: themeOverrides, ...rest }) {
|
|
|
62
62
|
) });
|
|
63
63
|
}
|
|
64
64
|
Footer.propTypes = {
|
|
65
|
-
meta:
|
|
65
|
+
meta: BlockletMetaProps,
|
|
66
66
|
// 允许覆盖 footer 内置的 theme
|
|
67
67
|
theme: PropTypes.object
|
|
68
68
|
};
|
package/es/Header/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
|
11
11
|
import omit from "lodash/omit";
|
|
12
12
|
import Icon from "../Icon/index.js";
|
|
13
13
|
import OverridableThemeProvider from "../common/overridable-theme-provider.js";
|
|
14
|
-
import {
|
|
14
|
+
import { BlockletMetaProps, SessionManagerProps } from "../types.js";
|
|
15
15
|
import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
16
16
|
import { publicPath, formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
17
17
|
import HeaderAddons from "../common/header-addons.js";
|
|
@@ -50,7 +50,7 @@ const parseNavigation = (navigation) => {
|
|
|
50
50
|
const matchedIndex = matchPaths(flattened.map((item) => item.link));
|
|
51
51
|
return { navItems, activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null };
|
|
52
52
|
};
|
|
53
|
-
function Header({ meta, addons, sessionManagerProps
|
|
53
|
+
function Header({ meta, addons, sessionManagerProps, homeLink, theme: themeOverrides, hideNavMenu, ...rest }) {
|
|
54
54
|
useWalletHiddenTopbar();
|
|
55
55
|
const { locale } = useLocaleContext() || {};
|
|
56
56
|
const formattedBlocklet = useMemo(() => {
|
|
@@ -70,7 +70,7 @@ function Header({ meta, addons, sessionManagerProps: sessionManagerProps2, homeL
|
|
|
70
70
|
const parsedNavigation = parseNavigation(navigation);
|
|
71
71
|
const { navItems, activeId } = parsedNavigation;
|
|
72
72
|
const _addons = typeof addons === "function" ? (builtInAddons) => addons(builtInAddons, { navigation: parsedNavigation }) : addons;
|
|
73
|
-
const headerAddons = /* @__PURE__ */ jsx(HeaderAddons, { formattedBlocklet, addons: _addons, sessionManagerProps
|
|
73
|
+
const headerAddons = /* @__PURE__ */ jsx(HeaderAddons, { formattedBlocklet, addons: _addons, sessionManagerProps });
|
|
74
74
|
return /* @__PURE__ */ jsx(OverridableThemeProvider, { theme: themeOverrides, children: /* @__PURE__ */ jsx(
|
|
75
75
|
StyledUxHeader,
|
|
76
76
|
{
|
|
@@ -95,12 +95,12 @@ function Header({ meta, addons, sessionManagerProps: sessionManagerProps2, homeL
|
|
|
95
95
|
) });
|
|
96
96
|
}
|
|
97
97
|
Header.propTypes = {
|
|
98
|
-
meta:
|
|
98
|
+
meta: BlockletMetaProps,
|
|
99
99
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
100
100
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
101
101
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
102
102
|
addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
103
|
-
sessionManagerProps,
|
|
103
|
+
sessionManagerProps: SessionManagerProps,
|
|
104
104
|
homeLink: PropTypes.string,
|
|
105
105
|
// 允许覆盖 header 内置的 theme
|
|
106
106
|
theme: PropTypes.object,
|
|
@@ -13,7 +13,7 @@ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
|
13
13
|
import { translations } from "../libs/locales.js";
|
|
14
14
|
import WebhookItem from "./webhook-item.js";
|
|
15
15
|
import { formatAxiosError } from "../libs/utils.js";
|
|
16
|
-
import { client } from "
|
|
16
|
+
import { client } from "../../libs/client.js";
|
|
17
17
|
export default function Notification({ user }) {
|
|
18
18
|
const { locale } = useLocaleContext();
|
|
19
19
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -7,7 +7,7 @@ import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
|
7
7
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
8
8
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
9
9
|
import { translations } from "../libs/locales.js";
|
|
10
|
-
import { client } from "
|
|
10
|
+
import { client } from "../../libs/client.js";
|
|
11
11
|
import { formatAxiosError } from "../libs/utils.js";
|
|
12
12
|
export default function Privacy({ configList, onSave }) {
|
|
13
13
|
const [dataList, setDataList] = useState(configList);
|
|
@@ -9,6 +9,7 @@ import { translations } from "../libs/locales.js";
|
|
|
9
9
|
import Notification from "./notification.js";
|
|
10
10
|
import Privacy from "./privacy.js";
|
|
11
11
|
import DidSpace from "./storage/index.js";
|
|
12
|
+
import { UserSessions } from "../../UserSessions/index.js";
|
|
12
13
|
export default function Settings({
|
|
13
14
|
user,
|
|
14
15
|
settings,
|
|
@@ -45,6 +46,11 @@ export default function Settings({
|
|
|
45
46
|
label: t("storageManagement"),
|
|
46
47
|
value: "storage",
|
|
47
48
|
content: /* @__PURE__ */ jsx(ConfigUserSpaceProvider, { children: /* @__PURE__ */ jsx(DidSpace, {}) })
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: t("sessionManagement"),
|
|
52
|
+
value: "session",
|
|
53
|
+
content: /* @__PURE__ */ jsx(UserSessions, { user })
|
|
48
54
|
}
|
|
49
55
|
].filter(Boolean);
|
|
50
56
|
}, [user, privacyConfigList]);
|
|
@@ -63,7 +69,9 @@ export default function Settings({
|
|
|
63
69
|
...rest,
|
|
64
70
|
sx: {
|
|
65
71
|
...rest?.sx,
|
|
66
|
-
|
|
72
|
+
minWidth: {
|
|
73
|
+
md: 500
|
|
74
|
+
},
|
|
67
75
|
maxWidth: "100%"
|
|
68
76
|
},
|
|
69
77
|
children: [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpaceGateway } from '../../../contexts/config-user-space';
|
|
3
|
-
declare function ConnectTo({ onConnect, storageEndpoint,
|
|
3
|
+
declare function ConnectTo({ onConnect, storageEndpoint, }: {
|
|
4
4
|
onConnect: (spaceGateway: SpaceGateway) => Promise<void>;
|
|
5
5
|
storageEndpoint: string;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
@@ -8,15 +8,21 @@ import { joinURL } from "ufo";
|
|
|
8
8
|
import toast from "@arcblock/ux/lib/Toast";
|
|
9
9
|
import isEmpty from "lodash/isEmpty";
|
|
10
10
|
import { axios } from "../../libs/api.js";
|
|
11
|
-
function ConnectTo({
|
|
11
|
+
function ConnectTo({
|
|
12
|
+
onConnect,
|
|
13
|
+
storageEndpoint
|
|
14
|
+
}) {
|
|
12
15
|
const { t, locale } = useLocaleContext();
|
|
13
16
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
|
|
14
17
|
open: false,
|
|
15
18
|
action: "connect-to-did-spaces-for-user",
|
|
16
19
|
checkTimeout: 1e3 * 300,
|
|
17
20
|
prefix: "/api/did",
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
checkFn: axios.create({
|
|
22
|
+
// FIXME: @jianchao 检查 env 的使用是否正确
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
baseURL: joinURL(window.location.origin, window.env && window.env.apiPrefix ? window.env.apiPrefix : "/")
|
|
25
|
+
}).get,
|
|
20
26
|
extraParams: {},
|
|
21
27
|
messages: {
|
|
22
28
|
title: t("storage.spaces.provideNFT.title", { appName: window.blocklet.appName }, locale),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SettingStorageEndpoint, SpaceGateway } from '../../../contexts/config-user-space';
|
|
3
|
-
declare function Connected({ spaceGateway, settingStorageEndpoint }: {
|
|
3
|
+
declare function Connected({ spaceGateway, settingStorageEndpoint, }: {
|
|
4
4
|
spaceGateway: SpaceGateway | undefined;
|
|
5
5
|
settingStorageEndpoint: SettingStorageEndpoint;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Typography } from "@mui/material";
|
|
3
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
+
import { Box, Typography } from "@mui/material";
|
|
4
4
|
import SpaceItem from "./item.js";
|
|
5
|
-
function Connected({
|
|
5
|
+
function Connected({
|
|
6
|
+
spaceGateway,
|
|
7
|
+
settingStorageEndpoint
|
|
8
|
+
}) {
|
|
6
9
|
const { t } = useLocaleContext();
|
|
7
10
|
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", children: [
|
|
8
11
|
/* @__PURE__ */ jsx(Box, { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "space-between", marginBottom: "12px", children: /* @__PURE__ */ jsx(Typography, { fontSize: "1.2rem", fontWeight: "bold", children: t("storage.spaces.connected.title") }) }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpaceGateway } from '../../../contexts/config-user-space';
|
|
3
|
-
declare function SpaceDelete({ spaceGateway, onDeleteSpace }: {
|
|
3
|
+
declare function SpaceDelete({ spaceGateway, onDeleteSpace, }: {
|
|
4
4
|
spaceGateway: SpaceGateway;
|
|
5
5
|
onDeleteSpace: (spaceGateway: SpaceGateway) => Promise<void>;
|
|
6
6
|
}): JSX.Element;
|
|
@@ -5,7 +5,10 @@ import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
|
5
5
|
import Confirm from "@arcblock/ux/lib/Dialog/confirm";
|
|
6
6
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
7
|
import toast from "@arcblock/ux/lib/Toast";
|
|
8
|
-
function SpaceDelete({
|
|
8
|
+
function SpaceDelete({
|
|
9
|
+
spaceGateway,
|
|
10
|
+
onDeleteSpace
|
|
11
|
+
}) {
|
|
9
12
|
const { t } = useLocaleContext();
|
|
10
13
|
const [open, setOpen] = useState(false);
|
|
11
14
|
const [loading, setLoading] = useState(false);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Center from "@arcblock/ux/lib/Center";
|
|
3
|
+
import { LocaleProvider } from "@arcblock/ux/lib/Locale/context";
|
|
3
4
|
import styled from "@emotion/styled";
|
|
4
5
|
import { Box, CircularProgress } from "@mui/material";
|
|
5
6
|
import { useConfigUserSpaceContext } from "../../../contexts/config-user-space.js";
|
|
@@ -7,16 +8,17 @@ import useMobile from "../../../hooks/use-mobile.js";
|
|
|
7
8
|
import ConnectTo from "./connect-to.js";
|
|
8
9
|
import Connected from "./connected.js";
|
|
9
10
|
import Disconnect from "./disconnect.js";
|
|
11
|
+
import { translations } from "../../libs/locales.js";
|
|
10
12
|
function DidSpace() {
|
|
11
13
|
const isMobile = useMobile({});
|
|
12
14
|
const { spaceGateway, updateSpaceGateway, settingStorageEndpoint, hasStorageEndpoint, loading, storageEndpoint } = useConfigUserSpaceContext();
|
|
13
15
|
if (loading) {
|
|
14
16
|
return /* @__PURE__ */ jsx(Center, { relative: "parent", children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
15
17
|
}
|
|
16
|
-
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
18
|
+
return /* @__PURE__ */ jsx(LocaleProvider, { translations, children: /* @__PURE__ */ jsxs(Container, { children: [
|
|
17
19
|
/* @__PURE__ */ jsx(Box, { maxWidth: isMobile ? "360px" : "720px", children: hasStorageEndpoint ? /* @__PURE__ */ jsx(Connected, { spaceGateway, settingStorageEndpoint }) : /* @__PURE__ */ jsx(Disconnect, {}) }),
|
|
18
20
|
/* @__PURE__ */ jsx(Box, { display: "flex", alignItems: "center", justifyContent: "center", paddingTop: "24px", children: /* @__PURE__ */ jsx(ConnectTo, { onConnect: updateSpaceGateway, storageEndpoint }) })
|
|
19
|
-
] });
|
|
21
|
+
] }) });
|
|
20
22
|
}
|
|
21
23
|
const Container = styled(Box)`
|
|
22
24
|
height: 100%;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Chip, Typography } from "@mui/material";
|
|
3
3
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
-
import toast from "@arcblock/ux/lib/Toast";
|
|
5
4
|
import CheckIcon from "@mui/icons-material/Check";
|
|
6
5
|
import styled from "@emotion/styled";
|
|
7
|
-
import SpacesConnectedSvg from "./icons/space-connected.svg?react";
|
|
8
6
|
import DidAddress from "@arcblock/ux/lib/DID";
|
|
7
|
+
import SpacesConnectedSvg from "./icons/space-connected.svg?react";
|
|
9
8
|
import PreviewSpaceNft from "./preview-nft.js";
|
|
10
9
|
import useMobile from "../../../hooks/use-mobile.js";
|
|
11
10
|
import { getSpaceNftDisplayUrlFromEndpoint } from "../../../libs/spaces.js";
|
|
12
|
-
function SpaceItem({
|
|
11
|
+
function SpaceItem({
|
|
12
|
+
spaceGateway,
|
|
13
|
+
connected,
|
|
14
|
+
onDisconnect,
|
|
15
|
+
...rest
|
|
16
|
+
}) {
|
|
13
17
|
const isMobile = useMobile({});
|
|
14
18
|
const { t } = useLocaleContext();
|
|
15
|
-
const handleOnDisconnect = async () => {
|
|
16
|
-
try {
|
|
17
|
-
await onDisconnect();
|
|
18
|
-
toast.success(t("storage.spaces.gateway.delete.succeeded", { name: spaceGateway.name }));
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error(error);
|
|
21
|
-
toast.error(error.message);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
19
|
return /* @__PURE__ */ jsxs(
|
|
25
20
|
BoxContainer,
|
|
26
21
|
{
|
|
@@ -7,8 +7,8 @@ export default function UserCenter({ children, currentTab, contentProps, disable
|
|
|
7
7
|
readonly disableAutoRedirect?: boolean;
|
|
8
8
|
readonly autoPopupSetting?: boolean;
|
|
9
9
|
readonly hideFooter?: boolean;
|
|
10
|
-
readonly headerProps?:
|
|
11
|
-
readonly footerProps?:
|
|
10
|
+
readonly headerProps?: any;
|
|
11
|
+
readonly footerProps?: any;
|
|
12
12
|
readonly userDid?: string;
|
|
13
13
|
readonly stickySidebar?: boolean;
|
|
14
14
|
}): import("react").JSX.Element | null;
|
|
@@ -14,14 +14,15 @@ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
|
14
14
|
import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
|
|
15
15
|
import cloneDeep from "lodash/cloneDeep";
|
|
16
16
|
import { getQuery, withQuery } from "ufo";
|
|
17
|
-
import
|
|
17
|
+
import Footer from "../../Footer/index.js";
|
|
18
|
+
import Header from "../../Header/index.js";
|
|
18
19
|
import { translations } from "../libs/locales.js";
|
|
19
20
|
import UserInfo from "./user-info.js";
|
|
20
21
|
import UserBasicInfo from "./user-basic-info.js";
|
|
21
22
|
import { formatBlockletInfo, getLocalizedNavigation } from "../../blocklets.js";
|
|
22
23
|
import Passport from "./passport.js";
|
|
23
24
|
import Settings from "./settings.js";
|
|
24
|
-
import { client } from "
|
|
25
|
+
import { client } from "../../libs/client.js";
|
|
25
26
|
export default function UserCenter({
|
|
26
27
|
children,
|
|
27
28
|
currentTab,
|
|
@@ -31,7 +32,7 @@ export default function UserCenter({
|
|
|
31
32
|
hideFooter = false,
|
|
32
33
|
headerProps = {},
|
|
33
34
|
footerProps = {},
|
|
34
|
-
userDid,
|
|
35
|
+
userDid = void 0,
|
|
35
36
|
stickySidebar = false
|
|
36
37
|
}) {
|
|
37
38
|
const { locale } = useLocaleContext();
|
|
@@ -61,13 +62,14 @@ export default function UserCenter({
|
|
|
61
62
|
return false;
|
|
62
63
|
}, [currentDid, session?.user?.did]);
|
|
63
64
|
const userState = useRequest(
|
|
65
|
+
// eslint-disable-next-line consistent-return
|
|
64
66
|
async () => {
|
|
65
67
|
await pWaitFor(() => session?.initialized);
|
|
66
68
|
if (isMyself) {
|
|
67
69
|
return session.user;
|
|
68
70
|
}
|
|
69
71
|
if (currentDid) {
|
|
70
|
-
return
|
|
72
|
+
return client.user.getUserPublicInfo({ did: currentDid });
|
|
71
73
|
}
|
|
72
74
|
},
|
|
73
75
|
{
|
|
@@ -90,7 +92,8 @@ export default function UserCenter({
|
|
|
90
92
|
const { confirmHolder, confirmApi } = useConfirm({
|
|
91
93
|
sx: {
|
|
92
94
|
".MuiDialog-paper": {
|
|
93
|
-
borderRadius: 2
|
|
95
|
+
borderRadius: 2,
|
|
96
|
+
maxWidth: 1200
|
|
94
97
|
},
|
|
95
98
|
".ux-dialog_title": {
|
|
96
99
|
fontWeight: 600
|
|
@@ -261,7 +264,13 @@ export default function UserCenter({
|
|
|
261
264
|
},
|
|
262
265
|
children: /* @__PURE__ */ jsx(CircularProgress, { sx: { color: colors.primary100 } })
|
|
263
266
|
}
|
|
264
|
-
) :
|
|
267
|
+
) : (
|
|
268
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
269
|
+
/* @__PURE__ */ jsx(Fragment, { children: currentActiveTab?.protected && !isMyself ? /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Empty, { children: t("underProtected") }) }) : (
|
|
270
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
271
|
+
/* @__PURE__ */ jsx(Fragment, { children: children && /* @__PURE__ */ jsx(Box, { ...contentProps, children }) })
|
|
272
|
+
) })
|
|
273
|
+
)
|
|
265
274
|
]
|
|
266
275
|
}
|
|
267
276
|
) : null,
|
|
@@ -41,6 +41,33 @@ export declare const translations: {
|
|
|
41
41
|
myInfo: string;
|
|
42
42
|
loginNow: string;
|
|
43
43
|
viewAfterLogin: string;
|
|
44
|
+
sessionManagement: string;
|
|
45
|
+
storage: {
|
|
46
|
+
spaces: {
|
|
47
|
+
tips: string;
|
|
48
|
+
label: string;
|
|
49
|
+
connectedWithName: string;
|
|
50
|
+
gateway: {
|
|
51
|
+
delete: {
|
|
52
|
+
failed: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
provideNFT: {
|
|
56
|
+
title: string;
|
|
57
|
+
scan: string;
|
|
58
|
+
success: string;
|
|
59
|
+
};
|
|
60
|
+
connect: {
|
|
61
|
+
useWallet: string;
|
|
62
|
+
useWalletReconnect: string;
|
|
63
|
+
providerForStorage: string;
|
|
64
|
+
};
|
|
65
|
+
connected: {
|
|
66
|
+
title: string;
|
|
67
|
+
tag: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
44
71
|
};
|
|
45
72
|
en: {
|
|
46
73
|
settings: string;
|
|
@@ -84,5 +111,32 @@ export declare const translations: {
|
|
|
84
111
|
myInfo: string;
|
|
85
112
|
loginNow: string;
|
|
86
113
|
viewAfterLogin: string;
|
|
114
|
+
sessionManagement: string;
|
|
115
|
+
storage: {
|
|
116
|
+
spaces: {
|
|
117
|
+
tips: string;
|
|
118
|
+
label: string;
|
|
119
|
+
connectedWithName: string;
|
|
120
|
+
gateway: {
|
|
121
|
+
delete: {
|
|
122
|
+
failed: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
provideNFT: {
|
|
126
|
+
title: string;
|
|
127
|
+
scan: string;
|
|
128
|
+
success: string;
|
|
129
|
+
};
|
|
130
|
+
connect: {
|
|
131
|
+
useWallet: string;
|
|
132
|
+
useWalletReconnect: string;
|
|
133
|
+
providerForStorage: string;
|
|
134
|
+
};
|
|
135
|
+
connected: {
|
|
136
|
+
title: string;
|
|
137
|
+
tag: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
87
141
|
};
|
|
88
142
|
};
|
|
@@ -40,7 +40,34 @@ export const translations = {
|
|
|
40
40
|
userInfo: "\u4E2A\u4EBA\u4FE1\u606F",
|
|
41
41
|
myInfo: "\u6211\u7684\u4FE1\u606F",
|
|
42
42
|
loginNow: "\u7ACB\u5373\u767B\u5F55",
|
|
43
|
-
viewAfterLogin: "\u767B\u5F55\u540E\u624D\u53EF\u4EE5\u67E5\u770B"
|
|
43
|
+
viewAfterLogin: "\u767B\u5F55\u540E\u624D\u53EF\u4EE5\u67E5\u770B",
|
|
44
|
+
sessionManagement: "\u4F1A\u8BDD\u7BA1\u7406",
|
|
45
|
+
storage: {
|
|
46
|
+
spaces: {
|
|
47
|
+
tips: "\u63D0\u793A",
|
|
48
|
+
label: "\u8BF7\u8F93\u5165 DID Spaces \u670D\u52A1\u5730\u5740",
|
|
49
|
+
connectedWithName: "\u4F60\u5DF2\u6210\u529F\u8FDE\u63A5\u81F3 {name}",
|
|
50
|
+
gateway: {
|
|
51
|
+
delete: {
|
|
52
|
+
failed: "\u5220\u9664 DID Spaces \u5931\u8D25"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
provideNFT: {
|
|
56
|
+
title: "\u8BF7\u4E3A {appName} \u51FA\u793A DID Spaces NFT",
|
|
57
|
+
scan: "\u4F7F\u7528\u4F60\u7684 DID Wallet \u626B\u63CF\u4E0B\u9762\u7684\u4E8C\u7EF4\u7801\u4E3A\u5E94\u7528 {appName} \u51FA\u793A DID Spaces NFT",
|
|
58
|
+
success: "\u8FDE\u63A5\u6210\u529F"
|
|
59
|
+
},
|
|
60
|
+
connect: {
|
|
61
|
+
useWallet: "\u4F7F\u7528 DID Wallet \u8FDE\u63A5",
|
|
62
|
+
useWalletReconnect: "\u4F7F\u7528 DID Wallet \u91CD\u65B0\u8FDE\u63A5",
|
|
63
|
+
providerForStorage: "\u8BF7\u8FDE\u63A5\u60A8\u7684 DID Spaces"
|
|
64
|
+
},
|
|
65
|
+
connected: {
|
|
66
|
+
title: "\u5DF2\u8FDE\u63A5\u7684 DID Spaces",
|
|
67
|
+
tag: "\u5DF2\u8FDE\u63A5"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
44
71
|
},
|
|
45
72
|
en: {
|
|
46
73
|
settings: "Settings",
|
|
@@ -83,6 +110,33 @@ export const translations = {
|
|
|
83
110
|
userInfo: "User Info",
|
|
84
111
|
myInfo: "My Info",
|
|
85
112
|
loginNow: "Login",
|
|
86
|
-
viewAfterLogin: "View after login"
|
|
113
|
+
viewAfterLogin: "View after login",
|
|
114
|
+
sessionManagement: "Session Management",
|
|
115
|
+
storage: {
|
|
116
|
+
spaces: {
|
|
117
|
+
tips: "Tips",
|
|
118
|
+
label: "Enter DID Spaces Gateway",
|
|
119
|
+
connectedWithName: "You have successfully connected to {name}",
|
|
120
|
+
gateway: {
|
|
121
|
+
delete: {
|
|
122
|
+
failed: "Delete gateway failed"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
provideNFT: {
|
|
126
|
+
title: "Please show the DID Spaces NFT for {appName}",
|
|
127
|
+
scan: "Use your DID Wallet to scan the QR code below to allow the app {appName} show DID space NFT",
|
|
128
|
+
success: "Connected successfully"
|
|
129
|
+
},
|
|
130
|
+
connect: {
|
|
131
|
+
useWallet: "Connect with DID Wallet",
|
|
132
|
+
useWalletReconnect: "Reconnect with DID Wallet",
|
|
133
|
+
providerForStorage: "Please connect your DID Spaces"
|
|
134
|
+
},
|
|
135
|
+
connected: {
|
|
136
|
+
title: "Connected DID Spaces",
|
|
137
|
+
tag: "Connected"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
87
141
|
}
|
|
88
142
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Chip, Typography } from "@mui/material";
|
|
3
|
+
import Avatar from "@arcblock/ux/lib/Avatar";
|
|
4
|
+
import { useCreation } from "ahooks";
|
|
5
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
|
+
export default function UserSessionInfo({ user, sessionUser }) {
|
|
7
|
+
const currentRole = useCreation(() => {
|
|
8
|
+
return (user?.passports || [])?.find((item) => item.name === sessionUser.role);
|
|
9
|
+
}, [user?.passports, sessionUser?.role]);
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
Box,
|
|
12
|
+
{
|
|
13
|
+
sx: {
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
gap: 1
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx(Avatar, { size: 40, variant: "circle", shape: "circle", src: sessionUser.avatar, did: sessionUser.did }),
|
|
20
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
21
|
+
/* @__PURE__ */ jsxs(
|
|
22
|
+
Box,
|
|
23
|
+
{
|
|
24
|
+
sx: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
gap: 1
|
|
28
|
+
},
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "normal", wordBreak: "break-all" }, children: sessionUser.fullName }),
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
Chip,
|
|
33
|
+
{
|
|
34
|
+
label: currentRole?.title || currentRole?.name || "Guest",
|
|
35
|
+
size: "small",
|
|
36
|
+
variant: "outlined",
|
|
37
|
+
sx: {
|
|
38
|
+
flexShrink: 0,
|
|
39
|
+
fontWeight: "bold",
|
|
40
|
+
fontSize: "12px",
|
|
41
|
+
color: colors.textBase,
|
|
42
|
+
borderColor: colors.strokeBorderStrong,
|
|
43
|
+
backgroundColor: "transparent",
|
|
44
|
+
textTransform: "capitalize",
|
|
45
|
+
pr: 1,
|
|
46
|
+
pl: 0.5
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "grey", children: sessionUser.email })
|
|
54
|
+
] })
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|