@arcblock/ux 2.8.25 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/es/Address/did-address.js +33 -21
- package/es/AnimationWaiter/index.js +2 -1
- package/es/Avatar/index.js +1 -1
- package/es/BlockletContext/index.js +1 -1
- package/es/CardSelector/index.js +2 -1
- package/es/Colors/index.js +2 -1
- package/es/Colors/themes/temp.js +17 -0
- package/es/Datatable/TableSearch.js +2 -1
- package/es/Header/header.js +0 -1
- package/es/Img/index.js +7 -6
- package/es/Locale/selector.js +15 -13
- package/es/NFTDisplay/index.js +2 -1
- package/es/QRCode/index.js +2 -1
- package/es/SessionBlocklet/index.js +169 -0
- package/es/SessionManager/index.js +2 -381
- package/es/SessionPermission/index.js +28 -0
- package/es/SessionUser/components/logged-in.js +224 -0
- package/es/SessionUser/components/session-user-item.js +148 -0
- package/es/SessionUser/components/session-user-switch.js +213 -0
- package/es/SessionUser/components/un-login.js +64 -0
- package/es/SessionUser/components/user-info.js +163 -0
- package/es/SessionUser/index.js +49 -0
- package/es/SessionUser/libs/translation.js +19 -0
- package/es/SessionUser/libs/utils.js +4 -0
- package/es/SplitButton/index.js +2 -1
- package/es/Toast/index.js +1 -1
- package/es/Util/constant.js +10 -0
- package/es/Util/index.js +11 -0
- package/lib/Address/did-address.js +36 -22
- package/lib/AnimationWaiter/index.js +2 -1
- package/lib/Avatar/index.js +1 -1
- package/lib/BlockletContext/index.js +1 -1
- package/lib/CardSelector/index.js +2 -1
- package/lib/Colors/index.js +7 -0
- package/lib/Colors/themes/temp.js +24 -0
- package/lib/Datatable/TableSearch.js +2 -1
- package/lib/Header/header.js +1 -1
- package/lib/Img/index.js +7 -6
- package/lib/Locale/selector.js +14 -13
- package/lib/NFTDisplay/index.js +2 -1
- package/lib/QRCode/index.js +2 -1
- package/lib/SessionBlocklet/index.js +187 -0
- package/lib/SessionManager/index.js +2 -390
- package/lib/SessionPermission/index.js +38 -0
- package/lib/SessionUser/components/logged-in.js +243 -0
- package/lib/SessionUser/components/session-user-item.js +163 -0
- package/lib/SessionUser/components/session-user-switch.js +232 -0
- package/lib/SessionUser/components/un-login.js +72 -0
- package/lib/SessionUser/components/user-info.js +175 -0
- package/lib/SessionUser/index.js +57 -0
- package/lib/SessionUser/libs/translation.js +26 -0
- package/lib/{SessionManager → SessionUser}/libs/utils.js +8 -1
- package/lib/SplitButton/index.js +2 -1
- package/lib/Toast/index.js +5 -5
- package/lib/Util/constant.js +26 -0
- package/lib/Util/index.js +16 -3
- package/package.json +19 -7
- package/src/Address/did-address.jsx +34 -20
- package/src/AnimationWaiter/index.js +2 -1
- package/src/Avatar/index.jsx +1 -1
- package/src/BlockletContext/index.jsx +1 -1
- package/src/CardSelector/index.jsx +2 -1
- package/src/Colors/index.js +1 -0
- package/src/Colors/themes/temp.js +18 -0
- package/src/Datatable/TableSearch.js +3 -1
- package/src/Header/header.jsx +0 -1
- package/src/Img/{index.js → index.jsx} +8 -6
- package/src/Locale/selector.jsx +11 -8
- package/src/NFTDisplay/index.js +2 -1
- package/src/QRCode/index.js +2 -1
- package/src/SessionBlocklet/index.jsx +181 -0
- package/src/SessionManager/index.jsx +2 -369
- package/src/SessionPermission/index.jsx +28 -0
- package/src/SessionUser/components/logged-in.jsx +194 -0
- package/src/SessionUser/components/session-user-item.jsx +96 -0
- package/src/SessionUser/components/session-user-switch.jsx +222 -0
- package/src/SessionUser/components/un-login.jsx +55 -0
- package/src/SessionUser/components/user-info.jsx +165 -0
- package/src/SessionUser/index.jsx +38 -0
- package/src/SessionUser/libs/translation.js +19 -0
- package/src/{SessionManager → SessionUser}/libs/utils.js +4 -0
- package/src/SplitButton/index.js +2 -1
- package/src/Toast/index.js +1 -1
- package/src/Util/constant.js +12 -0
- package/src/Util/index.js +13 -0
- package/es/SessionManager/components/account-item.js +0 -212
- package/es/SessionManager/components/add-account-item.js +0 -57
- package/es/SessionManager/components/federated-login-detecter.js +0 -183
- package/es/SessionManager/components/manage-accounts.js +0 -219
- package/es/SessionManager/components/manage-blocklet.js +0 -70
- package/es/SessionManager/components/menu-accordion.js +0 -103
- package/es/SessionManager/components/responsive-popper.js +0 -24
- package/es/SessionManager/components/user-drawer.js +0 -68
- package/es/SessionManager/components/user-info.js +0 -143
- package/es/SessionManager/components/user-popper.js +0 -110
- package/es/SessionManager/hooks/use-config.js +0 -34
- package/es/SessionManager/libs/translation.js +0 -52
- package/es/SessionManager/libs/utils.js +0 -2
- package/lib/SessionManager/components/account-item.js +0 -219
- package/lib/SessionManager/components/add-account-item.js +0 -66
- package/lib/SessionManager/components/federated-login-detecter.js +0 -193
- package/lib/SessionManager/components/manage-accounts.js +0 -232
- package/lib/SessionManager/components/manage-blocklet.js +0 -86
- package/lib/SessionManager/components/menu-accordion.js +0 -111
- package/lib/SessionManager/components/responsive-popper.js +0 -34
- package/lib/SessionManager/components/user-drawer.js +0 -75
- package/lib/SessionManager/components/user-info.js +0 -160
- package/lib/SessionManager/components/user-popper.js +0 -104
- package/lib/SessionManager/hooks/use-config.js +0 -41
- package/lib/SessionManager/libs/translation.js +0 -59
- package/src/SessionManager/components/account-item.jsx +0 -156
- package/src/SessionManager/components/add-account-item.jsx +0 -49
- package/src/SessionManager/components/federated-login-detecter.jsx +0 -167
- package/src/SessionManager/components/manage-accounts.jsx +0 -228
- package/src/SessionManager/components/manage-blocklet.jsx +0 -70
- package/src/SessionManager/components/menu-accordion.jsx +0 -93
- package/src/SessionManager/components/responsive-popper.jsx +0 -26
- package/src/SessionManager/components/user-drawer.jsx +0 -57
- package/src/SessionManager/components/user-info.jsx +0 -117
- package/src/SessionManager/components/user-popper.jsx +0 -95
- package/src/SessionManager/hooks/use-config.js +0 -33
- package/src/SessionManager/libs/translation.js +0 -52
@@ -1,75 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = UserDrawer;
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
8
|
-
var _material = require("@mui/material");
|
9
|
-
var _close = _interopRequireDefault(require("@iconify-icons/mdi/close"));
|
10
|
-
var _react = require("@iconify/react");
|
11
|
-
var _noop = _interopRequireDefault(require("lodash/noop"));
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
-
function UserDrawer(_ref) {
|
15
|
-
let {
|
16
|
-
children,
|
17
|
-
open,
|
18
|
-
onOpen,
|
19
|
-
onClose
|
20
|
-
} = _ref;
|
21
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Drawer, {
|
22
|
-
anchor: "bottom",
|
23
|
-
open: open,
|
24
|
-
onClose: onClose,
|
25
|
-
onOpen: onOpen,
|
26
|
-
sx: theme => ({
|
27
|
-
'& .MuiDrawer-paper.MuiPaper-root': {
|
28
|
-
width: '100%',
|
29
|
-
height: '90vh',
|
30
|
-
borderTopLeftRadius: '16px',
|
31
|
-
borderTopRightRadius: '16px'
|
32
|
-
},
|
33
|
-
'& .MuiChip-root .MuiChip-icon': {
|
34
|
-
color: theme.palette.success.main
|
35
|
-
},
|
36
|
-
'& .session-manager-menu-item': {
|
37
|
-
padding: '15px',
|
38
|
-
color: '#777',
|
39
|
-
fontSize: '16px',
|
40
|
-
'&:hover': {
|
41
|
-
backgroundColor: '#fbfbfb'
|
42
|
-
}
|
43
|
-
},
|
44
|
-
'& .session-manager-menu-icon': {
|
45
|
-
color: '#999',
|
46
|
-
marginRight: '8px'
|
47
|
-
}
|
48
|
-
}),
|
49
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
|
50
|
-
sx: {
|
51
|
-
cursor: 'pointer',
|
52
|
-
position: 'absolute',
|
53
|
-
right: '8px',
|
54
|
-
top: '8px',
|
55
|
-
zIndex: 1
|
56
|
-
},
|
57
|
-
onClick: onClose,
|
58
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
59
|
-
icon: _close.default,
|
60
|
-
width: 28,
|
61
|
-
height: 28
|
62
|
-
})
|
63
|
-
}), children]
|
64
|
-
});
|
65
|
-
}
|
66
|
-
UserDrawer.propTypes = {
|
67
|
-
children: _propTypes.default.any.isRequired,
|
68
|
-
open: _propTypes.default.bool.isRequired,
|
69
|
-
onOpen: _propTypes.default.func,
|
70
|
-
onClose: _propTypes.default.func
|
71
|
-
};
|
72
|
-
UserDrawer.defaultProps = {
|
73
|
-
onOpen: _noop.default,
|
74
|
-
onClose: _noop.default
|
75
|
-
};
|
@@ -1,160 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = UserInfo;
|
7
|
-
var _material = require("@mui/material");
|
8
|
-
var _shieldCheck = _interopRequireDefault(require("@iconify-icons/mdi/shield-check"));
|
9
|
-
var _expandMore = _interopRequireDefault(require("@iconify-icons/mdi/expand-more"));
|
10
|
-
var _react = require("@iconify/react");
|
11
|
-
var _ahooks = require("ahooks");
|
12
|
-
var _Avatar = _interopRequireDefault(require("../../Avatar"));
|
13
|
-
var _Address = _interopRequireDefault(require("../../Address"));
|
14
|
-
var _DID = _interopRequireDefault(require("../../DID"));
|
15
|
-
var _Util = require("../../Util");
|
16
|
-
var _util = require("../../Locale/util");
|
17
|
-
var _translation = require("../libs/translation");
|
18
|
-
var _Typography = _interopRequireDefault(require("../../Typography"));
|
19
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
/* eslint-disable react/jsx-no-bind */
|
22
|
-
/* eslint-disable react/prop-types */
|
23
|
-
|
24
|
-
function UserInfo(_ref) {
|
25
|
-
var _session$user, _session$user$avatar, _session$user3, _session$user4, _session$user6;
|
26
|
-
let {
|
27
|
-
session,
|
28
|
-
locale,
|
29
|
-
onSwitchProfile,
|
30
|
-
onSwitchPassport,
|
31
|
-
switchProfile,
|
32
|
-
hasBindWallet
|
33
|
-
} = _ref;
|
34
|
-
const t = function t(key) {
|
35
|
-
let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
36
|
-
return (0, _util.t)(_translation.translations, key, locale, 'en', data);
|
37
|
-
};
|
38
|
-
const avatar = (0, _Util.getUserAvatar)((_session$user = session.user) === null || _session$user === void 0 ? void 0 : (_session$user$avatar = _session$user.avatar) === null || _session$user$avatar === void 0 ? void 0 : _session$user$avatar.replace(/\s/g, encodeURIComponent(' ')), 64);
|
39
|
-
const {
|
40
|
-
walletDid
|
41
|
-
} = session.useDid({
|
42
|
-
session
|
43
|
-
});
|
44
|
-
const currentRole = (0, _ahooks.useCreation)(() => {
|
45
|
-
var _session$user2, _session$user2$passpo;
|
46
|
-
return (_session$user2 = session.user) === null || _session$user2 === void 0 ? void 0 : (_session$user2$passpo = _session$user2.passports) === null || _session$user2$passpo === void 0 ? void 0 : _session$user2$passpo.find(item => item.name === session.user.role);
|
47
|
-
}, [session === null || session === void 0 ? void 0 : (_session$user3 = session.user) === null || _session$user3 === void 0 ? void 0 : _session$user3.passports, session === null || session === void 0 ? void 0 : (_session$user4 = session.user) === null || _session$user4 === void 0 ? void 0 : _session$user4.role]);
|
48
|
-
const userEmail = (0, _ahooks.useCreation)(() => {
|
49
|
-
var _session$user5;
|
50
|
-
return (_session$user5 = session.user) === null || _session$user5 === void 0 ? void 0 : _session$user5.email;
|
51
|
-
}, [session === null || session === void 0 ? void 0 : session.user]);
|
52
|
-
const canEdit = (0, _ahooks.useCreation)(() => {
|
53
|
-
if (onSwitchProfile instanceof Function) {
|
54
|
-
if (switchProfile && hasBindWallet) {
|
55
|
-
return true;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
return false;
|
59
|
-
}, [onSwitchProfile, switchProfile, hasBindWallet, session.provider]);
|
60
|
-
const _onSwitchProfile = (0, _ahooks.useMemoizedFn)(() => {
|
61
|
-
var _window$blocklet;
|
62
|
-
if ((_window$blocklet = window.blocklet) !== null && _window$blocklet !== void 0 && _window$blocklet.appPid) {
|
63
|
-
window.location.href = '/.well-known/service/user/profile';
|
64
|
-
} else if (canEdit) {
|
65
|
-
onSwitchProfile();
|
66
|
-
}
|
67
|
-
});
|
68
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
69
|
-
sx: {
|
70
|
-
display: 'flex',
|
71
|
-
alignItems: 'center',
|
72
|
-
gap: '12px',
|
73
|
-
padding: '15px'
|
74
|
-
},
|
75
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
76
|
-
onClick: _onSwitchProfile,
|
77
|
-
"data-cy": "sessionManager-switch-profile-trigger",
|
78
|
-
sx: {
|
79
|
-
cursor: canEdit ? 'pointer' : 'default',
|
80
|
-
position: 'relative',
|
81
|
-
borderRadius: '100%',
|
82
|
-
overflow: 'hidden',
|
83
|
-
fontSize: 0,
|
84
|
-
'&:hover': canEdit ? {
|
85
|
-
'&::after': {
|
86
|
-
content: "\"".concat(t('switch'), "\""),
|
87
|
-
position: 'absolute',
|
88
|
-
bottom: 0,
|
89
|
-
background: 'rgba(0, 0, 0, 0.2)',
|
90
|
-
left: 0,
|
91
|
-
right: 0,
|
92
|
-
height: '2.2em',
|
93
|
-
color: 'white',
|
94
|
-
textAlign: 'center',
|
95
|
-
fontSize: '12px',
|
96
|
-
lineHeight: '2em'
|
97
|
-
}
|
98
|
-
} : {}
|
99
|
-
},
|
100
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
|
101
|
-
variant: "circle",
|
102
|
-
did: session.user.did,
|
103
|
-
src: avatar,
|
104
|
-
size: 64,
|
105
|
-
shape: "circle"
|
106
|
-
})
|
107
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
108
|
-
sx: {
|
109
|
-
flex: 1,
|
110
|
-
position: 'static',
|
111
|
-
overflow: 'hidden',
|
112
|
-
fontSize: '14px'
|
113
|
-
},
|
114
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
115
|
-
variant: "h5",
|
116
|
-
fontWeight: "bold",
|
117
|
-
sx: {
|
118
|
-
wordBreak: 'break-all',
|
119
|
-
lineHeight: 1
|
120
|
-
},
|
121
|
-
children: session.user.fullName
|
122
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
|
123
|
-
label: (currentRole === null || currentRole === void 0 ? void 0 : currentRole.title) || ((_session$user6 = session.user) === null || _session$user6 === void 0 ? void 0 : _session$user6.role.toUpperCase()),
|
124
|
-
size: "small",
|
125
|
-
variant: "outlined",
|
126
|
-
sx: {
|
127
|
-
height: 'auto',
|
128
|
-
marginRight: 0,
|
129
|
-
fontWeight: 'bold',
|
130
|
-
fontSize: '12px',
|
131
|
-
margin: '6px 0 4px 0'
|
132
|
-
},
|
133
|
-
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
134
|
-
icon: _shieldCheck.default,
|
135
|
-
height: "0.8em"
|
136
|
-
}),
|
137
|
-
deleteIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
138
|
-
icon: _expandMore.default,
|
139
|
-
height: "1em"
|
140
|
-
})
|
141
|
-
// HACK: 必须设置 onDelete 函数,deleteIcon 才能显示出来
|
142
|
-
,
|
143
|
-
onDelete: onSwitchPassport,
|
144
|
-
onClick: onSwitchPassport,
|
145
|
-
"data-cy": "sessionManager-switch-passport-trigger"
|
146
|
-
}), session.provider === 'auth0' ? walletDid ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DID.default, {
|
147
|
-
responsive: false,
|
148
|
-
compact: true,
|
149
|
-
did: walletDid
|
150
|
-
}) : null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_DID.default, {
|
151
|
-
responsive: false,
|
152
|
-
compact: true,
|
153
|
-
did: session.user.did
|
154
|
-
}), userEmail ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Address.default, {
|
155
|
-
responsive: false,
|
156
|
-
children: userEmail
|
157
|
-
}) : null]
|
158
|
-
})]
|
159
|
-
});
|
160
|
-
}
|
@@ -1,104 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = UserPopper;
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
8
|
-
var _material = require("@mui/material");
|
9
|
-
var _close = _interopRequireDefault(require("@iconify-icons/mdi/close"));
|
10
|
-
var _react = require("@iconify/react");
|
11
|
-
var _Theme = require("../../Theme");
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
-
var _templateObject;
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
16
|
-
function UserPopper(_ref) {
|
17
|
-
let {
|
18
|
-
anchorEl,
|
19
|
-
dark,
|
20
|
-
children,
|
21
|
-
open,
|
22
|
-
onClose,
|
23
|
-
autoClose
|
24
|
-
} = _ref;
|
25
|
-
return anchorEl && /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPopper, {
|
26
|
-
open: open,
|
27
|
-
disablePortal: true,
|
28
|
-
anchorEl: anchorEl,
|
29
|
-
placement: "bottom-end",
|
30
|
-
$dark: dark,
|
31
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Paper, {
|
32
|
-
sx: [theme => ({
|
33
|
-
borderColor: '#F0F0F0',
|
34
|
-
boxShadow: '0px 8px 12px rgba(92, 92, 92, 0.04)',
|
35
|
-
borderRadius: theme.spacing(2),
|
36
|
-
overflow: 'auto',
|
37
|
-
maxWidth: 'calc(100vw - 10px)',
|
38
|
-
maxHeight: 'calc(100vh - 80px)',
|
39
|
-
'& .MuiChip-root .MuiChip-icon': {
|
40
|
-
color: theme.palette.success.main
|
41
|
-
},
|
42
|
-
'& .MuiList-root': {
|
43
|
-
width: '320px'
|
44
|
-
}
|
45
|
-
}), dark && {
|
46
|
-
backgroundColor: '#27282c',
|
47
|
-
color: '#fff',
|
48
|
-
border: 0,
|
49
|
-
'& .MuiChip-root': {
|
50
|
-
borderColor: '#aaa'
|
51
|
-
},
|
52
|
-
'& .MuiListItem-root, & .MuiChip-label': {
|
53
|
-
color: '#aaa'
|
54
|
-
},
|
55
|
-
'& .MuiListItem-root:hover': {
|
56
|
-
backgroundColor: '#363434'
|
57
|
-
}
|
58
|
-
}],
|
59
|
-
variant: "outlined",
|
60
|
-
children: autoClose ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ClickAwayListener, {
|
61
|
-
onClickAway: onClose,
|
62
|
-
children: children
|
63
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
64
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
|
65
|
-
size: "small",
|
66
|
-
sx: {
|
67
|
-
cursor: 'pointer',
|
68
|
-
position: 'absolute',
|
69
|
-
right: 0,
|
70
|
-
top: 0,
|
71
|
-
zIndex: 1
|
72
|
-
},
|
73
|
-
onClick: onClose,
|
74
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
75
|
-
icon: _close.default,
|
76
|
-
width: 20,
|
77
|
-
height: 20
|
78
|
-
})
|
79
|
-
}), children]
|
80
|
-
})
|
81
|
-
})
|
82
|
-
});
|
83
|
-
}
|
84
|
-
UserPopper.propTypes = {
|
85
|
-
anchorEl: _propTypes.default.instanceOf(Element),
|
86
|
-
dark: _propTypes.default.bool,
|
87
|
-
open: _propTypes.default.bool,
|
88
|
-
children: _propTypes.default.any.isRequired,
|
89
|
-
onClose: _propTypes.default.func,
|
90
|
-
autoClose: _propTypes.default.bool
|
91
|
-
};
|
92
|
-
UserPopper.defaultProps = {
|
93
|
-
anchorEl: null,
|
94
|
-
dark: false,
|
95
|
-
open: false,
|
96
|
-
onClose: () => {},
|
97
|
-
autoClose: true
|
98
|
-
};
|
99
|
-
const StyledPopper = (0, _Theme.styled)(_material.Popper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: ", ";\n\n .session-manager-menu-item {\n padding: 15px;\n color: #777;\n font-size: 16px;\n &:hover {\n background-color: #fbfbfb;\n }\n }\n .session-manager-menu-icon {\n color: #999;\n margin-right: 8px;\n }\n"])), _ref2 => {
|
100
|
-
let {
|
101
|
-
theme
|
102
|
-
} = _ref2;
|
103
|
-
return theme.zIndex.tooltip;
|
104
|
-
});
|
@@ -1,41 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = useConfig;
|
7
|
-
var _ahooks = require("ahooks");
|
8
|
-
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
function useConfig() {
|
11
|
-
const [config, setConfig] = (0, _ahooks.useLocalStorageState)('blocklet:sessionManager:config', {
|
12
|
-
defaultValue: {
|
13
|
-
accounts: [],
|
14
|
-
expandAccount: true,
|
15
|
-
expandBlocklet: true
|
16
|
-
}
|
17
|
-
});
|
18
|
-
const connectAccount = (0, _ahooks.useMemoizedFn)(account => {
|
19
|
-
const cloneConfig = (0, _cloneDeep.default)(config);
|
20
|
-
const accountIndex = cloneConfig.accounts.findIndex(x => x.did === account.did);
|
21
|
-
if (accountIndex >= 0) {
|
22
|
-
cloneConfig.accounts.splice(accountIndex, 1);
|
23
|
-
}
|
24
|
-
cloneConfig.accounts.unshift(account);
|
25
|
-
setConfig(cloneConfig);
|
26
|
-
});
|
27
|
-
const deleteAccount = (0, _ahooks.useMemoizedFn)(account => {
|
28
|
-
const cloneConfig = (0, _cloneDeep.default)(config);
|
29
|
-
const findIndex = cloneConfig.accounts.findIndex(item => item.did === account.did);
|
30
|
-
if (findIndex >= 0) {
|
31
|
-
cloneConfig.accounts.splice(findIndex, 1);
|
32
|
-
}
|
33
|
-
setConfig(cloneConfig);
|
34
|
-
});
|
35
|
-
return {
|
36
|
-
config,
|
37
|
-
setConfig,
|
38
|
-
connectAccount,
|
39
|
-
deleteAccount
|
40
|
-
};
|
41
|
-
}
|
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.translations = void 0;
|
7
|
-
/* eslint-disable import/prefer-default-export */
|
8
|
-
const translations = {
|
9
|
-
en: {
|
10
|
-
switch: 'Switch',
|
11
|
-
account: 'account',
|
12
|
-
switchDid: 'Switch DID',
|
13
|
-
switchTo: 'Switch to',
|
14
|
-
switchProfile: 'Switch Profile',
|
15
|
-
switchPassport: 'Switch Passport',
|
16
|
-
disconnect: 'Disconnect',
|
17
|
-
connect: 'Connect',
|
18
|
-
openInWallet: 'Open DID Wallet',
|
19
|
-
alreadyBindOAuth: 'Already bind Auth0',
|
20
|
-
bind: 'Bind ',
|
21
|
-
thirdParty: 'Third Party Login',
|
22
|
-
addAppAccount: 'Add {appName} account',
|
23
|
-
accounts: 'Accounts',
|
24
|
-
blocklet: 'Blocklet',
|
25
|
-
from: 'From',
|
26
|
-
addAnotherAccount: 'Add another account',
|
27
|
-
deleteAccountTitle: 'Remove this account ?',
|
28
|
-
deleteAccountContent: 'After delete account, you can add it again',
|
29
|
-
confirm: 'Confirm',
|
30
|
-
cancel: 'Cancel',
|
31
|
-
noneMenu: 'Empty menu, maybe you should switch to another role'
|
32
|
-
},
|
33
|
-
zh: {
|
34
|
-
switch: '切换',
|
35
|
-
account: '账号',
|
36
|
-
switchDid: '切换账户',
|
37
|
-
switchTo: '切换至',
|
38
|
-
switchProfile: '切换用户信息',
|
39
|
-
switchPassport: '切换通行证',
|
40
|
-
disconnect: '退出登录',
|
41
|
-
connect: '登录',
|
42
|
-
openInWallet: '打开 DID 钱包',
|
43
|
-
// NOTE: 目前只有 Auth0,展示出具体的第三方名字会更好
|
44
|
-
alreadyBindOAuth: '已绑定 Auth0 账号',
|
45
|
-
bind: '绑定',
|
46
|
-
thirdParty: '第三方登录',
|
47
|
-
addAppAccount: '添加 {appName} 账户',
|
48
|
-
accounts: '账户',
|
49
|
-
blocklet: '应用',
|
50
|
-
from: '连接至',
|
51
|
-
addAnotherAccount: '添加账号',
|
52
|
-
deleteAccountTitle: '是否删除账户?',
|
53
|
-
deleteAccountContent: '账户删除后,可再次添加',
|
54
|
-
confirm: '确认',
|
55
|
-
cancel: '取消',
|
56
|
-
noneMenu: '无操作项,请尝试切换角色'
|
57
|
-
}
|
58
|
-
};
|
59
|
-
exports.translations = translations;
|
@@ -1,156 +0,0 @@
|
|
1
|
-
import { Box, IconButton, Link, MenuItem, Typography } from '@mui/material';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { Icon } from '@iconify/react';
|
4
|
-
import CheckIcon from '@iconify-icons/mdi/check';
|
5
|
-
import AppleIOSIcon from '@iconify-icons/mdi/apple-ios';
|
6
|
-
import AndroidIcon from '@iconify-icons/mdi/android';
|
7
|
-
import WebIcon from '@iconify-icons/mdi/web';
|
8
|
-
import ApiIcon from '@iconify-icons/mdi/api';
|
9
|
-
import Auth0Icon from '@iconify-icons/logos/auth0-icon';
|
10
|
-
import TrashCanOutlineIcon from '@iconify-icons/mdi/trash-can-outline';
|
11
|
-
import { useCreation, useMemoizedFn } from 'ahooks';
|
12
|
-
|
13
|
-
import Avatar from '../../Avatar';
|
14
|
-
import DID from '../../DID';
|
15
|
-
import { translate } from '../../Locale/util';
|
16
|
-
import { translations } from '../libs/translation';
|
17
|
-
import { getFederatedEnabled } from '../../Util/federated';
|
18
|
-
|
19
|
-
export default function AccountItem({ account, active, onDelete, onChoose, locale }) {
|
20
|
-
const t = useMemoizedFn((key, data = {}) => {
|
21
|
-
return translate(translations, key, locale, 'en', data);
|
22
|
-
});
|
23
|
-
|
24
|
-
const federatedEnabled = getFederatedEnabled();
|
25
|
-
|
26
|
-
const _onChoose = useMemoizedFn(() => onChoose(account, { active }));
|
27
|
-
|
28
|
-
const _onDelete = useMemoizedFn((e) => {
|
29
|
-
e.preventDefault();
|
30
|
-
e.stopPropagation();
|
31
|
-
onDelete(account, { active });
|
32
|
-
});
|
33
|
-
|
34
|
-
const stopPropagation = useMemoizedFn((e) => {
|
35
|
-
e.stopPropagation();
|
36
|
-
});
|
37
|
-
|
38
|
-
const walletIcon = useCreation(() => {
|
39
|
-
const { walletOS, provider } = account;
|
40
|
-
if (provider === 'auth0') {
|
41
|
-
return <Icon icon={Auth0Icon} width={10} height={10} style={{ color: 'black' }} />;
|
42
|
-
}
|
43
|
-
if (walletOS === 'ios') {
|
44
|
-
return <Icon icon={AppleIOSIcon} width={16} height={16} style={{ color: 'black' }} />;
|
45
|
-
}
|
46
|
-
if (walletOS === 'android') {
|
47
|
-
return <Icon icon={AndroidIcon} width={14} height={14} style={{ color: 'black' }} />;
|
48
|
-
}
|
49
|
-
if (walletOS === 'web') {
|
50
|
-
return <Icon icon={WebIcon} style={{ color: 'black' }} />;
|
51
|
-
}
|
52
|
-
if (walletOS === 'api') {
|
53
|
-
return <Icon icon={ApiIcon} width={14} height={14} style={{ color: 'black' }} />;
|
54
|
-
}
|
55
|
-
return null;
|
56
|
-
}, [account.walletOS]);
|
57
|
-
|
58
|
-
if (!account?.did || !account?.appName) {
|
59
|
-
return null;
|
60
|
-
}
|
61
|
-
|
62
|
-
return (
|
63
|
-
<MenuItem
|
64
|
-
onClick={_onChoose}
|
65
|
-
sx={{
|
66
|
-
display: 'flex',
|
67
|
-
alignItems: 'center',
|
68
|
-
overflow: 'hidden',
|
69
|
-
gap: '8px',
|
70
|
-
position: 'relative',
|
71
|
-
'.account-item-actions': {
|
72
|
-
position: 'absolute',
|
73
|
-
right: 0,
|
74
|
-
top: 0,
|
75
|
-
bottom: 0,
|
76
|
-
marginRight: '12px',
|
77
|
-
display: 'flex',
|
78
|
-
alignItems: 'center',
|
79
|
-
},
|
80
|
-
'.account-item-action': {
|
81
|
-
alignItems: 'center',
|
82
|
-
display: 'none',
|
83
|
-
},
|
84
|
-
'&:hover .account-item-action': {
|
85
|
-
display: 'flex',
|
86
|
-
},
|
87
|
-
}}
|
88
|
-
className="session-manager-menu-item">
|
89
|
-
<Avatar did={account.did} size={42} />
|
90
|
-
<Box
|
91
|
-
sx={{
|
92
|
-
flex: 1,
|
93
|
-
overflow: 'hidden',
|
94
|
-
fontSize: 0,
|
95
|
-
'.did-address-avatar': {
|
96
|
-
display: 'none !important',
|
97
|
-
},
|
98
|
-
}}>
|
99
|
-
<DID did={account.did} copyable={false} size={14} responsive={false} compact sx={{ lineHeight: 1 }} />
|
100
|
-
<Typography variant="caption" display="flex" alignItems="center" gap={0.5}>
|
101
|
-
{walletIcon}
|
102
|
-
{federatedEnabled ? (
|
103
|
-
<>
|
104
|
-
{t('from')}{' '}
|
105
|
-
<Link
|
106
|
-
href={account.appUrl}
|
107
|
-
target="_blank"
|
108
|
-
onClick={stopPropagation}
|
109
|
-
sx={{
|
110
|
-
textDecoration: 'none',
|
111
|
-
'&:hover': {
|
112
|
-
textDecoration: 'underline',
|
113
|
-
},
|
114
|
-
}}>
|
115
|
-
{account.appName}
|
116
|
-
</Link>
|
117
|
-
</>
|
118
|
-
) : (
|
119
|
-
// HACK: 用于在有 icon 的情况下,该该行的高度撑高为文字高度
|
120
|
-
walletIcon && ' '
|
121
|
-
)}
|
122
|
-
</Typography>
|
123
|
-
</Box>
|
124
|
-
<Box className="account-item-actions">
|
125
|
-
{active ? (
|
126
|
-
<Box className="account-item-action" style={{ display: 'flex' }} key="CheckIcon">
|
127
|
-
<IconButton color="success">
|
128
|
-
<Icon icon={CheckIcon} color="success" />
|
129
|
-
</IconButton>
|
130
|
-
</Box>
|
131
|
-
) : (
|
132
|
-
<Box className="account-item-action" key="TrashCanOutlineIcon">
|
133
|
-
<IconButton color="error" onClick={_onDelete}>
|
134
|
-
<Icon icon={TrashCanOutlineIcon} color="error" />
|
135
|
-
</IconButton>
|
136
|
-
</Box>
|
137
|
-
)}
|
138
|
-
</Box>
|
139
|
-
</MenuItem>
|
140
|
-
);
|
141
|
-
}
|
142
|
-
|
143
|
-
AccountItem.propTypes = {
|
144
|
-
account: PropTypes.object,
|
145
|
-
active: PropTypes.bool,
|
146
|
-
locale: PropTypes.string,
|
147
|
-
onChoose: PropTypes.func,
|
148
|
-
onDelete: PropTypes.func,
|
149
|
-
};
|
150
|
-
AccountItem.defaultProps = {
|
151
|
-
account: null,
|
152
|
-
active: false,
|
153
|
-
locale: 'en',
|
154
|
-
onChoose: () => {},
|
155
|
-
onDelete: () => {},
|
156
|
-
};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { Icon } from '@iconify/react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { MenuItem, Typography } from '@mui/material';
|
4
|
-
import AddIcon from '@iconify-icons/ion/ios-add-circle-outline';
|
5
|
-
import { useCreation, useMemoizedFn } from 'ahooks';
|
6
|
-
import { translate } from '../../Locale/util';
|
7
|
-
import { translations } from '../libs/translation';
|
8
|
-
import { getApps } from '../../Util/federated';
|
9
|
-
|
10
|
-
export default function AddAccountItem({ onAdd, locale, session }) {
|
11
|
-
const t = useMemoizedFn((key, data = {}) => {
|
12
|
-
return translate(translations, key, locale, 'en', data);
|
13
|
-
});
|
14
|
-
const apps = useCreation(() => {
|
15
|
-
return getApps();
|
16
|
-
}, []);
|
17
|
-
|
18
|
-
const _onAdd = useMemoizedFn(() => {
|
19
|
-
// HACK: 如果是非统一登录应用,则 sourceAppPid 的值为 null
|
20
|
-
const sourceAppPid = session?.user?.sourceAppPid || null;
|
21
|
-
const app = apps.find((x) => x.appPid === sourceAppPid);
|
22
|
-
if (app) {
|
23
|
-
onAdd(app);
|
24
|
-
} else {
|
25
|
-
onAdd(apps[0]);
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
return (
|
30
|
-
<MenuItem
|
31
|
-
onClick={_onAdd}
|
32
|
-
className="session-manager-menu-item"
|
33
|
-
sx={{ display: 'flex', gap: '8px' }}
|
34
|
-
data-cy="sessionManager-switch-trigger">
|
35
|
-
<Icon icon={AddIcon} width={24} height={24} />
|
36
|
-
<Typography>{t('addAnotherAccount')}</Typography>
|
37
|
-
</MenuItem>
|
38
|
-
);
|
39
|
-
}
|
40
|
-
|
41
|
-
AddAccountItem.propTypes = {
|
42
|
-
onAdd: PropTypes.func,
|
43
|
-
locale: PropTypes.string,
|
44
|
-
session: PropTypes.object.isRequired,
|
45
|
-
};
|
46
|
-
AddAccountItem.defaultProps = {
|
47
|
-
onAdd: () => {},
|
48
|
-
locale: 'en',
|
49
|
-
};
|