@blocklet/ui-react 2.9.91 → 2.10.0
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/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
|
@@ -1,89 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _Avatar = _interopRequireDefault(require("@arcblock/ux/lib/Avatar"));
|
|
10
|
-
var _ahooks = require("ahooks");
|
|
11
|
-
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function UserSessionInfo({
|
|
14
|
-
user,
|
|
15
|
-
sessionUser
|
|
16
|
-
}) {
|
|
17
|
-
const currentRole = (0, _ahooks.useCreation)(() => {
|
|
18
|
-
return (user?.passports || [])?.find(item => item.name === sessionUser.role);
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Chip, Tooltip, 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);
|
|
19
9
|
}, [user?.passports, sessionUser?.role]);
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
gap: 1
|
|
25
|
-
},
|
|
26
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
27
|
-
size: 40,
|
|
28
|
-
variant: "circle",
|
|
29
|
-
shape: "circle",
|
|
30
|
-
src: sessionUser.avatar,
|
|
31
|
-
did: sessionUser.did,
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
Box,
|
|
12
|
+
{
|
|
32
13
|
sx: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sx: {
|
|
37
|
-
flex: 1,
|
|
38
|
-
overflow: "hidden"
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
gap: 1
|
|
39
17
|
},
|
|
40
|
-
children: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
sx: {
|
|
50
|
-
whiteSpace: "nowrap",
|
|
51
|
-
overflow: "hidden",
|
|
52
|
-
textOverflow: "ellipsis",
|
|
53
|
-
flex: 1
|
|
54
|
-
},
|
|
55
|
-
children: sessionUser.fullName
|
|
56
|
-
})
|
|
57
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
58
|
-
label: currentRole?.title || currentRole?.name || "Guest",
|
|
59
|
-
size: "small",
|
|
60
|
-
variant: "outlined",
|
|
61
|
-
sx: {
|
|
62
|
-
flexShrink: 0,
|
|
63
|
-
fontWeight: "bold",
|
|
64
|
-
fontSize: "12px",
|
|
65
|
-
color: _Colors.temp.textBase,
|
|
66
|
-
borderColor: _Colors.temp.strokeBorderStrong,
|
|
67
|
-
backgroundColor: "transparent",
|
|
68
|
-
textTransform: "capitalize",
|
|
69
|
-
pr: 0.5,
|
|
70
|
-
pl: 0,
|
|
71
|
-
height: "auto"
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
Avatar,
|
|
21
|
+
{
|
|
22
|
+
size: 40,
|
|
23
|
+
variant: "circle",
|
|
24
|
+
shape: "circle",
|
|
25
|
+
src: sessionUser.avatar,
|
|
26
|
+
did: sessionUser.did,
|
|
27
|
+
sx: { flexShrink: 0 }
|
|
72
28
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
31
|
+
/* @__PURE__ */ jsxs(
|
|
32
|
+
Box,
|
|
33
|
+
{
|
|
34
|
+
sx: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
gap: 1
|
|
38
|
+
},
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Tooltip, { title: sessionUser.fullName, children: /* @__PURE__ */ jsx(
|
|
41
|
+
Typography,
|
|
42
|
+
{
|
|
43
|
+
sx: {
|
|
44
|
+
whiteSpace: "nowrap",
|
|
45
|
+
overflow: "hidden",
|
|
46
|
+
textOverflow: "ellipsis",
|
|
47
|
+
flex: 1
|
|
48
|
+
},
|
|
49
|
+
children: sessionUser.fullName
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
Chip,
|
|
54
|
+
{
|
|
55
|
+
label: currentRole?.title || currentRole?.name || "Guest",
|
|
56
|
+
size: "small",
|
|
57
|
+
variant: "outlined",
|
|
58
|
+
sx: {
|
|
59
|
+
flexShrink: 0,
|
|
60
|
+
fontWeight: "bold",
|
|
61
|
+
fontSize: "12px",
|
|
62
|
+
color: colors.textBase,
|
|
63
|
+
borderColor: colors.strokeBorderStrong,
|
|
64
|
+
backgroundColor: "transparent",
|
|
65
|
+
textTransform: "capitalize",
|
|
66
|
+
pr: 0.5,
|
|
67
|
+
pl: 0,
|
|
68
|
+
height: "auto"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(Tooltip, { title: sessionUser.email, children: /* @__PURE__ */ jsx(
|
|
76
|
+
Typography,
|
|
77
|
+
{
|
|
78
|
+
variant: "body2",
|
|
79
|
+
color: "grey",
|
|
80
|
+
sx: {
|
|
81
|
+
whiteSpace: "nowrap",
|
|
82
|
+
overflow: "hidden",
|
|
83
|
+
textOverflow: "ellipsis"
|
|
84
|
+
},
|
|
85
|
+
children: sessionUser.email
|
|
86
|
+
}
|
|
87
|
+
) })
|
|
88
|
+
] })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -1,61 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _userSessionInfo = _interopRequireDefault(require("./user-session-info"));
|
|
20
|
-
var _client = require("../../libs/client");
|
|
21
|
-
var _locales = require("../libs/locales");
|
|
22
|
-
var _utils = require("../libs/utils");
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
const parseUa = ua => {
|
|
25
|
-
const parser = new _uaParserJs.default(ua, {
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Datatable from "@arcblock/ux/lib/Datatable";
|
|
3
|
+
import { useCreation, useMemoizedFn, useRequest } from "ahooks";
|
|
4
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import RelativeTime from "@arcblock/ux/lib/RelativeTime";
|
|
7
|
+
import sortBy from "lodash/sortBy";
|
|
8
|
+
import UAParser from "ua-parser-js";
|
|
9
|
+
import { getVisitorId } from "@arcblock/ux/lib/Util";
|
|
10
|
+
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
11
|
+
import pAll from "p-all";
|
|
12
|
+
import { Box, Button, Tooltip, Typography } from "@mui/material";
|
|
13
|
+
import UserSessionInfo from "./user-session-info.js";
|
|
14
|
+
import { client } from "../../libs/client.js";
|
|
15
|
+
import { translations } from "../libs/locales.js";
|
|
16
|
+
import { batchIp2Region } from "../libs/utils.js";
|
|
17
|
+
const parseUa = (ua) => {
|
|
18
|
+
const parser = new UAParser(ua, {
|
|
26
19
|
// eslint-disable-next-line no-useless-escape
|
|
27
|
-
browser: [[/(ArcWallet)\/([\w\.]+)/i], [
|
|
20
|
+
browser: [[/(ArcWallet)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]]
|
|
28
21
|
});
|
|
29
22
|
const result = parser.getResult();
|
|
30
23
|
return result;
|
|
31
24
|
};
|
|
32
|
-
function UserSessions({
|
|
25
|
+
export default function UserSessions({
|
|
33
26
|
user,
|
|
34
27
|
showAction = true,
|
|
35
28
|
showUser = true
|
|
36
29
|
}) {
|
|
37
|
-
const currentVisitorId =
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
confirmApi,
|
|
43
|
-
confirmHolder
|
|
44
|
-
} = (0, _Dialog.useConfirm)();
|
|
45
|
-
const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
|
|
46
|
-
return (0, _util.translate)(_locales.translations, key, locale, "en", data);
|
|
30
|
+
const currentVisitorId = getVisitorId();
|
|
31
|
+
const { locale } = useLocaleContext();
|
|
32
|
+
const { confirmApi, confirmHolder } = useConfirm();
|
|
33
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
34
|
+
return translate(translations, key, locale, "en", data);
|
|
47
35
|
});
|
|
48
|
-
const getData =
|
|
36
|
+
const getData = useMemoizedFn(async () => {
|
|
49
37
|
let data = user?.userSessions;
|
|
50
38
|
if (!data) {
|
|
51
|
-
data = await
|
|
52
|
-
did: user.did
|
|
53
|
-
});
|
|
39
|
+
data = await client.userSession.getUserSessions({ did: user.did });
|
|
54
40
|
}
|
|
55
41
|
try {
|
|
56
|
-
const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp]).filter(x => !!x[1]);
|
|
57
|
-
const ipList = ipIndexList?.map(x => x[1]);
|
|
58
|
-
const result = await
|
|
42
|
+
const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp]).filter((x) => !!x[1]);
|
|
43
|
+
const ipList = ipIndexList?.map((x) => x[1]);
|
|
44
|
+
const result = await batchIp2Region(ipList);
|
|
59
45
|
for (let index = 0; index < result.length; index++) {
|
|
60
46
|
const x = result[index];
|
|
61
47
|
const ipIndexItem = ipIndexList[index];
|
|
@@ -66,58 +52,52 @@ function UserSessions({
|
|
|
66
52
|
console.warn("Failed to convert ip to region");
|
|
67
53
|
console.error(e);
|
|
68
54
|
}
|
|
69
|
-
const now = /* @__PURE__ */new Date().getTime();
|
|
70
|
-
return (
|
|
55
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
56
|
+
return sortBy(data, (x) => {
|
|
71
57
|
if (x.visitorId === currentVisitorId) {
|
|
72
58
|
return -1;
|
|
73
59
|
}
|
|
74
60
|
return now - new Date(x.updatedAt).getTime();
|
|
75
61
|
});
|
|
76
62
|
});
|
|
77
|
-
const pageState =
|
|
78
|
-
const safeData =
|
|
63
|
+
const pageState = useRequest(getData);
|
|
64
|
+
const safeData = useCreation(() => {
|
|
79
65
|
return pageState.data || [];
|
|
80
66
|
}, [pageState.data]);
|
|
81
|
-
const ipRegionMap =
|
|
67
|
+
const ipRegionMap = useCreation(() => {
|
|
82
68
|
return safeData.reduce((acc, x) => {
|
|
83
69
|
acc[x.lastLoginIp] = x.ipRegion;
|
|
84
70
|
return acc;
|
|
85
71
|
}, {});
|
|
86
72
|
}, [safeData]);
|
|
87
|
-
const logout =
|
|
88
|
-
visitorId
|
|
89
|
-
}) => {
|
|
73
|
+
const logout = useMemoizedFn(({ visitorId }) => {
|
|
90
74
|
confirmApi.open({
|
|
91
75
|
title: t("logoutThisSession"),
|
|
92
76
|
content: t("logoutThisSessionConfirm"),
|
|
93
77
|
confirmButtonText: t("confirm"),
|
|
94
78
|
cancelButtonText: t("cancel"),
|
|
95
79
|
onConfirm: async () => {
|
|
96
|
-
await
|
|
97
|
-
visitorId
|
|
98
|
-
});
|
|
80
|
+
await client.user.logout({ visitorId });
|
|
99
81
|
pageState.refresh();
|
|
100
82
|
confirmApi.close();
|
|
101
83
|
}
|
|
102
84
|
});
|
|
103
85
|
});
|
|
104
|
-
const otherUserSessions =
|
|
105
|
-
const list = safeData.filter(x => x.visitorId !== currentVisitorId);
|
|
86
|
+
const otherUserSessions = useCreation(() => {
|
|
87
|
+
const list = safeData.filter((x) => x.visitorId !== currentVisitorId);
|
|
106
88
|
return list;
|
|
107
89
|
}, [safeData]);
|
|
108
|
-
const logoutAll =
|
|
90
|
+
const logoutAll = useMemoizedFn(() => {
|
|
109
91
|
confirmApi.open({
|
|
110
92
|
title: t("logoutAllSession"),
|
|
111
93
|
content: t("logoutAllSessionConfirm"),
|
|
112
94
|
confirmButtonText: t("confirm"),
|
|
113
95
|
cancelButtonText: t("cancel"),
|
|
114
96
|
onConfirm: async () => {
|
|
115
|
-
const list = otherUserSessions.map(x => {
|
|
116
|
-
return () =>
|
|
117
|
-
visitorId: x.visitorId
|
|
118
|
-
});
|
|
97
|
+
const list = otherUserSessions.map((x) => {
|
|
98
|
+
return () => client.user.logout({ visitorId: x.visitorId });
|
|
119
99
|
});
|
|
120
|
-
await (
|
|
100
|
+
await pAll(list, {
|
|
121
101
|
concurrency: 3,
|
|
122
102
|
stopOnError: false
|
|
123
103
|
});
|
|
@@ -128,22 +108,22 @@ function UserSessions({
|
|
|
128
108
|
});
|
|
129
109
|
const customButtons = [];
|
|
130
110
|
if (showAction) {
|
|
131
|
-
customButtons.push(
|
|
132
|
-
title: t("logoutAllTips"),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
ml: 0.5
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})
|
|
144
|
-
|
|
111
|
+
customButtons.push(
|
|
112
|
+
/* @__PURE__ */ jsx(Tooltip, { title: t("logoutAllTips"), children: /* @__PURE__ */ jsx(
|
|
113
|
+
Button,
|
|
114
|
+
{
|
|
115
|
+
sx: { ml: 0.5 },
|
|
116
|
+
size: "small",
|
|
117
|
+
variant: "contained",
|
|
118
|
+
color: "error",
|
|
119
|
+
onClick: logoutAll,
|
|
120
|
+
disabled: otherUserSessions.length === 0,
|
|
121
|
+
children: t("logoutAll")
|
|
122
|
+
}
|
|
123
|
+
) }, "logoutAll")
|
|
124
|
+
);
|
|
145
125
|
}
|
|
146
|
-
const tableOptions =
|
|
126
|
+
const tableOptions = useCreation(() => {
|
|
147
127
|
return {
|
|
148
128
|
// viewColumns: false,
|
|
149
129
|
search: false,
|
|
@@ -155,147 +135,131 @@ function UserSessions({
|
|
|
155
135
|
searchDebounceTime: 600
|
|
156
136
|
};
|
|
157
137
|
}, []);
|
|
158
|
-
const columns = [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
children: [result.os?.name, result.os?.version].filter(Boolean).join("/") || t("unknown")
|
|
167
|
-
}
|
|
138
|
+
const columns = [
|
|
139
|
+
{
|
|
140
|
+
label: t("platform"),
|
|
141
|
+
name: "platform",
|
|
142
|
+
options: {
|
|
143
|
+
customBodyRenderLite: (rawIndex) => {
|
|
144
|
+
const x = safeData[rawIndex];
|
|
145
|
+
const result = parseUa(x.ua);
|
|
146
|
+
return /* @__PURE__ */ jsx(Box, { children: [result.os?.name, result.os?.version].filter(Boolean).join("/") || t("unknown") });
|
|
147
|
+
}
|
|
168
148
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: t("deviceType"),
|
|
152
|
+
name: "deviceType",
|
|
153
|
+
options: {
|
|
154
|
+
customBodyRenderLite: (rawIndex) => {
|
|
155
|
+
const x = safeData[rawIndex];
|
|
156
|
+
const result = parseUa(x.ua);
|
|
157
|
+
return /* @__PURE__ */ jsx(Box, { children: [result.browser?.name, result.browser?.version].filter(Boolean).join("/") || t("unknown") });
|
|
158
|
+
}
|
|
180
159
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: t("walletOS"),
|
|
163
|
+
name: "walletOS",
|
|
164
|
+
options: {
|
|
165
|
+
customBodyRenderLite: (rawIndex) => {
|
|
166
|
+
const x = safeData[rawIndex];
|
|
167
|
+
return /* @__PURE__ */ jsx(Box, { children: x.extra?.walletOS || t("unknown") });
|
|
168
|
+
}
|
|
191
169
|
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
minWidth: 150,
|
|
202
|
-
maxWidth: 250
|
|
203
|
-
},
|
|
204
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_userSessionInfo.default, {
|
|
205
|
-
sessionUser: x.user,
|
|
206
|
-
user
|
|
207
|
-
})
|
|
208
|
-
});
|
|
170
|
+
},
|
|
171
|
+
showUser && {
|
|
172
|
+
label: t("user"),
|
|
173
|
+
name: "user",
|
|
174
|
+
options: {
|
|
175
|
+
customBodyRenderLite: (rawIndex) => {
|
|
176
|
+
const x = safeData[rawIndex];
|
|
177
|
+
return /* @__PURE__ */ jsx(Box, { sx: { minWidth: 150, maxWidth: 250 }, children: /* @__PURE__ */ jsx(UserSessionInfo, { sessionUser: x.user, user }) });
|
|
178
|
+
}
|
|
209
179
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
relativeRange: 3 * 86400 * 1e3,
|
|
220
|
-
locale
|
|
221
|
-
}) : t("unknown");
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
label: t("createdAt"),
|
|
183
|
+
name: "createdAt",
|
|
184
|
+
options: {
|
|
185
|
+
customBodyRenderLite: (rawIndex) => {
|
|
186
|
+
const x = safeData[rawIndex];
|
|
187
|
+
return x.createdAt ? /* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale }) : t("unknown");
|
|
188
|
+
}
|
|
222
189
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
relativeRange: 3 * 86400 * 1e3,
|
|
233
|
-
locale
|
|
234
|
-
});
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
label: t("updatedAt"),
|
|
193
|
+
name: "updatedAt",
|
|
194
|
+
options: {
|
|
195
|
+
customBodyRenderLite: (rawIndex) => {
|
|
196
|
+
const x = safeData[rawIndex];
|
|
197
|
+
return x.status === "expired" ? t("expired") : /* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale });
|
|
198
|
+
}
|
|
235
199
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
249
|
-
variant: "body2",
|
|
250
|
-
color: "grey",
|
|
251
|
-
children: x.lastLoginIp || t("unknown")
|
|
252
|
-
})]
|
|
253
|
-
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
254
|
-
children: x.lastLoginIp || t("unknown")
|
|
255
|
-
})
|
|
256
|
-
});
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
label: t("lastLoginIp"),
|
|
203
|
+
name: "lastLoginIp",
|
|
204
|
+
options: {
|
|
205
|
+
customBodyRenderLite: (rawIndex) => {
|
|
206
|
+
const x = safeData[rawIndex];
|
|
207
|
+
return /* @__PURE__ */ jsx(Box, { children: ipRegionMap[x.lastLoginIp] ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
208
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: ipRegionMap[x.lastLoginIp] }),
|
|
209
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "grey", children: x.lastLoginIp || t("unknown") })
|
|
210
|
+
] }) : /* @__PURE__ */ jsx(Typography, { children: x.lastLoginIp || t("unknown") }) });
|
|
211
|
+
}
|
|
257
212
|
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
visitorId: x.visitorId
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
})
|
|
281
|
-
}
|
|
213
|
+
},
|
|
214
|
+
showAction && {
|
|
215
|
+
label: t("actions"),
|
|
216
|
+
name: "actions",
|
|
217
|
+
options: {
|
|
218
|
+
customBodyRenderLite: (rawIndex) => {
|
|
219
|
+
const x = safeData[rawIndex];
|
|
220
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
221
|
+
Button,
|
|
222
|
+
{
|
|
223
|
+
sx: {
|
|
224
|
+
whiteSpace: "nowrap",
|
|
225
|
+
fontSize: "12px",
|
|
226
|
+
px: 1
|
|
227
|
+
},
|
|
228
|
+
disabled: currentVisitorId === x.visitorId,
|
|
229
|
+
variant: "outlined",
|
|
230
|
+
size: "small",
|
|
231
|
+
color: "error",
|
|
232
|
+
onClick: () => logout({ visitorId: x.visitorId }),
|
|
233
|
+
children: x.status === "expired" ? t("remove") : currentVisitorId === x.visitorId ? t("currentSession") : t("logout")
|
|
234
|
+
}
|
|
235
|
+
) });
|
|
236
|
+
}
|
|
282
237
|
}
|
|
283
238
|
}
|
|
284
|
-
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
239
|
+
].filter(Boolean);
|
|
240
|
+
return /* @__PURE__ */ jsxs(
|
|
241
|
+
Box,
|
|
242
|
+
{
|
|
243
|
+
sx: {
|
|
244
|
+
".MuiTableCell-head": {
|
|
245
|
+
whiteSpace: "nowrap",
|
|
246
|
+
fontWeight: "bold"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
children: [
|
|
250
|
+
confirmHolder,
|
|
251
|
+
/* @__PURE__ */ jsx(
|
|
252
|
+
Datatable,
|
|
253
|
+
{
|
|
254
|
+
locale,
|
|
255
|
+
data: safeData,
|
|
256
|
+
columns,
|
|
257
|
+
customButtons,
|
|
258
|
+
options: tableOptions,
|
|
259
|
+
loading: pageState.loading
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "UserSessions", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _userSessions.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _userSessions = _interopRequireDefault(require("./components/user-sessions"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
export { default as UserSessions } from "./components/user-sessions.js";
|