@abtnode/ux 1.16.14-beta-a898bfcb → 1.16.14-beta-d802cd3c
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/blocklet/audit-logs.js +23 -4
- package/lib/blocklet/config-navigation.js +20 -6
- package/lib/blocklet/log.js +49 -5
- package/lib/blocklet/oauth/federated-detail-dialog.js +183 -0
- package/lib/blocklet/oauth/federated-invite-dialog.js +93 -0
- package/lib/blocklet/oauth/federated-join-dialog.js +120 -0
- package/lib/blocklet/oauth/federated-site-list.js +318 -0
- package/lib/blocklet/oauth/federated.js +92 -0
- package/lib/blocklet/oauth/index.js +9 -0
- package/lib/card-selector.js +8 -5
- package/lib/contexts/audit-log.js +17 -3
- package/lib/hooks/blocklet.js +2 -3
- package/lib/hooks/confirm.js +106 -0
- package/lib/invitation/invitation-passport.js +12 -26
- package/lib/invitation/invitation.js +3 -0
- package/lib/locales/en.js +49 -2
- package/lib/locales/zh.js +49 -2
- package/lib/logs/log-terminal.js +15 -6
- package/lib/lost-passport.js +1 -0
- package/lib/schema-form/passport-input.js +3 -2
- package/lib/team/members/index.js +9 -3
- package/lib/team/members/member.js +4 -1
- package/lib/team/members/passports.js +7 -5
- package/lib/team/passports/color.js +3 -2
- package/lib/team/passports/index.js +24 -15
- package/lib/team/passports/trusted-factories.js +0 -1
- package/package.json +20 -18
|
@@ -19,6 +19,7 @@ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
|
19
19
|
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
20
20
|
var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
|
|
21
21
|
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
22
|
+
var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
|
|
22
23
|
var _auditLog = require("../contexts/audit-log");
|
|
23
24
|
var _node = require("../contexts/node");
|
|
24
25
|
var _relativeTime = _interopRequireDefault(require("../relative-time"));
|
|
@@ -51,6 +52,10 @@ function AuditLog(_ref2) {
|
|
|
51
52
|
inService,
|
|
52
53
|
info
|
|
53
54
|
} = (0, _node.useNodeContext)();
|
|
55
|
+
const {
|
|
56
|
+
showScope,
|
|
57
|
+
scopeFormatter = x => x
|
|
58
|
+
} = (0, _auditLog.useAuditLogContext)();
|
|
54
59
|
if (!log.actor.did) {
|
|
55
60
|
return null;
|
|
56
61
|
}
|
|
@@ -80,17 +85,27 @@ function AuditLog(_ref2) {
|
|
|
80
85
|
target: "_blank",
|
|
81
86
|
children: [log.actor.fullName, log.actor.role ? "(".concat(log.actor.role, ")") : '']
|
|
82
87
|
}), ' ', "- ", log.action]
|
|
83
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
88
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
84
89
|
className: "log-content",
|
|
85
90
|
maxWidth: "lg",
|
|
86
91
|
color: "textPrimary",
|
|
87
92
|
component: "div",
|
|
88
93
|
"data-color-mode": "light",
|
|
89
94
|
gutterBottom: true,
|
|
90
|
-
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
children: [showScope && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
|
|
98
|
+
to: log.link,
|
|
99
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
|
|
100
|
+
style: {
|
|
101
|
+
marginRight: 8
|
|
102
|
+
},
|
|
103
|
+
children: scopeFormatter(log.scope)
|
|
104
|
+
})
|
|
105
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMarkdownPreview.default, {
|
|
91
106
|
source: log.content,
|
|
92
107
|
linkTarget: "_blank"
|
|
93
|
-
})
|
|
108
|
+
})]
|
|
94
109
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
95
110
|
className: "log-meta",
|
|
96
111
|
variant: "body2",
|
|
@@ -186,11 +201,15 @@ function AuditLogs() {
|
|
|
186
201
|
function WrappedAuditLogs(_ref3) {
|
|
187
202
|
let {
|
|
188
203
|
scope,
|
|
189
|
-
categories
|
|
204
|
+
categories,
|
|
205
|
+
showScope,
|
|
206
|
+
scopeFormatter
|
|
190
207
|
} = _ref3;
|
|
191
208
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_auditLog.AuditLogProvider, {
|
|
192
209
|
scope: scope,
|
|
193
210
|
categories: categories,
|
|
211
|
+
showScope: showScope,
|
|
212
|
+
scopeFormatter: scopeFormatter,
|
|
194
213
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AuditLogs, {})
|
|
195
214
|
});
|
|
196
215
|
}
|
|
@@ -22,6 +22,7 @@ var _ahooks = require("ahooks");
|
|
|
22
22
|
var _Dialog = require("@arcblock/ux/lib/Dialog");
|
|
23
23
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
24
24
|
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
25
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
25
26
|
var _sortableTree = _interopRequireDefault(require("./component/sortable-tree"));
|
|
26
27
|
var _navigationDialog = _interopRequireDefault(require("./component/navigation/navigation-dialog"));
|
|
27
28
|
var _navigationActions = _interopRequireDefault(require("./component/navigation/navigation-actions"));
|
|
@@ -38,12 +39,25 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
38
39
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
39
40
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // FIXME: @zhanghan 这里还有几处文案没有 i18n
|
|
40
41
|
const mockSession = {
|
|
41
|
-
login:
|
|
42
|
-
logout:
|
|
43
|
-
switch:
|
|
44
|
-
switchDid:
|
|
45
|
-
switchProfile:
|
|
46
|
-
switchPassport:
|
|
42
|
+
login: _noop.default,
|
|
43
|
+
logout: _noop.default,
|
|
44
|
+
switch: _noop.default,
|
|
45
|
+
switchDid: _noop.default,
|
|
46
|
+
switchProfile: _noop.default,
|
|
47
|
+
switchPassport: _noop.default,
|
|
48
|
+
useDid: () => {
|
|
49
|
+
return {
|
|
50
|
+
walletDid: 'abcdefghijklmnopqrstuvwxyz'
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
useOAuth: () => {
|
|
54
|
+
return {
|
|
55
|
+
logoutOAuth: _noop.default,
|
|
56
|
+
bindOAuth: _noop.default,
|
|
57
|
+
configs: {},
|
|
58
|
+
switchOAuthPassport: _noop.default
|
|
59
|
+
};
|
|
60
|
+
}
|
|
47
61
|
};
|
|
48
62
|
const navigationTypeMap = {
|
|
49
63
|
header: 'Header',
|
package/lib/blocklet/log.js
CHANGED
|
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = BlockletLog;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
8
|
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
-
var
|
|
9
|
+
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
10
|
+
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
11
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
12
|
+
var _useLocalStorage = _interopRequireDefault(require("react-use/lib/useLocalStorage"));
|
|
10
13
|
var _logTerminal = require("../logs/log-terminal");
|
|
11
14
|
var _download = _interopRequireDefault(require("../logs/download"));
|
|
12
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -39,6 +42,43 @@ function BlockletLog(_ref) {
|
|
|
39
42
|
} = _ref,
|
|
40
43
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
44
|
const initialData = ['Tip: this tab will only show runtime logs. Please go to "Blocklet Server" to view other lifecycle logs of the blocklet (install/start/stop...)', '\r\n\r\n'];
|
|
45
|
+
const logs = ((blocklet === null || blocklet === void 0 ? void 0 : blocklet.children) || []).map(x => ({
|
|
46
|
+
did: x.meta.did,
|
|
47
|
+
name: x.meta.title,
|
|
48
|
+
types: ['error', 'info', 'access', 'stdout', 'stderr']
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
// format: `{componentId},{defaultTypeIndex}`
|
|
52
|
+
const [config, setConfig] = (0, _useLocalStorage.default)("blocklet-log-".concat(blocklet.meta.did), '');
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line prefer-const
|
|
55
|
+
let [componentId, defaultTypeIndex] = config.split(',');
|
|
56
|
+
if (!logs.find(x => x.did === componentId)) {
|
|
57
|
+
var _logs$;
|
|
58
|
+
componentId = (_logs$ = logs[0]) === null || _logs$ === void 0 ? void 0 : _logs$.did;
|
|
59
|
+
}
|
|
60
|
+
const onSelectChange = e => {
|
|
61
|
+
setConfig([e.target.value, defaultTypeIndex].join(','));
|
|
62
|
+
};
|
|
63
|
+
const componentSelect = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl.default, {
|
|
64
|
+
sx: {
|
|
65
|
+
minWidth: 240
|
|
66
|
+
},
|
|
67
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
68
|
+
value: componentId,
|
|
69
|
+
onChange: onSelectChange,
|
|
70
|
+
size: "small",
|
|
71
|
+
children: logs.map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.default, {
|
|
72
|
+
value: x.did,
|
|
73
|
+
children: x.name
|
|
74
|
+
}, x.did))
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
const log = logs.find(item => item.did === componentId) || logs[0] || blocklet.meta;
|
|
78
|
+
const onTypeChange = type => {
|
|
79
|
+
const index = log.types.indexOf(type);
|
|
80
|
+
setConfig([componentId, index || 0].join(','));
|
|
81
|
+
};
|
|
42
82
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({
|
|
43
83
|
height: {
|
|
44
84
|
xs: 'calc(100vh - 444px)',
|
|
@@ -47,14 +87,18 @@ function BlockletLog(_ref) {
|
|
|
47
87
|
}
|
|
48
88
|
}, rest), {}, {
|
|
49
89
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_logTerminal.LogTerminalGroup, {
|
|
50
|
-
|
|
51
|
-
logId: "blocklet-".concat(blocklet.meta.did),
|
|
90
|
+
logId: log === blocklet.meta ? "blocklet-".concat(blocklet.meta.did) : "blocklet-".concat(blocklet.meta.did, "/").concat(log.did),
|
|
52
91
|
initialData: initialData,
|
|
92
|
+
prepend: componentSelect,
|
|
53
93
|
postpend: /*#__PURE__*/(0, _jsxRuntime.jsx)(_download.default, {
|
|
54
94
|
id: blocklet.meta.did,
|
|
55
95
|
name: blocklet.meta.name
|
|
56
|
-
})
|
|
57
|
-
|
|
96
|
+
}),
|
|
97
|
+
name: log.name,
|
|
98
|
+
types: log.types,
|
|
99
|
+
defaultTypeIndex: defaultTypeIndex,
|
|
100
|
+
onTypeChange: onTypeChange
|
|
101
|
+
}, log.did)
|
|
58
102
|
}));
|
|
59
103
|
}
|
|
60
104
|
BlockletLog.propTypes = {
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _InfoRow = _interopRequireDefault(require("@arcblock/ux/lib/InfoRow"));
|
|
8
|
+
var _pull = _interopRequireDefault(require("lodash/pull"));
|
|
9
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
10
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
13
|
+
var _ahooks = require("ahooks");
|
|
14
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
15
|
+
var _material = require("@mui/material");
|
|
16
|
+
var _didConnect = require("@arcblock/did-connect");
|
|
17
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
18
|
+
var _Stars = _interopRequireDefault(require("@mui/icons-material/Stars"));
|
|
19
|
+
var _blocklet = require("../../contexts/blocklet");
|
|
20
|
+
var _node = require("../../contexts/node");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
const FederatedDetailDialog = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
24
|
+
var _theme$transitions, _theme$transitions$du;
|
|
25
|
+
const {
|
|
26
|
+
t
|
|
27
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
28
|
+
const {
|
|
29
|
+
blocklet
|
|
30
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
31
|
+
const {
|
|
32
|
+
api
|
|
33
|
+
} = (0, _node.useNodeContext)();
|
|
34
|
+
const state = (0, _ahooks.useReactive)({
|
|
35
|
+
mode: 'view',
|
|
36
|
+
show: false,
|
|
37
|
+
data: {},
|
|
38
|
+
callback: _noop.default
|
|
39
|
+
});
|
|
40
|
+
const theme = (0, _Theme.useTheme)();
|
|
41
|
+
const leavingScreen = (theme === null || theme === void 0 ? void 0 : (_theme$transitions = theme.transitions) === null || _theme$transitions === void 0 ? void 0 : (_theme$transitions$du = _theme$transitions.duration) === null || _theme$transitions$du === void 0 ? void 0 : _theme$transitions$du.leavingScreen) || 300;
|
|
42
|
+
const reset = (0, _ahooks.useMemoizedFn)(() => {
|
|
43
|
+
state.mode = 'view';
|
|
44
|
+
state.data = {};
|
|
45
|
+
state.callback = _noop.default;
|
|
46
|
+
}, []);
|
|
47
|
+
const close = (0, _ahooks.useMemoizedFn)(() => {
|
|
48
|
+
state.show = false;
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
reset();
|
|
51
|
+
}, leavingScreen);
|
|
52
|
+
}, []);
|
|
53
|
+
const open = (0, _ahooks.useMemoizedFn)(data => {
|
|
54
|
+
state.mode = 'view';
|
|
55
|
+
state.show = true;
|
|
56
|
+
state.data = data;
|
|
57
|
+
}, []);
|
|
58
|
+
const approve = (0, _ahooks.useMemoizedFn)(function (data) {
|
|
59
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _noop.default;
|
|
60
|
+
state.mode = 'approve';
|
|
61
|
+
state.show = true;
|
|
62
|
+
state.data = data;
|
|
63
|
+
state.callback = callback;
|
|
64
|
+
}, []);
|
|
65
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
66
|
+
open,
|
|
67
|
+
close,
|
|
68
|
+
approve
|
|
69
|
+
}), [open, close, approve]);
|
|
70
|
+
const infoList = (0, _ahooks.useCreation)(() => {
|
|
71
|
+
state.data.migratedFrom = [state.data.appId, state.data.appPid];
|
|
72
|
+
// const keys = Object.keys(omit(state.data, ['isMaster', 'did', 'pk']));
|
|
73
|
+
const keys = ['appName', 'appLogo', 'appId', 'appPid', 'migratedFrom', 'appDescription', 'appUrl', 'version', 'appliedAt', 'status', 'serverId', 'serverVersion'];
|
|
74
|
+
if (state.data.isMaster !== false) {
|
|
75
|
+
(0, _pull.default)(keys, 'appliedAt', 'status');
|
|
76
|
+
}
|
|
77
|
+
return keys.map(key => {
|
|
78
|
+
const name = t("federated.info.".concat(key));
|
|
79
|
+
let value = state.data[key];
|
|
80
|
+
if (key === 'appName') {
|
|
81
|
+
if (state.data.isMaster) {
|
|
82
|
+
value = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SvgIcon, {
|
|
84
|
+
component: _Stars.default
|
|
85
|
+
}), value]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (['appId', 'appPid', 'serverId'].includes(key)) {
|
|
90
|
+
value = /*#__PURE__*/(0, _jsxRuntime.jsx)(_didConnect.Address, {
|
|
91
|
+
children: value
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (['appUrl'].includes(key)) {
|
|
95
|
+
value = /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
96
|
+
component: "a",
|
|
97
|
+
href: value,
|
|
98
|
+
target: "_blank",
|
|
99
|
+
children: value
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (['appLogo'].includes(key)) {
|
|
103
|
+
value = /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
104
|
+
src: "".concat(state.data.appUrl, "/").concat(value),
|
|
105
|
+
width: "60",
|
|
106
|
+
height: "60",
|
|
107
|
+
alt: state.data.appName
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (key === 'status') {
|
|
111
|
+
value = value && t("federated.status.".concat(value));
|
|
112
|
+
}
|
|
113
|
+
if (key === 'migratedFrom') {
|
|
114
|
+
const migratedFrom = state.data.migratedFrom || [];
|
|
115
|
+
const filterDids = migratedFrom.filter(item => ![state.data.appId, state.data.appPid].includes(item));
|
|
116
|
+
value = filterDids.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_didConnect.Address, {
|
|
117
|
+
children: item
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
if ((0, _isEmpty.default)(value)) {
|
|
121
|
+
value = '-';
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
name,
|
|
125
|
+
value
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
}, [state.data]);
|
|
129
|
+
const isApprove = state.mode === 'approve';
|
|
130
|
+
const onReject = (0, _ahooks.useMemoizedFn)(async () => {
|
|
131
|
+
await api.auditFederatedLogin({
|
|
132
|
+
input: {
|
|
133
|
+
appId: state.data.appId,
|
|
134
|
+
did: blocklet.meta.did,
|
|
135
|
+
status: 'rejected'
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
state === null || state === void 0 ? void 0 : state.callback(false);
|
|
139
|
+
});
|
|
140
|
+
const onApprove = (0, _ahooks.useMemoizedFn)(async () => {
|
|
141
|
+
await api.auditFederatedLogin({
|
|
142
|
+
input: {
|
|
143
|
+
appId: state.data.appId,
|
|
144
|
+
did: blocklet.meta.did,
|
|
145
|
+
status: 'approved'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
close();
|
|
149
|
+
state === null || state === void 0 ? void 0 : state.callback(true);
|
|
150
|
+
});
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.default, {
|
|
152
|
+
open: state.show,
|
|
153
|
+
title: isApprove ? t('federated.approveToJoinLogin') : t('federated.siteDetail'),
|
|
154
|
+
onClose: close,
|
|
155
|
+
actions: isApprove ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
156
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
157
|
+
color: "error",
|
|
158
|
+
variant: "contained",
|
|
159
|
+
onClick: onReject,
|
|
160
|
+
children: t('common.reject')
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
162
|
+
variant: "contained",
|
|
163
|
+
onClick: onApprove,
|
|
164
|
+
children: t('common.approve')
|
|
165
|
+
})]
|
|
166
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
167
|
+
variant: "outlined",
|
|
168
|
+
onClick: close,
|
|
169
|
+
children: t('common.close')
|
|
170
|
+
}),
|
|
171
|
+
children: infoList.map(row => /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoRow.default, {
|
|
172
|
+
style: {
|
|
173
|
+
alignItems: 'flex-start'
|
|
174
|
+
},
|
|
175
|
+
valueComponent: "div",
|
|
176
|
+
nameWidth: 180,
|
|
177
|
+
name: row.name,
|
|
178
|
+
children: row.value
|
|
179
|
+
}, row.name))
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var _default = FederatedDetailDialog;
|
|
183
|
+
exports.default = _default;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _ahooks = require("ahooks");
|
|
11
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
12
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
13
|
+
var _CodeBlock = _interopRequireDefault(require("@arcblock/ux/lib/CodeBlock"));
|
|
14
|
+
var _copyToClipboard = _interopRequireDefault(require("copy-to-clipboard"));
|
|
15
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
19
|
+
|
|
20
|
+
const FederatedInviteDialog = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
21
|
+
var _theme$transitions, _theme$transitions$du;
|
|
22
|
+
const theme = (0, _Theme.useTheme)();
|
|
23
|
+
const leavingScreen = (theme === null || theme === void 0 ? void 0 : (_theme$transitions = theme.transitions) === null || _theme$transitions === void 0 ? void 0 : (_theme$transitions$du = _theme$transitions.duration) === null || _theme$transitions$du === void 0 ? void 0 : _theme$transitions$du.leavingScreen) || 300;
|
|
24
|
+
const {
|
|
25
|
+
t
|
|
26
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
27
|
+
const state = (0, _ahooks.useReactive)({
|
|
28
|
+
show: false,
|
|
29
|
+
data: {
|
|
30
|
+
link: ''
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const reset = (0, _ahooks.useMemoizedFn)(() => {
|
|
34
|
+
state.data.link = '';
|
|
35
|
+
}, []);
|
|
36
|
+
const close = (0, _ahooks.useMemoizedFn)(() => {
|
|
37
|
+
state.show = false;
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
reset();
|
|
40
|
+
}, leavingScreen);
|
|
41
|
+
}, []);
|
|
42
|
+
const open = (0, _ahooks.useMemoizedFn)(_ref => {
|
|
43
|
+
let {
|
|
44
|
+
link
|
|
45
|
+
} = _ref;
|
|
46
|
+
state.show = true;
|
|
47
|
+
state.data.link = link;
|
|
48
|
+
}, []);
|
|
49
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
50
|
+
open,
|
|
51
|
+
close
|
|
52
|
+
}), [open, close]);
|
|
53
|
+
const copyAndClose = (0, _ahooks.useMemoizedFn)(() => {
|
|
54
|
+
(0, _copyToClipboard.default)(state.data.link);
|
|
55
|
+
close();
|
|
56
|
+
}, [close]);
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
58
|
+
open: state.show,
|
|
59
|
+
title: t('federated.joinFederatedLogin'),
|
|
60
|
+
onClose: close,
|
|
61
|
+
PaperProps: {
|
|
62
|
+
style: {
|
|
63
|
+
minHeight: 'unset'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
67
|
+
color: "primary",
|
|
68
|
+
autoFocus: true,
|
|
69
|
+
variant: "contained",
|
|
70
|
+
onClick: copyAndClose,
|
|
71
|
+
children: t('common.copyAndClose')
|
|
72
|
+
}),
|
|
73
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
74
|
+
mb: 1,
|
|
75
|
+
children: t('federated.inviteJoinFederatedLoginDescription')
|
|
76
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
77
|
+
sx: {
|
|
78
|
+
'& .copy-button': {
|
|
79
|
+
display: 'none !important'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CodeBlock.default, {
|
|
83
|
+
language: "shell",
|
|
84
|
+
style: {
|
|
85
|
+
marginBottom: 0
|
|
86
|
+
},
|
|
87
|
+
children: state.data.link
|
|
88
|
+
})
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
var _default = FederatedInviteDialog;
|
|
93
|
+
exports.default = _default;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
var _ahooks = require("ahooks");
|
|
11
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
12
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
13
|
+
var _material = require("@mui/material");
|
|
14
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
15
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
16
|
+
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
17
|
+
var _blocklet = require("../../contexts/blocklet");
|
|
18
|
+
var _node = require("../../contexts/node");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
const FederatedJoinDialog = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
22
|
+
var _blocklet$meta, _theme$transitions, _theme$transitions$du;
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
26
|
+
const {
|
|
27
|
+
api
|
|
28
|
+
} = (0, _node.useNodeContext)();
|
|
29
|
+
const {
|
|
30
|
+
blocklet
|
|
31
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
32
|
+
const did = blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did;
|
|
33
|
+
const theme = (0, _Theme.useTheme)();
|
|
34
|
+
const leavingScreen = (theme === null || theme === void 0 ? void 0 : (_theme$transitions = theme.transitions) === null || _theme$transitions === void 0 ? void 0 : (_theme$transitions$du = _theme$transitions.duration) === null || _theme$transitions$du === void 0 ? void 0 : _theme$transitions$du.leavingScreen) || 300;
|
|
35
|
+
const state = (0, _ahooks.useReactive)({
|
|
36
|
+
show: false,
|
|
37
|
+
appUrl: '',
|
|
38
|
+
appUrlError: '',
|
|
39
|
+
callback: _noop.default
|
|
40
|
+
});
|
|
41
|
+
const reset = (0, _ahooks.useMemoizedFn)(() => {
|
|
42
|
+
state.appUrl = '';
|
|
43
|
+
state.appUrlError = '';
|
|
44
|
+
state.callback = _noop.default;
|
|
45
|
+
}, []);
|
|
46
|
+
const close = (0, _ahooks.useMemoizedFn)(() => {
|
|
47
|
+
state.show = false;
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
reset();
|
|
50
|
+
}, leavingScreen);
|
|
51
|
+
}, []);
|
|
52
|
+
const open = (0, _ahooks.useMemoizedFn)(function () {
|
|
53
|
+
let callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _noop.default;
|
|
54
|
+
state.show = true;
|
|
55
|
+
state.callback = callback;
|
|
56
|
+
}, []);
|
|
57
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
58
|
+
open,
|
|
59
|
+
close
|
|
60
|
+
}), [open, close]);
|
|
61
|
+
const validateAppUrl = (0, _ahooks.useMemoizedFn)(value => {
|
|
62
|
+
if (!value) {
|
|
63
|
+
throw new Error(t('federated.federatedJoinAppUrlRequired'));
|
|
64
|
+
}
|
|
65
|
+
if (!(0, _isUrl.default)(value)) {
|
|
66
|
+
throw new Error(t('federated.federatedJoinAppUrlInvalid'));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const confirm = (0, _ahooks.useMemoizedFn)(async () => {
|
|
70
|
+
try {
|
|
71
|
+
validateAppUrl(state.appUrl);
|
|
72
|
+
const data = await api.joinFederatedLogin({
|
|
73
|
+
input: {
|
|
74
|
+
did,
|
|
75
|
+
appUrl: state.appUrl
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
state.show = false;
|
|
79
|
+
close();
|
|
80
|
+
state === null || state === void 0 ? void 0 : state.callback(data);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
state.appUrlError = err.message;
|
|
83
|
+
}
|
|
84
|
+
}, [close, did]);
|
|
85
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
86
|
+
open: state.show,
|
|
87
|
+
title: t('federated.joinFederatedLogin'),
|
|
88
|
+
onClose: close,
|
|
89
|
+
PaperProps: {
|
|
90
|
+
style: {
|
|
91
|
+
minHeight: 'unset'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
95
|
+
color: "primary",
|
|
96
|
+
autoFocus: true,
|
|
97
|
+
variant: "contained",
|
|
98
|
+
onClick: confirm,
|
|
99
|
+
children: t('common.confirm')
|
|
100
|
+
}),
|
|
101
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
102
|
+
mb: 1,
|
|
103
|
+
children: t('federated.joinFederatedLoginDescription')
|
|
104
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
105
|
+
fullWidth: true,
|
|
106
|
+
variant: "outlined",
|
|
107
|
+
margin: "dense",
|
|
108
|
+
placeholder: t('federated.federatedJoinAppUrl'),
|
|
109
|
+
label: t('federated.federatedJoinAppUrl'),
|
|
110
|
+
value: state.appUrl,
|
|
111
|
+
error: !!state.appUrlError,
|
|
112
|
+
helperText: state.appUrlError || 'eg: https://www.arcblock.io',
|
|
113
|
+
onChange: e => {
|
|
114
|
+
state.appUrl = e.target.value;
|
|
115
|
+
}
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
var _default = FederatedJoinDialog;
|
|
120
|
+
exports.default = _default;
|