@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b
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 +1308 -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/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 +373 -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 +144 -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 +1534 -0
- package/es/locales/index.js +9 -0
- package/es/locales/zh.js +1537 -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 +54 -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 +126 -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 +151 -0
- package/es/who-can-access/config.js +38 -0
- package/es/wrap-locale.js +15 -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 +1 -1
- 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/invitation/invitation-receive.js +1 -1
- package/lib/team/passports/trusted-factory.js +1 -1
- package/package.json +81 -18
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import get from 'lodash/get';
|
|
6
|
+
import upperFirst from 'lodash/upperFirst';
|
|
7
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
8
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
9
|
+
import Box from '@mui/material/Box';
|
|
10
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
11
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
12
|
+
import { getWalletDid } from '@blocklet/meta/lib/did-utils';
|
|
13
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
14
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
15
|
+
import RevokeIcon from '@arcblock/icons/lib/RevokeIcon';
|
|
16
|
+
import ExternalIssuerIcon from '@arcblock/icons/lib/ExternalIssuerIcon';
|
|
17
|
+
import Empty from '@arcblock/ux/lib/Empty';
|
|
18
|
+
import { PASSPORT_STATUS } from '@abtnode/constant';
|
|
19
|
+
import { useNodeContext } from '../../contexts/node';
|
|
20
|
+
import { useSessionContext } from '../../contexts/session';
|
|
21
|
+
import { useTeamContext } from '../../contexts/team';
|
|
22
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
23
|
+
import { formatError, BlockletAdminRoles } from '../../util';
|
|
24
|
+
import Confirm from '../../confirm';
|
|
25
|
+
import Permission from '../../permission';
|
|
26
|
+
import SearchInput from '../search-input';
|
|
27
|
+
import ListHeader from '../styles/list-header';
|
|
28
|
+
import IssuePassport from './issue-passport';
|
|
29
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
|
+
function ConfirmDescription({
|
|
32
|
+
action,
|
|
33
|
+
passport
|
|
34
|
+
}) {
|
|
35
|
+
const {
|
|
36
|
+
t
|
|
37
|
+
} = useLocaleContext();
|
|
38
|
+
const {
|
|
39
|
+
roles
|
|
40
|
+
} = useTeamContext();
|
|
41
|
+
const role = roles.find(x => x.name === passport.role);
|
|
42
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
43
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
44
|
+
children: action === 'enable' ? t('team.member.enablePassportDescription') : t('team.member.revokePassportDescription')
|
|
45
|
+
}), role && /*#__PURE__*/_jsx(Box, {
|
|
46
|
+
mt: 3,
|
|
47
|
+
fontWeight: "bold",
|
|
48
|
+
children: t('team.member.passportPermissionTitle')
|
|
49
|
+
}), role && /*#__PURE__*/_jsx(Box, {
|
|
50
|
+
mt: 1,
|
|
51
|
+
children: role.description
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
ConfirmDescription.propTypes = {
|
|
56
|
+
action: PropTypes.string.isRequired,
|
|
57
|
+
passport: PropTypes.object.isRequired
|
|
58
|
+
};
|
|
59
|
+
ConfirmDescription.defaultProps = {};
|
|
60
|
+
export default function Passports({
|
|
61
|
+
user,
|
|
62
|
+
onCreate,
|
|
63
|
+
createPassportSvg
|
|
64
|
+
}) {
|
|
65
|
+
const {
|
|
66
|
+
t
|
|
67
|
+
} = useLocaleContext();
|
|
68
|
+
const {
|
|
69
|
+
session
|
|
70
|
+
} = useSessionContext();
|
|
71
|
+
const {
|
|
72
|
+
roles,
|
|
73
|
+
teamDid,
|
|
74
|
+
teamIssuerDid,
|
|
75
|
+
refresh: refreshTeam,
|
|
76
|
+
enablePassportIssuance,
|
|
77
|
+
trustedPassports,
|
|
78
|
+
passportColor,
|
|
79
|
+
blocklet
|
|
80
|
+
} = useTeamContext();
|
|
81
|
+
const {
|
|
82
|
+
appIdList: idList
|
|
83
|
+
} = useBlockletContext();
|
|
84
|
+
const {
|
|
85
|
+
api,
|
|
86
|
+
inService
|
|
87
|
+
} = useNodeContext();
|
|
88
|
+
const [loading, setLoading] = useState(false);
|
|
89
|
+
const [toggleConfirm, setToggleConfirm] = useState(null);
|
|
90
|
+
const [showIssueDialog, setShowIssueDialog] = useState(false);
|
|
91
|
+
const [search, setSearch] = useState('');
|
|
92
|
+
const appIdList = [teamIssuerDid, ...(idList || [])].filter(Boolean);
|
|
93
|
+
const passports = (get(user, 'passports') || []).map(x => ({
|
|
94
|
+
...x,
|
|
95
|
+
revoked: x.status === PASSPORT_STATUS.REVOKED
|
|
96
|
+
}));
|
|
97
|
+
const togglePassportStatus = async passport => {
|
|
98
|
+
if (loading) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
setLoading(true);
|
|
102
|
+
try {
|
|
103
|
+
const method = passport.status === PASSPORT_STATUS.REVOKED ? 'enableUserPassport' : 'revokeUserPassport';
|
|
104
|
+
await api[method]({
|
|
105
|
+
input: {
|
|
106
|
+
teamDid,
|
|
107
|
+
userDid: user.did,
|
|
108
|
+
passportId: passport.id
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
refreshTeam();
|
|
112
|
+
} catch (err) {
|
|
113
|
+
Toast.error(formatError(err));
|
|
114
|
+
} finally {
|
|
115
|
+
setLoading(false);
|
|
116
|
+
setToggleConfirm(null);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const confirmToggle = item => item.status === PASSPORT_STATUS.REVOKED ? setToggleConfirm({
|
|
120
|
+
title: t('team.member.enablePassport'),
|
|
121
|
+
description: /*#__PURE__*/_jsx(ConfirmDescription, {
|
|
122
|
+
action: "enable",
|
|
123
|
+
passport: item
|
|
124
|
+
}),
|
|
125
|
+
confirm: t('common.enable'),
|
|
126
|
+
cancel: t('common.cancel'),
|
|
127
|
+
onConfirm: () => {
|
|
128
|
+
togglePassportStatus(item);
|
|
129
|
+
},
|
|
130
|
+
onCancel: () => {
|
|
131
|
+
setLoading(false);
|
|
132
|
+
setToggleConfirm(null);
|
|
133
|
+
},
|
|
134
|
+
color: 'primary'
|
|
135
|
+
}) : setToggleConfirm({
|
|
136
|
+
title: t('team.member.revokePassport'),
|
|
137
|
+
description: /*#__PURE__*/_jsx(ConfirmDescription, {
|
|
138
|
+
action: "revoke",
|
|
139
|
+
passport: item
|
|
140
|
+
}),
|
|
141
|
+
confirm: t('common.revoke'),
|
|
142
|
+
cancel: t('common.cancel'),
|
|
143
|
+
onConfirm: () => {
|
|
144
|
+
togglePassportStatus(item);
|
|
145
|
+
},
|
|
146
|
+
onCancel: () => {
|
|
147
|
+
setLoading(false);
|
|
148
|
+
setToggleConfirm(null);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const revokeInfo = (hasPermission, passport) => {
|
|
152
|
+
if (user.did === session.user.did && session.user.passportId && session.user.passportId === passport.id) {
|
|
153
|
+
return {
|
|
154
|
+
revokable: false,
|
|
155
|
+
message: t('team.passport.shouldNotDeleteCurrent')
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (!hasPermission) {
|
|
159
|
+
return {
|
|
160
|
+
revokable: false,
|
|
161
|
+
message: t('team.passport.noPermission')
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (teamDid === passport.issuer.id && passport.name === 'owner') {
|
|
165
|
+
return {
|
|
166
|
+
revokable: false,
|
|
167
|
+
message: t('team.passport.noPermission')
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
revokable: true
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const filteredPassports = passports.filter(x => !search || x.title.includes(search) || x.name.includes(search));
|
|
175
|
+
return /*#__PURE__*/_jsxs(Div, {
|
|
176
|
+
children: [/*#__PURE__*/_jsxs(ListHeader, {
|
|
177
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
178
|
+
className: "left",
|
|
179
|
+
children: /*#__PURE__*/_jsx(SearchInput, {
|
|
180
|
+
placeholder: t('team.passport.search'),
|
|
181
|
+
value: search,
|
|
182
|
+
onChange: e => setSearch(e.target.value)
|
|
183
|
+
})
|
|
184
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
185
|
+
className: "right",
|
|
186
|
+
children: enablePassportIssuance && !!user.approved && /*#__PURE__*/_jsx(Permission, {
|
|
187
|
+
permission: inService ? '' : 'mutate_team',
|
|
188
|
+
role: inService ? BlockletAdminRoles : [],
|
|
189
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
190
|
+
variant: "contained",
|
|
191
|
+
color: "primary",
|
|
192
|
+
"data-cy": "issue-passport",
|
|
193
|
+
onClick: () => setShowIssueDialog(true),
|
|
194
|
+
children: [/*#__PURE__*/_jsx(AddIcon, {
|
|
195
|
+
style: {
|
|
196
|
+
fontSize: 16,
|
|
197
|
+
marginRight: 4
|
|
198
|
+
}
|
|
199
|
+
}), t('team.passport.issue')]
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})]
|
|
203
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
204
|
+
children: [filteredPassports.map(x => /*#__PURE__*/_jsx(Permission, {
|
|
205
|
+
permission: inService ? '' : 'mutate_team',
|
|
206
|
+
role: inService ? BlockletAdminRoles : [],
|
|
207
|
+
children: can => /*#__PURE__*/_jsxs(Box, {
|
|
208
|
+
className: "passport-item",
|
|
209
|
+
display: "flex",
|
|
210
|
+
justifyContent: "space-between",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
mt: 3,
|
|
213
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
214
|
+
display: "flex",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
217
|
+
// eslint-disable-next-line react/no-danger
|
|
218
|
+
dangerouslySetInnerHTML: {
|
|
219
|
+
__html: createPassportSvg({
|
|
220
|
+
title: x.title || x.name,
|
|
221
|
+
issuer: x.issuer && x.issuer.name,
|
|
222
|
+
issuerDid: x.issuer && x.issuer.id,
|
|
223
|
+
ownerName: user.fullName,
|
|
224
|
+
ownerDid: user.did,
|
|
225
|
+
ownerAvatarUrl: user.avatar,
|
|
226
|
+
revoked: x.revoked,
|
|
227
|
+
preferredColor: passportColor,
|
|
228
|
+
width: '150px'
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
232
|
+
className: "body",
|
|
233
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
234
|
+
className: "title",
|
|
235
|
+
display: "flex",
|
|
236
|
+
alignItems: "center",
|
|
237
|
+
children: [upperFirst(x.title), /*#__PURE__*/_jsxs("div", {
|
|
238
|
+
className: "status-icons",
|
|
239
|
+
children: [!!appIdList.length && !appIdList.includes(x.issuer.id) && /*#__PURE__*/_jsx(ExternalIssuerIcon, {}), x.revoked && /*#__PURE__*/_jsx(RevokeIcon, {})]
|
|
240
|
+
})]
|
|
241
|
+
}), x.expirationDate && /*#__PURE__*/_jsx(Box, {
|
|
242
|
+
className: "title",
|
|
243
|
+
display: "flex",
|
|
244
|
+
alignItems: "center",
|
|
245
|
+
children: t('team.passport.validUntil', {
|
|
246
|
+
date: x.expirationDate
|
|
247
|
+
})
|
|
248
|
+
}), !!appIdList.length && !appIdList.includes(x.issuer.id) && /*#__PURE__*/_jsxs("div", {
|
|
249
|
+
className: "tip",
|
|
250
|
+
children: [x.issuer.id !== teamIssuerDid && !trustedPassports.some(y => y.issuerDid === x.issuer.id) && /*#__PURE__*/_jsx(Tooltip, {
|
|
251
|
+
title: t('team.passport.notTrustedIssuerTip'),
|
|
252
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
253
|
+
component: ErrorOutlineIcon,
|
|
254
|
+
style: {
|
|
255
|
+
fontSize: '1.3em'
|
|
256
|
+
},
|
|
257
|
+
color: "error.main",
|
|
258
|
+
mr: 0.5
|
|
259
|
+
})
|
|
260
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
261
|
+
children: t('team.passport.issueBy', {
|
|
262
|
+
name: x.issuer.name
|
|
263
|
+
})
|
|
264
|
+
})]
|
|
265
|
+
})]
|
|
266
|
+
})]
|
|
267
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
268
|
+
children: revokeInfo(can, x).revokable ? /*#__PURE__*/_jsxs(Button, {
|
|
269
|
+
variant: "outlined",
|
|
270
|
+
color: x.revoked ? 'primary' : 'secondary',
|
|
271
|
+
onClick: () => confirmToggle(x),
|
|
272
|
+
children: [x.revoked ? /*#__PURE__*/_jsx(AddIcon, {
|
|
273
|
+
style: {
|
|
274
|
+
fontSize: 16,
|
|
275
|
+
marginRight: 4
|
|
276
|
+
}
|
|
277
|
+
}) : /*#__PURE__*/_jsx(RevokeIcon, {
|
|
278
|
+
style: {
|
|
279
|
+
height: 16,
|
|
280
|
+
marginRight: 4
|
|
281
|
+
}
|
|
282
|
+
}), x.revoked ? t('common.enable') : t('common.revoke')]
|
|
283
|
+
}) : /*#__PURE__*/_jsx(Tooltip, {
|
|
284
|
+
title: revokeInfo(can, x).message,
|
|
285
|
+
children: /*#__PURE__*/_jsx(ErrorOutlineIcon, {
|
|
286
|
+
style: {
|
|
287
|
+
color: '#ddd'
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
})
|
|
291
|
+
})]
|
|
292
|
+
})
|
|
293
|
+
}, x.id)), !filteredPassports.length && /*#__PURE__*/_jsx(Empty, {
|
|
294
|
+
children: t('common.empty')
|
|
295
|
+
})]
|
|
296
|
+
}), showIssueDialog && /*#__PURE__*/_jsx(IssuePassport, {
|
|
297
|
+
teamDid: teamDid,
|
|
298
|
+
ownerDid: user.did,
|
|
299
|
+
needReceive: getWalletDid(user) === user.did,
|
|
300
|
+
roles: roles,
|
|
301
|
+
onCancel: () => setShowIssueDialog(false),
|
|
302
|
+
onSuccess: () => {
|
|
303
|
+
onCreate();
|
|
304
|
+
setShowIssueDialog(false);
|
|
305
|
+
},
|
|
306
|
+
showOwnerPassport: blocklet && !blocklet.settings?.owner
|
|
307
|
+
}), toggleConfirm && /*#__PURE__*/_jsx(Confirm, {
|
|
308
|
+
title: toggleConfirm.title,
|
|
309
|
+
description: toggleConfirm.description,
|
|
310
|
+
confirm: toggleConfirm.confirm,
|
|
311
|
+
cancel: toggleConfirm.cancel,
|
|
312
|
+
params: toggleConfirm.params,
|
|
313
|
+
onConfirm: toggleConfirm.onConfirm,
|
|
314
|
+
onCancel: toggleConfirm.onCancel,
|
|
315
|
+
color: toggleConfirm.color
|
|
316
|
+
})]
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
Passports.propTypes = {
|
|
320
|
+
user: PropTypes.object.isRequired,
|
|
321
|
+
createPassportSvg: PropTypes.func.isRequired,
|
|
322
|
+
onCreate: PropTypes.func
|
|
323
|
+
};
|
|
324
|
+
Passports.defaultProps = {
|
|
325
|
+
onCreate: () => {}
|
|
326
|
+
};
|
|
327
|
+
const Div = styled.div`
|
|
328
|
+
.passport-item {
|
|
329
|
+
.body {
|
|
330
|
+
padding: 0;
|
|
331
|
+
margin-left: 24px;
|
|
332
|
+
margin-top: 0;
|
|
333
|
+
}
|
|
334
|
+
.title {
|
|
335
|
+
font-weight: 400;
|
|
336
|
+
font-size: 16px;
|
|
337
|
+
line-height: 19px;
|
|
338
|
+
color: #222222;
|
|
339
|
+
}
|
|
340
|
+
.tip {
|
|
341
|
+
display: flex;
|
|
342
|
+
align-items: center;
|
|
343
|
+
font-size: 14px;
|
|
344
|
+
margin-top: 6px;
|
|
345
|
+
color: #bbb;
|
|
346
|
+
}
|
|
347
|
+
.status-icons {
|
|
348
|
+
svg {
|
|
349
|
+
fill: #bfbfbf;
|
|
350
|
+
height: 1.2em;
|
|
351
|
+
margin-left: 0.4em;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
.MuiButton-outlinedSecondary {
|
|
355
|
+
color: #f16e6e;
|
|
356
|
+
fill: #f16e6e;
|
|
357
|
+
background: #fcf3f3;
|
|
358
|
+
border: 0;
|
|
359
|
+
&:hover {
|
|
360
|
+
border: 0;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
5
|
+
import Confirm from '../../confirm';
|
|
6
|
+
import { useNodeContext } from '../../contexts/node';
|
|
7
|
+
import { useTeamContext } from '../../contexts/team';
|
|
8
|
+
import { useSessionContext } from '../../contexts/session';
|
|
9
|
+
import { formatError } from '../../util';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const isNodeOwner = (nodeInfo, userDid) => nodeInfo.nodeOwner && nodeInfo.nodeOwner.did === userDid;
|
|
14
|
+
const isSelf = (sessionUser, userDid) => sessionUser && sessionUser.did === userDid;
|
|
15
|
+
export default function ToggleUserApproval({
|
|
16
|
+
user,
|
|
17
|
+
onCancel,
|
|
18
|
+
onSuccess,
|
|
19
|
+
onError,
|
|
20
|
+
children
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
api,
|
|
24
|
+
info: nodeInfo,
|
|
25
|
+
inService
|
|
26
|
+
} = useNodeContext();
|
|
27
|
+
const {
|
|
28
|
+
session
|
|
29
|
+
} = useSessionContext();
|
|
30
|
+
const {
|
|
31
|
+
teamDid,
|
|
32
|
+
refresh
|
|
33
|
+
} = useTeamContext();
|
|
34
|
+
const {
|
|
35
|
+
t
|
|
36
|
+
} = useLocaleContext();
|
|
37
|
+
const [loading, setLoading] = useState(false);
|
|
38
|
+
const [show, setShow] = useState(false);
|
|
39
|
+
const open = () => setShow(true);
|
|
40
|
+
const updateUserApproval = async d => {
|
|
41
|
+
const {
|
|
42
|
+
did,
|
|
43
|
+
approved
|
|
44
|
+
} = d;
|
|
45
|
+
if (loading) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setLoading(true);
|
|
49
|
+
try {
|
|
50
|
+
await api.updateUserApproval({
|
|
51
|
+
input: {
|
|
52
|
+
teamDid,
|
|
53
|
+
user: {
|
|
54
|
+
did,
|
|
55
|
+
approved: !approved
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
setShow(false);
|
|
60
|
+
onSuccess();
|
|
61
|
+
refresh();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
Toast.error(formatError(error));
|
|
64
|
+
onError();
|
|
65
|
+
} finally {
|
|
66
|
+
setLoading(false);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const approveConfirm = {
|
|
70
|
+
title: user.approved ? t('team.member.forbidLogin') : t('team.member.allowLogin'),
|
|
71
|
+
description: user.approved ? t('team.member.forbidLoginDescription') : t('team.member.allowLoginDescription'),
|
|
72
|
+
confirm: t('common.confirm'),
|
|
73
|
+
cancel: t('common.cancel'),
|
|
74
|
+
onConfirm: () => {
|
|
75
|
+
updateUserApproval(user);
|
|
76
|
+
},
|
|
77
|
+
onCancel: () => {
|
|
78
|
+
setLoading(false);
|
|
79
|
+
setShow(false);
|
|
80
|
+
onCancel();
|
|
81
|
+
},
|
|
82
|
+
color: user.approved ? 'error' : 'primary'
|
|
83
|
+
};
|
|
84
|
+
let can;
|
|
85
|
+
if (!inService) {
|
|
86
|
+
can = nodeInfo.nodeOwner && !isNodeOwner(nodeInfo, user.did) && !isSelf(session.user, user.did);
|
|
87
|
+
} else {
|
|
88
|
+
can = !isSelf(session.user, user.did);
|
|
89
|
+
}
|
|
90
|
+
if (!can) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
94
|
+
children: [typeof children === 'function' ? children({
|
|
95
|
+
can,
|
|
96
|
+
open
|
|
97
|
+
}) : children, show ? /*#__PURE__*/_jsx(Confirm, {
|
|
98
|
+
title: approveConfirm.title,
|
|
99
|
+
description: approveConfirm.description,
|
|
100
|
+
confirm: approveConfirm.confirm,
|
|
101
|
+
cancel: approveConfirm.cancel,
|
|
102
|
+
params: approveConfirm.params,
|
|
103
|
+
onConfirm: approveConfirm.onConfirm,
|
|
104
|
+
onCancel: approveConfirm.onCancel,
|
|
105
|
+
color: approveConfirm.color
|
|
106
|
+
}) : null]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
ToggleUserApproval.propTypes = {
|
|
110
|
+
user: PropTypes.object,
|
|
111
|
+
onSuccess: PropTypes.func,
|
|
112
|
+
onCancel: PropTypes.func,
|
|
113
|
+
onError: PropTypes.func,
|
|
114
|
+
children: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
|
115
|
+
};
|
|
116
|
+
ToggleUserApproval.defaultProps = {
|
|
117
|
+
user: {},
|
|
118
|
+
onSuccess: () => {},
|
|
119
|
+
onCancel: () => {},
|
|
120
|
+
onError: () => {},
|
|
121
|
+
children: null
|
|
122
|
+
};
|