@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,167 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import AddIcon from '@mui/icons-material/CallMerge';
|
|
4
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
|
+
import TextField from '@mui/material/TextField';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
8
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
10
|
+
import Confirm from '../../../confirm';
|
|
11
|
+
import { formatError, sleep } from '../../../util';
|
|
12
|
+
import { useNodeContext } from '../../../contexts/node';
|
|
13
|
+
import { validateDomain } from '../util';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
export default function AddDomainAlias({
|
|
18
|
+
id,
|
|
19
|
+
children,
|
|
20
|
+
title,
|
|
21
|
+
teamDid
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = useLocaleContext();
|
|
26
|
+
const {
|
|
27
|
+
api
|
|
28
|
+
} = useNodeContext();
|
|
29
|
+
const [loading, setLoading] = useState(false);
|
|
30
|
+
const [confirmSetting, setConfirmSetting] = useState(null);
|
|
31
|
+
const onCancel = () => {
|
|
32
|
+
setLoading(false);
|
|
33
|
+
setConfirmSetting(null);
|
|
34
|
+
};
|
|
35
|
+
const onConfirm = async params => {
|
|
36
|
+
if (loading) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setLoading(true);
|
|
40
|
+
try {
|
|
41
|
+
await api.addDomainAlias({
|
|
42
|
+
input: {
|
|
43
|
+
id,
|
|
44
|
+
domainAlias: params.domain.trim(),
|
|
45
|
+
teamDid
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
await sleep(2000);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
Toast.error(err.message);
|
|
51
|
+
} finally {
|
|
52
|
+
setConfirmSetting(null);
|
|
53
|
+
setLoading(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const onEnter = async (params, confirm, setError) => {
|
|
57
|
+
try {
|
|
58
|
+
await confirm(params);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
setError(formatError(err));
|
|
61
|
+
} finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const setting = {
|
|
66
|
+
title: title || t('router.domainAlias.add.title'),
|
|
67
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
68
|
+
description: (params, setParams, setError) => /*#__PURE__*/_jsx(Typography, {
|
|
69
|
+
component: "div",
|
|
70
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
|
71
|
+
label: t('router.domainAlias.add.domainDescription'),
|
|
72
|
+
autoComplete: "off",
|
|
73
|
+
variant: "outlined",
|
|
74
|
+
name: "domain",
|
|
75
|
+
"data-cy": "add-domain",
|
|
76
|
+
fullWidth: true,
|
|
77
|
+
autoFocus: true,
|
|
78
|
+
inputProps: {
|
|
79
|
+
'data-cy': 'domain-name-input'
|
|
80
|
+
},
|
|
81
|
+
value: params.domain,
|
|
82
|
+
style: {
|
|
83
|
+
marginBottom: 8
|
|
84
|
+
},
|
|
85
|
+
margin: "dense",
|
|
86
|
+
onChange: e => {
|
|
87
|
+
const domain = e.target.value.trim();
|
|
88
|
+
const errMsg = validateDomain(domain, t);
|
|
89
|
+
setParams({
|
|
90
|
+
...params,
|
|
91
|
+
domain,
|
|
92
|
+
__disableConfirm: !!errMsg
|
|
93
|
+
});
|
|
94
|
+
if (errMsg) {
|
|
95
|
+
setError(errMsg);
|
|
96
|
+
} else {
|
|
97
|
+
setError('');
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
onKeyPress: e => {
|
|
101
|
+
if (e.key === 'Enter') {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
const domain = e.target.value.trim();
|
|
104
|
+
const errMsg = validateDomain(domain, t);
|
|
105
|
+
if (errMsg) {
|
|
106
|
+
setError(errMsg);
|
|
107
|
+
} else {
|
|
108
|
+
onEnter(params, onConfirm, setError);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
}),
|
|
114
|
+
confirm: t('common.confirm'),
|
|
115
|
+
cancel: t('common.cancel'),
|
|
116
|
+
params: {
|
|
117
|
+
domain: '',
|
|
118
|
+
__disableConfirm: true
|
|
119
|
+
},
|
|
120
|
+
onConfirm,
|
|
121
|
+
onCancel
|
|
122
|
+
};
|
|
123
|
+
const onMenuItemClick = e => {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
// eslint-disable-next-line no-unused-expressions
|
|
126
|
+
setConfirmSetting(setting);
|
|
127
|
+
};
|
|
128
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
129
|
+
children: [typeof children === 'function' ? children({
|
|
130
|
+
loading,
|
|
131
|
+
open: onMenuItemClick
|
|
132
|
+
}) : /*#__PURE__*/_jsxs(MenuItem, {
|
|
133
|
+
onClick: onMenuItemClick,
|
|
134
|
+
className: "rule-action",
|
|
135
|
+
"data-cy": "action-add-domain-alias",
|
|
136
|
+
children: [loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
137
|
+
size: 16
|
|
138
|
+
}) : /*#__PURE__*/_jsx(AddIcon, {
|
|
139
|
+
style: {
|
|
140
|
+
fontSize: 18,
|
|
141
|
+
marginRight: 5
|
|
142
|
+
}
|
|
143
|
+
}), t('router.domainAlias.add.title')]
|
|
144
|
+
}), confirmSetting && /*#__PURE__*/_jsx(Confirm, {
|
|
145
|
+
title: confirmSetting.title,
|
|
146
|
+
description: confirmSetting.description,
|
|
147
|
+
confirm: confirmSetting.confirm,
|
|
148
|
+
cancel: confirmSetting.cancel,
|
|
149
|
+
params: confirmSetting.params,
|
|
150
|
+
onConfirm: confirmSetting.onConfirm,
|
|
151
|
+
onCancel: confirmSetting.onCancel,
|
|
152
|
+
color: "primary",
|
|
153
|
+
loading: loading
|
|
154
|
+
})]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
AddDomainAlias.propTypes = {
|
|
158
|
+
id: PropTypes.string.isRequired,
|
|
159
|
+
children: PropTypes.any,
|
|
160
|
+
title: PropTypes.string,
|
|
161
|
+
teamDid: PropTypes.string
|
|
162
|
+
};
|
|
163
|
+
AddDomainAlias.defaultProps = {
|
|
164
|
+
children: null,
|
|
165
|
+
title: '',
|
|
166
|
+
teamDid: ''
|
|
167
|
+
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import AddIcon from '@mui/icons-material/Link';
|
|
4
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
|
+
import TextField from '@mui/material/TextField';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
8
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
|
+
import { ROUTING_RULE_TYPES } from '@abtnode/constant';
|
|
10
|
+
import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
|
|
11
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
12
|
+
import { useNodeContext } from '../../../contexts/node';
|
|
13
|
+
import { useBlockletContext } from '../../../contexts/blocklet';
|
|
14
|
+
import Confirm from '../../../confirm';
|
|
15
|
+
import { validateRule, validatePathPrefix } from '../util';
|
|
16
|
+
import ConfigRoutingRule from './config-routing-rule';
|
|
17
|
+
import { formatMountPoint } from '../../../util';
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
export default function AddRule({
|
|
22
|
+
children
|
|
23
|
+
}) {
|
|
24
|
+
const {
|
|
25
|
+
t
|
|
26
|
+
} = useLocaleContext();
|
|
27
|
+
const {
|
|
28
|
+
api
|
|
29
|
+
} = useNodeContext();
|
|
30
|
+
const {
|
|
31
|
+
blocklet
|
|
32
|
+
} = useBlockletContext();
|
|
33
|
+
const [loading, setLoading] = useState(false);
|
|
34
|
+
const [confirmSetting, setConfirmSetting] = useState(null);
|
|
35
|
+
const teamDid = blocklet.meta.did;
|
|
36
|
+
const siteId = blocklet.site.id;
|
|
37
|
+
const onCancel = () => {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
setConfirmSetting(null);
|
|
40
|
+
};
|
|
41
|
+
const onConfirm = async params => {
|
|
42
|
+
try {
|
|
43
|
+
const err = await validateRule(params, t);
|
|
44
|
+
if (err) {
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
setLoading(true);
|
|
48
|
+
const rule = {
|
|
49
|
+
from: {
|
|
50
|
+
pathPrefix: urlPathFriendly(params.pathPrefix)
|
|
51
|
+
},
|
|
52
|
+
to: {
|
|
53
|
+
type: params.type
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (params.type === ROUTING_RULE_TYPES.REDIRECT) {
|
|
57
|
+
rule.to.url = params.url.trim();
|
|
58
|
+
rule.to.redirectCode = params.redirectCode;
|
|
59
|
+
}
|
|
60
|
+
if (params.type === ROUTING_RULE_TYPES.COMPONENT) {
|
|
61
|
+
rule.to.did = teamDid;
|
|
62
|
+
rule.to.componentId = params.componentId;
|
|
63
|
+
rule.to.pageGroup = params.pageGroup;
|
|
64
|
+
}
|
|
65
|
+
if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
|
|
66
|
+
rule.to.url = urlPathFriendly(params.url);
|
|
67
|
+
}
|
|
68
|
+
await api.addRoutingRule({
|
|
69
|
+
input: {
|
|
70
|
+
id: siteId,
|
|
71
|
+
rule,
|
|
72
|
+
teamDid
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
Toast.error(error.message);
|
|
77
|
+
} finally {
|
|
78
|
+
setLoading(false);
|
|
79
|
+
setConfirmSetting(null);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const setting = {
|
|
83
|
+
title: t('router.rule.add.title'),
|
|
84
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
85
|
+
description: (params, setParams, setError) => {
|
|
86
|
+
const setValue = value => {
|
|
87
|
+
setError(null);
|
|
88
|
+
const validateResult = validateRule(value, t);
|
|
89
|
+
if (validateResult) {
|
|
90
|
+
setParams({
|
|
91
|
+
...value,
|
|
92
|
+
__disableConfirm: true
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setParams({
|
|
97
|
+
...value
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/_jsxs(Typography, {
|
|
101
|
+
component: "div",
|
|
102
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
|
103
|
+
label: t('router.rule.add.pathPrefix'),
|
|
104
|
+
autoComplete: "off",
|
|
105
|
+
variant: "outlined",
|
|
106
|
+
name: "pathPrefix",
|
|
107
|
+
"data-cy": "path-prefix-input",
|
|
108
|
+
fullWidth: true,
|
|
109
|
+
autoFocus: true,
|
|
110
|
+
helperText: params.pathPrefixHint || t('router.rule.add.pathPrefixTip'),
|
|
111
|
+
style: {
|
|
112
|
+
marginBottom: 32
|
|
113
|
+
},
|
|
114
|
+
margin: "dense",
|
|
115
|
+
value: params.pathPrefix,
|
|
116
|
+
onChange: e => {
|
|
117
|
+
let disable = false;
|
|
118
|
+
const validateResult = validatePathPrefix({
|
|
119
|
+
params: {
|
|
120
|
+
...params,
|
|
121
|
+
pathPrefix: e.target.value
|
|
122
|
+
},
|
|
123
|
+
blocklets: [blocklet]
|
|
124
|
+
});
|
|
125
|
+
setError(validateResult);
|
|
126
|
+
if (params.type === ROUTING_RULE_TYPES.BLOCKLET && validateResult) {
|
|
127
|
+
disable = true;
|
|
128
|
+
}
|
|
129
|
+
if (params.type === ROUTING_RULE_TYPES.REDIRECT && !params.url) {
|
|
130
|
+
disable = true;
|
|
131
|
+
}
|
|
132
|
+
if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && !params.url) {
|
|
133
|
+
disable = true;
|
|
134
|
+
}
|
|
135
|
+
if (!e.target.value.trim()) {
|
|
136
|
+
disable = true;
|
|
137
|
+
setError(t('router.validation.pathPrefixRequired'));
|
|
138
|
+
}
|
|
139
|
+
if (!disable) {
|
|
140
|
+
setError('');
|
|
141
|
+
}
|
|
142
|
+
const pathPrefixHint = t('common.slugifyHint', {
|
|
143
|
+
value: formatMountPoint(e.target.value)
|
|
144
|
+
});
|
|
145
|
+
setParams({
|
|
146
|
+
...params,
|
|
147
|
+
pathPrefix: e.target.value,
|
|
148
|
+
pathPrefixHint,
|
|
149
|
+
__disableConfirm: disable
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}), /*#__PURE__*/_jsx(ConfigRoutingRule, {
|
|
153
|
+
params: params,
|
|
154
|
+
setParams: setValue,
|
|
155
|
+
setError: setError
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
confirm: t('router.rule.add.confirm'),
|
|
160
|
+
cancel: t('common.cancel'),
|
|
161
|
+
params: {
|
|
162
|
+
did: '',
|
|
163
|
+
pathPrefix: '',
|
|
164
|
+
type: ROUTING_RULE_TYPES.REDIRECT,
|
|
165
|
+
componentId: '',
|
|
166
|
+
pageGroup: '',
|
|
167
|
+
redirectCode: 302,
|
|
168
|
+
__disableConfirm: true
|
|
169
|
+
},
|
|
170
|
+
onConfirm,
|
|
171
|
+
onCancel
|
|
172
|
+
};
|
|
173
|
+
const onMenuItemClick = e => {
|
|
174
|
+
e.stopPropagation();
|
|
175
|
+
// eslint-disable-next-line no-unused-expressions
|
|
176
|
+
setConfirmSetting(setting);
|
|
177
|
+
};
|
|
178
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
179
|
+
children: [typeof children === 'function' ? children({
|
|
180
|
+
loading,
|
|
181
|
+
open: onMenuItemClick
|
|
182
|
+
}) : /*#__PURE__*/_jsxs(MenuItem, {
|
|
183
|
+
onClick: onMenuItemClick,
|
|
184
|
+
className: "rule-action",
|
|
185
|
+
"data-cy": "action-add-rule",
|
|
186
|
+
children: [loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
187
|
+
size: 16
|
|
188
|
+
}) : /*#__PURE__*/_jsx(AddIcon, {
|
|
189
|
+
style: {
|
|
190
|
+
fontSize: 18,
|
|
191
|
+
marginRight: 5
|
|
192
|
+
}
|
|
193
|
+
}), t('router.rule.add.title')]
|
|
194
|
+
}), confirmSetting && /*#__PURE__*/_jsx(Confirm, {
|
|
195
|
+
title: confirmSetting.title,
|
|
196
|
+
description: confirmSetting.description,
|
|
197
|
+
confirm: confirmSetting.confirm,
|
|
198
|
+
cancel: confirmSetting.cancel,
|
|
199
|
+
params: confirmSetting.params,
|
|
200
|
+
onConfirm: confirmSetting.onConfirm,
|
|
201
|
+
onCancel: confirmSetting.onCancel,
|
|
202
|
+
color: "primary"
|
|
203
|
+
})]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
AddRule.propTypes = {
|
|
207
|
+
children: PropTypes.any
|
|
208
|
+
};
|
|
209
|
+
AddRule.defaultProps = {
|
|
210
|
+
children: null
|
|
211
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import TextField from '@mui/material/TextField';
|
|
4
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
5
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
|
+
import { ROUTING_RULE_TYPES } from '@abtnode/constant';
|
|
7
|
+
import { BLOCKLET_INTERFACE_TYPE_WEB } from '@blocklet/constant';
|
|
8
|
+
import { findWebInterface, getDisplayName } from '@blocklet/meta/lib/util';
|
|
9
|
+
import { useBlockletContext } from '../../../contexts/blocklet';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const getComponents = blocklet => blocklet.children.filter(x => x.meta.interfaces.find(i => i.type === BLOCKLET_INTERFACE_TYPE_WEB));
|
|
14
|
+
export default function ConfigRoutingRule({
|
|
15
|
+
params,
|
|
16
|
+
setParams,
|
|
17
|
+
setError,
|
|
18
|
+
serviceTypes
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
t
|
|
22
|
+
} = useLocaleContext();
|
|
23
|
+
const {
|
|
24
|
+
blocklet
|
|
25
|
+
} = useBlockletContext();
|
|
26
|
+
const teamDid = blocklet.meta.did;
|
|
27
|
+
const components = getComponents(blocklet);
|
|
28
|
+
const [pageGroups, setPageGroups] = useState([]);
|
|
29
|
+
const redirectCodesMap = {
|
|
30
|
+
301: t('common.redirectPermanently'),
|
|
31
|
+
302: t('common.redirectTemporary'),
|
|
32
|
+
307: t('common.redirectTemporary'),
|
|
33
|
+
308: t('common.redirectPermanently')
|
|
34
|
+
};
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (params.type === ROUTING_RULE_TYPES.COMPONENT && params.componentId) {
|
|
37
|
+
const component = components.find(x => x.meta.did === params.componentId);
|
|
38
|
+
const webInterface = findWebInterface(component.meta);
|
|
39
|
+
const groups = (Array.isArray(webInterface?.pageGroups) ? webInterface.pageGroups : []).map(x => ({
|
|
40
|
+
value: x,
|
|
41
|
+
label: `${x} pages`
|
|
42
|
+
}));
|
|
43
|
+
if (groups.length) {
|
|
44
|
+
groups.unshift({
|
|
45
|
+
value: '',
|
|
46
|
+
label: 'All pages'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
setPageGroups(groups);
|
|
50
|
+
if (params.pageGroup && groups.find(x => x.value === params.pageGroup) === false) {
|
|
51
|
+
setParams({
|
|
52
|
+
...params,
|
|
53
|
+
pageGroups: ''
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, [params.componentId, params.type]);
|
|
59
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
60
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
|
61
|
+
select: true,
|
|
62
|
+
label: t('router.domain.add.type'),
|
|
63
|
+
autoComplete: "off",
|
|
64
|
+
variant: "outlined",
|
|
65
|
+
name: "type",
|
|
66
|
+
"data-cy": "domain-add-type",
|
|
67
|
+
fullWidth: true,
|
|
68
|
+
value: params.type,
|
|
69
|
+
onChange: e => {
|
|
70
|
+
setError('');
|
|
71
|
+
setParams({
|
|
72
|
+
...params,
|
|
73
|
+
type: e.target.value,
|
|
74
|
+
did: e.target.value === ROUTING_RULE_TYPES.BLOCKLET ? teamDid : '',
|
|
75
|
+
__disableConfirm: false
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
style: {
|
|
79
|
+
marginBottom: 32
|
|
80
|
+
},
|
|
81
|
+
SelectProps: {},
|
|
82
|
+
children: serviceTypes.map(({
|
|
83
|
+
name,
|
|
84
|
+
value
|
|
85
|
+
}) => /*#__PURE__*/_jsx(MenuItem, {
|
|
86
|
+
value: value,
|
|
87
|
+
children: name
|
|
88
|
+
}, value))
|
|
89
|
+
}), params.type === ROUTING_RULE_TYPES.REDIRECT && [/*#__PURE__*/_jsx(TextField, {
|
|
90
|
+
select: true,
|
|
91
|
+
label: t('router.domain.add.redirect'),
|
|
92
|
+
autoComplete: "off",
|
|
93
|
+
variant: "outlined",
|
|
94
|
+
name: "type",
|
|
95
|
+
fullWidth: true,
|
|
96
|
+
value: params.redirectCode,
|
|
97
|
+
onChange: e => setParams({
|
|
98
|
+
...params,
|
|
99
|
+
redirectCode: e.target.value
|
|
100
|
+
}),
|
|
101
|
+
style: {
|
|
102
|
+
marginBottom: 32
|
|
103
|
+
},
|
|
104
|
+
SelectProps: {},
|
|
105
|
+
children: Object.keys(redirectCodesMap).map(code => /*#__PURE__*/_jsx(MenuItem, {
|
|
106
|
+
value: code,
|
|
107
|
+
children: `${redirectCodesMap[code]} - ${code}`
|
|
108
|
+
}, code))
|
|
109
|
+
}, "redirectCode"), /*#__PURE__*/_jsx(TextField, {
|
|
110
|
+
label: t('common.redirectUrl'),
|
|
111
|
+
autoComplete: "off",
|
|
112
|
+
variant: "outlined",
|
|
113
|
+
name: "url",
|
|
114
|
+
"data-cy": "redirect-url-input",
|
|
115
|
+
fullWidth: true,
|
|
116
|
+
value: params.url,
|
|
117
|
+
helperText: t('router.urlHelperText'),
|
|
118
|
+
style: {
|
|
119
|
+
marginBottom: 32
|
|
120
|
+
},
|
|
121
|
+
onChange: e => {
|
|
122
|
+
setParams({
|
|
123
|
+
...params,
|
|
124
|
+
url: e.target.value,
|
|
125
|
+
__disableConfirm: !e.target.value.trim()
|
|
126
|
+
});
|
|
127
|
+
if (!e.target.value.trim()) {
|
|
128
|
+
setError(t('router.validation.redirectUrlRequired'));
|
|
129
|
+
} else {
|
|
130
|
+
setError('');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, "redirectUrl")], params.type === ROUTING_RULE_TYPES.COMPONENT && [/*#__PURE__*/_jsx(TextField, {
|
|
134
|
+
select: true,
|
|
135
|
+
label: t('router.domain.add.component'),
|
|
136
|
+
autoComplete: "off",
|
|
137
|
+
variant: "outlined",
|
|
138
|
+
"data-cy": "select-component-input",
|
|
139
|
+
name: "componentId",
|
|
140
|
+
fullWidth: true,
|
|
141
|
+
value: params.componentId,
|
|
142
|
+
onChange: e => {
|
|
143
|
+
setParams({
|
|
144
|
+
...params,
|
|
145
|
+
componentId: e.target.value
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
style: {
|
|
149
|
+
marginBottom: 32
|
|
150
|
+
},
|
|
151
|
+
SelectProps: {},
|
|
152
|
+
children: components.map(component => /*#__PURE__*/_jsx(MenuItem, {
|
|
153
|
+
value: component.meta.did,
|
|
154
|
+
selected: component.meta.did === params.componentId,
|
|
155
|
+
children: getDisplayName(component, true)
|
|
156
|
+
}, component.meta.did))
|
|
157
|
+
}, "componentId"), pageGroups.length ? /*#__PURE__*/_jsx(TextField, {
|
|
158
|
+
select: true,
|
|
159
|
+
label: t('router.domain.add.pageGroup'),
|
|
160
|
+
autoComplete: "off",
|
|
161
|
+
variant: "outlined",
|
|
162
|
+
name: "pageGroup",
|
|
163
|
+
"data-cy": "route-group-input",
|
|
164
|
+
fullWidth: true,
|
|
165
|
+
value: params.pageGroup,
|
|
166
|
+
helperText: t('router.domain.add.pageGroupTip'),
|
|
167
|
+
style: {
|
|
168
|
+
marginBottom: 32
|
|
169
|
+
},
|
|
170
|
+
onChange: e => {
|
|
171
|
+
setParams({
|
|
172
|
+
...params,
|
|
173
|
+
pageGroup: e.target.value
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
SelectProps: {},
|
|
177
|
+
children: pageGroups.map(x => /*#__PURE__*/_jsx(MenuItem, {
|
|
178
|
+
value: x.value,
|
|
179
|
+
selected: x.value === params.pageGroup,
|
|
180
|
+
children: x.label
|
|
181
|
+
}, x.label))
|
|
182
|
+
}, "pageGroup") : null].filter(Boolean), params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && /*#__PURE__*/_jsx(TextField, {
|
|
183
|
+
label: t('common.rewriteUrl'),
|
|
184
|
+
autoComplete: "off",
|
|
185
|
+
variant: "outlined",
|
|
186
|
+
name: "url",
|
|
187
|
+
"data-cy": "rewrite-url-input",
|
|
188
|
+
fullWidth: true,
|
|
189
|
+
value: params.url,
|
|
190
|
+
helperText: t('router.urlHelperText'),
|
|
191
|
+
style: {
|
|
192
|
+
marginBottom: 32
|
|
193
|
+
},
|
|
194
|
+
onChange: e => {
|
|
195
|
+
setParams({
|
|
196
|
+
...params,
|
|
197
|
+
url: e.target.value,
|
|
198
|
+
__disableConfirm: !e.target.value.trim()
|
|
199
|
+
});
|
|
200
|
+
if (!e.target.value.trim()) {
|
|
201
|
+
setError(t('router.validation.rewriteUrlRequired'));
|
|
202
|
+
} else {
|
|
203
|
+
setError('');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}, "url")]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
ConfigRoutingRule.propTypes = {
|
|
210
|
+
params: PropTypes.object,
|
|
211
|
+
serviceTypes: PropTypes.array,
|
|
212
|
+
setParams: PropTypes.func,
|
|
213
|
+
setError: PropTypes.func
|
|
214
|
+
};
|
|
215
|
+
ConfigRoutingRule.defaultProps = {
|
|
216
|
+
params: {},
|
|
217
|
+
serviceTypes: [{
|
|
218
|
+
name: 'Redirect',
|
|
219
|
+
value: ROUTING_RULE_TYPES.REDIRECT
|
|
220
|
+
}, {
|
|
221
|
+
name: 'Default - User will see the 404 page',
|
|
222
|
+
value: ROUTING_RULE_TYPES.NONE
|
|
223
|
+
}, {
|
|
224
|
+
name: 'Rewrite - Route traffic without redirect',
|
|
225
|
+
value: ROUTING_RULE_TYPES.GENERAL_REWRITE
|
|
226
|
+
}, {
|
|
227
|
+
name: 'Component - Pass traffic to blocklet component',
|
|
228
|
+
value: ROUTING_RULE_TYPES.COMPONENT
|
|
229
|
+
}],
|
|
230
|
+
setParams: () => {},
|
|
231
|
+
setError: () => {}
|
|
232
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ActionIcon from '@mui/icons-material/Delete';
|
|
4
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
5
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
6
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
8
|
+
import Confirm from '../../../confirm';
|
|
9
|
+
import { useNodeContext } from '../../../contexts/node';
|
|
10
|
+
import { sleep } from '../../../util';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
export default function DeleteDomainAlias(props) {
|
|
15
|
+
const {
|
|
16
|
+
t
|
|
17
|
+
} = useLocaleContext();
|
|
18
|
+
const [loading, setLoading] = useState(false);
|
|
19
|
+
const [confirmSetting, setConfirmSetting] = useState(null);
|
|
20
|
+
const {
|
|
21
|
+
id,
|
|
22
|
+
domain,
|
|
23
|
+
children,
|
|
24
|
+
teamDid
|
|
25
|
+
} = props;
|
|
26
|
+
const {
|
|
27
|
+
api
|
|
28
|
+
} = useNodeContext();
|
|
29
|
+
const onCancel = () => {
|
|
30
|
+
setLoading(false);
|
|
31
|
+
setConfirmSetting(null);
|
|
32
|
+
};
|
|
33
|
+
const onConfirm = async () => {
|
|
34
|
+
setLoading(true);
|
|
35
|
+
try {
|
|
36
|
+
await api.deleteDomainAlias({
|
|
37
|
+
input: {
|
|
38
|
+
id,
|
|
39
|
+
domainAlias: domain,
|
|
40
|
+
teamDid
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
await sleep(2000);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
Toast.error(err.message);
|
|
46
|
+
} finally {
|
|
47
|
+
setConfirmSetting(null);
|
|
48
|
+
setLoading(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const setting = {
|
|
52
|
+
title: t('router.domainAlias.delete.title'),
|
|
53
|
+
description: t('router.domainAlias.delete.description'),
|
|
54
|
+
confirm: t('common.confirm'),
|
|
55
|
+
onConfirm,
|
|
56
|
+
onCancel
|
|
57
|
+
};
|
|
58
|
+
const onClick = e => {
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
setConfirmSetting(setting);
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
63
|
+
children: [typeof children === 'function' ? children({
|
|
64
|
+
loading,
|
|
65
|
+
open: onClick
|
|
66
|
+
}) : /*#__PURE__*/_jsxs(Button, {
|
|
67
|
+
edge: "end",
|
|
68
|
+
onClick: onClick,
|
|
69
|
+
size: "small",
|
|
70
|
+
className: "rule-action",
|
|
71
|
+
color: "error",
|
|
72
|
+
"data-cy": "action-delete-domain-alias",
|
|
73
|
+
children: [loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
74
|
+
size: 16
|
|
75
|
+
}) : /*#__PURE__*/_jsx(ActionIcon, {
|
|
76
|
+
style: {
|
|
77
|
+
fontSize: 16
|
|
78
|
+
}
|
|
79
|
+
}), t('router.domainAlias.delete.title')]
|
|
80
|
+
}), confirmSetting && /*#__PURE__*/_jsx(Confirm, {
|
|
81
|
+
title: confirmSetting.title,
|
|
82
|
+
description: confirmSetting.description,
|
|
83
|
+
confirm: confirmSetting.confirm,
|
|
84
|
+
params: confirmSetting.params,
|
|
85
|
+
onConfirm: confirmSetting.onConfirm,
|
|
86
|
+
onCancel: confirmSetting.onCancel
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
DeleteDomainAlias.propTypes = {
|
|
91
|
+
id: PropTypes.string.isRequired,
|
|
92
|
+
domain: PropTypes.string.isRequired,
|
|
93
|
+
children: PropTypes.any,
|
|
94
|
+
teamDid: PropTypes.string
|
|
95
|
+
};
|
|
96
|
+
DeleteDomainAlias.defaultProps = {
|
|
97
|
+
children: null,
|
|
98
|
+
teamDid: ''
|
|
99
|
+
};
|