@arcblock/ux 3.1.42 → 3.1.44
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/DIDConnect/auth-apps/index.d.ts +3 -1
- package/lib/DIDConnect/auth-apps/index.js +92 -78
- package/lib/DIDConnect/auth-apps/switch-role.d.ts +13 -0
- package/lib/DIDConnect/auth-apps/switch-role.js +45 -0
- package/lib/UserCard/Content/minimal.js +3 -3
- package/lib/Util/constant.d.ts +1 -1
- package/lib/Util/constant.js +8 -8
- package/lib/package.json.js +1 -1
- package/package.json +7 -7
- package/src/DIDConnect/auth-apps/index.tsx +20 -3
- package/src/DIDConnect/auth-apps/switch-role.tsx +47 -0
- package/src/UserCard/Content/minimal.tsx +1 -1
- package/src/Util/constant.ts +1 -1
- package/src/Util/index.ts +1 -1
@@ -5,7 +5,7 @@ import { RequestAppInfo, CurrentAppInfo } from './auth-apps-info';
|
|
5
5
|
/**
|
6
6
|
* @example app/connect-to-did-space?appPid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appDid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appName=233&appDescription=456&appUrl=https://bbqaw5mgxc6fnihrwqcejcxvukkdgkk4anwxwk5msvm.did.abtnet.io/zh
|
7
7
|
*/
|
8
|
-
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, hideButton, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onCancel, ref, }: {
|
8
|
+
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, hideButton, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onSwitchPassport, onCancel, ref, disableAuthorizeButton, }: {
|
9
9
|
session: any;
|
10
10
|
requestAppInfo: RequestAppInfo;
|
11
11
|
currentAppInfo: CurrentAppInfo;
|
@@ -28,8 +28,10 @@ export default function AuthApps({ session, requestAppInfo, currentAppInfo, chil
|
|
28
28
|
onConnect?: (done: () => void) => void;
|
29
29
|
onAuthorize?: (done: () => void) => void;
|
30
30
|
onSwitchConnect?: (done: () => void) => void;
|
31
|
+
onSwitchPassport?: (done: () => void) => void;
|
31
32
|
onCancel?: () => void;
|
32
33
|
ref: Ref<{
|
33
34
|
closeLoading: () => void;
|
34
35
|
}>;
|
36
|
+
disableAuthorizeButton?: boolean;
|
35
37
|
}): import("react/jsx-runtime").JSX.Element;
|
@@ -1,18 +1,19 @@
|
|
1
|
-
import { jsx as e, jsxs as o, Fragment as
|
2
|
-
import { CircularProgress as u, Box as
|
3
|
-
import { useReactive as
|
1
|
+
import { jsx as e, jsxs as o, Fragment as p } from "react/jsx-runtime";
|
2
|
+
import { CircularProgress as u, Box as d, Stack as G, Button as h, Typography as J, Link as K } from "@mui/material";
|
3
|
+
import { useReactive as O, useMemoizedFn as r } from "ahooks";
|
4
4
|
import c from "lodash/noop";
|
5
|
-
import { useImperativeHandle as
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import { translate as
|
11
|
-
import { useLocaleContext as
|
12
|
-
import
|
13
|
-
import { InfoType as
|
14
|
-
import { mergeSx as
|
15
|
-
|
5
|
+
import { useImperativeHandle as Q } from "react";
|
6
|
+
import V from "../did-connect-container.js";
|
7
|
+
import X from "./auth-apps-info.js";
|
8
|
+
import Y from "../../Center/index.js";
|
9
|
+
import Z from "../landing-page.js";
|
10
|
+
import { translate as _ } from "../../Locale/util.js";
|
11
|
+
import { useLocaleContext as $ } from "../../Locale/context.js";
|
12
|
+
import ee from "../../UserCard/index.js";
|
13
|
+
import { InfoType as ne, CardType as oe } from "../../UserCard/types.js";
|
14
|
+
import { mergeSx as f } from "../../Util/style.js";
|
15
|
+
import re from "./switch-role.js";
|
16
|
+
const ie = {
|
16
17
|
en: {
|
17
18
|
notThis: "Not you?",
|
18
19
|
useAnother: "Use another account",
|
@@ -28,62 +29,66 @@ const ee = {
|
|
28
29
|
cancel: "取消"
|
29
30
|
}
|
30
31
|
};
|
31
|
-
function
|
32
|
+
function ye({
|
32
33
|
session: s,
|
33
|
-
requestAppInfo:
|
34
|
-
currentAppInfo:
|
35
|
-
children:
|
36
|
-
userInfo:
|
37
|
-
hideSwitchConnect:
|
38
|
-
hideAuthorize:
|
39
|
-
hideCancel:
|
34
|
+
requestAppInfo: g,
|
35
|
+
currentAppInfo: x,
|
36
|
+
children: C = null,
|
37
|
+
userInfo: v = void 0,
|
38
|
+
hideSwitchConnect: y = !1,
|
39
|
+
hideAuthorize: z = !1,
|
40
|
+
hideCancel: w = !1,
|
40
41
|
hideButton: A = !1,
|
41
|
-
notThisText:
|
42
|
-
authorizeText:
|
43
|
-
connectText:
|
44
|
-
cancelText:
|
42
|
+
notThisText: T = void 0,
|
43
|
+
authorizeText: b = void 0,
|
44
|
+
connectText: k = void 0,
|
45
|
+
cancelText: S = void 0,
|
45
46
|
useAnotherText: D = void 0,
|
46
|
-
slotProps:
|
47
|
+
slotProps: i = void 0,
|
47
48
|
onConnect: I = c,
|
48
49
|
onAuthorize: L = c,
|
49
|
-
onSwitchConnect:
|
50
|
-
|
51
|
-
|
50
|
+
onSwitchConnect: R = c,
|
51
|
+
onSwitchPassport: W = c,
|
52
|
+
onCancel: j = c,
|
53
|
+
ref: B,
|
54
|
+
disableAuthorizeButton: m = !1
|
52
55
|
}) {
|
53
|
-
const n =
|
56
|
+
const n = O({
|
54
57
|
loading: !1
|
55
|
-
}), { locale:
|
58
|
+
}), { locale: F = "en" } = $() || {}, t = r((q, E = {}) => _(ie, q, F, "en", E)), l = r(() => {
|
56
59
|
n.loading = !1;
|
57
|
-
}),
|
58
|
-
n.loading = !0, I?.(
|
59
|
-
}),
|
60
|
-
n.loading = !0,
|
61
|
-
}),
|
62
|
-
n.loading = !0, L?.(
|
63
|
-
}),
|
64
|
-
W?.();
|
60
|
+
}), M = r(() => {
|
61
|
+
n.loading = !0, I?.(l);
|
62
|
+
}), U = r(() => {
|
63
|
+
n.loading = !0, R?.(l);
|
64
|
+
}), H = r(() => {
|
65
|
+
n.loading = !0, L?.(l);
|
66
|
+
}), N = r(() => {
|
67
|
+
n.loading = !0, W?.(l);
|
68
|
+
}), P = r(() => {
|
69
|
+
j?.();
|
65
70
|
});
|
66
|
-
if (
|
67
|
-
closeLoading:
|
71
|
+
if (Q(B, () => ({
|
72
|
+
closeLoading: l
|
68
73
|
})), s.loading || !s.initialized)
|
69
|
-
return /* @__PURE__ */ e(
|
70
|
-
const
|
71
|
-
return /* @__PURE__ */ e(
|
72
|
-
|
74
|
+
return /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(u, {}) });
|
75
|
+
const a = v ?? s?.user;
|
76
|
+
return /* @__PURE__ */ e(Z, { did: window.blocklet?.appPid, standalone: !0, children: /* @__PURE__ */ e(
|
77
|
+
d,
|
73
78
|
{
|
74
|
-
...
|
75
|
-
sx:
|
79
|
+
...i?.root,
|
80
|
+
sx: f(
|
76
81
|
{
|
77
82
|
width: 420,
|
78
83
|
maxWidth: "100%"
|
79
84
|
},
|
80
|
-
|
85
|
+
i?.root?.sx
|
81
86
|
),
|
82
|
-
children: /* @__PURE__ */ e(
|
83
|
-
|
87
|
+
children: /* @__PURE__ */ e(V, { hideCloseButton: !0, ...i?.didConnectContainer, children: /* @__PURE__ */ o(
|
88
|
+
d,
|
84
89
|
{
|
85
|
-
...
|
86
|
-
sx:
|
90
|
+
...i?.contentContainer,
|
91
|
+
sx: f(
|
87
92
|
{
|
88
93
|
display: "flex",
|
89
94
|
flexDirection: "column",
|
@@ -99,18 +104,27 @@ function fe({
|
|
99
104
|
},
|
100
105
|
bgcolor: "background.paper"
|
101
106
|
},
|
102
|
-
|
107
|
+
i?.contentContainer?.sx
|
103
108
|
),
|
104
109
|
children: [
|
105
|
-
/* @__PURE__ */ e(
|
106
|
-
|
107
|
-
/* @__PURE__ */ e(
|
108
|
-
|
110
|
+
/* @__PURE__ */ e(X, { requestAppInfo: g, currentAppInfo: x }),
|
111
|
+
a ? /* @__PURE__ */ o(p, { children: [
|
112
|
+
/* @__PURE__ */ e(
|
113
|
+
ee,
|
114
|
+
{
|
115
|
+
user: a,
|
116
|
+
showDid: !0,
|
117
|
+
cardType: oe.Detailed,
|
118
|
+
infoType: ne.Minimal,
|
119
|
+
renderTopRightContent: () => /* @__PURE__ */ e(re, { user: a, switchPassport: N })
|
120
|
+
}
|
121
|
+
),
|
122
|
+
/* @__PURE__ */ e(d, {})
|
109
123
|
] }) : null,
|
110
|
-
|
111
|
-
A ? null : /* @__PURE__ */ o(
|
124
|
+
C,
|
125
|
+
A ? null : /* @__PURE__ */ o(p, { children: [
|
112
126
|
/* @__PURE__ */ e(
|
113
|
-
|
127
|
+
d,
|
114
128
|
{
|
115
129
|
sx: {
|
116
130
|
border: "1px solid",
|
@@ -121,32 +135,32 @@ function fe({
|
|
121
135
|
}
|
122
136
|
}
|
123
137
|
),
|
124
|
-
/* @__PURE__ */ o(
|
125
|
-
|
138
|
+
/* @__PURE__ */ o(G, { direction: "row", spacing: 2, children: [
|
139
|
+
w ? null : /* @__PURE__ */ e(
|
126
140
|
h,
|
127
141
|
{
|
128
142
|
color: "inherit",
|
129
143
|
variant: "outlined",
|
130
144
|
size: "large",
|
131
145
|
fullWidth: !0,
|
132
|
-
onClick:
|
146
|
+
onClick: P,
|
133
147
|
sx: {
|
134
148
|
color: "grey.500"
|
135
149
|
},
|
136
|
-
children:
|
150
|
+
children: S || t("cancel")
|
137
151
|
}
|
138
152
|
),
|
139
|
-
|
153
|
+
a && !z ? /* @__PURE__ */ o(
|
140
154
|
h,
|
141
155
|
{
|
142
156
|
variant: "contained",
|
143
157
|
size: "large",
|
144
158
|
fullWidth: !0,
|
145
|
-
onClick:
|
146
|
-
disabled: n.loading,
|
159
|
+
onClick: H,
|
160
|
+
disabled: n.loading || m,
|
147
161
|
children: [
|
148
162
|
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
149
|
-
|
163
|
+
b || t("authorize")
|
150
164
|
]
|
151
165
|
}
|
152
166
|
) : /* @__PURE__ */ o(
|
@@ -155,18 +169,18 @@ function fe({
|
|
155
169
|
variant: "contained",
|
156
170
|
size: "large",
|
157
171
|
fullWidth: !0,
|
158
|
-
disabled: n.loading,
|
159
|
-
onClick:
|
172
|
+
disabled: n.loading || m,
|
173
|
+
onClick: M,
|
160
174
|
children: [
|
161
175
|
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
162
|
-
|
176
|
+
k || t("connect")
|
163
177
|
]
|
164
178
|
}
|
165
179
|
)
|
166
180
|
] })
|
167
181
|
] }),
|
168
|
-
|
169
|
-
|
182
|
+
y || !a ? null : /* @__PURE__ */ e(d, { sx: { textAlign: "center" }, children: /* @__PURE__ */ o(
|
183
|
+
J,
|
170
184
|
{
|
171
185
|
variant: "body2",
|
172
186
|
sx: {
|
@@ -176,13 +190,13 @@ function fe({
|
|
176
190
|
gap: 1
|
177
191
|
},
|
178
192
|
children: [
|
179
|
-
|
193
|
+
T || t("notThis"),
|
180
194
|
" ",
|
181
195
|
/* @__PURE__ */ e(
|
182
|
-
|
196
|
+
K,
|
183
197
|
{
|
184
198
|
underline: "hover",
|
185
|
-
onClick:
|
199
|
+
onClick: U,
|
186
200
|
sx: {
|
187
201
|
cursor: "pointer"
|
188
202
|
},
|
@@ -199,5 +213,5 @@ function fe({
|
|
199
213
|
) });
|
200
214
|
}
|
201
215
|
export {
|
202
|
-
|
216
|
+
ye as default
|
203
217
|
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { UserPublicInfo } from '@blocklet/js-sdk';
|
2
|
+
declare function SwitchRole({ user, switchPassport, }: {
|
3
|
+
user: UserPublicInfo & {
|
4
|
+
passports: {
|
5
|
+
name: string;
|
6
|
+
title: string;
|
7
|
+
role: string;
|
8
|
+
}[];
|
9
|
+
};
|
10
|
+
switchPassport: () => void;
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
12
|
+
declare const _default: import('react').MemoExoticComponent<typeof SwitchRole>;
|
13
|
+
export default _default;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
2
|
+
import { memo as n } from "react";
|
3
|
+
import { Chip as i } from "@mui/material";
|
4
|
+
import { Icon as a } from "@iconify/react";
|
5
|
+
import p from "@iconify-icons/material-symbols/swap-horiz-rounded";
|
6
|
+
import { useCreation as c } from "ahooks";
|
7
|
+
function m({
|
8
|
+
user: o,
|
9
|
+
switchPassport: r
|
10
|
+
}) {
|
11
|
+
const l = c(
|
12
|
+
() => (o?.passports || [])?.find((e) => e.name === o.role || e.role === o.role),
|
13
|
+
[o?.passports, o?.role]
|
14
|
+
);
|
15
|
+
return /* @__PURE__ */ t(
|
16
|
+
i,
|
17
|
+
{
|
18
|
+
label: l?.title || o?.role || "Guest",
|
19
|
+
size: "small",
|
20
|
+
variant: "outlined",
|
21
|
+
sx: {
|
22
|
+
flexShrink: 0,
|
23
|
+
fontWeight: "bold",
|
24
|
+
fontSize: "12px",
|
25
|
+
color: "text.primary",
|
26
|
+
borderColor: "grey.100",
|
27
|
+
backgroundColor: "transparent",
|
28
|
+
textTransform: "capitalize",
|
29
|
+
pr: 1,
|
30
|
+
pl: 0.5,
|
31
|
+
"&:active": {
|
32
|
+
boxShadow: "none"
|
33
|
+
}
|
34
|
+
},
|
35
|
+
clickable: !0,
|
36
|
+
deleteIcon: /* @__PURE__ */ t(a, { icon: p, color: "inherit" }),
|
37
|
+
onDelete: r,
|
38
|
+
onClick: r
|
39
|
+
}
|
40
|
+
);
|
41
|
+
}
|
42
|
+
const S = n(m);
|
43
|
+
export {
|
44
|
+
S as default
|
45
|
+
};
|
@@ -6,7 +6,7 @@ import b from "./tooltip-avatar.js";
|
|
6
6
|
import { renderTopRight as v } from "../components.js";
|
7
7
|
import W from "./shorten-label.js";
|
8
8
|
import j from "../Cards/social-actions.js";
|
9
|
-
function
|
9
|
+
function A({ ...s }) {
|
10
10
|
const {
|
11
11
|
user: e,
|
12
12
|
showDid: c,
|
@@ -87,7 +87,7 @@ function D({ ...s }) {
|
|
87
87
|
) : null
|
88
88
|
] })
|
89
89
|
] }),
|
90
|
-
i ? /* @__PURE__ */ t(C, { sx: { width: "100%" } }) : null,
|
90
|
+
i && (l || o.showSocialActions) ? /* @__PURE__ */ t(C, { sx: { width: "100%" } }) : null,
|
91
91
|
l ? null : /* @__PURE__ */ t(
|
92
92
|
j,
|
93
93
|
{
|
@@ -105,7 +105,7 @@ function D({ ...s }) {
|
|
105
105
|
}
|
106
106
|
);
|
107
107
|
}
|
108
|
-
const P = g(
|
108
|
+
const P = g(A);
|
109
109
|
export {
|
110
110
|
P as default
|
111
111
|
};
|
package/lib/Util/constant.d.ts
CHANGED
@@ -5,7 +5,7 @@ export declare const SESSION_TOKEN_STORAGE_KEY = "login_token";
|
|
5
5
|
export declare const REFRESH_TOKEN_STORAGE_KEY = "refresh_token";
|
6
6
|
export declare const RELAY_SOCKET_PREFIX = "/.well-known/service";
|
7
7
|
export declare const API_DID_PREFIX = "/api/did";
|
8
|
-
export declare const DASHBOARD_URL = "/.well-known/service/admin";
|
8
|
+
export declare const DASHBOARD_URL = "/.well-known/service/admin/overview";
|
9
9
|
export declare const PROFILE_URL = "/.well-known/service/user";
|
10
10
|
export declare const DID_SPACE_URL = "/.well-known/service/user/did-spaces";
|
11
11
|
export declare const NAVIGATION_URL = "/.well-known/service/admin/navigation";
|
package/lib/Util/constant.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const T = 300,
|
1
|
+
const T = 300, e = 1800, t = "/.well-known/service", o = "login_token", _ = "refresh_token", I = "/.well-known/service", A = "/api/did", n = `${t}/admin/overview`, s = `${t}/user`, O = `${t}/user/did-spaces`, R = `${t}/admin/navigation`, i = "did:abt:", D = {
|
2
2
|
VALID: "valid",
|
3
3
|
REVOKED: "revoked"
|
4
4
|
}, E = {
|
@@ -11,7 +11,7 @@ const T = 300, _ = 1800, t = "/.well-known/service", e = "login_token", o = "ref
|
|
11
11
|
NFT: "nft",
|
12
12
|
PASSKEY: "passkey",
|
13
13
|
TWITTER: "twitter"
|
14
|
-
},
|
14
|
+
}, L = {
|
15
15
|
[E.EMAIL]: "Email",
|
16
16
|
[E.AUTH0]: "Auth0",
|
17
17
|
[E.APPLE]: "Apple",
|
@@ -34,18 +34,18 @@ export {
|
|
34
34
|
t as BLOCKLET_SERVICE_PATH_PREFIX,
|
35
35
|
n as DASHBOARD_URL,
|
36
36
|
T as DEFAULT_TIMEOUT,
|
37
|
-
|
37
|
+
e as DEFAULT_WINDOW_TIMEOUT,
|
38
38
|
a as DID_CONNECT_MEDIUM_WIDTH,
|
39
39
|
c as DID_CONNECT_SMALL_WIDTH,
|
40
|
-
|
40
|
+
i as DID_PREFIX,
|
41
41
|
O as DID_SPACE_URL,
|
42
42
|
E as LOGIN_PROVIDER,
|
43
|
-
|
43
|
+
L as LOGIN_PROVIDER_NAME,
|
44
44
|
R as NAVIGATION_URL,
|
45
45
|
l as OAUTH_PROVIDER,
|
46
|
-
|
46
|
+
D as PASSPORT_STATUS,
|
47
47
|
s as PROFILE_URL,
|
48
|
-
|
48
|
+
_ as REFRESH_TOKEN_STORAGE_KEY,
|
49
49
|
I as RELAY_SOCKET_PREFIX,
|
50
|
-
|
50
|
+
o as SESSION_TOKEN_STORAGE_KEY
|
51
51
|
};
|
package/lib/package.json.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.44",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -68,16 +68,16 @@
|
|
68
68
|
"react": "^19.0.0",
|
69
69
|
"react-router-dom": "^6.22.3"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "fa84963f32d492f869850195429951e99d9b4df8",
|
72
72
|
"dependencies": {
|
73
|
-
"@arcblock/bridge": "3.1.
|
73
|
+
"@arcblock/bridge": "3.1.44",
|
74
74
|
"@arcblock/did": "^1.21.3",
|
75
75
|
"@arcblock/did-motif": "^1.1.14",
|
76
|
-
"@arcblock/icons": "3.1.
|
77
|
-
"@arcblock/nft-display": "3.1.
|
78
|
-
"@arcblock/react-hooks": "3.1.
|
76
|
+
"@arcblock/icons": "3.1.44",
|
77
|
+
"@arcblock/nft-display": "3.1.44",
|
78
|
+
"@arcblock/react-hooks": "3.1.44",
|
79
79
|
"@blocklet/js-sdk": "^1.16.49-beta-20250823-082650-626c1473",
|
80
|
-
"@blocklet/theme": "3.1.
|
80
|
+
"@blocklet/theme": "3.1.44",
|
81
81
|
"@fontsource/roboto": "~5.1.1",
|
82
82
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
83
83
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -13,6 +13,7 @@ import { useLocaleContext } from '../../Locale/context';
|
|
13
13
|
import UserCard from '../../UserCard';
|
14
14
|
import { CardType, InfoType } from '../../UserCard/types';
|
15
15
|
import { mergeSx } from '../../Util/style';
|
16
|
+
import SwitchRole from './switch-role';
|
16
17
|
|
17
18
|
const translations = {
|
18
19
|
en: {
|
@@ -57,8 +58,11 @@ export default function AuthApps({
|
|
57
58
|
onConnect = noop,
|
58
59
|
onAuthorize = noop,
|
59
60
|
onSwitchConnect = noop,
|
61
|
+
onSwitchPassport = noop,
|
60
62
|
onCancel = noop,
|
61
63
|
ref,
|
64
|
+
|
65
|
+
disableAuthorizeButton = false,
|
62
66
|
}: {
|
63
67
|
session: any;
|
64
68
|
requestAppInfo: RequestAppInfo;
|
@@ -86,8 +90,11 @@ export default function AuthApps({
|
|
86
90
|
onConnect?: (done: () => void) => void;
|
87
91
|
onAuthorize?: (done: () => void) => void;
|
88
92
|
onSwitchConnect?: (done: () => void) => void;
|
93
|
+
onSwitchPassport?: (done: () => void) => void;
|
89
94
|
onCancel?: () => void;
|
90
95
|
ref: Ref<{ closeLoading: () => void }>;
|
96
|
+
|
97
|
+
disableAuthorizeButton?: boolean;
|
91
98
|
}) {
|
92
99
|
const currentState = useReactive({
|
93
100
|
loading: false,
|
@@ -111,6 +118,10 @@ export default function AuthApps({
|
|
111
118
|
currentState.loading = true;
|
112
119
|
onAuthorize?.(handleCloseLoading);
|
113
120
|
});
|
121
|
+
const handleSwitchPassport = useMemoizedFn(() => {
|
122
|
+
currentState.loading = true;
|
123
|
+
onSwitchPassport?.(handleCloseLoading);
|
124
|
+
});
|
114
125
|
const handleCancel = useMemoizedFn(() => {
|
115
126
|
onCancel?.();
|
116
127
|
});
|
@@ -165,7 +176,13 @@ export default function AuthApps({
|
|
165
176
|
|
166
177
|
{user ? (
|
167
178
|
<>
|
168
|
-
<UserCard
|
179
|
+
<UserCard
|
180
|
+
user={user}
|
181
|
+
showDid
|
182
|
+
cardType={CardType.Detailed}
|
183
|
+
infoType={InfoType.Minimal}
|
184
|
+
renderTopRightContent={() => <SwitchRole user={user} switchPassport={handleSwitchPassport} />}
|
185
|
+
/>
|
169
186
|
<Box />
|
170
187
|
</>
|
171
188
|
) : null}
|
@@ -204,7 +221,7 @@ export default function AuthApps({
|
|
204
221
|
size="large"
|
205
222
|
fullWidth
|
206
223
|
onClick={handleAuthorize}
|
207
|
-
disabled={currentState.loading}>
|
224
|
+
disabled={currentState.loading || disableAuthorizeButton}>
|
208
225
|
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
209
226
|
{authorizeText || t('authorize')}
|
210
227
|
</Button>
|
@@ -213,7 +230,7 @@ export default function AuthApps({
|
|
213
230
|
variant="contained"
|
214
231
|
size="large"
|
215
232
|
fullWidth
|
216
|
-
disabled={currentState.loading}
|
233
|
+
disabled={currentState.loading || disableAuthorizeButton}
|
217
234
|
onClick={handleConnect}>
|
218
235
|
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
219
236
|
{connectText || t('connect')}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { memo } from 'react';
|
2
|
+
import { Chip } from '@mui/material';
|
3
|
+
import { Icon } from '@iconify/react';
|
4
|
+
import SwapHorizRoundedIcon from '@iconify-icons/material-symbols/swap-horiz-rounded';
|
5
|
+
import { useCreation } from 'ahooks';
|
6
|
+
import type { UserPublicInfo } from '@blocklet/js-sdk';
|
7
|
+
|
8
|
+
function SwitchRole({
|
9
|
+
user,
|
10
|
+
switchPassport,
|
11
|
+
}: {
|
12
|
+
user: UserPublicInfo & { passports: { name: string; title: string; role: string }[] };
|
13
|
+
switchPassport: () => void;
|
14
|
+
}) {
|
15
|
+
const currentRole = useCreation(
|
16
|
+
() => (user?.passports || [])?.find((item) => item.name === user.role || item.role === user.role),
|
17
|
+
[user?.passports, user?.role]
|
18
|
+
);
|
19
|
+
|
20
|
+
return (
|
21
|
+
<Chip
|
22
|
+
label={currentRole?.title || user?.role || 'Guest'}
|
23
|
+
size="small"
|
24
|
+
variant="outlined"
|
25
|
+
sx={{
|
26
|
+
flexShrink: 0,
|
27
|
+
fontWeight: 'bold',
|
28
|
+
fontSize: '12px',
|
29
|
+
color: 'text.primary',
|
30
|
+
borderColor: 'grey.100',
|
31
|
+
backgroundColor: 'transparent',
|
32
|
+
textTransform: 'capitalize',
|
33
|
+
pr: 1,
|
34
|
+
pl: 0.5,
|
35
|
+
'&:active': {
|
36
|
+
boxShadow: 'none',
|
37
|
+
},
|
38
|
+
}}
|
39
|
+
clickable
|
40
|
+
deleteIcon={<Icon icon={SwapHorizRoundedIcon} color="inherit" />}
|
41
|
+
onDelete={switchPassport}
|
42
|
+
onClick={switchPassport}
|
43
|
+
/>
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
47
|
+
export default memo(SwitchRole);
|
@@ -93,7 +93,7 @@ function MinimalContent({ ...props }: MinimalContentProps) {
|
|
93
93
|
) : null}
|
94
94
|
</Box>
|
95
95
|
</Box>
|
96
|
-
{isSmallScreen ? <Divider sx={{ width: '100%' }} /> : null}
|
96
|
+
{isSmallScreen && (renderTopRightContent || rest.showSocialActions) ? <Divider sx={{ width: '100%' }} /> : null}
|
97
97
|
{!renderTopRightContent ? (
|
98
98
|
<SocialActions
|
99
99
|
onFollowClick={rest.onFollowClick}
|
package/src/Util/constant.ts
CHANGED
@@ -7,7 +7,7 @@ export const REFRESH_TOKEN_STORAGE_KEY = 'refresh_token';
|
|
7
7
|
export const RELAY_SOCKET_PREFIX = '/.well-known/service';
|
8
8
|
export const API_DID_PREFIX = '/api/did';
|
9
9
|
|
10
|
-
export const DASHBOARD_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin`;
|
10
|
+
export const DASHBOARD_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin/overview`;
|
11
11
|
export const PROFILE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user`;
|
12
12
|
export const DID_SPACE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user/did-spaces`;
|
13
13
|
export const NAVIGATION_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin/navigation`;
|
package/src/Util/index.ts
CHANGED
@@ -687,7 +687,7 @@ export const getJsSdkVersion = () => {
|
|
687
687
|
* @param {*} version2
|
688
688
|
* @returns boolean
|
689
689
|
*/
|
690
|
-
export const compareVersions = (version1: string, version2: string) => {
|
690
|
+
export const compareVersions = (version1: string, version2: string): boolean => {
|
691
691
|
const getDateVersion = (version: string) => {
|
692
692
|
const match = version.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
|
693
693
|
return match ? match[1] : version;
|