@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,175 @@
|
|
|
1
|
+
import InfoRow from '@arcblock/ux/lib/InfoRow';
|
|
2
|
+
import pull from 'lodash/pull';
|
|
3
|
+
import noop from 'lodash/noop';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
|
+
import { forwardRef, useContext, useImperativeHandle } from 'react';
|
|
6
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
|
+
import { useCreation, useMemoizedFn, useReactive } from 'ahooks';
|
|
8
|
+
import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
9
|
+
import { Box, Button, SvgIcon } from '@mui/material';
|
|
10
|
+
import { Address } from '@arcblock/did-connect';
|
|
11
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
12
|
+
import StarsIcon from '@mui/icons-material/Stars';
|
|
13
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
14
|
+
import { useNodeContext } from '../../contexts/node';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
const FederatedDetailDialog = /*#__PURE__*/forwardRef((props, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = useContext(LocaleContext);
|
|
22
|
+
const {
|
|
23
|
+
blocklet
|
|
24
|
+
} = useBlockletContext();
|
|
25
|
+
const {
|
|
26
|
+
api
|
|
27
|
+
} = useNodeContext();
|
|
28
|
+
const state = useReactive({
|
|
29
|
+
mode: 'view',
|
|
30
|
+
show: false,
|
|
31
|
+
data: {},
|
|
32
|
+
callback: noop
|
|
33
|
+
});
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const leavingScreen = theme?.transitions?.duration?.leavingScreen || 300;
|
|
36
|
+
const reset = useMemoizedFn(() => {
|
|
37
|
+
state.mode = 'view';
|
|
38
|
+
state.data = {};
|
|
39
|
+
state.callback = noop;
|
|
40
|
+
}, []);
|
|
41
|
+
const close = useMemoizedFn(() => {
|
|
42
|
+
state.show = false;
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
reset();
|
|
45
|
+
}, leavingScreen);
|
|
46
|
+
}, []);
|
|
47
|
+
const open = useMemoizedFn(data => {
|
|
48
|
+
state.mode = 'view';
|
|
49
|
+
state.show = true;
|
|
50
|
+
state.data = data;
|
|
51
|
+
}, []);
|
|
52
|
+
const approve = useMemoizedFn((data, callback = noop) => {
|
|
53
|
+
state.mode = 'approve';
|
|
54
|
+
state.show = true;
|
|
55
|
+
state.data = data;
|
|
56
|
+
state.callback = callback;
|
|
57
|
+
}, []);
|
|
58
|
+
useImperativeHandle(ref, () => ({
|
|
59
|
+
open,
|
|
60
|
+
close,
|
|
61
|
+
approve
|
|
62
|
+
}), [open, close, approve]);
|
|
63
|
+
const infoList = useCreation(() => {
|
|
64
|
+
state.data.migratedFrom = [state.data.appId, state.data.appPid];
|
|
65
|
+
const keys = ['appName', 'appLogo', 'appId', 'appPid', 'migratedFrom', 'appDescription', 'appUrl', 'version', 'appliedAt', 'status', 'serverId', 'serverVersion'];
|
|
66
|
+
if (state.data.isMaster !== false) {
|
|
67
|
+
pull(keys, 'appliedAt', 'status');
|
|
68
|
+
}
|
|
69
|
+
return keys.map(key => {
|
|
70
|
+
const name = t(`federated.info.${key}`);
|
|
71
|
+
let value = state.data[key];
|
|
72
|
+
if (key === 'appName') {
|
|
73
|
+
if (state.data.isMaster) {
|
|
74
|
+
value = /*#__PURE__*/_jsxs(Box, {
|
|
75
|
+
children: [/*#__PURE__*/_jsx(SvgIcon, {
|
|
76
|
+
component: StarsIcon
|
|
77
|
+
}), value]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (['appId', 'appPid', 'serverId'].includes(key)) {
|
|
82
|
+
value = /*#__PURE__*/_jsx(Address, {
|
|
83
|
+
children: value
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (['appUrl'].includes(key)) {
|
|
87
|
+
value = /*#__PURE__*/_jsx(Box, {
|
|
88
|
+
component: "a",
|
|
89
|
+
href: value,
|
|
90
|
+
target: "_blank",
|
|
91
|
+
children: value
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (['appLogo'].includes(key)) {
|
|
95
|
+
value = /*#__PURE__*/_jsx("img", {
|
|
96
|
+
src: `${state.data.appUrl}/${value}`,
|
|
97
|
+
width: "60",
|
|
98
|
+
height: "60",
|
|
99
|
+
alt: state.data.appName
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (key === 'status') {
|
|
103
|
+
value = value && t(`federated.status.${value}`);
|
|
104
|
+
}
|
|
105
|
+
if (key === 'migratedFrom') {
|
|
106
|
+
const migratedFrom = state.data.migratedFrom || [];
|
|
107
|
+
const filterDids = migratedFrom.filter(item => ![state.data.appId, state.data.appPid].includes(item));
|
|
108
|
+
value = filterDids.map(item => /*#__PURE__*/_jsx(Address, {
|
|
109
|
+
children: item
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
if (isEmpty(value)) {
|
|
113
|
+
value = '-';
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
name,
|
|
117
|
+
value
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}, [state.data]);
|
|
121
|
+
const isApprove = state.mode === 'approve';
|
|
122
|
+
const onReject = useMemoizedFn(async () => {
|
|
123
|
+
await api.auditFederatedLogin({
|
|
124
|
+
input: {
|
|
125
|
+
memberPid: state.data.appPid,
|
|
126
|
+
did: blocklet.appPid,
|
|
127
|
+
status: 'rejected'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
close();
|
|
131
|
+
state?.callback(false);
|
|
132
|
+
});
|
|
133
|
+
const onApprove = useMemoizedFn(async () => {
|
|
134
|
+
await api.auditFederatedLogin({
|
|
135
|
+
input: {
|
|
136
|
+
memberPid: state.data.appPid,
|
|
137
|
+
did: blocklet.appPid,
|
|
138
|
+
status: 'approved'
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
close();
|
|
142
|
+
state?.callback(true);
|
|
143
|
+
});
|
|
144
|
+
return /*#__PURE__*/_jsx(Dialog, {
|
|
145
|
+
open: state.show,
|
|
146
|
+
title: isApprove ? t('federated.approveToJoinLogin') : t('federated.siteDetail'),
|
|
147
|
+
onClose: close,
|
|
148
|
+
actions: isApprove ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
149
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
150
|
+
color: "error",
|
|
151
|
+
variant: "contained",
|
|
152
|
+
onClick: onReject,
|
|
153
|
+
children: t('common.reject')
|
|
154
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
155
|
+
variant: "contained",
|
|
156
|
+
onClick: onApprove,
|
|
157
|
+
children: t('common.approve')
|
|
158
|
+
})]
|
|
159
|
+
}) : /*#__PURE__*/_jsx(Button, {
|
|
160
|
+
variant: "outlined",
|
|
161
|
+
onClick: close,
|
|
162
|
+
children: t('common.close')
|
|
163
|
+
}),
|
|
164
|
+
children: infoList.map(row => /*#__PURE__*/_jsx(InfoRow, {
|
|
165
|
+
style: {
|
|
166
|
+
alignItems: 'flex-start'
|
|
167
|
+
},
|
|
168
|
+
valueComponent: "div",
|
|
169
|
+
nameWidth: 180,
|
|
170
|
+
name: row.name,
|
|
171
|
+
children: row.value
|
|
172
|
+
}, row.name))
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
export default FederatedDetailDialog;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
+
import { useContext, forwardRef, useImperativeHandle } from 'react';
|
|
5
|
+
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
6
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
7
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
8
|
+
import CodeBlock from '@arcblock/ux/lib/CodeBlock';
|
|
9
|
+
import copy from 'copy-to-clipboard';
|
|
10
|
+
import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const FederatedInviteDialog = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const leavingScreen = theme?.transitions?.duration?.leavingScreen || 300;
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = useContext(LocaleContext);
|
|
19
|
+
const state = useReactive({
|
|
20
|
+
show: false,
|
|
21
|
+
data: {
|
|
22
|
+
link: ''
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const reset = useMemoizedFn(() => {
|
|
26
|
+
state.data.link = '';
|
|
27
|
+
}, []);
|
|
28
|
+
const close = useMemoizedFn(() => {
|
|
29
|
+
state.show = false;
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
reset();
|
|
32
|
+
}, leavingScreen);
|
|
33
|
+
}, []);
|
|
34
|
+
const open = useMemoizedFn(({
|
|
35
|
+
link
|
|
36
|
+
}) => {
|
|
37
|
+
state.show = true;
|
|
38
|
+
state.data.link = link;
|
|
39
|
+
}, []);
|
|
40
|
+
useImperativeHandle(ref, () => ({
|
|
41
|
+
open,
|
|
42
|
+
close
|
|
43
|
+
}), [open, close]);
|
|
44
|
+
const copyAndClose = useMemoizedFn(() => {
|
|
45
|
+
copy(state.data.link);
|
|
46
|
+
close();
|
|
47
|
+
}, [close]);
|
|
48
|
+
return /*#__PURE__*/_jsxs(Dialog, {
|
|
49
|
+
open: state.show,
|
|
50
|
+
title: t('federated.joinFederatedLogin'),
|
|
51
|
+
onClose: close,
|
|
52
|
+
PaperProps: {
|
|
53
|
+
style: {
|
|
54
|
+
minHeight: 'unset'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
actions: /*#__PURE__*/_jsx(Button, {
|
|
58
|
+
color: "primary",
|
|
59
|
+
autoFocus: true,
|
|
60
|
+
variant: "contained",
|
|
61
|
+
onClick: copyAndClose,
|
|
62
|
+
children: t('common.copyAndClose')
|
|
63
|
+
}),
|
|
64
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
65
|
+
mb: 1,
|
|
66
|
+
children: t('federated.inviteJoinFederatedLoginDescription')
|
|
67
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
68
|
+
sx: {
|
|
69
|
+
'& .copy-button': {
|
|
70
|
+
display: 'none !important'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
children: /*#__PURE__*/_jsx(CodeBlock, {
|
|
74
|
+
language: "shell",
|
|
75
|
+
style: {
|
|
76
|
+
marginBottom: 0
|
|
77
|
+
},
|
|
78
|
+
children: state.data.link
|
|
79
|
+
})
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
export default FederatedInviteDialog;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { forwardRef, useContext, useImperativeHandle } from 'react';
|
|
3
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
+
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
5
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
6
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
7
|
+
import { TextField } from '@mui/material';
|
|
8
|
+
import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
9
|
+
import noop from 'lodash/noop';
|
|
10
|
+
import isUrl from 'is-url';
|
|
11
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
12
|
+
import { useNodeContext } from '../../contexts/node';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const FederatedJoinDialog = /*#__PURE__*/forwardRef((props, ref) => {
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = useContext(LocaleContext);
|
|
19
|
+
const {
|
|
20
|
+
api
|
|
21
|
+
} = useNodeContext();
|
|
22
|
+
const {
|
|
23
|
+
blocklet
|
|
24
|
+
} = useBlockletContext();
|
|
25
|
+
const did = blocklet?.appPid;
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const leavingScreen = theme?.transitions?.duration?.leavingScreen || 300;
|
|
28
|
+
const state = useReactive({
|
|
29
|
+
show: false,
|
|
30
|
+
appUrl: '',
|
|
31
|
+
appUrlError: '',
|
|
32
|
+
callback: noop
|
|
33
|
+
});
|
|
34
|
+
const reset = useMemoizedFn(() => {
|
|
35
|
+
state.appUrl = '';
|
|
36
|
+
state.appUrlError = '';
|
|
37
|
+
state.callback = noop;
|
|
38
|
+
}, []);
|
|
39
|
+
const close = useMemoizedFn(() => {
|
|
40
|
+
state.show = false;
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
reset();
|
|
43
|
+
}, leavingScreen);
|
|
44
|
+
}, []);
|
|
45
|
+
const open = useMemoizedFn((callback = noop) => {
|
|
46
|
+
state.show = true;
|
|
47
|
+
state.callback = callback;
|
|
48
|
+
}, []);
|
|
49
|
+
useImperativeHandle(ref, () => ({
|
|
50
|
+
open,
|
|
51
|
+
close
|
|
52
|
+
}), [open, close]);
|
|
53
|
+
const validateAppUrl = useMemoizedFn(value => {
|
|
54
|
+
if (!value) {
|
|
55
|
+
throw new Error(t('federated.federatedJoinAppUrlRequired'));
|
|
56
|
+
}
|
|
57
|
+
if (!isUrl(value)) {
|
|
58
|
+
throw new Error(t('federated.federatedJoinAppUrlInvalid'));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const confirm = useMemoizedFn(async () => {
|
|
62
|
+
try {
|
|
63
|
+
validateAppUrl(state.appUrl);
|
|
64
|
+
const data = await api.joinFederatedLogin({
|
|
65
|
+
input: {
|
|
66
|
+
did,
|
|
67
|
+
appUrl: state.appUrl
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
state.show = false;
|
|
71
|
+
close();
|
|
72
|
+
state?.callback(data);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
state.appUrlError = err.message;
|
|
75
|
+
}
|
|
76
|
+
}, [close, did]);
|
|
77
|
+
return /*#__PURE__*/_jsxs(Dialog, {
|
|
78
|
+
open: state.show,
|
|
79
|
+
title: t('federated.joinFederatedLogin'),
|
|
80
|
+
onClose: close,
|
|
81
|
+
PaperProps: {
|
|
82
|
+
style: {
|
|
83
|
+
minHeight: 'unset'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
actions: /*#__PURE__*/_jsx(Button, {
|
|
87
|
+
color: "primary",
|
|
88
|
+
autoFocus: true,
|
|
89
|
+
variant: "contained",
|
|
90
|
+
onClick: confirm,
|
|
91
|
+
children: t('common.confirm')
|
|
92
|
+
}),
|
|
93
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
94
|
+
mb: 1,
|
|
95
|
+
children: t('federated.joinFederatedLoginDescription')
|
|
96
|
+
}), /*#__PURE__*/_jsx(TextField, {
|
|
97
|
+
fullWidth: true,
|
|
98
|
+
variant: "outlined",
|
|
99
|
+
margin: "dense",
|
|
100
|
+
placeholder: t('federated.federatedJoinAppUrl'),
|
|
101
|
+
label: t('federated.federatedJoinAppUrl'),
|
|
102
|
+
value: state.appUrl,
|
|
103
|
+
error: !!state.appUrlError,
|
|
104
|
+
helperText: state.appUrlError || 'eg: https://www.arcblock.io',
|
|
105
|
+
onChange: e => {
|
|
106
|
+
state.appUrl = e.target.value;
|
|
107
|
+
}
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
export default FederatedJoinDialog;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import SvgIcon from '@mui/material/SvgIcon';
|
|
3
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
4
|
+
import StarsIcon from '@mui/icons-material/Stars';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import Datatable from '@arcblock/ux/lib/Datatable';
|
|
8
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
|
+
import Address from '@arcblock/did-connect/lib/Address';
|
|
10
|
+
import { useContext, useRef, useState } from 'react';
|
|
11
|
+
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
12
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
13
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
14
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
15
|
+
import { useNodeContext } from '../../contexts/node';
|
|
16
|
+
import useConfirm from '../../hooks/confirm';
|
|
17
|
+
import FederatedDetailDialog from './federated-detail-dialog';
|
|
18
|
+
import FederatedInviteDialog from './federated-invite-dialog';
|
|
19
|
+
import SwitchControl from '../component/switch-control';
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
function FederatedSiteList({
|
|
24
|
+
mode
|
|
25
|
+
}) {
|
|
26
|
+
const federatedInviteDialogRef = useRef(null);
|
|
27
|
+
const federatedDetailDialogRef = useRef(null);
|
|
28
|
+
const {
|
|
29
|
+
t,
|
|
30
|
+
locale
|
|
31
|
+
} = useContext(LocaleContext);
|
|
32
|
+
const {
|
|
33
|
+
blocklet,
|
|
34
|
+
actions: {
|
|
35
|
+
refreshBlocklet
|
|
36
|
+
}
|
|
37
|
+
} = useBlockletContext();
|
|
38
|
+
const {
|
|
39
|
+
confirmApi,
|
|
40
|
+
confirmHolder
|
|
41
|
+
} = useConfirm();
|
|
42
|
+
const {
|
|
43
|
+
api
|
|
44
|
+
} = useNodeContext();
|
|
45
|
+
const federatedSites = blocklet.settings.federated?.sites || [];
|
|
46
|
+
const federatedConfig = blocklet.settings.federated?.config || {
|
|
47
|
+
autoLogin: false
|
|
48
|
+
};
|
|
49
|
+
const isMaster = federatedConfig.isMaster !== false;
|
|
50
|
+
const viewDetail = useMemoizedFn(row => {
|
|
51
|
+
federatedDetailDialogRef.current?.open(row);
|
|
52
|
+
});
|
|
53
|
+
const approveSite = useMemoizedFn(row => {
|
|
54
|
+
federatedDetailDialogRef.current?.approve(row, refreshBlocklet);
|
|
55
|
+
});
|
|
56
|
+
const toRevokeSite = useMemoizedFn(row => {
|
|
57
|
+
confirmApi.open({
|
|
58
|
+
title: t('federated.disableFederatedLogin'),
|
|
59
|
+
content: t('federated.disableFederatedLoginDescription'),
|
|
60
|
+
async onConfirm(close) {
|
|
61
|
+
await api.auditFederatedLogin({
|
|
62
|
+
input: {
|
|
63
|
+
memberPid: row.appPid,
|
|
64
|
+
did: blocklet.appPid,
|
|
65
|
+
status: 'revoked'
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
close();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
const toApproveSite = useMemoizedFn(row => {
|
|
73
|
+
confirmApi.open({
|
|
74
|
+
title: t('federated.enableFederatedLogin'),
|
|
75
|
+
content: t('federated.enableFederatedLoginDescription'),
|
|
76
|
+
async onConfirm(close) {
|
|
77
|
+
await api.auditFederatedLogin({
|
|
78
|
+
input: {
|
|
79
|
+
memberPid: row.appPid,
|
|
80
|
+
did: blocklet.appPid,
|
|
81
|
+
status: 'approved'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
close();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
const columns = useCreation(() => {
|
|
89
|
+
const list = [{
|
|
90
|
+
label: t('common.name'),
|
|
91
|
+
name: 'appName',
|
|
92
|
+
options: {
|
|
93
|
+
customBodyRenderLite: rowIndex => {
|
|
94
|
+
const row = federatedSites[rowIndex];
|
|
95
|
+
const isSelfMaster = row.isMaster !== false;
|
|
96
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
97
|
+
display: "inline-block",
|
|
98
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
99
|
+
component: "a",
|
|
100
|
+
display: "flex",
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
href: row.appUrl,
|
|
103
|
+
target: "_blank",
|
|
104
|
+
onClick: e => {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
},
|
|
107
|
+
children: [isSelfMaster && /*#__PURE__*/_jsx(SvgIcon, {
|
|
108
|
+
component: StarsIcon,
|
|
109
|
+
style: {
|
|
110
|
+
marginRight: '4px'
|
|
111
|
+
}
|
|
112
|
+
}), row.appName]
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
label: t('common.did'),
|
|
119
|
+
name: 'appId',
|
|
120
|
+
options: {
|
|
121
|
+
customBodyRenderLite: rowIndex => {
|
|
122
|
+
const row = federatedSites[rowIndex];
|
|
123
|
+
return /*#__PURE__*/_jsx(Address, {
|
|
124
|
+
children: row.appId
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
label: t('common.status'),
|
|
130
|
+
name: 'status',
|
|
131
|
+
options: {
|
|
132
|
+
customBodyRenderLite: rowIndex => {
|
|
133
|
+
const row = federatedSites[rowIndex];
|
|
134
|
+
const isSelfMaster = row.isMaster !== false;
|
|
135
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
136
|
+
children: isSelfMaster ? '-' : t(`federated.status.${row.status}`)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}];
|
|
141
|
+
if (isMaster) {
|
|
142
|
+
list.push({
|
|
143
|
+
label: t('common.actions'),
|
|
144
|
+
name: 'actions',
|
|
145
|
+
options: {
|
|
146
|
+
customBodyRenderLite: rowIndex => {
|
|
147
|
+
const row = federatedSites[rowIndex];
|
|
148
|
+
const isSelfMaster = row.isMaster !== false;
|
|
149
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
150
|
+
display: "flex",
|
|
151
|
+
gap: 1,
|
|
152
|
+
children: !isSelfMaster ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
153
|
+
children: [row.status === 'pending' && /*#__PURE__*/_jsx(Button, {
|
|
154
|
+
variant: "contained",
|
|
155
|
+
color: "primary",
|
|
156
|
+
size: "small",
|
|
157
|
+
onClick: e => {
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
approveSite(row);
|
|
160
|
+
},
|
|
161
|
+
children: t('federated.status.pending')
|
|
162
|
+
}), row.status === 'approved' && /*#__PURE__*/_jsx(Button, {
|
|
163
|
+
variant: "contained",
|
|
164
|
+
color: "error",
|
|
165
|
+
size: "small",
|
|
166
|
+
onClick: e => {
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
toRevokeSite(row);
|
|
169
|
+
},
|
|
170
|
+
style: {
|
|
171
|
+
whiteSpace: 'nowrap'
|
|
172
|
+
},
|
|
173
|
+
children: t('federated.revoke')
|
|
174
|
+
}), row.status === 'revoked' && /*#__PURE__*/_jsx(Button, {
|
|
175
|
+
variant: "contained",
|
|
176
|
+
color: "warning",
|
|
177
|
+
size: "small",
|
|
178
|
+
onClick: e => {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
toApproveSite(row);
|
|
181
|
+
},
|
|
182
|
+
style: {
|
|
183
|
+
whiteSpace: 'nowrap'
|
|
184
|
+
},
|
|
185
|
+
children: t('federated.approve')
|
|
186
|
+
})]
|
|
187
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
188
|
+
children: [row.status === 'rejected' && /*#__PURE__*/_jsx(Button, {
|
|
189
|
+
variant: "contained",
|
|
190
|
+
color: "error",
|
|
191
|
+
size: "small",
|
|
192
|
+
onClick: e => {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
},
|
|
195
|
+
children: t('federated.status.rejected')
|
|
196
|
+
}), row.status === 'revoked' && /*#__PURE__*/_jsx(Button, {
|
|
197
|
+
variant: "contained",
|
|
198
|
+
color: "secondary",
|
|
199
|
+
size: "small",
|
|
200
|
+
onClick: e => {
|
|
201
|
+
e.stopPropagation();
|
|
202
|
+
},
|
|
203
|
+
children: t('federated.status.revoked')
|
|
204
|
+
})]
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return list;
|
|
212
|
+
}, [federatedConfig.appId, federatedSites, isMaster]);
|
|
213
|
+
const tableOptions = useCreation(() => {
|
|
214
|
+
return {
|
|
215
|
+
sort: true,
|
|
216
|
+
download: false,
|
|
217
|
+
filter: false,
|
|
218
|
+
print: false,
|
|
219
|
+
expandableRowsOnClick: true,
|
|
220
|
+
onRowClick(e, {
|
|
221
|
+
dataIndex
|
|
222
|
+
}) {
|
|
223
|
+
const x = federatedSites[dataIndex];
|
|
224
|
+
viewDetail(x);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}, []);
|
|
228
|
+
const showInvite = useMemoizedFn(() => {
|
|
229
|
+
const link = blocklet.site?.domainAliases?.[0]?.href;
|
|
230
|
+
if (link) {
|
|
231
|
+
try {
|
|
232
|
+
const url = new URL(link);
|
|
233
|
+
federatedInviteDialogRef.current?.open({
|
|
234
|
+
link: url.origin
|
|
235
|
+
});
|
|
236
|
+
} catch {
|
|
237
|
+
Toast.error(t('federated.failedToGetFederatedLoginLink'));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, [blocklet.site?.domainAliases?.[0]?.href]);
|
|
241
|
+
const [checked, setChecked] = useState(federatedConfig.autoLogin || false);
|
|
242
|
+
const changeAutoLogin = useMemoizedFn(() => {
|
|
243
|
+
confirmApi.open({
|
|
244
|
+
title: checked ? t('federated.disableFederatedAutoLogin') : t('federated.enableFederatedAutoLogin'),
|
|
245
|
+
content: checked ? t('federated.disableFederatedAutoLoginDescription') : t('federated.enableFederatedAutoLoginDescription'),
|
|
246
|
+
async onConfirm(close) {
|
|
247
|
+
await api.configFederated({
|
|
248
|
+
input: {
|
|
249
|
+
did: blocklet.appPid,
|
|
250
|
+
autoLogin: !checked
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
setChecked(prevValue => !prevValue);
|
|
254
|
+
close();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}, [setChecked, checked]);
|
|
258
|
+
const quitFederatedLogin = useMemoizedFn(() => {
|
|
259
|
+
confirmApi.open({
|
|
260
|
+
title: t('federated.quitFederatedLogin'),
|
|
261
|
+
content: t('federated.quitFederatedLoginDescription'),
|
|
262
|
+
async onConfirm(close) {
|
|
263
|
+
await api.quitFederatedLogin({
|
|
264
|
+
input: {
|
|
265
|
+
did: blocklet.appPid
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
close();
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
const customButtons = [];
|
|
273
|
+
if (mode !== 'master') {
|
|
274
|
+
customButtons.push( /*#__PURE__*/_jsx(Button, {
|
|
275
|
+
size: "small",
|
|
276
|
+
variant: "contained",
|
|
277
|
+
color: "error",
|
|
278
|
+
onClick: quitFederatedLogin,
|
|
279
|
+
sx: {
|
|
280
|
+
ml: 1
|
|
281
|
+
},
|
|
282
|
+
children: t('federated.quitFederatedLogin')
|
|
283
|
+
}));
|
|
284
|
+
} else {
|
|
285
|
+
customButtons.push( /*#__PURE__*/_jsx(Button, {
|
|
286
|
+
size: "small",
|
|
287
|
+
variant: "contained",
|
|
288
|
+
onClick: showInvite,
|
|
289
|
+
sx: {
|
|
290
|
+
ml: 1
|
|
291
|
+
},
|
|
292
|
+
children: t('federated.inviteJoinFederatedLogin')
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
296
|
+
children: [/*#__PURE__*/_jsx(Datatable, {
|
|
297
|
+
className: "main-table",
|
|
298
|
+
locale: locale,
|
|
299
|
+
data: federatedSites,
|
|
300
|
+
columns: columns,
|
|
301
|
+
customButtons: customButtons,
|
|
302
|
+
title: /*#__PURE__*/_jsx(Box, {
|
|
303
|
+
className: "table-toolbar-left",
|
|
304
|
+
children: mode === 'master' ? t('oauth.federated') : /*#__PURE__*/_jsx(FormControlLabel, {
|
|
305
|
+
sx: {
|
|
306
|
+
ml: 0,
|
|
307
|
+
'& span.MuiSwitch-switchBase': {
|
|
308
|
+
display: 'flex'
|
|
309
|
+
},
|
|
310
|
+
'& span.MuiSwitch-track': {
|
|
311
|
+
display: 'block'
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
control: /*#__PURE__*/_jsx(SwitchControl, {
|
|
315
|
+
checked: checked,
|
|
316
|
+
style: {
|
|
317
|
+
marginRight: '6px'
|
|
318
|
+
},
|
|
319
|
+
onChange: changeAutoLogin
|
|
320
|
+
}),
|
|
321
|
+
label: t('federated.enableFederatedAutoLogin')
|
|
322
|
+
})
|
|
323
|
+
}),
|
|
324
|
+
options: tableOptions
|
|
325
|
+
}), confirmHolder, /*#__PURE__*/_jsx(FederatedInviteDialog, {
|
|
326
|
+
ref: federatedInviteDialogRef
|
|
327
|
+
}), /*#__PURE__*/_jsx(FederatedDetailDialog, {
|
|
328
|
+
ref: federatedDetailDialogRef
|
|
329
|
+
})]
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
FederatedSiteList.propTypes = {
|
|
333
|
+
mode: PropTypes.oneOf(['member', 'master'])
|
|
334
|
+
};
|
|
335
|
+
FederatedSiteList.defaultProps = {
|
|
336
|
+
mode: 'member'
|
|
337
|
+
};
|
|
338
|
+
export default FederatedSiteList;
|