@blocklet/ui-react 2.11.25 → 2.11.27
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/Header/index.d.ts +3 -4
- package/lib/UserCenter/components/settings.js +0 -7
- package/lib/UserCenter/components/storage/action.d.ts +3 -3
- package/lib/UserCenter/components/storage/action.js +5 -4
- package/lib/UserCenter/components/storage/connected.js +5 -4
- package/lib/UserCenter/components/storage/disconnect.js +16 -6
- package/lib/UserCenter/components/user-center.js +17 -1
- package/lib/UserCenter/libs/locales.js +2 -2
- package/package.json +4 -4
- package/src/Header/index.tsx +10 -5
- package/src/UserCenter/components/settings.tsx +0 -11
- package/src/UserCenter/components/storage/action.tsx +7 -6
- package/src/UserCenter/components/storage/connected.tsx +7 -4
- package/src/UserCenter/components/storage/disconnect.tsx +16 -9
- package/src/UserCenter/components/user-center.tsx +22 -1
- package/src/UserCenter/libs/locales.ts +2 -2
package/lib/Header/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { BoxProps } from '@mui/material';
|
|
1
|
+
import type { BoxProps, Breakpoint } from '@mui/material';
|
|
3
2
|
import { BlockletMetaProps, SessionManagerProps } from '../@types';
|
|
4
3
|
type HeaderProps = {
|
|
5
4
|
meta?: BlockletMetaProps;
|
|
6
5
|
addons?: Function | React.ReactNode;
|
|
7
6
|
sessionManagerProps?: SessionManagerProps;
|
|
8
|
-
homeLink?: string |
|
|
7
|
+
homeLink?: string | ((brandContent: React.ReactNode) => JSX.Element | null);
|
|
9
8
|
theme?: object;
|
|
10
9
|
hideNavMenu?: boolean;
|
|
11
10
|
bordered?: boolean;
|
|
@@ -16,7 +15,7 @@ type HeaderProps = {
|
|
|
16
15
|
children?: React.ReactNode;
|
|
17
16
|
prepend?: React.ReactNode;
|
|
18
17
|
align?: 'left' | 'right';
|
|
19
|
-
maxWidth?: false |
|
|
18
|
+
maxWidth?: false | Breakpoint;
|
|
20
19
|
};
|
|
21
20
|
declare const _default: import("react").ComponentType<HeaderProps & Omit<BoxProps, keyof HeaderProps>>;
|
|
22
21
|
export default _default;
|
|
@@ -5,11 +5,9 @@ import { useCreation, useMemoizedFn } from "ahooks";
|
|
|
5
5
|
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
6
6
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
7
|
import colors from "@arcblock/ux/lib/Colors/themes/temp";
|
|
8
|
-
import { ConfigUserSpaceProvider } from "../../contexts/config-user-space.js";
|
|
9
8
|
import { translations } from "../libs/locales.js";
|
|
10
9
|
import Notification from "./notification.js";
|
|
11
10
|
import Privacy from "./privacy.js";
|
|
12
|
-
import DidSpace from "./storage/index.js";
|
|
13
11
|
import { UserSessions } from "../../UserSessions/index.js";
|
|
14
12
|
import ThirdPartyLogin from "./third-party-login/index.js";
|
|
15
13
|
import ConfigProfile from "./config-profile.js";
|
|
@@ -56,11 +54,6 @@ export default function Settings({
|
|
|
56
54
|
value: "privacy",
|
|
57
55
|
content: /* @__PURE__ */ jsx(Privacy, { configList: privacyConfigList, onSave })
|
|
58
56
|
},
|
|
59
|
-
{
|
|
60
|
-
label: t("storageManagement"),
|
|
61
|
-
value: "storage",
|
|
62
|
-
content: /* @__PURE__ */ jsx(ConfigUserSpaceProvider, { children: /* @__PURE__ */ jsx(DidSpace, {}) })
|
|
63
|
-
},
|
|
64
57
|
{
|
|
65
58
|
label: t("sessionManagement"),
|
|
66
59
|
value: "session",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DIDSpaceGateway, DIDSpaceStatus } from '@blocklet/did-space-react';
|
|
2
2
|
import { Session } from '../../../@types';
|
|
3
3
|
declare function Action({ session, spaceGateway, spaceStatus, refresh, }: {
|
|
4
4
|
session: Session;
|
|
5
|
-
spaceGateway:
|
|
6
|
-
spaceStatus:
|
|
5
|
+
spaceGateway: DIDSpaceGateway;
|
|
6
|
+
spaceStatus: DIDSpaceStatus;
|
|
7
7
|
refresh: Function;
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
9
|
export default Action;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DIDSpaceConnect, DIDSpaceStatus } from "@blocklet/did-space-react";
|
|
3
3
|
import { IconButton, Link, Stack } from "@mui/material";
|
|
4
4
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
5
5
|
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
|
@@ -12,14 +12,15 @@ function Action({
|
|
|
12
12
|
refresh
|
|
13
13
|
}) {
|
|
14
14
|
return /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
|
|
15
|
-
spaceStatus ===
|
|
16
|
-
|
|
15
|
+
spaceStatus === DIDSpaceStatus.DISCONNECTED && /* @__PURE__ */ jsx(
|
|
16
|
+
DIDSpaceConnect,
|
|
17
17
|
{
|
|
18
|
+
reconnect: true,
|
|
18
19
|
variant: "outlined",
|
|
19
20
|
session,
|
|
20
21
|
spaceDid: session.user?.didSpace?.did,
|
|
21
22
|
spaceGatewayUrl: session.user?.didSpace?.url,
|
|
22
|
-
|
|
23
|
+
onSuccess: async () => {
|
|
23
24
|
await refresh();
|
|
24
25
|
},
|
|
25
26
|
onError: (error) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
3
|
import { Box, Typography } from "@mui/material";
|
|
4
|
-
import {
|
|
4
|
+
import { DIDSpaceConnection, DIDSpaceConnect } from "@blocklet/did-space-react";
|
|
5
5
|
import { useConfigUserSpaceContext } from "../../../contexts/config-user-space.js";
|
|
6
6
|
import Action from "./action.js";
|
|
7
7
|
import useMobile from "../../../hooks/use-mobile.js";
|
|
@@ -9,13 +9,14 @@ function Connected({ spaceGateway }) {
|
|
|
9
9
|
const { t } = useLocaleContext();
|
|
10
10
|
const { updateSpaceGateway, session } = useConfigUserSpaceContext();
|
|
11
11
|
const isMobile = useMobile();
|
|
12
|
+
const onSuccess = ({ spaceGateway: _spaceGateway }) => updateSpaceGateway(_spaceGateway);
|
|
12
13
|
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", children: [
|
|
13
14
|
/* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "space-between", marginBottom: "12px", children: [
|
|
14
15
|
/* @__PURE__ */ jsx(Typography, { fontSize: "16px", fontWeight: "bold", children: t("storage.spaces.connected.title") }),
|
|
15
|
-
!isMobile && /* @__PURE__ */ jsx(
|
|
16
|
+
!isMobile && /* @__PURE__ */ jsx(DIDSpaceConnect, { session, onSuccess })
|
|
16
17
|
] }),
|
|
17
18
|
/* @__PURE__ */ jsx(Box, { children: spaceGateway && /* @__PURE__ */ jsx(
|
|
18
|
-
|
|
19
|
+
DIDSpaceConnection,
|
|
19
20
|
{
|
|
20
21
|
endpoint: spaceGateway.endpoint,
|
|
21
22
|
deps: [spaceGateway],
|
|
@@ -24,7 +25,7 @@ function Connected({ spaceGateway }) {
|
|
|
24
25
|
},
|
|
25
26
|
spaceGateway.endpoint
|
|
26
27
|
) }),
|
|
27
|
-
isMobile && /* @__PURE__ */ jsx(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "center", marginTop: 2 }, children: /* @__PURE__ */ jsx(
|
|
28
|
+
isMobile && /* @__PURE__ */ jsx(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "center", marginTop: 2 }, children: /* @__PURE__ */ jsx(DIDSpaceConnect, { session, onSuccess }) })
|
|
28
29
|
] });
|
|
29
30
|
}
|
|
30
31
|
export default Connected;
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Typography } from "@mui/material";
|
|
3
3
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
-
import {
|
|
5
|
-
import EmptySpacesNFT from "./icons/empty-spaces-nft.svg?react";
|
|
4
|
+
import { DIDSpaceConnect, EmptySpacesNFTIcon } from "@blocklet/did-space-react";
|
|
6
5
|
import { useConfigUserSpaceContext } from "../../../contexts/config-user-space.js";
|
|
7
6
|
function Disconnect() {
|
|
8
7
|
const { t } = useLocaleContext();
|
|
9
8
|
const { updateSpaceGateway, session } = useConfigUserSpaceContext();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
13
|
-
/* @__PURE__ */ jsx(
|
|
9
|
+
const onSuccess = ({ spaceGateway }) => updateSpaceGateway(spaceGateway);
|
|
10
|
+
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", children: [
|
|
11
|
+
/* @__PURE__ */ jsx(Typography, { fontSize: "16px", fontWeight: "bold", children: t("storage.spaces.connect.providerForStorage") }),
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
EmptySpacesNFTIcon,
|
|
14
|
+
{
|
|
15
|
+
viewBox: "0 0 228 258",
|
|
16
|
+
style: {
|
|
17
|
+
width: "156px",
|
|
18
|
+
height: "156px",
|
|
19
|
+
margin: "16px 0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ jsx(DIDSpaceConnect, { session, onSuccess })
|
|
14
24
|
] });
|
|
15
25
|
}
|
|
16
26
|
export default Disconnect;
|
|
@@ -25,8 +25,11 @@ import Passport from "./passport.js";
|
|
|
25
25
|
import Settings from "./settings.js";
|
|
26
26
|
import { client } from "../../libs/client.js";
|
|
27
27
|
import useMobile from "../../hooks/use-mobile.js";
|
|
28
|
+
import { ConfigUserSpaceProvider } from "../../contexts/config-user-space.js";
|
|
29
|
+
import DidSpace from "./storage/index.js";
|
|
28
30
|
const profileLink = joinURL(PROFILE_URL, "/profile");
|
|
29
31
|
const settingsLink = joinURL(PROFILE_URL, "/settings");
|
|
32
|
+
const didSpacesLink = joinURL(PROFILE_URL, "/did-spaces");
|
|
30
33
|
export default function UserCenter({
|
|
31
34
|
children,
|
|
32
35
|
notLoginContent = null,
|
|
@@ -141,6 +144,13 @@ export default function UserCenter({
|
|
|
141
144
|
value: settingsLink,
|
|
142
145
|
url: getLink(settingsLink, locale)
|
|
143
146
|
});
|
|
147
|
+
tabs.push({
|
|
148
|
+
label: t("storageManagement"),
|
|
149
|
+
protected: true,
|
|
150
|
+
isPrivate: true,
|
|
151
|
+
value: didSpacesLink,
|
|
152
|
+
url: getLink(didSpacesLink, locale)
|
|
153
|
+
});
|
|
144
154
|
}
|
|
145
155
|
return tabs;
|
|
146
156
|
}, [isMyself, locale]);
|
|
@@ -196,12 +206,15 @@ export default function UserCenter({
|
|
|
196
206
|
const isProfileTab = useCreation(() => {
|
|
197
207
|
return currentActiveTab && currentActiveTab?.value === joinURL(PROFILE_URL, "/profile");
|
|
198
208
|
}, [currentActiveTab]);
|
|
209
|
+
const isDidSpaceTab = useCreation(() => {
|
|
210
|
+
return currentActiveTab && currentActiveTab?.value === joinURL(PROFILE_URL, "/did-spaces");
|
|
211
|
+
}, [currentActiveTab]);
|
|
199
212
|
const oauth = session.useOAuth();
|
|
200
213
|
const passkey = session.usePasskey();
|
|
201
214
|
const handleSwitchPassport = useMemoizedFn(() => {
|
|
202
215
|
if (session?.user?.sourceProvider === "passkey") {
|
|
203
216
|
passkey.switchPassport(session.user);
|
|
204
|
-
} else if (["google", "apple", "email", "github"].includes(session?.user?.sourceProvider)) {
|
|
217
|
+
} else if (["google", "apple", "email", "github"].includes(session?.user?.sourceProvider ?? "")) {
|
|
205
218
|
oauth.switchOAuthPassport(session.user);
|
|
206
219
|
} else if (session) {
|
|
207
220
|
session.switchPassport();
|
|
@@ -261,6 +274,9 @@ export default function UserCenter({
|
|
|
261
274
|
if (isSettingTab && isMyself) {
|
|
262
275
|
return settingContent;
|
|
263
276
|
}
|
|
277
|
+
if (isDidSpaceTab && isMyself) {
|
|
278
|
+
return /* @__PURE__ */ jsx(ConfigUserSpaceProvider, { children: /* @__PURE__ */ jsx(DidSpace, {}) });
|
|
279
|
+
}
|
|
264
280
|
return null;
|
|
265
281
|
}, [isSettingTab, isProfileTab, userState, isMyself, stickySidebar, settingContent]);
|
|
266
282
|
const content = useCreation(() => {
|
|
@@ -28,7 +28,7 @@ export const translations = {
|
|
|
28
28
|
noUserFound: "\u672A\u627E\u5230\u6307\u5B9A\u7684\u7528\u6237",
|
|
29
29
|
notificationManagement: "\u901A\u77E5\u7BA1\u7406",
|
|
30
30
|
privacyManagement: "\u9690\u79C1\u7BA1\u7406",
|
|
31
|
-
storageManagement: "
|
|
31
|
+
storageManagement: "DID Spaces",
|
|
32
32
|
webhook: {
|
|
33
33
|
url: "\u81EA\u5B9A\u4E49URL",
|
|
34
34
|
slack: "Slack"
|
|
@@ -121,7 +121,7 @@ export const translations = {
|
|
|
121
121
|
emptyField: "None",
|
|
122
122
|
notificationManagement: "Notifications",
|
|
123
123
|
privacyManagement: "Privacy",
|
|
124
|
-
storageManagement: "
|
|
124
|
+
storageManagement: "DID Spaces",
|
|
125
125
|
emptyContent: "Empty",
|
|
126
126
|
underProtected: "This page has protected privacy",
|
|
127
127
|
noUserFound: "No user found",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.27",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "^2.11.
|
|
36
|
-
"@arcblock/react-hooks": "^2.11.
|
|
35
|
+
"@arcblock/bridge": "^2.11.27",
|
|
36
|
+
"@arcblock/react-hooks": "^2.11.27",
|
|
37
37
|
"@blocklet/did-space-react": "^1.0.2",
|
|
38
38
|
"@iconify-icons/logos": "^1.2.36",
|
|
39
39
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"jest": "^29.7.0",
|
|
82
82
|
"unbuild": "^2.0.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "cfe12067f89f858787bcbea4822f940a2e850b76"
|
|
85
85
|
}
|
package/src/Header/index.tsx
CHANGED
|
@@ -7,8 +7,7 @@ import NavMenu from '@arcblock/ux/lib/NavMenu';
|
|
|
7
7
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
8
|
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
9
9
|
import omit from 'lodash/omit';
|
|
10
|
-
import {
|
|
11
|
-
import type { BoxProps } from '@mui/material';
|
|
10
|
+
import type { BoxProps, Breakpoint } from '@mui/material';
|
|
12
11
|
import clsx from 'clsx';
|
|
13
12
|
|
|
14
13
|
import Icon from '../Icon';
|
|
@@ -63,7 +62,7 @@ type HeaderProps = {
|
|
|
63
62
|
meta?: BlockletMetaProps;
|
|
64
63
|
addons?: Function | React.ReactNode;
|
|
65
64
|
sessionManagerProps?: SessionManagerProps;
|
|
66
|
-
homeLink?: string |
|
|
65
|
+
homeLink?: string | ((brandContent: React.ReactNode) => JSX.Element | null);
|
|
67
66
|
theme?: object;
|
|
68
67
|
hideNavMenu?: boolean;
|
|
69
68
|
bordered?: boolean;
|
|
@@ -74,7 +73,7 @@ type HeaderProps = {
|
|
|
74
73
|
children?: React.ReactNode;
|
|
75
74
|
prepend?: React.ReactNode;
|
|
76
75
|
align?: 'left' | 'right';
|
|
77
|
-
maxWidth?: false |
|
|
76
|
+
maxWidth?: false | Breakpoint;
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
/**
|
|
@@ -109,6 +108,7 @@ function Header({
|
|
|
109
108
|
return null;
|
|
110
109
|
}
|
|
111
110
|
const { appLogo, appLogoRect, theme } = formattedBlocklet;
|
|
111
|
+
|
|
112
112
|
const navigation = getLocalizedNavigation(formattedBlocklet?.navigation?.header, locale);
|
|
113
113
|
const parsedNavigation = parseNavigation(navigation);
|
|
114
114
|
const { navItems, activeId } = parsedNavigation;
|
|
@@ -153,7 +153,12 @@ function Header({
|
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
type StyledUxHeaderProps = {
|
|
157
|
+
$bordered?: boolean;
|
|
158
|
+
$bgcolor?: string;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const StyledUxHeader = styled(ResponsiveHeader)<StyledUxHeaderProps>`
|
|
157
162
|
${({ $bgcolor }) => `background-color: ${$bgcolor || '#fff'};`}
|
|
158
163
|
font-family: Inter, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
159
164
|
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
@@ -6,12 +6,10 @@ import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
|
6
6
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
7
|
|
|
8
8
|
import colors from '@arcblock/ux/lib/Colors/themes/temp';
|
|
9
|
-
import { ConfigUserSpaceProvider } from '../../contexts/config-user-space';
|
|
10
9
|
import { translations } from '../libs/locales';
|
|
11
10
|
import Notification from './notification';
|
|
12
11
|
import Privacy from './privacy';
|
|
13
12
|
import { User, UserCenterTab } from '../../@types';
|
|
14
|
-
import DidSpace from './storage';
|
|
15
13
|
import { UserSessions } from '../../UserSessions';
|
|
16
14
|
import ThirdPartyLogin from './third-party-login';
|
|
17
15
|
import ConfigProfile from './config-profile';
|
|
@@ -65,15 +63,6 @@ export default function Settings({
|
|
|
65
63
|
value: 'privacy',
|
|
66
64
|
content: <Privacy configList={privacyConfigList} onSave={onSave} />,
|
|
67
65
|
},
|
|
68
|
-
{
|
|
69
|
-
label: t('storageManagement'),
|
|
70
|
-
value: 'storage',
|
|
71
|
-
content: (
|
|
72
|
-
<ConfigUserSpaceProvider>
|
|
73
|
-
<DidSpace />
|
|
74
|
-
</ConfigUserSpaceProvider>
|
|
75
|
-
),
|
|
76
|
-
},
|
|
77
66
|
{
|
|
78
67
|
label: t('sessionManagement'),
|
|
79
68
|
value: 'session',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DIDSpaceConnect, DIDSpaceGateway, DIDSpaceStatus } from '@blocklet/did-space-react';
|
|
2
2
|
import { IconButton, Link, Stack } from '@mui/material';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
4
|
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
|
@@ -14,20 +14,21 @@ function Action({
|
|
|
14
14
|
refresh,
|
|
15
15
|
}: {
|
|
16
16
|
session: Session;
|
|
17
|
-
spaceGateway:
|
|
18
|
-
spaceStatus:
|
|
17
|
+
spaceGateway: DIDSpaceGateway;
|
|
18
|
+
spaceStatus: DIDSpaceStatus;
|
|
19
19
|
refresh: Function;
|
|
20
20
|
}) {
|
|
21
21
|
return (
|
|
22
22
|
<Stack direction="row" spacing={1}>
|
|
23
23
|
{/* 重新连接 */}
|
|
24
|
-
{spaceStatus ===
|
|
25
|
-
<
|
|
24
|
+
{spaceStatus === DIDSpaceStatus.DISCONNECTED && (
|
|
25
|
+
<DIDSpaceConnect
|
|
26
|
+
reconnect
|
|
26
27
|
variant="outlined"
|
|
27
28
|
session={session}
|
|
28
29
|
spaceDid={session.user?.didSpace?.did}
|
|
29
30
|
spaceGatewayUrl={session.user?.didSpace?.url}
|
|
30
|
-
|
|
31
|
+
onSuccess={async () => {
|
|
31
32
|
await refresh();
|
|
32
33
|
}}
|
|
33
34
|
onError={(error) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import { Box, Typography } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { DIDSpaceConnection, DIDSpaceConnect } from '@blocklet/did-space-react';
|
|
4
4
|
import { SpaceGateway, useConfigUserSpaceContext } from '../../../contexts/config-user-space';
|
|
5
5
|
import Action from './action';
|
|
6
6
|
import useMobile from '../../../hooks/use-mobile';
|
|
@@ -10,17 +10,20 @@ function Connected({ spaceGateway }: { spaceGateway: SpaceGateway | undefined })
|
|
|
10
10
|
const { updateSpaceGateway, session } = useConfigUserSpaceContext();
|
|
11
11
|
const isMobile = useMobile();
|
|
12
12
|
|
|
13
|
+
const onSuccess = ({ spaceGateway: _spaceGateway }: { spaceGateway: SpaceGateway }) =>
|
|
14
|
+
updateSpaceGateway(_spaceGateway);
|
|
15
|
+
|
|
13
16
|
return (
|
|
14
17
|
<Box display="flex" flexDirection="column">
|
|
15
18
|
<Box display="flex" flexDirection="row" alignItems="center" justifyContent="space-between" marginBottom="12px">
|
|
16
19
|
<Typography fontSize="16px" fontWeight="bold">
|
|
17
20
|
{t('storage.spaces.connected.title')}
|
|
18
21
|
</Typography>
|
|
19
|
-
{!isMobile && <
|
|
22
|
+
{!isMobile && <DIDSpaceConnect session={session} onSuccess={onSuccess} />}
|
|
20
23
|
</Box>
|
|
21
24
|
<Box>
|
|
22
25
|
{spaceGateway && (
|
|
23
|
-
<
|
|
26
|
+
<DIDSpaceConnection
|
|
24
27
|
key={spaceGateway.endpoint}
|
|
25
28
|
endpoint={spaceGateway.endpoint}
|
|
26
29
|
deps={[spaceGateway]}
|
|
@@ -32,7 +35,7 @@ function Connected({ spaceGateway }: { spaceGateway: SpaceGateway | undefined })
|
|
|
32
35
|
</Box>
|
|
33
36
|
{isMobile && (
|
|
34
37
|
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: 2 }}>
|
|
35
|
-
<
|
|
38
|
+
<DIDSpaceConnect session={session} onSuccess={onSuccess} />
|
|
36
39
|
</Box>
|
|
37
40
|
)}
|
|
38
41
|
</Box>
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { Box, Typography } from '@mui/material';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import {
|
|
4
|
-
// @ts-expect-error
|
|
5
|
-
import EmptySpacesNFT from './icons/empty-spaces-nft.svg?react';
|
|
3
|
+
import { DIDSpaceConnect, EmptySpacesNFTIcon, type DIDSpaceGateway } from '@blocklet/did-space-react';
|
|
6
4
|
import { useConfigUserSpaceContext } from '../../../contexts/config-user-space';
|
|
7
5
|
|
|
8
6
|
function Disconnect() {
|
|
9
7
|
const { t } = useLocaleContext();
|
|
10
8
|
const { updateSpaceGateway, session } = useConfigUserSpaceContext();
|
|
11
9
|
|
|
10
|
+
const onSuccess = ({ spaceGateway }: { spaceGateway: DIDSpaceGateway }) => updateSpaceGateway(spaceGateway);
|
|
11
|
+
|
|
12
12
|
return (
|
|
13
|
-
<Box display="flex" flexDirection="column"
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
<Box display="flex" flexDirection="column">
|
|
14
|
+
<Typography fontSize="16px" fontWeight="bold">
|
|
15
|
+
{t('storage.spaces.connect.providerForStorage')}
|
|
16
|
+
</Typography>
|
|
17
|
+
<EmptySpacesNFTIcon
|
|
18
|
+
viewBox="0 0 228 258"
|
|
19
|
+
style={{
|
|
20
|
+
width: '156px',
|
|
21
|
+
height: '156px',
|
|
22
|
+
margin: '16px 0',
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
<DIDSpaceConnect session={session} onSuccess={onSuccess} />
|
|
19
26
|
</Box>
|
|
20
27
|
);
|
|
21
28
|
}
|
|
@@ -31,9 +31,12 @@ import Passport from './passport';
|
|
|
31
31
|
import Settings from './settings';
|
|
32
32
|
import { client } from '../../libs/client';
|
|
33
33
|
import useMobile from '../../hooks/use-mobile';
|
|
34
|
+
import { ConfigUserSpaceProvider } from '../../contexts/config-user-space';
|
|
35
|
+
import DidSpace from './storage';
|
|
34
36
|
|
|
35
37
|
const profileLink = joinURL(PROFILE_URL, '/profile');
|
|
36
38
|
const settingsLink = joinURL(PROFILE_URL, '/settings');
|
|
39
|
+
const didSpacesLink = joinURL(PROFILE_URL, '/did-spaces');
|
|
37
40
|
|
|
38
41
|
export default function UserCenter({
|
|
39
42
|
children,
|
|
@@ -170,6 +173,13 @@ export default function UserCenter({
|
|
|
170
173
|
value: settingsLink,
|
|
171
174
|
url: getLink(settingsLink, locale),
|
|
172
175
|
});
|
|
176
|
+
tabs.push({
|
|
177
|
+
label: t('storageManagement'),
|
|
178
|
+
protected: true,
|
|
179
|
+
isPrivate: true,
|
|
180
|
+
value: didSpacesLink,
|
|
181
|
+
url: getLink(didSpacesLink, locale),
|
|
182
|
+
});
|
|
173
183
|
}
|
|
174
184
|
return tabs;
|
|
175
185
|
}, [isMyself, locale]);
|
|
@@ -235,12 +245,16 @@ export default function UserCenter({
|
|
|
235
245
|
return currentActiveTab && currentActiveTab?.value === joinURL(PROFILE_URL, '/profile');
|
|
236
246
|
}, [currentActiveTab]);
|
|
237
247
|
|
|
248
|
+
const isDidSpaceTab = useCreation(() => {
|
|
249
|
+
return currentActiveTab && currentActiveTab?.value === joinURL(PROFILE_URL, '/did-spaces');
|
|
250
|
+
}, [currentActiveTab]);
|
|
251
|
+
|
|
238
252
|
const oauth = session.useOAuth();
|
|
239
253
|
const passkey = session.usePasskey();
|
|
240
254
|
const handleSwitchPassport = useMemoizedFn(() => {
|
|
241
255
|
if (session?.user?.sourceProvider === 'passkey') {
|
|
242
256
|
passkey.switchPassport(session.user);
|
|
243
|
-
} else if (['google', 'apple', 'email', 'github'].includes(session?.user?.sourceProvider)) {
|
|
257
|
+
} else if (['google', 'apple', 'email', 'github'].includes(session?.user?.sourceProvider ?? '')) {
|
|
244
258
|
oauth.switchOAuthPassport(session.user);
|
|
245
259
|
} else if (session) {
|
|
246
260
|
session.switchPassport();
|
|
@@ -292,6 +306,13 @@ export default function UserCenter({
|
|
|
292
306
|
if (isSettingTab && isMyself) {
|
|
293
307
|
return settingContent;
|
|
294
308
|
}
|
|
309
|
+
if (isDidSpaceTab && isMyself) {
|
|
310
|
+
return (
|
|
311
|
+
<ConfigUserSpaceProvider>
|
|
312
|
+
<DidSpace />
|
|
313
|
+
</ConfigUserSpaceProvider>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
295
316
|
return null;
|
|
296
317
|
}, [isSettingTab, isProfileTab, userState, isMyself, stickySidebar, settingContent]);
|
|
297
318
|
|
|
@@ -28,7 +28,7 @@ export const translations = {
|
|
|
28
28
|
noUserFound: '未找到指定的用户',
|
|
29
29
|
notificationManagement: '通知管理',
|
|
30
30
|
privacyManagement: '隐私管理',
|
|
31
|
-
storageManagement: '
|
|
31
|
+
storageManagement: 'DID Spaces',
|
|
32
32
|
webhook: {
|
|
33
33
|
url: '自定义URL',
|
|
34
34
|
slack: 'Slack',
|
|
@@ -123,7 +123,7 @@ export const translations = {
|
|
|
123
123
|
emptyField: 'None',
|
|
124
124
|
notificationManagement: 'Notifications',
|
|
125
125
|
privacyManagement: 'Privacy',
|
|
126
|
-
storageManagement: '
|
|
126
|
+
storageManagement: 'DID Spaces',
|
|
127
127
|
emptyContent: 'Empty',
|
|
128
128
|
underProtected: 'This page has protected privacy',
|
|
129
129
|
noUserFound: 'No user found',
|