@blocklet/ui-react 3.1.44 → 3.1.45
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/UserCenter/components/user-center.js +70 -69
- package/lib/common/header-addons.js +45 -37
- package/lib/common/org-switch/create.d.ts +14 -0
- package/lib/common/org-switch/create.js +124 -0
- package/lib/common/org-switch/index.d.ts +12 -0
- package/lib/common/org-switch/index.js +295 -0
- package/lib/common/org-switch/locales.d.ts +54 -0
- package/lib/common/org-switch/locales.js +41 -0
- package/lib/common/org-switch/use-org.d.ts +5 -0
- package/lib/common/org-switch/use-org.js +47 -0
- package/package.json +6 -6
- package/src/UserCenter/components/user-center.tsx +1 -0
- package/src/common/header-addons.jsx +17 -0
- package/src/common/org-switch/create.jsx +147 -0
- package/src/common/org-switch/index.jsx +402 -0
- package/src/common/org-switch/locales.js +40 -0
- package/src/common/org-switch/use-org.jsx +66 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import { use as we, useMemo as ye, isValidElement as X, cloneElement as Y, Children as ke } from "react";
|
|
3
|
-
import { Box as
|
|
4
|
-
import { useMemoizedFn as k, useCreation as
|
|
3
|
+
import { Box as d, Typography as Ce, CircularProgress as Pe, Divider as Se } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as k, useCreation as c, useRequest as Z } from "ahooks";
|
|
5
5
|
import Me from "p-wait-for";
|
|
6
6
|
import ee from "react-helmet";
|
|
7
7
|
import { SessionContext as De } from "@arcblock/did-connect-react/lib/Session";
|
|
@@ -42,7 +42,7 @@ import Ge from "./storage/index.js";
|
|
|
42
42
|
import Qe from "./nft.js";
|
|
43
43
|
import { UserFollowersProvider as le } from "../../contexts/user-followers.js";
|
|
44
44
|
import Ve from "./fallback.js";
|
|
45
|
-
const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(P, "/user-followers"), ue = ce(
|
|
45
|
+
const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(P, "/user-followers"), ue = ce(d)(({ theme: v }) => ({
|
|
46
46
|
flex: 1,
|
|
47
47
|
boxSizing: "border-box",
|
|
48
48
|
padding: "0 16px",
|
|
@@ -56,7 +56,7 @@ const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(
|
|
|
56
56
|
[v.breakpoints.up("md")]: {
|
|
57
57
|
flexDirection: "row"
|
|
58
58
|
}
|
|
59
|
-
})), W = ce(
|
|
59
|
+
})), W = ce(d)(({ theme: v }) => ({
|
|
60
60
|
overflow: "hidden",
|
|
61
61
|
flex: "revert",
|
|
62
62
|
[v.breakpoints.up("md")]: {
|
|
@@ -84,12 +84,12 @@ function _r({
|
|
|
84
84
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
85
85
|
onDestroySelf: me = void 0
|
|
86
86
|
}) {
|
|
87
|
-
const { locale: h } = Ue(),
|
|
87
|
+
const { locale: h } = Ue(), l = $e({ key: "md" }), p = k((e, t = {}) => Ae(Ne, e, h, "en", t)), o = we(De)?.session, x = c(() => {
|
|
88
88
|
if (M)
|
|
89
89
|
return M;
|
|
90
90
|
const e = window.location.href, t = Ie(e);
|
|
91
91
|
return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : o?.user?.did;
|
|
92
|
-
}, [o?.user?.did, M]), i =
|
|
92
|
+
}, [o?.user?.did, M]), i = c(() => o?.user ? x === o?.user?.did : !1, [x, o?.user?.did]), w = ye(() => je(), []), n = Z(
|
|
93
93
|
// eslint-disable-next-line consistent-return
|
|
94
94
|
async () => {
|
|
95
95
|
if (await Me(() => o?.initialized), i)
|
|
@@ -107,7 +107,7 @@ function _r({
|
|
|
107
107
|
loadingDelay: 300
|
|
108
108
|
}
|
|
109
109
|
), { confirmHolder: H } = We({
|
|
110
|
-
fullScreen:
|
|
110
|
+
fullScreen: l,
|
|
111
111
|
sx: {
|
|
112
112
|
".MuiDialog-paper": {
|
|
113
113
|
borderRadius: 1,
|
|
@@ -126,14 +126,14 @@ function _r({
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
}), N =
|
|
129
|
+
}), N = c(() => {
|
|
130
130
|
const e = Be(window.blocklet);
|
|
131
131
|
try {
|
|
132
132
|
return Ee(e);
|
|
133
133
|
} catch (t) {
|
|
134
134
|
return console.error("Failed to format blocklet info", t, e), e;
|
|
135
135
|
}
|
|
136
|
-
}, []), E =
|
|
136
|
+
}, []), E = c(() => {
|
|
137
137
|
const e = {
|
|
138
138
|
label: p("common.nft"),
|
|
139
139
|
protected: !1,
|
|
@@ -150,7 +150,7 @@ function _r({
|
|
|
150
150
|
};
|
|
151
151
|
let f = w ? [e, t] : [e];
|
|
152
152
|
if (i) {
|
|
153
|
-
const
|
|
153
|
+
const u = [
|
|
154
154
|
e,
|
|
155
155
|
{
|
|
156
156
|
label: p("common.setting"),
|
|
@@ -167,52 +167,52 @@ function _r({
|
|
|
167
167
|
url: S(z, h)
|
|
168
168
|
}
|
|
169
169
|
];
|
|
170
|
-
f = w ? [...
|
|
170
|
+
f = w ? [...u, t] : u;
|
|
171
171
|
}
|
|
172
172
|
return f;
|
|
173
|
-
}, [i, h, w]),
|
|
173
|
+
}, [i, h, w]), a = c(() => {
|
|
174
174
|
const e = N?.navigation?.userCenter || [];
|
|
175
|
-
return (_e(e, h) || []).concat(E).map((
|
|
176
|
-
const K =
|
|
175
|
+
return (_e(e, h) || []).concat(E).map((u) => {
|
|
176
|
+
const K = u.value ?? u._rawLink ?? u.link ?? u.url;
|
|
177
177
|
return {
|
|
178
178
|
value: K,
|
|
179
|
-
label:
|
|
180
|
-
url:
|
|
179
|
+
label: u.title || u.label,
|
|
180
|
+
url: u.link || u.url,
|
|
181
181
|
protected: g?.data?.[K] ?? !1,
|
|
182
|
-
isPrivate:
|
|
182
|
+
isPrivate: u.isPrivate || u.private || (u?._rawLink?.includes("/customer") ?? !1),
|
|
183
183
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
184
|
-
followersOnly:
|
|
184
|
+
followersOnly: u.component === "did-comments"
|
|
185
185
|
// 是否开启仅粉丝可查看的功能,目前只对 discuss kit 开启
|
|
186
186
|
// icon: x.icon,
|
|
187
187
|
};
|
|
188
|
-
}).filter((
|
|
189
|
-
}, [N, n.data, g?.data, h, E, i]), s =
|
|
188
|
+
}).filter((u) => i || !u.isPrivate);
|
|
189
|
+
}, [N, n.data, g?.data, h, E, i]), s = c(() => a.find((e) => te(e.value) === te(b)), [a]), _ = c(() => {
|
|
190
190
|
const e = window.blocklet?.appName, f = [s?.label, p("userCenter.title")].filter(Boolean).join("-");
|
|
191
191
|
return e ? `${f} | ${e}` : f;
|
|
192
192
|
}, [s, p]), he = k((e) => e && (X(e) ? Y(e, {
|
|
193
193
|
...e.props || {},
|
|
194
|
-
userCenterTabs:
|
|
194
|
+
userCenterTabs: a
|
|
195
195
|
}) : ke.map(e, (t) => X(t) ? Y(t, {
|
|
196
196
|
...t.props || {},
|
|
197
|
-
userCenterTabs:
|
|
197
|
+
userCenterTabs: a
|
|
198
198
|
}) : t))), xe = k((e) => {
|
|
199
|
-
const t =
|
|
199
|
+
const t = a.find((f) => f.value === e);
|
|
200
200
|
t && (window.location.href = ie(t.url, {
|
|
201
201
|
did: i ? void 0 : x
|
|
202
202
|
}));
|
|
203
|
-
}), O =
|
|
203
|
+
}), O = c(() => /* @__PURE__ */ r(
|
|
204
204
|
Re,
|
|
205
205
|
{
|
|
206
206
|
user: n.data,
|
|
207
|
-
settings: { userCenterTabs:
|
|
207
|
+
settings: { userCenterTabs: a },
|
|
208
208
|
onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await o.refresh(), null),
|
|
209
|
-
isMobile:
|
|
209
|
+
isMobile: l,
|
|
210
210
|
onDestroySelf: me
|
|
211
211
|
}
|
|
212
|
-
), [n.data,
|
|
212
|
+
), [n.data, a, g.data, g.runAsync]), R = c(() => s && s?.value === F, [s]), $ = c(() => s && s?.value === C(P, "/profile") || s?.value === T, [s]), ge = c(() => s && s?.value === z, [s]), be = o.useOAuth(), ve = o.usePasskey(), q = k(() => {
|
|
213
213
|
o?.user?.sourceProvider === "passkey" ? ve.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? be.switchOAuthPassport(o.user) : o && o.switchPassport();
|
|
214
|
-
}), D =
|
|
215
|
-
|
|
214
|
+
}), D = c(() => $ ? /* @__PURE__ */ m(
|
|
215
|
+
d,
|
|
216
216
|
{
|
|
217
217
|
sx: {
|
|
218
218
|
display: "flex",
|
|
@@ -220,7 +220,7 @@ function _r({
|
|
|
220
220
|
gap: 2.5
|
|
221
221
|
},
|
|
222
222
|
children: [
|
|
223
|
-
i ? /* @__PURE__ */ m(
|
|
223
|
+
i ? /* @__PURE__ */ m(d, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
|
|
224
224
|
/* @__PURE__ */ r(
|
|
225
225
|
Ce,
|
|
226
226
|
{
|
|
@@ -237,8 +237,8 @@ function _r({
|
|
|
237
237
|
/* @__PURE__ */ r(Qe, { user: n.data })
|
|
238
238
|
]
|
|
239
239
|
}
|
|
240
|
-
) : R && i ? O : ge && i ? /* @__PURE__ */ r(qe, { children: /* @__PURE__ */ r(Ge, {}) }) : null, [R, $, n, i, B, O]), G =
|
|
241
|
-
|
|
240
|
+
) : R && i ? O : ge && i ? /* @__PURE__ */ r(qe, { children: /* @__PURE__ */ r(Ge, {}) }) : null, [R, $, n, i, B, O]), G = c(() => /* @__PURE__ */ r(
|
|
241
|
+
d,
|
|
242
242
|
{
|
|
243
243
|
sx: {
|
|
244
244
|
display: {
|
|
@@ -249,8 +249,8 @@ function _r({
|
|
|
249
249
|
},
|
|
250
250
|
children: /* @__PURE__ */ r(re, { children: p("emptyContent") })
|
|
251
251
|
}
|
|
252
|
-
), [i, h]), Q =
|
|
253
|
-
|
|
252
|
+
), [i, h]), Q = c(() => !g.data || g.loading ? /* @__PURE__ */ r(
|
|
253
|
+
d,
|
|
254
254
|
{
|
|
255
255
|
sx: {
|
|
256
256
|
height: "100%",
|
|
@@ -263,27 +263,27 @@ function _r({
|
|
|
263
263
|
},
|
|
264
264
|
children: /* @__PURE__ */ r(Pe, {})
|
|
265
265
|
}
|
|
266
|
-
) : /* @__PURE__ */ r(
|
|
266
|
+
) : /* @__PURE__ */ r(d, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
267
267
|
Ve,
|
|
268
268
|
{
|
|
269
269
|
isSupportFollow: w,
|
|
270
270
|
currentActiveTab: s,
|
|
271
271
|
isMyself: i,
|
|
272
|
-
children: v ? /* @__PURE__ */ r(
|
|
272
|
+
children: v ? /* @__PURE__ */ r(d, { ...U, children: he(v) }) : D
|
|
273
273
|
}
|
|
274
|
-
) }), [g, s, i, v, U, D, h]), V =
|
|
274
|
+
) }), [g, s, i, v, U, D, h]), V = c(() => {
|
|
275
275
|
if (n.loading || o.loading)
|
|
276
276
|
return null;
|
|
277
277
|
if (n.error) {
|
|
278
278
|
if (n.error?.response?.status === 404)
|
|
279
|
-
return /* @__PURE__ */ r(
|
|
279
|
+
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(ze, { status: 404, description: p("noUserFound") }) });
|
|
280
280
|
const f = {
|
|
281
281
|
message: n.error.response?.data?.error || n.error.message || "error occurred"
|
|
282
282
|
};
|
|
283
|
-
return /* @__PURE__ */ r(
|
|
283
|
+
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Le, { error: f }) });
|
|
284
284
|
}
|
|
285
|
-
return !x && !n.data ? A || /* @__PURE__ */ r(
|
|
286
|
-
|
|
285
|
+
return !x && !n.data ? A || /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
|
|
286
|
+
d,
|
|
287
287
|
{
|
|
288
288
|
sx: {
|
|
289
289
|
display: "flex",
|
|
@@ -298,11 +298,11 @@ function _r({
|
|
|
298
298
|
]
|
|
299
299
|
}
|
|
300
300
|
) }) : I ? /* @__PURE__ */ m(W, { children: [
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
a.length > 0 && b ? /* @__PURE__ */ r(
|
|
302
|
+
d,
|
|
303
303
|
{
|
|
304
304
|
sx: {
|
|
305
|
-
display:
|
|
305
|
+
display: l ? "block" : "flex",
|
|
306
306
|
height: "100%",
|
|
307
307
|
overflow: "auto",
|
|
308
308
|
padding: "1px"
|
|
@@ -310,12 +310,12 @@ function _r({
|
|
|
310
310
|
children: Q
|
|
311
311
|
}
|
|
312
312
|
) : null,
|
|
313
|
-
|
|
314
|
-
] }) : y ? /* @__PURE__ */ r(W, { display: "flex", flexDirection:
|
|
313
|
+
a.length === 0 && G
|
|
314
|
+
] }) : y ? /* @__PURE__ */ r(W, { display: "flex", flexDirection: l ? "column" : "row", children: /* @__PURE__ */ r(
|
|
315
315
|
ne,
|
|
316
316
|
{
|
|
317
|
-
isMobile:
|
|
318
|
-
order:
|
|
317
|
+
isMobile: l,
|
|
318
|
+
order: l ? 1 : "unset",
|
|
319
319
|
isMyself: i,
|
|
320
320
|
switchPassport: q,
|
|
321
321
|
switchProfile: o.switchProfile,
|
|
@@ -325,23 +325,24 @@ function _r({
|
|
|
325
325
|
refreshProfile: j,
|
|
326
326
|
isShowSocialActions: w,
|
|
327
327
|
sx: {
|
|
328
|
-
padding:
|
|
329
|
-
...
|
|
328
|
+
padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
329
|
+
...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
330
330
|
boxSizing: "content-box"
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
) }) : /* @__PURE__ */ m(W, { display: "flex", flexDirection:
|
|
333
|
+
) }) : /* @__PURE__ */ m(W, { display: "flex", flexDirection: l ? "column" : "row", children: [
|
|
334
334
|
/* @__PURE__ */ m(
|
|
335
|
-
|
|
335
|
+
d,
|
|
336
336
|
{
|
|
337
337
|
className: "user-center-tabs",
|
|
338
338
|
sx: {
|
|
339
339
|
flex: "1",
|
|
340
|
-
order:
|
|
340
|
+
order: l ? 2 : "unset",
|
|
341
|
+
width: l ? "unset" : "calc(100% - 424px)"
|
|
341
342
|
},
|
|
342
343
|
children: [
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
a.length > 0 && b ? /* @__PURE__ */ m(
|
|
345
|
+
d,
|
|
345
346
|
{
|
|
346
347
|
sx: {
|
|
347
348
|
display: "flex",
|
|
@@ -356,7 +357,7 @@ function _r({
|
|
|
356
357
|
{
|
|
357
358
|
orientation: "horizontal",
|
|
358
359
|
variant: "line",
|
|
359
|
-
tabs:
|
|
360
|
+
tabs: a,
|
|
360
361
|
current: s?.value ?? b,
|
|
361
362
|
onChange: xe,
|
|
362
363
|
enableTabClick: !0,
|
|
@@ -365,7 +366,7 @@ function _r({
|
|
|
365
366
|
".MuiTabs-flexContainer": {
|
|
366
367
|
gap: 3,
|
|
367
368
|
".MuiButtonBase-root": {
|
|
368
|
-
padding:
|
|
369
|
+
padding: l ? "16px 4px" : "32px 4px 16px 4px",
|
|
369
370
|
fontSize: 16
|
|
370
371
|
},
|
|
371
372
|
".MuiTab-root": {
|
|
@@ -399,16 +400,16 @@ function _r({
|
|
|
399
400
|
]
|
|
400
401
|
}
|
|
401
402
|
) : null,
|
|
402
|
-
|
|
403
|
+
a.length === 0 && G
|
|
403
404
|
]
|
|
404
405
|
}
|
|
405
406
|
),
|
|
406
|
-
!
|
|
407
|
+
!l && /* @__PURE__ */ r(Se, { orientation: "vertical", sx: { ml: 5 } }),
|
|
407
408
|
/* @__PURE__ */ r(
|
|
408
409
|
ne,
|
|
409
410
|
{
|
|
410
|
-
isMobile:
|
|
411
|
-
order:
|
|
411
|
+
isMobile: l,
|
|
412
|
+
order: l ? 1 : "unset",
|
|
412
413
|
isMyself: i,
|
|
413
414
|
switchPassport: q,
|
|
414
415
|
switchProfile: o.switchProfile,
|
|
@@ -417,8 +418,8 @@ function _r({
|
|
|
417
418
|
showFullDid: !1,
|
|
418
419
|
isShowSocialActions: w,
|
|
419
420
|
sx: {
|
|
420
|
-
padding:
|
|
421
|
-
...
|
|
421
|
+
padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
422
|
+
...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
422
423
|
boxSizing: "content-box"
|
|
423
424
|
}
|
|
424
425
|
}
|
|
@@ -426,23 +427,23 @@ function _r({
|
|
|
426
427
|
] });
|
|
427
428
|
}, [
|
|
428
429
|
n,
|
|
429
|
-
|
|
430
|
+
a,
|
|
430
431
|
i,
|
|
431
432
|
s,
|
|
432
433
|
g,
|
|
433
434
|
b,
|
|
434
435
|
B,
|
|
435
436
|
D
|
|
436
|
-
]), J =
|
|
437
|
-
if (
|
|
438
|
-
const e =
|
|
437
|
+
]), J = c(() => i ? !1 : s?.isPrivate, [i, s]);
|
|
438
|
+
if (c(() => y ? !1 : !L && !b && a?.length > 0 || !s || J, [L, b, a, s, J, y])) {
|
|
439
|
+
const e = a[0]?.url, t = a.find((f) => f.value === e);
|
|
439
440
|
return e && !t?.isPrivate && window.location.replace(
|
|
440
441
|
ie(e, {
|
|
441
442
|
did: i ? void 0 : x
|
|
442
443
|
})
|
|
443
444
|
), null;
|
|
444
445
|
}
|
|
445
|
-
return I || y ? /* @__PURE__ */ m(
|
|
446
|
+
return I || y ? /* @__PURE__ */ m(d, { children: [
|
|
446
447
|
/* @__PURE__ */ r(ee, { children: /* @__PURE__ */ r("title", { children: _ }) }),
|
|
447
448
|
/* @__PURE__ */ r(oe, { style: { display: "none" } }),
|
|
448
449
|
/* @__PURE__ */ m(ue, { children: [
|
|
@@ -450,7 +451,7 @@ function _r({
|
|
|
450
451
|
H
|
|
451
452
|
] })
|
|
452
453
|
] }) : /* @__PURE__ */ m(
|
|
453
|
-
|
|
454
|
+
d,
|
|
454
455
|
{
|
|
455
456
|
sx: {
|
|
456
457
|
minHeight: "100vh",
|
|
@@ -1,47 +1,55 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, Fragment as A } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import
|
|
4
|
-
import { use as b, createElement as
|
|
5
|
-
import { SessionContext as
|
|
6
|
-
import
|
|
7
|
-
import { useLocaleContext as
|
|
8
|
-
import
|
|
3
|
+
import a from "prop-types";
|
|
4
|
+
import { use as b, createElement as L } from "react";
|
|
5
|
+
import { SessionContext as v } from "@arcblock/did-connect-react/lib/Session";
|
|
6
|
+
import N from "@arcblock/ux/lib/Config/theme-mode-toggle";
|
|
7
|
+
import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import k from "@arcblock/ux/lib/Locale/selector";
|
|
9
9
|
import C from "@arcblock/ux/lib/SessionBlocklet";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
10
|
+
import S from "@arcblock/ux/lib/SessionUser";
|
|
11
|
+
import { WELLKNOWN_BLOCKLET_ADMIN_PATH as D } from "@abtnode/constant";
|
|
12
|
+
import { getLocalizedNavigation as E, filterNavByRole as M } from "../blocklets.js";
|
|
13
|
+
import { SessionManagerProps as O } from "../types.js";
|
|
14
|
+
import R from "./domain-warning.js";
|
|
15
|
+
import W from "./notification-addon.js";
|
|
16
|
+
import P from "./org-switch/index.js";
|
|
17
|
+
const B = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification"), _ = (n) => {
|
|
18
|
+
const { settings: o = {} } = n ?? window?.blocklet ?? {};
|
|
19
|
+
return o?.org?.enabled || !1;
|
|
20
|
+
}, j = () => {
|
|
21
|
+
const { pathname: n = "" } = window.location || {};
|
|
22
|
+
return n.startsWith(D);
|
|
23
|
+
};
|
|
16
24
|
function x({
|
|
17
|
-
formattedBlocklet:
|
|
25
|
+
formattedBlocklet: n,
|
|
18
26
|
addons: o = null,
|
|
19
27
|
showDomainWarningDialog: m = !0,
|
|
20
28
|
sessionManagerProps: u = { showRole: !0 }
|
|
21
29
|
}) {
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
|
|
30
|
+
const e = b(v), { locale: t, languages: p } = T() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = n, h = !!e?.session?.user;
|
|
31
|
+
let l = E(n?.navigation?.sessionManager, t) || [];
|
|
32
|
+
l = M(l, e?.session?.user?.role);
|
|
25
33
|
const c = (() => {
|
|
26
34
|
if (o && typeof o != "function")
|
|
27
35
|
return Array.isArray(o) ? o : [o];
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
36
|
+
let s = [];
|
|
37
|
+
if (B() && s.push(/* @__PURE__ */ i(W, { session: e.session }, "notification-addon")), d && t && p.length > 1 && s.push(/* @__PURE__ */ i(k, { showText: !1 }, "locale-selector")), s.push(/* @__PURE__ */ i(N, {}, "theme-mode-toggle")), g && e) {
|
|
30
38
|
const f = [];
|
|
31
|
-
h && (
|
|
39
|
+
h && (l ? l.slice(0, 5) : []).forEach((r) => {
|
|
32
40
|
f.push({
|
|
33
|
-
label:
|
|
34
|
-
icon:
|
|
41
|
+
label: r.title,
|
|
42
|
+
icon: r.icon ? /* @__PURE__ */ i("iconify-icon", { icon: r.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
35
43
|
component: "a",
|
|
36
|
-
href:
|
|
37
|
-
key:
|
|
44
|
+
href: r.link,
|
|
45
|
+
key: r.link
|
|
38
46
|
});
|
|
39
|
-
}),
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
|
|
47
|
+
}), s.push(/* @__PURE__ */ i(C, { session: e.session, locale: t }, "session-blocklet")), s.push(
|
|
48
|
+
/* @__PURE__ */ i(
|
|
49
|
+
S,
|
|
42
50
|
{
|
|
43
|
-
session:
|
|
44
|
-
locale:
|
|
51
|
+
session: e.session,
|
|
52
|
+
locale: t,
|
|
45
53
|
menu: f,
|
|
46
54
|
showRole: !0,
|
|
47
55
|
...u
|
|
@@ -50,21 +58,21 @@ function x({
|
|
|
50
58
|
)
|
|
51
59
|
);
|
|
52
60
|
}
|
|
53
|
-
return typeof o == "function" && (
|
|
54
|
-
})(), y = Array.isArray(c) ? c : [c],
|
|
55
|
-
m ? /* @__PURE__ */
|
|
61
|
+
return !j() && _(n) && e?.session?.user && s.unshift(/* @__PURE__ */ i(P, { session: e.session, locale: t }, "orgs-switch")), typeof o == "function" && (s = o(s) || []), s;
|
|
62
|
+
})(), y = Array.isArray(c) ? c : [c], w = [
|
|
63
|
+
m ? /* @__PURE__ */ i(R, { session: e?.session, locale: t }) : null,
|
|
56
64
|
...y
|
|
57
65
|
].filter(Boolean);
|
|
58
|
-
return
|
|
66
|
+
return L(A, null, ...w);
|
|
59
67
|
}
|
|
60
68
|
x.propTypes = {
|
|
61
|
-
formattedBlocklet:
|
|
69
|
+
formattedBlocklet: a.object.isRequired,
|
|
62
70
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
63
71
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
64
72
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
65
|
-
addons:
|
|
66
|
-
sessionManagerProps:
|
|
67
|
-
showDomainWarningDialog:
|
|
73
|
+
addons: a.oneOfType([a.func, a.node]),
|
|
74
|
+
sessionManagerProps: O,
|
|
75
|
+
showDomainWarningDialog: a.bool
|
|
68
76
|
};
|
|
69
77
|
export {
|
|
70
78
|
x as default
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as PropTypes } from 'prop-types';
|
|
2
|
+
declare function CreateOrgDialog({ onSuccess, onCancel, locale }: {
|
|
3
|
+
onSuccess?: ((...args: any[]) => void) | undefined;
|
|
4
|
+
onCancel?: ((...args: any[]) => void) | undefined;
|
|
5
|
+
locale?: string | undefined;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare namespace CreateOrgDialog {
|
|
8
|
+
namespace propTypes {
|
|
9
|
+
let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
|
+
let onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
|
+
let locale: PropTypes.Requireable<string>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default CreateOrgDialog;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsxs as m, jsx as o, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f } from "react";
|
|
3
|
+
import l from "prop-types";
|
|
4
|
+
import { useMemoizedFn as S, useReactive as B } from "ahooks";
|
|
5
|
+
import g from "lodash/noop";
|
|
6
|
+
import D from "@arcblock/ux/lib/Dialog";
|
|
7
|
+
import E from "@mui/material/CircularProgress";
|
|
8
|
+
import L from "@mui/material/DialogContentText";
|
|
9
|
+
import h from "@mui/material/Typography";
|
|
10
|
+
import y from "@mui/material/TextField";
|
|
11
|
+
import O from "@mui/material/Alert";
|
|
12
|
+
import W from "@arcblock/ux/lib/Toast";
|
|
13
|
+
import v from "@arcblock/ux/lib/Button";
|
|
14
|
+
import { translate as j } from "@arcblock/ux/lib/Locale/util";
|
|
15
|
+
import { formatAxiosError as k } from "../../UserCenter/libs/utils.js";
|
|
16
|
+
import z from "./use-org.js";
|
|
17
|
+
import A from "./locales.js";
|
|
18
|
+
function M({ onSuccess: C = g, onCancel: s = g, locale: T = "en" }) {
|
|
19
|
+
const [i, c] = f(!1), [p, r] = f(""), { createOrg: b } = z(), t = S((e, a = {}) => j(A, e, T, "en", a)), n = B({
|
|
20
|
+
name: "",
|
|
21
|
+
description: ""
|
|
22
|
+
}), x = async () => {
|
|
23
|
+
const e = n.name.trim();
|
|
24
|
+
if (!e) {
|
|
25
|
+
r(t("nameEmpty"));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (e.length > 25) {
|
|
29
|
+
r(t("nameTooLong", { length: 25 }));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const a = n.description.trim();
|
|
33
|
+
if (a.length > 255) {
|
|
34
|
+
r(t("descriptionTooLong", { length: 25 }));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
r(""), c(!0);
|
|
38
|
+
try {
|
|
39
|
+
await b({ name: e, description: a }), C();
|
|
40
|
+
} catch (u) {
|
|
41
|
+
console.error(u);
|
|
42
|
+
const d = k(u);
|
|
43
|
+
r(d), W.error(d);
|
|
44
|
+
} finally {
|
|
45
|
+
c(!1);
|
|
46
|
+
}
|
|
47
|
+
}, F = /* @__PURE__ */ m("div", { children: [
|
|
48
|
+
/* @__PURE__ */ o(h, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ o(
|
|
49
|
+
y,
|
|
50
|
+
{
|
|
51
|
+
label: t("mutate.name"),
|
|
52
|
+
autoComplete: "off",
|
|
53
|
+
variant: "outlined",
|
|
54
|
+
name: "name",
|
|
55
|
+
"data-cy": "mutate-org-input-name",
|
|
56
|
+
fullWidth: !0,
|
|
57
|
+
autoFocus: !0,
|
|
58
|
+
value: n.name,
|
|
59
|
+
onChange: (e) => {
|
|
60
|
+
r(""), n.name = e.target.value;
|
|
61
|
+
},
|
|
62
|
+
disabled: i
|
|
63
|
+
}
|
|
64
|
+
) }),
|
|
65
|
+
/* @__PURE__ */ o(h, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ o(
|
|
66
|
+
y,
|
|
67
|
+
{
|
|
68
|
+
label: t("mutate.description"),
|
|
69
|
+
autoComplete: "off",
|
|
70
|
+
variant: "outlined",
|
|
71
|
+
name: "description",
|
|
72
|
+
"data-cy": "mutate-org-input-description",
|
|
73
|
+
fullWidth: !0,
|
|
74
|
+
value: n.description,
|
|
75
|
+
onChange: (e) => {
|
|
76
|
+
r(""), n.description = e.target.value;
|
|
77
|
+
},
|
|
78
|
+
disabled: i,
|
|
79
|
+
multiline: !0,
|
|
80
|
+
rows: 3
|
|
81
|
+
}
|
|
82
|
+
) })
|
|
83
|
+
] });
|
|
84
|
+
return /* @__PURE__ */ m(
|
|
85
|
+
D,
|
|
86
|
+
{
|
|
87
|
+
title: t("mutate.title", { mode: t("create") }),
|
|
88
|
+
fullWidth: !0,
|
|
89
|
+
open: !0,
|
|
90
|
+
onClose: s,
|
|
91
|
+
showCloseButton: !1,
|
|
92
|
+
actions: /* @__PURE__ */ m(w, { children: [
|
|
93
|
+
/* @__PURE__ */ o(v, { onClick: s, color: "inherit", children: t("cancel") }),
|
|
94
|
+
/* @__PURE__ */ m(
|
|
95
|
+
v,
|
|
96
|
+
{
|
|
97
|
+
"data-cy": "mutate-org-confirm",
|
|
98
|
+
onClick: x,
|
|
99
|
+
color: "primary",
|
|
100
|
+
disabled: i,
|
|
101
|
+
variant: "contained",
|
|
102
|
+
autoFocus: !0,
|
|
103
|
+
children: [
|
|
104
|
+
i && /* @__PURE__ */ o(E, { size: 16 }),
|
|
105
|
+
t("create")
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] }),
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ o(L, { component: "div", children: F }),
|
|
112
|
+
!!p && /* @__PURE__ */ o(O, { severity: "error", style: { width: "100%", margin: 0 }, children: p })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
M.propTypes = {
|
|
118
|
+
onSuccess: l.func,
|
|
119
|
+
onCancel: l.func,
|
|
120
|
+
locale: l.string
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
M as default
|
|
124
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as PropTypes } from 'prop-types';
|
|
2
|
+
declare function OrgsSwitch({ session, locale }: {
|
|
3
|
+
session: any;
|
|
4
|
+
locale?: string | undefined;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare namespace OrgsSwitch {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
let session: PropTypes.Validator<object>;
|
|
9
|
+
let locale: PropTypes.Requireable<string>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export default OrgsSwitch;
|