@abtnode/ux 1.16.14-beta-c308dc3b → 1.16.14-beta-963cb583
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/es/actions.js +97 -0
- package/es/analytics/card.js +92 -0
- package/es/analytics/chart.js +96 -0
- package/es/analytics/cpu.js +36 -0
- package/es/analytics/disk.js +111 -0
- package/es/analytics/memory.js +72 -0
- package/es/analytics/runtime.js +173 -0
- package/es/analytics/traffic.js +259 -0
- package/es/blocklet/access/config-access.js +307 -0
- package/es/blocklet/access/index.js +216 -0
- package/es/blocklet/actions.js +474 -0
- package/es/blocklet/add-cert.js +177 -0
- package/es/blocklet/agreement-app.js +21 -0
- package/es/blocklet/agreement.js +127 -0
- package/es/blocklet/app-avatar.js +57 -0
- package/es/blocklet/audit-logs.js +259 -0
- package/es/blocklet/blocklet-source.js +48 -0
- package/es/blocklet/bundle-avatar.js +64 -0
- package/es/blocklet/component/add.js +1313 -0
- package/es/blocklet/component/configuration.js +122 -0
- package/es/blocklet/component/delete.js +134 -0
- package/es/blocklet/component/environment.js +370 -0
- package/es/blocklet/component/index.js +975 -0
- package/es/blocklet/component/line.js +20 -0
- package/es/blocklet/component/navigation/locale-tabs.js +225 -0
- package/es/blocklet/component/navigation/navigation-actions.js +112 -0
- package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
- package/es/blocklet/component/navigation/navigation-preview.js +101 -0
- package/es/blocklet/component/navigation/simple-select.js +124 -0
- package/es/blocklet/component/select-store.js +155 -0
- package/es/blocklet/component/selected/index.js +94 -0
- package/es/blocklet/component/setting.js +109 -0
- package/es/blocklet/component/sortable-tree.js +126 -0
- package/es/blocklet/component/space-connector.js +199 -0
- package/es/blocklet/component/space-selector.js +178 -0
- package/es/blocklet/component/start.js +101 -0
- package/es/blocklet/component/store-blocklet-list.js +200 -0
- package/es/blocklet/component/switch-control.js +57 -0
- package/es/blocklet/config-navigation.js +331 -0
- package/es/blocklet/configuration.js +603 -0
- package/es/blocklet/disk-info.js +75 -0
- package/es/blocklet/icons.js +18 -0
- package/es/blocklet/install-from-url.js +337 -0
- package/es/blocklet/log.js +90 -0
- package/es/blocklet/migration.js +149 -0
- package/es/blocklet/mode.js +19 -0
- package/es/blocklet/notification/email.js +257 -0
- package/es/blocklet/notification/index.js +49 -0
- package/es/blocklet/oauth/auth0.js +145 -0
- package/es/blocklet/oauth/common-settings.js +133 -0
- package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
- package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
- package/es/blocklet/oauth/federated-join-dialog.js +111 -0
- package/es/blocklet/oauth/federated-site-list.js +338 -0
- package/es/blocklet/oauth/federated.js +81 -0
- package/es/blocklet/oauth/index.js +69 -0
- package/es/blocklet/overview.js +293 -0
- package/es/blocklet/page-group.js +19 -0
- package/es/blocklet/preferences/app-sk.js +142 -0
- package/es/blocklet/preferences/index.js +305 -0
- package/es/blocklet/purchase/common.js +95 -0
- package/es/blocklet/purchase/component-purchase.js +237 -0
- package/es/blocklet/purchase/index.js +4 -0
- package/es/blocklet/router/action/add-domain-alias.js +167 -0
- package/es/blocklet/router/action/add-rule.js +211 -0
- package/es/blocklet/router/action/config-routing-rule.js +232 -0
- package/es/blocklet/router/action/delete-domain-alias.js +99 -0
- package/es/blocklet/router/action/delete-rule.js +108 -0
- package/es/blocklet/router/action/update-rule.js +209 -0
- package/es/blocklet/router/domain-actions.js +64 -0
- package/es/blocklet/router/domain-status.js +88 -0
- package/es/blocklet/router/rule-actions.js +66 -0
- package/es/blocklet/router/rule-list.js +190 -0
- package/es/blocklet/router/util.js +131 -0
- package/es/blocklet/runtime-info.js +68 -0
- package/es/blocklet/status.js +91 -0
- package/es/blocklet/storage/action.js +134 -0
- package/es/blocklet/storage/backups.js +241 -0
- package/es/blocklet/storage/connect-to.js +372 -0
- package/es/blocklet/storage/connected.js +198 -0
- package/es/blocklet/storage/delete.js +113 -0
- package/es/blocklet/storage/disconnect.js +243 -0
- package/es/blocklet/storage/index.js +19 -0
- package/es/blocklet/storage/item.js +558 -0
- package/es/blocklet/storage/preview-nft.js +286 -0
- package/es/blocklet/transfer-owner.js +198 -0
- package/es/blocklet/types.js +18 -0
- package/es/blocklet/util.js +145 -0
- package/es/blocklet/version.js +141 -0
- package/es/card-selector.js +134 -0
- package/es/certificate.js +105 -0
- package/es/chain.js +13 -0
- package/es/click-to-copy.js +22 -0
- package/es/confirm.js +149 -0
- package/es/contexts/audit-log.js +152 -0
- package/es/contexts/blocklet.js +10 -0
- package/es/contexts/deleting-blocklets.js +70 -0
- package/es/contexts/node.js +17 -0
- package/es/contexts/session.js +8 -0
- package/es/contexts/team.js +10 -0
- package/es/delete-confirm.js +121 -0
- package/es/did-address.js +46 -0
- package/es/dot.js +14 -0
- package/es/exchange-passport.js +102 -0
- package/es/form/form-select-input.js +184 -0
- package/es/form/form-text-input.js +178 -0
- package/es/form/form-wrapper.js +88 -0
- package/es/form/input-triggers.js +98 -0
- package/es/form/required.js +8 -0
- package/es/hooks/blocklet.js +229 -0
- package/es/hooks/confirm.js +90 -0
- package/es/hooks/mobile-width.js +11 -0
- package/es/hooks/url-evaluation.js +155 -0
- package/es/hooks/use-app-logo.js +16 -0
- package/es/hooks/use-backup-progress.js +31 -0
- package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
- package/es/hooks/use-bundle-logo.js +27 -0
- package/es/hooks/use-navigation.js +347 -0
- package/es/hooks/use-passport-id.js +14 -0
- package/es/hooks/use-subscription.js +22 -0
- package/es/icons/empty-space-nft.svg +59 -0
- package/es/icons/empty-spaces-nft.svg +58 -0
- package/es/icons/long-arrow.svg +5 -0
- package/es/icons/space-connected.svg +3 -0
- package/es/icons/space-disconnect.svg +3 -0
- package/es/index.js +3 -0
- package/es/invitation/invitation-app.js +58 -0
- package/es/invitation/invitation-login.js +68 -0
- package/es/invitation/invitation-passport.js +146 -0
- package/es/invitation/invitation-receive.js +138 -0
- package/es/invitation/invitation-success.js +93 -0
- package/es/invitation/invitation-user.js +90 -0
- package/es/invitation/invitation.js +90 -0
- package/es/issue-passport.js +142 -0
- package/es/launch-blocklet/content-layout.js +58 -0
- package/es/launch-blocklet/page-header.js +43 -0
- package/es/layout/addon.js +114 -0
- package/es/layout/feedback.js +55 -0
- package/es/locales/en.js +1541 -0
- package/es/locales/index.js +9 -0
- package/es/locales/zh.js +1544 -0
- package/es/logs/clock.js +11 -0
- package/es/logs/download.js +132 -0
- package/es/logs/log-terminal.js +253 -0
- package/es/lost-passport.js +452 -0
- package/es/nav-logo.js +219 -0
- package/es/passport-tag.js +43 -0
- package/es/permission.js +57 -0
- package/es/relative-time.js +53 -0
- package/es/result-message.js +11 -0
- package/es/schema-form/color-input.js +98 -0
- package/es/schema-form/common-prop-types.js +13 -0
- package/es/schema-form/index.js +215 -0
- package/es/schema-form/passport-input.js +55 -0
- package/es/schema-form/text-input.js +57 -0
- package/es/store/add.js +179 -0
- package/es/store/delete.js +96 -0
- package/es/store/item.js +76 -0
- package/es/subscription.js +144 -0
- package/es/table-icons.js +34 -0
- package/es/table.js +52 -0
- package/es/tag.js +21 -0
- package/es/team/members/actions.js +89 -0
- package/es/team/members/index.js +636 -0
- package/es/team/members/invitations.js +188 -0
- package/es/team/members/invite-member.js +208 -0
- package/es/team/members/issue-passport.js +152 -0
- package/es/team/members/member.js +408 -0
- package/es/team/members/passport-issuances.js +155 -0
- package/es/team/members/passports.js +364 -0
- package/es/team/members/toggle-user-approval.js +122 -0
- package/es/team/members/transfer-node.js +256 -0
- package/es/team/members/util.js +14 -0
- package/es/team/passports/color.js +127 -0
- package/es/team/passports/detail.js +312 -0
- package/es/team/passports/index.js +282 -0
- package/es/team/passports/mutate-role.js +198 -0
- package/es/team/passports/trusted-factories.js +221 -0
- package/es/team/passports/trusted-factory.js +343 -0
- package/es/team/passports/trusted-issuer.js +296 -0
- package/es/team/passports/trusted-issuers.js +226 -0
- package/es/team/search-input.js +46 -0
- package/es/team/styles/dialog.js +72 -0
- package/es/team/styles/list-header.js +31 -0
- package/es/util/api.js +6 -0
- package/es/util/constants.js +2 -0
- package/es/util/index.js +598 -0
- package/es/util/mode.js +4 -0
- package/es/util/space-gateway.js +51 -0
- package/es/util/spaces.js +160 -0
- package/es/who-can-access/config.js +38 -0
- package/es/wrap-locale.js +15 -0
- package/lib/blocklet/component/add.js +5 -0
- package/lib/blocklet/component/selected/index.js +47 -0
- package/lib/blocklet/component/space-connector.js +1 -1
- package/lib/blocklet/component/space-selector.js +1 -1
- package/lib/blocklet/storage/backups.js +1 -1
- package/lib/blocklet/storage/connect-to.js +6 -7
- package/lib/blocklet/storage/connected.js +1 -1
- package/lib/blocklet/storage/disconnect.js +1 -1
- package/lib/blocklet/storage/index.js +1 -1
- package/lib/blocklet/storage/item.js +1 -1
- package/lib/card-selector.js +14 -14
- package/lib/invitation/invitation-passport.js +7 -6
- package/lib/invitation/invitation-receive.js +1 -1
- package/lib/locales/en.js +12 -5
- package/lib/locales/zh.js +10 -3
- package/lib/lost-passport.js +2 -2
- package/lib/schema-form/passport-input.js +12 -11
- package/lib/team/passports/color.js +14 -14
- package/lib/team/passports/trusted-factory.js +1 -1
- package/lib/util/spaces.js +13 -1
- package/package.json +88 -21
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
6
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
7
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
8
|
+
import Box from '@mui/material/Box';
|
|
9
|
+
import Avatar from '@mui/material/Avatar';
|
|
10
|
+
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
11
|
+
import InfoRow from '@arcblock/ux/lib/InfoRow';
|
|
12
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
13
|
+
import ForbidLoginIcon from '@arcblock/icons/lib/ForbidLoginIcon';
|
|
14
|
+
import AllowLoginIcon from '@arcblock/icons/lib/AllowLoginIcon';
|
|
15
|
+
import { useReactive } from 'ahooks';
|
|
16
|
+
import { EVENTS, USER_TYPE } from '@abtnode/constant';
|
|
17
|
+
import { LOGIN_PROVIDER } from '@blocklet/constant';
|
|
18
|
+
import DidAddress from '../../did-address';
|
|
19
|
+
import Permission from '../../permission';
|
|
20
|
+
import { useNodeContext } from '../../contexts/node';
|
|
21
|
+
import { useTeamContext } from '../../contexts/team';
|
|
22
|
+
import { formatError, formatToDatetime, BlockletAdminRoles } from '../../util';
|
|
23
|
+
import PassportIssuances from './passport-issuances';
|
|
24
|
+
import Passports from './passports';
|
|
25
|
+
import ToggleUserApproval from './toggle-user-approval';
|
|
26
|
+
import { parseAvatar } from './util';
|
|
27
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
function LinkUser({
|
|
30
|
+
name,
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
34
|
+
...rest,
|
|
35
|
+
sx: {
|
|
36
|
+
color: 'primary.main',
|
|
37
|
+
'&:hover': {
|
|
38
|
+
textDecoration: 'underline'
|
|
39
|
+
},
|
|
40
|
+
cursor: 'pointer'
|
|
41
|
+
},
|
|
42
|
+
children: name
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
LinkUser.propTypes = {
|
|
46
|
+
name: PropTypes.string.isRequired
|
|
47
|
+
};
|
|
48
|
+
function TabOAuth({
|
|
49
|
+
user
|
|
50
|
+
}) {
|
|
51
|
+
const connectedAccounts = user.connectedAccounts || [];
|
|
52
|
+
return connectedAccounts.map(account => {
|
|
53
|
+
return /*#__PURE__*/_jsx(InfoRow, {
|
|
54
|
+
style: {
|
|
55
|
+
alignItems: 'flex-start'
|
|
56
|
+
},
|
|
57
|
+
valueComponent: "div",
|
|
58
|
+
nameWidth: 120,
|
|
59
|
+
name: account.provider,
|
|
60
|
+
children: /*#__PURE__*/_jsx(DidAddress, {
|
|
61
|
+
did: account.did
|
|
62
|
+
})
|
|
63
|
+
}, account.did);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
TabOAuth.propTypes = {
|
|
67
|
+
user: PropTypes.object.isRequired,
|
|
68
|
+
onChangeUser: PropTypes.func
|
|
69
|
+
};
|
|
70
|
+
TabOAuth.defaultProps = {
|
|
71
|
+
onChangeUser: () => {}
|
|
72
|
+
};
|
|
73
|
+
const defaultTab = 'info';
|
|
74
|
+
export default function Member({
|
|
75
|
+
userDid,
|
|
76
|
+
onCancel,
|
|
77
|
+
initTab,
|
|
78
|
+
createPassportSvg
|
|
79
|
+
}) {
|
|
80
|
+
const {
|
|
81
|
+
api,
|
|
82
|
+
ws: {
|
|
83
|
+
useSubscription
|
|
84
|
+
},
|
|
85
|
+
inService
|
|
86
|
+
} = useNodeContext();
|
|
87
|
+
const {
|
|
88
|
+
roles,
|
|
89
|
+
teamDid,
|
|
90
|
+
enablePassportIssuance
|
|
91
|
+
} = useTeamContext();
|
|
92
|
+
const {
|
|
93
|
+
t,
|
|
94
|
+
locale
|
|
95
|
+
} = useLocaleContext();
|
|
96
|
+
const pageState = useReactive({
|
|
97
|
+
user: null,
|
|
98
|
+
issuances: null,
|
|
99
|
+
tab: initTab || defaultTab
|
|
100
|
+
});
|
|
101
|
+
const getData = async (_teamDid, _userDid) => {
|
|
102
|
+
try {
|
|
103
|
+
const res = await api.doBatchQuery({
|
|
104
|
+
getUser: {
|
|
105
|
+
input: {
|
|
106
|
+
teamDid: _teamDid,
|
|
107
|
+
user: {
|
|
108
|
+
did: _userDid
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
getPassportIssuances: {
|
|
113
|
+
input: {
|
|
114
|
+
teamDid: _teamDid,
|
|
115
|
+
ownerDid: _userDid
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (res.getUser.user) {
|
|
120
|
+
res.getUser.user.avatar = parseAvatar(res.getUser.user.avatar, _teamDid, inService);
|
|
121
|
+
|
|
122
|
+
// for backwards compatibility
|
|
123
|
+
res.getUser.user.passports = (res.getUser.user.passports || []).filter(x => x.issuer);
|
|
124
|
+
}
|
|
125
|
+
pageState.user = res.getUser.user || {};
|
|
126
|
+
pageState.issuances = res.getPassportIssuances.list || [];
|
|
127
|
+
} catch (err) {
|
|
128
|
+
Toast.error(formatError(err));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (teamDid) {
|
|
133
|
+
getData(teamDid, userDid);
|
|
134
|
+
}
|
|
135
|
+
}, [userDid, teamDid]); // eslint-disable-line
|
|
136
|
+
|
|
137
|
+
const onUserEvent = data => {
|
|
138
|
+
if (data.teamDid === teamDid && data.user && data.user.did === userDid) {
|
|
139
|
+
getData(teamDid, userDid);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
useSubscription(EVENTS.USER_UPDATED, onUserEvent, [userDid, teamDid]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (pageState.issuances && !pageState.issuances.length && pageState.tab === 'issuances') {
|
|
145
|
+
pageState.tab = defaultTab;
|
|
146
|
+
}
|
|
147
|
+
}, [pageState.issuances]); // eslint-disable-line
|
|
148
|
+
|
|
149
|
+
const handleChangeUser = async changedUser => {
|
|
150
|
+
await getData(teamDid, changedUser.did);
|
|
151
|
+
pageState.tab = defaultTab;
|
|
152
|
+
};
|
|
153
|
+
const providerNameMap = {
|
|
154
|
+
auth0: 'Auth0',
|
|
155
|
+
wallet: 'DID wallet',
|
|
156
|
+
federated: 'Federated'
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// tab
|
|
160
|
+
const Info = () => {
|
|
161
|
+
const rows = pageState.user ? [{
|
|
162
|
+
name: t('team.member.name'),
|
|
163
|
+
value: pageState.user.fullName
|
|
164
|
+
}, {
|
|
165
|
+
name: t('common.email'),
|
|
166
|
+
value: pageState.user.email
|
|
167
|
+
}, {
|
|
168
|
+
name: t('team.member.source'),
|
|
169
|
+
value: /*#__PURE__*/_jsx(Box, {
|
|
170
|
+
display: "flex",
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
children: providerNameMap[pageState.user?.sourceProvider || USER_TYPE.WALLET] || pageState.user?.sourceProvider
|
|
173
|
+
})
|
|
174
|
+
}, {
|
|
175
|
+
name: t('team.member.allowLogin'),
|
|
176
|
+
value: pageState.user.approved ? t('common.yes') : t('common.no')
|
|
177
|
+
}, {
|
|
178
|
+
name: t('team.member.lastLogin'),
|
|
179
|
+
value: formatToDatetime(pageState.user.lastLoginAt, locale)
|
|
180
|
+
}, {
|
|
181
|
+
name: t('team.member.lastLoginIp'),
|
|
182
|
+
value: pageState.user.lastLoginIp || ''
|
|
183
|
+
}, {
|
|
184
|
+
name: t('common.createdAt'),
|
|
185
|
+
value: formatToDatetime(pageState.user.createdAt, locale)
|
|
186
|
+
}, {
|
|
187
|
+
name: t('common.remark'),
|
|
188
|
+
value: pageState.user.remark || '--'
|
|
189
|
+
}].filter(Boolean) : [];
|
|
190
|
+
return rows.map(row => {
|
|
191
|
+
if (row.name === t('common.did')) {
|
|
192
|
+
return /*#__PURE__*/_jsx(InfoRow, {
|
|
193
|
+
valueComponent: "div",
|
|
194
|
+
nameWidth: 120,
|
|
195
|
+
name: row.name,
|
|
196
|
+
nameFormatter: () => t('common.did'),
|
|
197
|
+
children: row.value
|
|
198
|
+
}, row.name);
|
|
199
|
+
}
|
|
200
|
+
return /*#__PURE__*/_jsx(InfoRow, {
|
|
201
|
+
style: {
|
|
202
|
+
alignItems: 'flex-start'
|
|
203
|
+
},
|
|
204
|
+
valueComponent: "div",
|
|
205
|
+
nameWidth: 120,
|
|
206
|
+
name: row.name,
|
|
207
|
+
children: row.value
|
|
208
|
+
}, row.name);
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
const tabConfigs = {
|
|
212
|
+
info: {
|
|
213
|
+
label: t('common.basicInfo'),
|
|
214
|
+
value: defaultTab,
|
|
215
|
+
component: Info
|
|
216
|
+
},
|
|
217
|
+
oauth: {
|
|
218
|
+
label: t('team.member.connectedAccounts'),
|
|
219
|
+
value: 'oauth',
|
|
220
|
+
component: () => /*#__PURE__*/_jsx(TabOAuth, {
|
|
221
|
+
user: pageState.user,
|
|
222
|
+
onChangeUser: handleChangeUser
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
passports: {
|
|
226
|
+
label: t('common.passport'),
|
|
227
|
+
value: 'passports',
|
|
228
|
+
component: () => /*#__PURE__*/_jsx(Passports, {
|
|
229
|
+
user: pageState.user,
|
|
230
|
+
teamDid: teamDid,
|
|
231
|
+
roles: roles,
|
|
232
|
+
createPassportSvg: createPassportSvg,
|
|
233
|
+
onCreate: () => {
|
|
234
|
+
getData(teamDid, userDid).then(() => {
|
|
235
|
+
// oauth 账户邀请后,不会产生待领取的邀请链接
|
|
236
|
+
// 当没有邀请链接的情况下,当前 tab 激活应当保持现状不变
|
|
237
|
+
if (enablePassportIssuance && pageState.issuances && !!pageState.issuances.length) {
|
|
238
|
+
pageState.tab = 'issuances';
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
onRefresh: () => {
|
|
243
|
+
getData(teamDid, userDid);
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
},
|
|
247
|
+
issuances: {
|
|
248
|
+
label: t('team.passport.issuance.pending'),
|
|
249
|
+
value: 'issuances',
|
|
250
|
+
component: () => /*#__PURE__*/_jsx(PassportIssuances, {
|
|
251
|
+
issuances: pageState.issuances || [],
|
|
252
|
+
teamDid: teamDid,
|
|
253
|
+
onRefresh: () => getData(teamDid, userDid)
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const tabs = Object.values(tabConfigs).map(({
|
|
258
|
+
label,
|
|
259
|
+
value
|
|
260
|
+
}) => ({
|
|
261
|
+
label,
|
|
262
|
+
value
|
|
263
|
+
})).filter(x => {
|
|
264
|
+
if (x.value === 'issuances') {
|
|
265
|
+
return enablePassportIssuance && pageState.issuances && !!pageState.issuances.length;
|
|
266
|
+
}
|
|
267
|
+
if (x.value === 'oauth') {
|
|
268
|
+
const connectedAccounts = pageState.user?.connectedAccounts || [];
|
|
269
|
+
return connectedAccounts.find(item => item.provider !== (pageState.user?.sourceProvider || LOGIN_PROVIDER.WALLET));
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
});
|
|
273
|
+
const tabConfig = tabConfigs[pageState.tab] || tabConfigs.info;
|
|
274
|
+
const onTabChange = newTab => {
|
|
275
|
+
pageState.tab = newTab;
|
|
276
|
+
};
|
|
277
|
+
return /*#__PURE__*/_jsx(Dialog, {
|
|
278
|
+
title: t('common.member'),
|
|
279
|
+
onClose: onCancel,
|
|
280
|
+
open: true,
|
|
281
|
+
PaperProps: {
|
|
282
|
+
style: {
|
|
283
|
+
maxWidth: 632,
|
|
284
|
+
minHeight: '80vh'
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
fullWidth: true,
|
|
288
|
+
actions: pageState.user && /*#__PURE__*/_jsx(Permission, {
|
|
289
|
+
permission: inService ? '' : 'mutate_team',
|
|
290
|
+
role: inService ? BlockletAdminRoles : [],
|
|
291
|
+
children: /*#__PURE__*/_jsx(ToggleUserApproval, {
|
|
292
|
+
user: pageState.user,
|
|
293
|
+
children: ({
|
|
294
|
+
open
|
|
295
|
+
}) => /*#__PURE__*/_jsxs(BlockButton, {
|
|
296
|
+
onClick: open,
|
|
297
|
+
children: [pageState.user.approved ? /*#__PURE__*/_jsx(ForbidLoginIcon, {
|
|
298
|
+
style: {
|
|
299
|
+
fontSize: '1.2em',
|
|
300
|
+
marginRight: '0.4em'
|
|
301
|
+
}
|
|
302
|
+
}) : /*#__PURE__*/_jsx(AllowLoginIcon, {
|
|
303
|
+
style: {
|
|
304
|
+
fontSize: '1.2em',
|
|
305
|
+
marginRight: '0.4em'
|
|
306
|
+
}
|
|
307
|
+
}), pageState.user.approved ? t('team.member.forbidLogin') : t('team.member.allowLogin')]
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
}),
|
|
311
|
+
children: /*#__PURE__*/_jsxs(Div, {
|
|
312
|
+
children: [!pageState.user && /*#__PURE__*/_jsx(Center, {
|
|
313
|
+
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
314
|
+
}), pageState.user && /*#__PURE__*/_jsxs("div", {
|
|
315
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
316
|
+
display: "flex",
|
|
317
|
+
alignItems: "center",
|
|
318
|
+
className: "info",
|
|
319
|
+
children: [/*#__PURE__*/_jsx(Avatar, {
|
|
320
|
+
src: pageState.user.avatar,
|
|
321
|
+
style: {
|
|
322
|
+
width: 48,
|
|
323
|
+
height: 48,
|
|
324
|
+
backgroundColor: 'transparent',
|
|
325
|
+
marginRight: 16
|
|
326
|
+
}
|
|
327
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
328
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
329
|
+
className: "name",
|
|
330
|
+
children: pageState.user.fullName
|
|
331
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
332
|
+
className: "did",
|
|
333
|
+
mt: 1,
|
|
334
|
+
children: /*#__PURE__*/_jsx(DidAddress, {
|
|
335
|
+
did: pageState.user.did
|
|
336
|
+
})
|
|
337
|
+
})]
|
|
338
|
+
})]
|
|
339
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
340
|
+
mx: 3,
|
|
341
|
+
className: "tabs",
|
|
342
|
+
children: /*#__PURE__*/_jsx(Tabs, {
|
|
343
|
+
tabs: tabs,
|
|
344
|
+
current: pageState.tab,
|
|
345
|
+
onChange: onTabChange,
|
|
346
|
+
scrollButtons: "auto"
|
|
347
|
+
})
|
|
348
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
349
|
+
className: "body",
|
|
350
|
+
children: /*#__PURE__*/_jsx(tabConfig.component, {})
|
|
351
|
+
})]
|
|
352
|
+
})]
|
|
353
|
+
})
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
Member.propTypes = {
|
|
357
|
+
userDid: PropTypes.string.isRequired,
|
|
358
|
+
onCancel: PropTypes.func.isRequired,
|
|
359
|
+
createPassportSvg: PropTypes.func.isRequired,
|
|
360
|
+
initTab: PropTypes.string
|
|
361
|
+
};
|
|
362
|
+
Member.defaultProps = {
|
|
363
|
+
initTab: defaultTab
|
|
364
|
+
};
|
|
365
|
+
const Div = styled.div`
|
|
366
|
+
.info {
|
|
367
|
+
.name {
|
|
368
|
+
font-weight: 400;
|
|
369
|
+
font-size: 18px;
|
|
370
|
+
line-height: 25px;
|
|
371
|
+
color: #222222;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.tabs {
|
|
376
|
+
margin-top: 24px;
|
|
377
|
+
margin-left: 0;
|
|
378
|
+
margin-right: 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.body {
|
|
382
|
+
margin-top: 24px;
|
|
383
|
+
}
|
|
384
|
+
`;
|
|
385
|
+
const Center = styled.div`
|
|
386
|
+
flex: 1;
|
|
387
|
+
display: flex;
|
|
388
|
+
justify-content: center;
|
|
389
|
+
align-items: center;
|
|
390
|
+
height: 200px;
|
|
391
|
+
`;
|
|
392
|
+
const BlockButton = styled.div`
|
|
393
|
+
flex-shrink: 0;
|
|
394
|
+
width: 100%;
|
|
395
|
+
height: 64px;
|
|
396
|
+
display: flex;
|
|
397
|
+
justify-content: center;
|
|
398
|
+
align-items: center;
|
|
399
|
+
cursor: pointer;
|
|
400
|
+
color: #999;
|
|
401
|
+
fill: #999;
|
|
402
|
+
font-size: 16px;
|
|
403
|
+
border-top: 1px solid #f0f0f0;
|
|
404
|
+
position: sticky;
|
|
405
|
+
bottom: 0;
|
|
406
|
+
background: #fff;
|
|
407
|
+
z-index: 10;
|
|
408
|
+
`;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
|
+
import { useNodeContext } from '../../contexts/node';
|
|
9
|
+
import { useTeamContext } from '../../contexts/team';
|
|
10
|
+
import Confirm from '../../confirm';
|
|
11
|
+
import Permission from '../../permission';
|
|
12
|
+
import ClickToCopy from '../../click-to-copy';
|
|
13
|
+
import PassportTag from '../../passport-tag';
|
|
14
|
+
import { getIssuePassportLink, formatToDatetime, BlockletAdminRoles } from '../../util';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
export default function PassportIssuances({
|
|
18
|
+
issuances,
|
|
19
|
+
teamDid,
|
|
20
|
+
onRefresh
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
api: client,
|
|
24
|
+
inService
|
|
25
|
+
} = useNodeContext();
|
|
26
|
+
const {
|
|
27
|
+
t,
|
|
28
|
+
locale
|
|
29
|
+
} = useContext(LocaleContext);
|
|
30
|
+
const [delConfirm, setDelConfirm] = useState(null);
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
const {
|
|
33
|
+
endpoint
|
|
34
|
+
} = useTeamContext();
|
|
35
|
+
const deleteIssuance = async ({
|
|
36
|
+
id
|
|
37
|
+
}) => {
|
|
38
|
+
if (loading) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setLoading(true);
|
|
42
|
+
try {
|
|
43
|
+
await client.deletePassportIssuance({
|
|
44
|
+
input: {
|
|
45
|
+
teamDid,
|
|
46
|
+
sessionId: id
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
onRefresh();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
Toast.error(error.message);
|
|
52
|
+
} finally {
|
|
53
|
+
setLoading(false);
|
|
54
|
+
setDelConfirm(null);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onCancel = () => {
|
|
58
|
+
setLoading(false);
|
|
59
|
+
setDelConfirm(null);
|
|
60
|
+
};
|
|
61
|
+
const getLink = column => endpoint ? getIssuePassportLink({
|
|
62
|
+
id: column.id,
|
|
63
|
+
endpoint
|
|
64
|
+
}) : '';
|
|
65
|
+
|
|
66
|
+
// eslint-disable-next-line react/prop-types
|
|
67
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
68
|
+
function Issuance({
|
|
69
|
+
data: d
|
|
70
|
+
}) {
|
|
71
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
72
|
+
className: "issuance",
|
|
73
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
74
|
+
display: "flex",
|
|
75
|
+
justifyContent: "space-between",
|
|
76
|
+
children: [/*#__PURE__*/_jsx(Permission, {
|
|
77
|
+
permission: inService ? '' : 'mutate_team',
|
|
78
|
+
role: inService ? BlockletAdminRoles : [],
|
|
79
|
+
children: can => can ? /*#__PURE__*/_jsx(PassportTag, {
|
|
80
|
+
passport: {
|
|
81
|
+
title: d.title,
|
|
82
|
+
name: d.name
|
|
83
|
+
},
|
|
84
|
+
onDelete: () => setDelConfirm({
|
|
85
|
+
title: t('team.passport.issuance.delete.title'),
|
|
86
|
+
description: t('team.passport.issuance.delete.description', {
|
|
87
|
+
link: getLink(d)
|
|
88
|
+
}),
|
|
89
|
+
confirm: t('common.delConfirm'),
|
|
90
|
+
cancel: t('common.cancel'),
|
|
91
|
+
onConfirm: () => {
|
|
92
|
+
deleteIssuance(d);
|
|
93
|
+
},
|
|
94
|
+
onCancel
|
|
95
|
+
})
|
|
96
|
+
}) : /*#__PURE__*/_jsx(PassportTag, {
|
|
97
|
+
passport: {
|
|
98
|
+
title: d.title,
|
|
99
|
+
name: d.name
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
103
|
+
style: {
|
|
104
|
+
color: '#999'
|
|
105
|
+
},
|
|
106
|
+
children: [t('common.expires'), ":\xA0", formatToDatetime(d.expireDate, locale)]
|
|
107
|
+
})]
|
|
108
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
109
|
+
mt: 2,
|
|
110
|
+
children: /*#__PURE__*/_jsx(ClickToCopy, {
|
|
111
|
+
children: getLink(d)
|
|
112
|
+
})
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return /*#__PURE__*/_jsxs(Div, {
|
|
117
|
+
children: [issuances.map(x => /*#__PURE__*/_jsx(Issuance, {
|
|
118
|
+
data: x
|
|
119
|
+
})), delConfirm && /*#__PURE__*/_jsx(Confirm, {
|
|
120
|
+
title: delConfirm.title,
|
|
121
|
+
description: delConfirm.description,
|
|
122
|
+
confirm: delConfirm.confirm,
|
|
123
|
+
cancel: delConfirm.cancel,
|
|
124
|
+
params: delConfirm.params,
|
|
125
|
+
onConfirm: delConfirm.onConfirm,
|
|
126
|
+
onCancel: delConfirm.onCancel
|
|
127
|
+
})]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const Div = styled.div`
|
|
131
|
+
.MuiTableHead-root {
|
|
132
|
+
display: none;
|
|
133
|
+
}
|
|
134
|
+
.issuance {
|
|
135
|
+
padding: 16px 0;
|
|
136
|
+
border-bottom: 1px solid #f0f0f0;
|
|
137
|
+
.MuiTypography-root {
|
|
138
|
+
display: inline-block;
|
|
139
|
+
width: 100%;
|
|
140
|
+
background: #f3f3f3;
|
|
141
|
+
border-radius: 4px;
|
|
142
|
+
padding-top: 6px;
|
|
143
|
+
padding-bottom: 6px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
PassportIssuances.propTypes = {
|
|
148
|
+
teamDid: PropTypes.string.isRequired,
|
|
149
|
+
issuances: PropTypes.array,
|
|
150
|
+
onRefresh: PropTypes.func
|
|
151
|
+
};
|
|
152
|
+
PassportIssuances.defaultProps = {
|
|
153
|
+
issuances: [],
|
|
154
|
+
onRefresh: () => {}
|
|
155
|
+
};
|