@abtnode/ux 1.8.26 → 1.8.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions.js +109 -0
- package/lib/blocklet/actions.js +437 -0
- package/lib/blocklet/audit-logs.js +194 -0
- package/lib/blocklet/avatar.js +96 -0
- package/lib/blocklet/blocklet-source.js +56 -0
- package/lib/blocklet/component/configuration.js +124 -0
- package/lib/blocklet/component/delete.js +115 -0
- package/lib/blocklet/component/environment.js +277 -0
- package/lib/blocklet/component/index.js +742 -0
- package/lib/blocklet/component/setting.js +135 -0
- package/lib/blocklet/configuration.js +463 -0
- package/lib/blocklet/disk-info.js +89 -0
- package/lib/blocklet/icons.js +26 -0
- package/lib/blocklet/log.js +55 -0
- package/lib/blocklet/mode.js +33 -0
- package/lib/blocklet/overview.js +184 -0
- package/lib/blocklet/runtime-info.js +85 -0
- package/lib/blocklet/status.js +103 -0
- package/lib/blocklet/util.js +119 -0
- package/lib/blocklet/version.js +178 -0
- package/lib/card-selector.js +9 -22
- package/lib/click-to-copy.js +36 -0
- package/lib/confirm.js +149 -0
- package/lib/contexts/audit-log.js +141 -0
- package/lib/contexts/deleting-blocklets.js +78 -0
- package/lib/contexts/node.js +28 -0
- package/lib/contexts/session.js +20 -0
- package/lib/contexts/team.js +19 -0
- package/lib/did-address.js +75 -0
- package/lib/dot.js +18 -0
- package/lib/form/form-text-input.js +12 -38
- package/lib/form/form-wrapper.js +0 -7
- package/lib/form/required.js +0 -6
- package/lib/hooks/mobile-width.js +19 -0
- package/lib/hooks/use-passport-id.js +0 -5
- package/lib/icons/long-arrow.svg +5 -0
- package/lib/index.js +0 -3
- package/lib/invitation/invitation-app.js +3 -21
- package/lib/invitation/invitation-passport.js +2 -16
- package/lib/invitation/invitation-receive.js +2 -19
- package/lib/invitation/invitation-user.js +0 -16
- package/lib/invitation/invitation.js +0 -23
- package/lib/issue-passport.js +2 -31
- package/lib/launch-blocklet/content-layout.js +3 -19
- package/lib/launch-blocklet/page-header.js +0 -9
- package/lib/layout/addon.js +0 -24
- package/lib/locales/en.js +1046 -38
- package/lib/locales/index.js +0 -3
- package/lib/locales/zh.js +1049 -36
- package/lib/logs/clock.js +19 -0
- package/lib/logs/log-terminal.js +172 -0
- package/lib/lost-passport.js +6 -51
- package/lib/nav-logo.js +12 -33
- package/lib/passport-tag.js +41 -0
- package/lib/permission.js +68 -0
- package/lib/relative-time.js +61 -0
- package/lib/schema-form/color-input.js +2 -15
- package/lib/schema-form/common-prop-types.js +0 -3
- package/lib/schema-form/index.js +8 -45
- package/lib/schema-form/passport-input.js +6 -24
- package/lib/schema-form/text-input.js +9 -26
- package/lib/table-icons.js +42 -0
- package/lib/table.js +13 -0
- package/lib/tag.js +35 -0
- package/lib/team/members/actions.js +99 -0
- package/lib/team/members/index.js +476 -0
- package/lib/team/members/invitations.js +196 -0
- package/lib/team/members/invite-member.js +212 -0
- package/lib/team/members/issue-passport.js +155 -0
- package/lib/team/members/member.js +294 -0
- package/lib/team/members/passport-issuances.js +154 -0
- package/lib/team/members/passports.js +329 -0
- package/lib/team/members/toggle-user-approval.js +128 -0
- package/lib/team/members/transfer-node.js +262 -0
- package/lib/team/members/util.js +20 -0
- package/lib/team/passports/detail.js +261 -0
- package/lib/team/passports/index.js +220 -0
- package/lib/team/passports/mutate-role.js +204 -0
- package/lib/team/passports/trusted-issuer.js +295 -0
- package/lib/team/passports/trusted-issuers.js +238 -0
- package/lib/team/search-input.js +36 -0
- package/lib/team/styles/dialog.js +13 -0
- package/lib/team/styles/list-header.js +13 -0
- package/lib/toast.js +4 -19
- package/lib/util/index.js +504 -38
- package/lib/who-can-access/config.js +0 -6
- package/lib/wrap-locale.js +0 -7
- package/package.json +43 -20
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = PassportIssuances;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _notistack = require("notistack");
|
|
11
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
12
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
13
|
+
var _node = require("../../contexts/node");
|
|
14
|
+
var _team = require("../../contexts/team");
|
|
15
|
+
var _confirm = _interopRequireDefault(require("../../confirm"));
|
|
16
|
+
var _permission = _interopRequireDefault(require("../../permission"));
|
|
17
|
+
var _clickToCopy = _interopRequireDefault(require("../../click-to-copy"));
|
|
18
|
+
var _passportTag = _interopRequireDefault(require("../../passport-tag"));
|
|
19
|
+
var _util = require("../../util");
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
var _templateObject;
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
24
|
+
function PassportIssuances(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
issuances,
|
|
27
|
+
teamDid,
|
|
28
|
+
onRefresh
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
api: client,
|
|
32
|
+
inService
|
|
33
|
+
} = (0, _node.useNodeContext)();
|
|
34
|
+
const {
|
|
35
|
+
t
|
|
36
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
37
|
+
const [delConfirm, setDelConfirm] = (0, _react.useState)(null);
|
|
38
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
39
|
+
const {
|
|
40
|
+
enqueueSnackbar
|
|
41
|
+
} = (0, _notistack.useSnackbar)();
|
|
42
|
+
const {
|
|
43
|
+
endpoint
|
|
44
|
+
} = (0, _team.useTeamContext)();
|
|
45
|
+
const deleteIssuance = async _ref2 => {
|
|
46
|
+
let {
|
|
47
|
+
id
|
|
48
|
+
} = _ref2;
|
|
49
|
+
if (loading) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
setLoading(true);
|
|
53
|
+
try {
|
|
54
|
+
await client.deletePassportIssuance({
|
|
55
|
+
input: {
|
|
56
|
+
teamDid,
|
|
57
|
+
sessionId: id
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
onRefresh();
|
|
61
|
+
} catch (error) {
|
|
62
|
+
enqueueSnackbar(error.message, {
|
|
63
|
+
autoHideDuration: 5000,
|
|
64
|
+
variant: 'error'
|
|
65
|
+
});
|
|
66
|
+
} finally {
|
|
67
|
+
setLoading(false);
|
|
68
|
+
setDelConfirm(null);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const onCancel = () => {
|
|
72
|
+
setLoading(false);
|
|
73
|
+
setDelConfirm(null);
|
|
74
|
+
};
|
|
75
|
+
const getLink = column => endpoint ? (0, _util.getIssuePassportLink)({
|
|
76
|
+
id: column.id,
|
|
77
|
+
endpoint
|
|
78
|
+
}) : '';
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line react/prop-types
|
|
81
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
82
|
+
function Issuance(_ref3) {
|
|
83
|
+
let {
|
|
84
|
+
data: d
|
|
85
|
+
} = _ref3;
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
87
|
+
className: "issuance",
|
|
88
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
89
|
+
display: "flex",
|
|
90
|
+
justifyContent: "space-between",
|
|
91
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
|
|
92
|
+
permission: inService ? '' : 'mutate_team',
|
|
93
|
+
role: inService ? _util.BlockletAdminRoles : [],
|
|
94
|
+
children: can => can ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_passportTag.default, {
|
|
95
|
+
passport: {
|
|
96
|
+
title: d.title,
|
|
97
|
+
name: d.name
|
|
98
|
+
},
|
|
99
|
+
onDelete: () => setDelConfirm({
|
|
100
|
+
title: t('team.passport.issuance.delete.title'),
|
|
101
|
+
description: t('team.passport.issuance.delete.description', {
|
|
102
|
+
link: getLink(d)
|
|
103
|
+
}),
|
|
104
|
+
confirm: t('common.delConfirm'),
|
|
105
|
+
cancel: t('common.cancel'),
|
|
106
|
+
onConfirm: () => {
|
|
107
|
+
deleteIssuance(d);
|
|
108
|
+
},
|
|
109
|
+
onCancel
|
|
110
|
+
})
|
|
111
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_passportTag.default, {
|
|
112
|
+
passport: {
|
|
113
|
+
title: d.title,
|
|
114
|
+
name: d.name
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
118
|
+
style: {
|
|
119
|
+
color: '#999'
|
|
120
|
+
},
|
|
121
|
+
children: [t('common.expires'), ":\xA0", (0, _util.formatToDatetime)(d.expireDate)]
|
|
122
|
+
})]
|
|
123
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
124
|
+
mt: 2,
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
|
|
126
|
+
children: getLink(d)
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
|
|
132
|
+
children: [issuances.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(Issuance, {
|
|
133
|
+
data: x
|
|
134
|
+
})), delConfirm && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
135
|
+
title: delConfirm.title,
|
|
136
|
+
description: delConfirm.description,
|
|
137
|
+
confirm: delConfirm.confirm,
|
|
138
|
+
cancel: delConfirm.cancel,
|
|
139
|
+
params: delConfirm.params,
|
|
140
|
+
onConfirm: delConfirm.onConfirm,
|
|
141
|
+
onCancel: delConfirm.onCancel
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiTableHead-root {\n display: none;\n }\n .issuance {\n padding: 16px 0;\n border-bottom: 1px solid #f0f0f0;\n .MuiTypography-root {\n display: inline-block;\n width: 100%;\n background: #f3f3f3;\n border-radius: 4px;\n padding-top: 6px;\n padding-bottom: 6px;\n }\n }\n"])));
|
|
146
|
+
PassportIssuances.propTypes = {
|
|
147
|
+
teamDid: _propTypes.default.string.isRequired,
|
|
148
|
+
issuances: _propTypes.default.array,
|
|
149
|
+
onRefresh: _propTypes.default.func
|
|
150
|
+
};
|
|
151
|
+
PassportIssuances.defaultProps = {
|
|
152
|
+
issuances: [],
|
|
153
|
+
onRefresh: () => {}
|
|
154
|
+
};
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Passports;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _notistack = require("notistack");
|
|
11
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
12
|
+
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
13
|
+
var _Add = _interopRequireDefault(require("@mui/icons-material/Add"));
|
|
14
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
15
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
16
|
+
var _ErrorOutline = _interopRequireDefault(require("@mui/icons-material/ErrorOutline"));
|
|
17
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
18
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
19
|
+
var _RevokeIcon = _interopRequireDefault(require("@arcblock/icons/lib/RevokeIcon"));
|
|
20
|
+
var _ExternalIssuerIcon = _interopRequireDefault(require("@arcblock/icons/lib/ExternalIssuerIcon"));
|
|
21
|
+
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
22
|
+
var _constant = require("@abtnode/constant");
|
|
23
|
+
var _createPassportSvg = _interopRequireDefault(require("@abtnode/auth/lib/util/create-passport-svg"));
|
|
24
|
+
var _node = require("../../contexts/node");
|
|
25
|
+
var _session = require("../../contexts/session");
|
|
26
|
+
var _team = require("../../contexts/team");
|
|
27
|
+
var _util = require("../../util");
|
|
28
|
+
var _confirm = _interopRequireDefault(require("../../confirm"));
|
|
29
|
+
var _permission = _interopRequireDefault(require("../../permission"));
|
|
30
|
+
var _searchInput = _interopRequireDefault(require("../search-input"));
|
|
31
|
+
var _listHeader = _interopRequireDefault(require("../styles/list-header"));
|
|
32
|
+
var _issuePassport = _interopRequireDefault(require("./issue-passport"));
|
|
33
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
34
|
+
var _templateObject;
|
|
35
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
37
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
40
|
+
function ConfirmDescription(_ref) {
|
|
41
|
+
let {
|
|
42
|
+
action,
|
|
43
|
+
passport
|
|
44
|
+
} = _ref;
|
|
45
|
+
const {
|
|
46
|
+
t
|
|
47
|
+
} = (0, _context.useLocaleContext)();
|
|
48
|
+
const {
|
|
49
|
+
roles
|
|
50
|
+
} = (0, _team.useTeamContext)();
|
|
51
|
+
const role = roles.find(x => x.name === passport.role);
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
53
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
54
|
+
children: action === 'enable' ? t('team.member.enablePassportDescription') : t('team.member.revokePassportDescription')
|
|
55
|
+
}), role && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
56
|
+
mt: 3,
|
|
57
|
+
fontWeight: "bold",
|
|
58
|
+
children: t('team.member.passportPermissionTitle')
|
|
59
|
+
}), role && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
60
|
+
mt: 1,
|
|
61
|
+
children: role.description
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
ConfirmDescription.propTypes = {
|
|
66
|
+
action: _propTypes.default.string.isRequired,
|
|
67
|
+
passport: _propTypes.default.object.isRequired
|
|
68
|
+
};
|
|
69
|
+
ConfirmDescription.defaultProps = {};
|
|
70
|
+
function Passports(_ref2) {
|
|
71
|
+
var _blocklet$settings;
|
|
72
|
+
let {
|
|
73
|
+
user,
|
|
74
|
+
onCreate
|
|
75
|
+
} = _ref2;
|
|
76
|
+
const {
|
|
77
|
+
t
|
|
78
|
+
} = (0, _context.useLocaleContext)();
|
|
79
|
+
const {
|
|
80
|
+
session,
|
|
81
|
+
inService
|
|
82
|
+
} = (0, _session.useSessionContext)();
|
|
83
|
+
const {
|
|
84
|
+
roles,
|
|
85
|
+
teamDid,
|
|
86
|
+
teamIssuerDid,
|
|
87
|
+
refresh: refreshTeam,
|
|
88
|
+
enablePassportIssuance,
|
|
89
|
+
trustedPassports,
|
|
90
|
+
passportColor,
|
|
91
|
+
blocklet
|
|
92
|
+
} = (0, _team.useTeamContext)();
|
|
93
|
+
const {
|
|
94
|
+
api
|
|
95
|
+
} = (0, _node.useNodeContext)();
|
|
96
|
+
const {
|
|
97
|
+
enqueueSnackbar
|
|
98
|
+
} = (0, _notistack.useSnackbar)();
|
|
99
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
100
|
+
const [toggleConfirm, setToggleConfirm] = (0, _react.useState)(null);
|
|
101
|
+
const [showIssueDialog, setShowIssueDialog] = (0, _react.useState)(false);
|
|
102
|
+
const [search, setSearch] = (0, _react.useState)('');
|
|
103
|
+
const passports = ((0, _get.default)(user, 'passports') || []).map(x => _objectSpread(_objectSpread({}, x), {}, {
|
|
104
|
+
revoked: x.status === _constant.PASSPORT_STATUS.REVOKED
|
|
105
|
+
}));
|
|
106
|
+
const togglePassportStatus = async passport => {
|
|
107
|
+
if (loading) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
setLoading(true);
|
|
111
|
+
try {
|
|
112
|
+
const method = passport.status === _constant.PASSPORT_STATUS.REVOKED ? 'enableUserPassport' : 'revokeUserPassport';
|
|
113
|
+
await api[method]({
|
|
114
|
+
input: {
|
|
115
|
+
teamDid,
|
|
116
|
+
userDid: user.did,
|
|
117
|
+
passportId: passport.id
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
refreshTeam();
|
|
121
|
+
} catch (err) {
|
|
122
|
+
enqueueSnackbar((0, _util.formatError)(err), {
|
|
123
|
+
autoHideDuration: 5000,
|
|
124
|
+
variant: 'error'
|
|
125
|
+
});
|
|
126
|
+
} finally {
|
|
127
|
+
setLoading(false);
|
|
128
|
+
setToggleConfirm(null);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const confirmToggle = item => item.status === _constant.PASSPORT_STATUS.REVOKED ? setToggleConfirm({
|
|
132
|
+
title: t('team.member.enablePassport'),
|
|
133
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfirmDescription, {
|
|
134
|
+
action: "enable",
|
|
135
|
+
passport: item
|
|
136
|
+
}),
|
|
137
|
+
confirm: t('common.enable'),
|
|
138
|
+
cancel: t('common.cancel'),
|
|
139
|
+
onConfirm: () => {
|
|
140
|
+
togglePassportStatus(item);
|
|
141
|
+
},
|
|
142
|
+
onCancel: () => {
|
|
143
|
+
setLoading(false);
|
|
144
|
+
setToggleConfirm(null);
|
|
145
|
+
},
|
|
146
|
+
color: 'primary'
|
|
147
|
+
}) : setToggleConfirm({
|
|
148
|
+
title: t('team.member.revokePassport'),
|
|
149
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfirmDescription, {
|
|
150
|
+
action: "revoke",
|
|
151
|
+
passport: item
|
|
152
|
+
}),
|
|
153
|
+
confirm: t('common.revoke'),
|
|
154
|
+
cancel: t('common.cancel'),
|
|
155
|
+
onConfirm: () => {
|
|
156
|
+
togglePassportStatus(item);
|
|
157
|
+
},
|
|
158
|
+
onCancel: () => {
|
|
159
|
+
setLoading(false);
|
|
160
|
+
setToggleConfirm(null);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
const revokeInfo = (hasPermission, passport) => {
|
|
164
|
+
if (user.did === session.user.did && session.user.passportId && session.user.passportId === passport.id) {
|
|
165
|
+
return {
|
|
166
|
+
revokable: false,
|
|
167
|
+
message: t('team.passport.shouldNotDeleteCurrent')
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (!hasPermission) {
|
|
171
|
+
return {
|
|
172
|
+
revokable: false,
|
|
173
|
+
message: t('team.passport.noPermission')
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (teamDid === passport.issuer.id && passport.name === 'owner') {
|
|
177
|
+
return {
|
|
178
|
+
revokable: false,
|
|
179
|
+
message: t('team.passport.noPermission')
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
revokable: true
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const filteredPassports = passports.filter(x => !search || x.title.includes(search) || x.name.includes(search));
|
|
187
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
|
|
188
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_listHeader.default, {
|
|
189
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
190
|
+
className: "left",
|
|
191
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_searchInput.default, {
|
|
192
|
+
placeholder: t('team.passport.search'),
|
|
193
|
+
value: search,
|
|
194
|
+
onChange: e => setSearch(e.target.value)
|
|
195
|
+
})
|
|
196
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
197
|
+
className: "right",
|
|
198
|
+
children: enablePassportIssuance && !!user.approved && /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
|
|
199
|
+
permission: inService ? '' : 'mutate_team',
|
|
200
|
+
role: inService ? _util.BlockletAdminRoles : [],
|
|
201
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
202
|
+
variant: "contained",
|
|
203
|
+
color: "primary",
|
|
204
|
+
"data-cy": "issue-passport",
|
|
205
|
+
onClick: () => setShowIssueDialog(true),
|
|
206
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
|
|
207
|
+
style: {
|
|
208
|
+
fontSize: 16,
|
|
209
|
+
marginRight: 4
|
|
210
|
+
}
|
|
211
|
+
}), t('team.passport.issue')]
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})]
|
|
215
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
216
|
+
children: [filteredPassports.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
|
|
217
|
+
permission: inService ? '' : 'mutate_team',
|
|
218
|
+
role: inService ? _util.BlockletAdminRoles : [],
|
|
219
|
+
children: can => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
220
|
+
className: "passport-item",
|
|
221
|
+
display: "flex",
|
|
222
|
+
justifyContent: "space-between",
|
|
223
|
+
alignItems: "center",
|
|
224
|
+
mt: 3,
|
|
225
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
226
|
+
display: "flex",
|
|
227
|
+
alignItems: "center",
|
|
228
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
229
|
+
// eslint-disable-next-line react/no-danger
|
|
230
|
+
dangerouslySetInnerHTML: {
|
|
231
|
+
__html: (0, _createPassportSvg.default)({
|
|
232
|
+
title: x.title || x.name,
|
|
233
|
+
issuer: x.issuer && x.issuer.name,
|
|
234
|
+
issuerDid: x.issuer && x.issuer.id,
|
|
235
|
+
ownerName: user.fullName,
|
|
236
|
+
ownerAvatarUrl: user.avatar,
|
|
237
|
+
revoked: x.revoked,
|
|
238
|
+
preferredColor: passportColor,
|
|
239
|
+
width: '120px'
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
243
|
+
className: "body",
|
|
244
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
245
|
+
className: "title",
|
|
246
|
+
display: "flex",
|
|
247
|
+
alignItems: "center",
|
|
248
|
+
children: [(0, _upperFirst.default)(x.title), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
249
|
+
className: "status-icons",
|
|
250
|
+
children: [!!teamIssuerDid && x.issuer.id !== teamIssuerDid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExternalIssuerIcon.default, {}), x.revoked && /*#__PURE__*/(0, _jsxRuntime.jsx)(_RevokeIcon.default, {})]
|
|
251
|
+
})]
|
|
252
|
+
}), !!teamIssuerDid && x.issuer.id !== teamIssuerDid && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
253
|
+
className: "tip",
|
|
254
|
+
children: [x.issuer.id !== teamIssuerDid && !trustedPassports.some(y => y.issuerDid === x.issuer.id) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
255
|
+
title: t('team.passport.notTrustedIssuerTip'),
|
|
256
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
257
|
+
component: _ErrorOutline.default,
|
|
258
|
+
style: {
|
|
259
|
+
fontSize: '1.3em'
|
|
260
|
+
},
|
|
261
|
+
color: "error.main",
|
|
262
|
+
mr: 0.5
|
|
263
|
+
})
|
|
264
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
265
|
+
children: t('team.passport.issueBy', {
|
|
266
|
+
name: x.issuer.name
|
|
267
|
+
})
|
|
268
|
+
})]
|
|
269
|
+
})]
|
|
270
|
+
})]
|
|
271
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
272
|
+
children: revokeInfo(can, x).revokable ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
273
|
+
variant: "outlined",
|
|
274
|
+
color: x.revoked ? 'primary' : 'secondary',
|
|
275
|
+
onClick: () => confirmToggle(x),
|
|
276
|
+
children: [x.revoked ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
|
|
277
|
+
style: {
|
|
278
|
+
fontSize: 16,
|
|
279
|
+
marginRight: 4
|
|
280
|
+
}
|
|
281
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_RevokeIcon.default, {
|
|
282
|
+
style: {
|
|
283
|
+
height: 16,
|
|
284
|
+
marginRight: 4
|
|
285
|
+
}
|
|
286
|
+
}), x.revoked ? t('common.enable') : t('common.revoke')]
|
|
287
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
288
|
+
title: revokeInfo(can, x).message,
|
|
289
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorOutline.default, {
|
|
290
|
+
style: {
|
|
291
|
+
color: '#ddd'
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
})]
|
|
296
|
+
})
|
|
297
|
+
})), !filteredPassports.length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Empty.default, {
|
|
298
|
+
children: t('common.empty')
|
|
299
|
+
})]
|
|
300
|
+
}), showIssueDialog && /*#__PURE__*/(0, _jsxRuntime.jsx)(_issuePassport.default, {
|
|
301
|
+
teamDid: teamDid,
|
|
302
|
+
ownerDid: user.did,
|
|
303
|
+
roles: roles,
|
|
304
|
+
onCancel: () => setShowIssueDialog(false),
|
|
305
|
+
onSuccess: () => {
|
|
306
|
+
onCreate();
|
|
307
|
+
setShowIssueDialog(false);
|
|
308
|
+
},
|
|
309
|
+
showOwnerPassport: blocklet && !((_blocklet$settings = blocklet.settings) !== null && _blocklet$settings !== void 0 && _blocklet$settings.owner)
|
|
310
|
+
}), toggleConfirm && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
311
|
+
title: toggleConfirm.title,
|
|
312
|
+
description: toggleConfirm.description,
|
|
313
|
+
confirm: toggleConfirm.confirm,
|
|
314
|
+
cancel: toggleConfirm.cancel,
|
|
315
|
+
params: toggleConfirm.params,
|
|
316
|
+
onConfirm: toggleConfirm.onConfirm,
|
|
317
|
+
onCancel: toggleConfirm.onCancel,
|
|
318
|
+
color: toggleConfirm.color
|
|
319
|
+
})]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
Passports.propTypes = {
|
|
323
|
+
user: _propTypes.default.object.isRequired,
|
|
324
|
+
onCreate: _propTypes.default.func
|
|
325
|
+
};
|
|
326
|
+
Passports.defaultProps = {
|
|
327
|
+
onCreate: () => {}
|
|
328
|
+
};
|
|
329
|
+
const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .passport-item {\n .body {\n padding: 0;\n margin-left: 24px;\n margin-top: 0;\n }\n .title {\n font-weight: 400;\n font-size: 16px;\n line-height: 19px;\n color: #222222;\n }\n .tip {\n display: flex;\n align-items: center;\n font-size: 14px;\n margin-top: 6px;\n color: #bbb;\n }\n .status-icons {\n svg {\n fill: #bfbfbf;\n height: 1.2em;\n margin-left: 0.4em;\n }\n }\n .MuiButton-outlinedSecondary {\n color: #f16e6e;\n fill: #f16e6e;\n background: #fcf3f3;\n border: 0;\n &:hover {\n border: 0;\n }\n }\n }\n"])));
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ToggleUserApproval;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
var _toast = _interopRequireDefault(require("../../toast"));
|
|
11
|
+
var _confirm = _interopRequireDefault(require("../../confirm"));
|
|
12
|
+
var _node = require("../../contexts/node");
|
|
13
|
+
var _team = require("../../contexts/team");
|
|
14
|
+
var _session = require("../../contexts/session");
|
|
15
|
+
var _util = require("../../util");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const isNodeOwner = (nodeInfo, userDid) => nodeInfo.nodeOwner && nodeInfo.nodeOwner.did === userDid;
|
|
19
|
+
const isSelf = (sessionUser, userDid) => sessionUser && sessionUser.did === userDid;
|
|
20
|
+
function ToggleUserApproval(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
user,
|
|
23
|
+
onCancel: _onCancel,
|
|
24
|
+
onSuccess,
|
|
25
|
+
onError,
|
|
26
|
+
children
|
|
27
|
+
} = _ref;
|
|
28
|
+
const {
|
|
29
|
+
api,
|
|
30
|
+
info: nodeInfo,
|
|
31
|
+
inService
|
|
32
|
+
} = (0, _node.useNodeContext)();
|
|
33
|
+
const {
|
|
34
|
+
session
|
|
35
|
+
} = (0, _session.useSessionContext)();
|
|
36
|
+
const {
|
|
37
|
+
teamDid,
|
|
38
|
+
refresh
|
|
39
|
+
} = (0, _team.useTeamContext)();
|
|
40
|
+
const {
|
|
41
|
+
t
|
|
42
|
+
} = (0, _context.useLocaleContext)();
|
|
43
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
44
|
+
const [show, setShow] = (0, _react.useState)(false);
|
|
45
|
+
const open = () => setShow(true);
|
|
46
|
+
const updateUserApproval = async d => {
|
|
47
|
+
const {
|
|
48
|
+
did,
|
|
49
|
+
approved
|
|
50
|
+
} = d;
|
|
51
|
+
if (loading) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setLoading(true);
|
|
55
|
+
try {
|
|
56
|
+
await api.updateUserApproval({
|
|
57
|
+
input: {
|
|
58
|
+
teamDid,
|
|
59
|
+
user: {
|
|
60
|
+
did,
|
|
61
|
+
approved: !approved
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
setShow(false);
|
|
66
|
+
onSuccess();
|
|
67
|
+
refresh();
|
|
68
|
+
} catch (error) {
|
|
69
|
+
_toast.default.error((0, _util.formatError)(error));
|
|
70
|
+
onError();
|
|
71
|
+
} finally {
|
|
72
|
+
setLoading(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const approveConfirm = {
|
|
76
|
+
title: user.approved ? t('team.member.forbidLogin') : t('team.member.allowLogin'),
|
|
77
|
+
description: user.approved ? t('team.member.forbidLoginDescription') : t('team.member.allowLoginDescription'),
|
|
78
|
+
confirm: t('common.confirm'),
|
|
79
|
+
cancel: t('common.cancel'),
|
|
80
|
+
onConfirm: () => {
|
|
81
|
+
updateUserApproval(user);
|
|
82
|
+
},
|
|
83
|
+
onCancel: () => {
|
|
84
|
+
setLoading(false);
|
|
85
|
+
setShow(false);
|
|
86
|
+
_onCancel();
|
|
87
|
+
},
|
|
88
|
+
color: user.approved ? 'error' : 'primary'
|
|
89
|
+
};
|
|
90
|
+
let can;
|
|
91
|
+
if (!inService) {
|
|
92
|
+
can = nodeInfo.nodeOwner && !isNodeOwner(nodeInfo, user.did) && !isSelf(session.user, user.did);
|
|
93
|
+
} else {
|
|
94
|
+
can = !isSelf(session.user, user.did);
|
|
95
|
+
}
|
|
96
|
+
if (!can) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
100
|
+
children: [typeof children === 'function' ? children({
|
|
101
|
+
can,
|
|
102
|
+
open
|
|
103
|
+
}) : children, show ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
104
|
+
title: approveConfirm.title,
|
|
105
|
+
description: approveConfirm.description,
|
|
106
|
+
confirm: approveConfirm.confirm,
|
|
107
|
+
cancel: approveConfirm.cancel,
|
|
108
|
+
params: approveConfirm.params,
|
|
109
|
+
onConfirm: approveConfirm.onConfirm,
|
|
110
|
+
onCancel: approveConfirm.onCancel,
|
|
111
|
+
color: approveConfirm.color
|
|
112
|
+
}) : null]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
ToggleUserApproval.propTypes = {
|
|
116
|
+
user: _propTypes.default.object,
|
|
117
|
+
onSuccess: _propTypes.default.func,
|
|
118
|
+
onCancel: _propTypes.default.func,
|
|
119
|
+
onError: _propTypes.default.func,
|
|
120
|
+
children: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func])
|
|
121
|
+
};
|
|
122
|
+
ToggleUserApproval.defaultProps = {
|
|
123
|
+
user: {},
|
|
124
|
+
onSuccess: () => {},
|
|
125
|
+
onCancel: () => {},
|
|
126
|
+
onError: () => {},
|
|
127
|
+
children: null
|
|
128
|
+
};
|