@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,190 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import isUrl from 'is-url';
|
|
4
|
+
import useTheme from '@mui/material/styles/useTheme';
|
|
5
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import ExternalLink from '@mui/material/Link';
|
|
8
|
+
import IconButton from '@mui/material/IconButton';
|
|
9
|
+
import Avatar from '@mui/material/Avatar';
|
|
10
|
+
import LockIcon from '@arcblock/icons/lib/LockIcon';
|
|
11
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
12
|
+
import { ROUTING_RULE_TYPES } from '@abtnode/constant';
|
|
13
|
+
import { getDisplayName } from '@blocklet/meta/lib/util';
|
|
14
|
+
import { getBlockletUrlParams, getAccessUrl, BlockletAdminRoles } from '../../util';
|
|
15
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
16
|
+
import { useNodeContext } from '../../contexts/node';
|
|
17
|
+
import { withPermission } from '../../permission';
|
|
18
|
+
import Line from '../component/line';
|
|
19
|
+
import RuleActions from './rule-actions';
|
|
20
|
+
import BlockletPageGroup from '../page-group';
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
function RedirectRule({
|
|
24
|
+
domain,
|
|
25
|
+
isHttps,
|
|
26
|
+
toUrl
|
|
27
|
+
}) {
|
|
28
|
+
const scheme = isHttps ? 'https' : 'http';
|
|
29
|
+
let tmpToUrl = toUrl;
|
|
30
|
+
if (!isUrl(tmpToUrl)) {
|
|
31
|
+
tmpToUrl = `${scheme}://${domain}${toUrl}`;
|
|
32
|
+
}
|
|
33
|
+
return /*#__PURE__*/_jsx(ExternalLink, {
|
|
34
|
+
href: tmpToUrl,
|
|
35
|
+
target: "_blank",
|
|
36
|
+
style: {
|
|
37
|
+
fontSize: 14
|
|
38
|
+
},
|
|
39
|
+
underline: "hover",
|
|
40
|
+
children: toUrl
|
|
41
|
+
}, tmpToUrl);
|
|
42
|
+
}
|
|
43
|
+
RedirectRule.propTypes = {
|
|
44
|
+
domain: PropTypes.string.isRequired,
|
|
45
|
+
toUrl: PropTypes.string.isRequired,
|
|
46
|
+
isHttps: PropTypes.bool
|
|
47
|
+
};
|
|
48
|
+
RedirectRule.defaultProps = {
|
|
49
|
+
isHttps: false
|
|
50
|
+
};
|
|
51
|
+
function RuleList({
|
|
52
|
+
hasPermission
|
|
53
|
+
}) {
|
|
54
|
+
const {
|
|
55
|
+
t,
|
|
56
|
+
locale
|
|
57
|
+
} = useLocaleContext();
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
const {
|
|
60
|
+
blocklet,
|
|
61
|
+
recommendedDomain: domain
|
|
62
|
+
} = useBlockletContext();
|
|
63
|
+
const rules = blocklet.site.rules.filter(rule => rule.to.type !== ROUTING_RULE_TYPES.BLOCKLET);
|
|
64
|
+
return rules.map(rule => {
|
|
65
|
+
let avatar = null;
|
|
66
|
+
let component = null;
|
|
67
|
+
if (rule.to.type === ROUTING_RULE_TYPES.NONE) {
|
|
68
|
+
avatar = '404';
|
|
69
|
+
} else if (rule.to.type === ROUTING_RULE_TYPES.REDIRECT) {
|
|
70
|
+
avatar = rule.to.redirectCode;
|
|
71
|
+
} else if (rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
|
|
72
|
+
avatar = 'R';
|
|
73
|
+
} else if (rule.to.type === ROUTING_RULE_TYPES.COMPONENT) {
|
|
74
|
+
component = blocklet.children.find(x => x.meta.did === rule.to.componentId);
|
|
75
|
+
avatar = 'C';
|
|
76
|
+
}
|
|
77
|
+
const action = rule.isProtected ? /*#__PURE__*/_jsx(Tooltip, {
|
|
78
|
+
title: t('blocklet.router.urlLockTooltip'),
|
|
79
|
+
placement: "top",
|
|
80
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
81
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
82
|
+
disabled: true,
|
|
83
|
+
size: "small",
|
|
84
|
+
style: {
|
|
85
|
+
pointerEvents: 'auto',
|
|
86
|
+
// padding replace to margin, fix the tooltip position
|
|
87
|
+
paddingTop: 0,
|
|
88
|
+
paddingBottom: 0,
|
|
89
|
+
margin: '12px 0'
|
|
90
|
+
},
|
|
91
|
+
children: /*#__PURE__*/_jsx(LockIcon, {
|
|
92
|
+
style: {
|
|
93
|
+
fill: theme.palette.text.disabled
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}) : /*#__PURE__*/_jsx(RuleActions, {
|
|
99
|
+
...rule
|
|
100
|
+
});
|
|
101
|
+
return [/*#__PURE__*/_jsxs(Box, {
|
|
102
|
+
display: "flex",
|
|
103
|
+
py: 2,
|
|
104
|
+
className: "component-item",
|
|
105
|
+
justifyContent: "space-between",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
108
|
+
width: {
|
|
109
|
+
xs: 300,
|
|
110
|
+
md: 400
|
|
111
|
+
},
|
|
112
|
+
display: "flex",
|
|
113
|
+
alignItems: "center",
|
|
114
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
115
|
+
width: 28
|
|
116
|
+
}), typeof avatar === 'object' ? avatar : /*#__PURE__*/_jsx(Avatar, {
|
|
117
|
+
children: avatar
|
|
118
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
119
|
+
ml: 2,
|
|
120
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
121
|
+
style: {
|
|
122
|
+
color: '#222',
|
|
123
|
+
fontSize: 16
|
|
124
|
+
},
|
|
125
|
+
children: [rule.to.type === ROUTING_RULE_TYPES.NONE && t('common.page404'), rule.to.type === ROUTING_RULE_TYPES.REDIRECT && t('common.redirect'), rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && t('common.rewrite'), rule.to.type === ROUTING_RULE_TYPES.COMPONENT && getDisplayName(component, true)]
|
|
126
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
127
|
+
display: "flex",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
children: [rule.to.type === ROUTING_RULE_TYPES.REDIRECT && /*#__PURE__*/_jsx(RedirectRule, {
|
|
130
|
+
domain: domain,
|
|
131
|
+
toUrl: rule.to.url
|
|
132
|
+
}), rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && /*#__PURE__*/_jsx(RedirectRule, {
|
|
133
|
+
domain: domain,
|
|
134
|
+
toUrl: rule.to.url
|
|
135
|
+
}), rule.to.type === ROUTING_RULE_TYPES.COMPONENT && /*#__PURE__*/_jsx(BlockletPageGroup, {
|
|
136
|
+
group: rule.to.pageGroup
|
|
137
|
+
})]
|
|
138
|
+
})]
|
|
139
|
+
})]
|
|
140
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
141
|
+
px: 2,
|
|
142
|
+
sx: {
|
|
143
|
+
display: {
|
|
144
|
+
xs: 'none',
|
|
145
|
+
md: 'flex'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
flexGrow: "1",
|
|
150
|
+
children: /*#__PURE__*/_jsx(ExternalLink, {
|
|
151
|
+
href: getAccessUrl(domain, rule.from.pathPrefix, getBlockletUrlParams(blocklet, locale)),
|
|
152
|
+
target: "_blank",
|
|
153
|
+
style: {
|
|
154
|
+
fontSize: 16
|
|
155
|
+
},
|
|
156
|
+
underline: "hover",
|
|
157
|
+
children: rule.from.pathPrefix
|
|
158
|
+
})
|
|
159
|
+
}, rule.from.pathPrefix), /*#__PURE__*/_jsx(Box, {
|
|
160
|
+
children: hasPermission && /*#__PURE__*/_jsx("div", {
|
|
161
|
+
style: {
|
|
162
|
+
textAlign: 'right'
|
|
163
|
+
},
|
|
164
|
+
children: action
|
|
165
|
+
})
|
|
166
|
+
}, "actions")]
|
|
167
|
+
}, "rule"), /*#__PURE__*/_jsx(Line, {}, "divider")];
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
RuleList.propTypes = {
|
|
171
|
+
hasPermission: PropTypes.bool
|
|
172
|
+
};
|
|
173
|
+
RuleList.defaultProps = {
|
|
174
|
+
hasPermission: false
|
|
175
|
+
};
|
|
176
|
+
const RuleListInDaemon = withPermission(RuleList, 'mutate_blocklets');
|
|
177
|
+
const RuleListInService = withPermission(RuleList, '', BlockletAdminRoles);
|
|
178
|
+
export default function RuleListWithPermission(props) {
|
|
179
|
+
const {
|
|
180
|
+
inService
|
|
181
|
+
} = useNodeContext();
|
|
182
|
+
if (inService) {
|
|
183
|
+
return /*#__PURE__*/_jsx(RuleListInService, {
|
|
184
|
+
...props
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return /*#__PURE__*/_jsx(RuleListInDaemon, {
|
|
188
|
+
...props
|
|
189
|
+
});
|
|
190
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import { ROUTING_RULE_TYPES, DEFAULT_IP_DOMAIN_SUFFIX, DOMAIN_FOR_IP_SITE_REGEXP, DOMAIN_FOR_DEFAULT_SITE, DOMAIN_FOR_IP_SITE } from '@abtnode/constant';
|
|
3
|
+
import isPathPrefixEqual from '@abtnode/util/lib/is-path-prefix-equal';
|
|
4
|
+
import { BLOCKLET_DYNAMIC_PATH_PREFIX } from '@blocklet/constant';
|
|
5
|
+
const validateRuleByServiceType = (params, localeContext) => {
|
|
6
|
+
if (params.type === ROUTING_RULE_TYPES.REDIRECT) {
|
|
7
|
+
if (!params.url) {
|
|
8
|
+
return new Error(`${localeContext('router.validation.redirectUrlRequired')}`);
|
|
9
|
+
}
|
|
10
|
+
if (!params.redirectCode) {
|
|
11
|
+
return new Error(`redirect ${localeContext('router.validation.redirectCodeRequired')}`);
|
|
12
|
+
}
|
|
13
|
+
} else if (params.type === ROUTING_RULE_TYPES.BLOCKLET) {
|
|
14
|
+
if (!params.did) {
|
|
15
|
+
return new Error(localeContext('router.validation.didRequired'));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
export const validateDomain = (domain, localeContext) => {
|
|
21
|
+
if (!domain) {
|
|
22
|
+
return localeContext('router.domain.validate.emptyTip');
|
|
23
|
+
}
|
|
24
|
+
if (domain.endsWith(DEFAULT_IP_DOMAIN_SUFFIX)) {
|
|
25
|
+
return localeContext('router.domain.validate.suffixTip', {
|
|
26
|
+
suffix: DEFAULT_IP_DOMAIN_SUFFIX
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* form validator of add site(add domain)
|
|
34
|
+
* @param {Object} params form params
|
|
35
|
+
* @param {Function} localeContext error message
|
|
36
|
+
*/
|
|
37
|
+
export const validateSite = (params, localeContext) => {
|
|
38
|
+
const validateResult = validateRuleByServiceType(params, localeContext);
|
|
39
|
+
if (validateResult) {
|
|
40
|
+
return validateResult;
|
|
41
|
+
}
|
|
42
|
+
const errMsg = validateDomain(params.domain, localeContext);
|
|
43
|
+
if (errMsg) {
|
|
44
|
+
return new Error(errMsg);
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* form validator of add_rule and update_rule
|
|
51
|
+
* @param {Object} params form params
|
|
52
|
+
* @param {Function} localeContext error message
|
|
53
|
+
*/
|
|
54
|
+
export const validateRule = (params, localeContext) => {
|
|
55
|
+
const validateResult = validateRuleByServiceType(params, localeContext);
|
|
56
|
+
if (validateResult) {
|
|
57
|
+
return validateResult;
|
|
58
|
+
}
|
|
59
|
+
if (!params.pathPrefix.length) {
|
|
60
|
+
return new Error(localeContext('router.validation.pathPrefixCannotBeEmpty'));
|
|
61
|
+
}
|
|
62
|
+
if (params.pathPrefix.length > 150) {
|
|
63
|
+
return new Error(localeContext('router.validation.pathPrefixTooLong', {
|
|
64
|
+
length: 150
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
export const validatePathPrefix = ({
|
|
70
|
+
params,
|
|
71
|
+
blocklets,
|
|
72
|
+
blocklet: curBlocklet,
|
|
73
|
+
locale = 'en'
|
|
74
|
+
}) => {
|
|
75
|
+
// validate children
|
|
76
|
+
if (curBlocklet) {
|
|
77
|
+
let exist = (curBlocklet.children || []).find(x => isPathPrefixEqual(x.mountPoint, params.pathPrefix));
|
|
78
|
+
if (curBlocklet.meta.group !== 'gateway' && params.pathPrefix === '/') {
|
|
79
|
+
exist = '/';
|
|
80
|
+
}
|
|
81
|
+
if (exist) {
|
|
82
|
+
return {
|
|
83
|
+
zh: `挂载点 ${params.pathPrefix} 已存在,请使用其他挂载点`,
|
|
84
|
+
en: `The mount point ${params.pathPrefix} already exist, please use another mount point`
|
|
85
|
+
}[locale];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const blocklet = blocklets.find(item => item.meta.did === params.did);
|
|
89
|
+
if (!blocklet) {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
const selected = blocklet.meta.interfaces.find(x => x.type === 'web');
|
|
93
|
+
if (!selected) {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
if (selected.prefix !== BLOCKLET_DYNAMIC_PATH_PREFIX && params.pathPrefix !== selected.prefix) {
|
|
97
|
+
return {
|
|
98
|
+
zh: `该 blocklet 只能挂载在 ${selected.prefix}`,
|
|
99
|
+
en: `This blocklet can only be mounted on ${selected.prefix}`
|
|
100
|
+
}[locale];
|
|
101
|
+
}
|
|
102
|
+
return '';
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* get initial blocklet did when add rule / update rule / add domain
|
|
107
|
+
* @param {array} blocklets
|
|
108
|
+
*/
|
|
109
|
+
export const getInitialBlockletDid = blocklets => {
|
|
110
|
+
if (blocklets.length === 0) {
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
const {
|
|
114
|
+
searchParams
|
|
115
|
+
} = new URL(window.location.href);
|
|
116
|
+
const fromDid = searchParams.get('fromDid');
|
|
117
|
+
if (fromDid) {
|
|
118
|
+
const blocklet = blocklets.find(x => x.meta.did === fromDid);
|
|
119
|
+
if (blocklet) {
|
|
120
|
+
return blocklet.meta.did;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return blocklets[0].meta.did;
|
|
124
|
+
};
|
|
125
|
+
export const isSpecialDomain = name => {
|
|
126
|
+
const specialDomains = [DOMAIN_FOR_IP_SITE_REGEXP, DOMAIN_FOR_DEFAULT_SITE, DOMAIN_FOR_IP_SITE];
|
|
127
|
+
if (typeof window !== 'undefined' && typeof window.location !== 'undefined') {
|
|
128
|
+
specialDomains.push(window.location.hostname);
|
|
129
|
+
}
|
|
130
|
+
return specialDomains.includes(name);
|
|
131
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Typography from '@mui/material/Typography';
|
|
4
|
+
import Grid from '@mui/material/Grid';
|
|
5
|
+
import CpuMonitor from '../analytics/cpu';
|
|
6
|
+
import MemoryMonitor from '../analytics/memory';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export default function BlockletRuntimeInfo({
|
|
10
|
+
blocklet,
|
|
11
|
+
cpuHistory,
|
|
12
|
+
memoryHistory,
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
const runtimeInfo = blocklet.appRuntimeInfo || {};
|
|
16
|
+
return /*#__PURE__*/_jsx(Div, {
|
|
17
|
+
component: "div",
|
|
18
|
+
...rest,
|
|
19
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
20
|
+
className: "page-metrics",
|
|
21
|
+
container: true,
|
|
22
|
+
spacing: 5,
|
|
23
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
|
24
|
+
item: true,
|
|
25
|
+
lg: 4,
|
|
26
|
+
md: 6,
|
|
27
|
+
sm: 6,
|
|
28
|
+
xs: 12,
|
|
29
|
+
children: !!cpuHistory.length && /*#__PURE__*/_jsx(CpuMonitor, {
|
|
30
|
+
currentLoad: runtimeInfo.cpuUsage || 0,
|
|
31
|
+
history: cpuHistory,
|
|
32
|
+
style: {
|
|
33
|
+
height: 150
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}, "cpu"), /*#__PURE__*/_jsx(Grid, {
|
|
37
|
+
item: true,
|
|
38
|
+
lg: 4,
|
|
39
|
+
md: 6,
|
|
40
|
+
sm: 6,
|
|
41
|
+
xs: 12,
|
|
42
|
+
children: !!memoryHistory.length && /*#__PURE__*/_jsx(MemoryMonitor, {
|
|
43
|
+
used: runtimeInfo.memoryUsage || 0,
|
|
44
|
+
history: memoryHistory,
|
|
45
|
+
style: {
|
|
46
|
+
height: 150
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}, "memory")]
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
BlockletRuntimeInfo.propTypes = {
|
|
54
|
+
blocklet: PropTypes.object.isRequired,
|
|
55
|
+
cpuHistory: PropTypes.arrayOf(PropTypes.shape({
|
|
56
|
+
date: PropTypes.number,
|
|
57
|
+
value: PropTypes.number
|
|
58
|
+
})),
|
|
59
|
+
memoryHistory: PropTypes.arrayOf(PropTypes.shape({
|
|
60
|
+
date: PropTypes.number,
|
|
61
|
+
value: PropTypes.number
|
|
62
|
+
}))
|
|
63
|
+
};
|
|
64
|
+
BlockletRuntimeInfo.defaultProps = {
|
|
65
|
+
cpuHistory: [],
|
|
66
|
+
memoryHistory: []
|
|
67
|
+
};
|
|
68
|
+
const Div = styled(Typography)``;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
5
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
|
+
import { isInProgress } from '@blocklet/meta/lib/util';
|
|
7
|
+
import Dot from '../dot';
|
|
8
|
+
import Tag from '../tag';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const colors = {
|
|
12
|
+
yellow: '#FFCF71',
|
|
13
|
+
grey: '#888888'
|
|
14
|
+
};
|
|
15
|
+
export default function BlockletStatus({
|
|
16
|
+
status,
|
|
17
|
+
variant,
|
|
18
|
+
source,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const {
|
|
22
|
+
t
|
|
23
|
+
} = useContext(LocaleContext);
|
|
24
|
+
const map = {
|
|
25
|
+
added: 'primary',
|
|
26
|
+
waiting: 'warning',
|
|
27
|
+
downloading: 'warning',
|
|
28
|
+
downloaded: 'primary',
|
|
29
|
+
installing: 'warning',
|
|
30
|
+
installed: 'primary',
|
|
31
|
+
starting: 'warning',
|
|
32
|
+
running: 'success',
|
|
33
|
+
stopping: 'warning',
|
|
34
|
+
stopped: 'reverse',
|
|
35
|
+
error: 'error',
|
|
36
|
+
upgrading: 'warning',
|
|
37
|
+
restarting: 'warning',
|
|
38
|
+
corrupted: 'error',
|
|
39
|
+
deleting: 'warning'
|
|
40
|
+
};
|
|
41
|
+
const colorMap = {
|
|
42
|
+
added: colors.grey,
|
|
43
|
+
waiting: colors.yellow,
|
|
44
|
+
downloading: colors.yellow,
|
|
45
|
+
downloaded: colors.grey,
|
|
46
|
+
installing: colors.yellow,
|
|
47
|
+
installed: colors.grey,
|
|
48
|
+
starting: colors.yellow,
|
|
49
|
+
running: 'success',
|
|
50
|
+
stopping: colors.yellow,
|
|
51
|
+
stopped: colors.grey,
|
|
52
|
+
error: 'error',
|
|
53
|
+
upgrading: colors.yellow,
|
|
54
|
+
restarting: colors.yellow,
|
|
55
|
+
corrupted: 'error',
|
|
56
|
+
deleting: colors.yellow
|
|
57
|
+
};
|
|
58
|
+
const inProgress = isInProgress(status);
|
|
59
|
+
const statusTxt = t(`blocklet.status.${status}`);
|
|
60
|
+
if (variant === 'dot') {
|
|
61
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
62
|
+
title: t('blocklet.statusTip', {
|
|
63
|
+
status: statusTxt
|
|
64
|
+
}),
|
|
65
|
+
children: /*#__PURE__*/_jsx(Dot, {
|
|
66
|
+
color: colorMap[status],
|
|
67
|
+
...rest
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/_jsxs(Tag, {
|
|
72
|
+
type: map[status],
|
|
73
|
+
...rest,
|
|
74
|
+
children: [inProgress && /*#__PURE__*/_jsx(Spinner, {
|
|
75
|
+
size: 12,
|
|
76
|
+
color: "inherit",
|
|
77
|
+
style: {
|
|
78
|
+
marginRight: 5
|
|
79
|
+
}
|
|
80
|
+
}), statusTxt]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
BlockletStatus.propTypes = {
|
|
84
|
+
status: PropTypes.string.isRequired,
|
|
85
|
+
variant: PropTypes.oneOf(['dot', 'tag']),
|
|
86
|
+
source: PropTypes.string
|
|
87
|
+
};
|
|
88
|
+
BlockletStatus.defaultProps = {
|
|
89
|
+
variant: 'tag',
|
|
90
|
+
source: ''
|
|
91
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
|
|
3
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import ElectricBoltOutlinedIcon from '@mui/icons-material/ElectricBoltOutlined';
|
|
8
|
+
import FolderOutlinedIcon from '@mui/icons-material/FolderOutlined';
|
|
9
|
+
import { getBackupFilesUrlFromEndpoint, getDIDSpaceUrlFromEndpoint } from '../../util/spaces';
|
|
10
|
+
import DeleteDIDSpacesGateWay from './delete';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* @param {{
|
|
15
|
+
* spaceGateway: import('./connected').SpaceGateway,
|
|
16
|
+
* onDelete: (import('./connected').SpaceGateway) => Promise<void>,
|
|
17
|
+
* onDelete: (import('./connected').SpaceGateway) => Promise<void>,
|
|
18
|
+
* enableSwitchToSpace: boolean,
|
|
19
|
+
* connected: boolean
|
|
20
|
+
* }} { spaceGateway, onDelete, ...rest }
|
|
21
|
+
* @return {*}
|
|
22
|
+
*/
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
+
function SpaceItemAction({
|
|
27
|
+
spaceGateway,
|
|
28
|
+
connected,
|
|
29
|
+
onDelete,
|
|
30
|
+
onConnect,
|
|
31
|
+
enableSwitchToSpace,
|
|
32
|
+
...rest
|
|
33
|
+
}) {
|
|
34
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
35
|
+
const {
|
|
36
|
+
t
|
|
37
|
+
} = useLocaleContext();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @description
|
|
41
|
+
* @param {React.MouseEvent<HTMLButtonElement> | undefined} event
|
|
42
|
+
*/
|
|
43
|
+
const handleOpen = (event, open) => {
|
|
44
|
+
event.stopPropagation();
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
setAnchorEl(open && event.currentTarget);
|
|
47
|
+
};
|
|
48
|
+
const handleOnConnect = async e => {
|
|
49
|
+
handleOpen(e, false);
|
|
50
|
+
await onConnect(spaceGateway);
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
53
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
54
|
+
"aria-label": "more",
|
|
55
|
+
"aria-controls": "actions-menu",
|
|
56
|
+
"aria-haspopup": "true",
|
|
57
|
+
"data-cy": "trigger-blocklet-actions",
|
|
58
|
+
onClick: e => handleOpen(e, true),
|
|
59
|
+
size: "small",
|
|
60
|
+
...rest,
|
|
61
|
+
children: /*#__PURE__*/_jsx(MoreVertIcon, {})
|
|
62
|
+
}), /*#__PURE__*/_jsxs(Menu, {
|
|
63
|
+
id: "simple-menu",
|
|
64
|
+
anchorEl: anchorEl,
|
|
65
|
+
keepMounted: true,
|
|
66
|
+
open: Boolean(anchorEl),
|
|
67
|
+
onClose: e => handleOpen(e, false),
|
|
68
|
+
children: [/*#__PURE__*/_jsxs(MenuItem, {
|
|
69
|
+
onClick: e => {
|
|
70
|
+
handleOpen(e, false);
|
|
71
|
+
window.open(spaceGateway.endpoint ? getDIDSpaceUrlFromEndpoint(spaceGateway.endpoint) : spaceGateway.url);
|
|
72
|
+
},
|
|
73
|
+
children: [/*#__PURE__*/_jsx(ListItemIcon, {
|
|
74
|
+
style: {
|
|
75
|
+
minWidth: 24
|
|
76
|
+
},
|
|
77
|
+
children: /*#__PURE__*/_jsx(ArrowOutwardIcon, {
|
|
78
|
+
fontSize: "small"
|
|
79
|
+
})
|
|
80
|
+
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
81
|
+
children: t('common.open')
|
|
82
|
+
})]
|
|
83
|
+
}), /*#__PURE__*/_jsxs(MenuItem, {
|
|
84
|
+
onClick: e => {
|
|
85
|
+
handleOpen(e, false);
|
|
86
|
+
window.open(getBackupFilesUrlFromEndpoint(spaceGateway.endpoint));
|
|
87
|
+
},
|
|
88
|
+
children: [/*#__PURE__*/_jsx(ListItemIcon, {
|
|
89
|
+
style: {
|
|
90
|
+
minWidth: 24
|
|
91
|
+
},
|
|
92
|
+
children: /*#__PURE__*/_jsx(FolderOutlinedIcon, {
|
|
93
|
+
fontSize: "small"
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
96
|
+
children: t('storage.spaces.strategy.viewBackupFiles')
|
|
97
|
+
})]
|
|
98
|
+
}), !connected && enableSwitchToSpace && /*#__PURE__*/_jsxs(MenuItem, {
|
|
99
|
+
onClick: handleOnConnect,
|
|
100
|
+
children: [/*#__PURE__*/_jsx(ListItemIcon, {
|
|
101
|
+
style: {
|
|
102
|
+
minWidth: 24
|
|
103
|
+
},
|
|
104
|
+
children: /*#__PURE__*/_jsx(ElectricBoltOutlinedIcon, {
|
|
105
|
+
fontSize: "small"
|
|
106
|
+
})
|
|
107
|
+
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
108
|
+
children: t('storage.spaces.connect.switchToSpace')
|
|
109
|
+
})]
|
|
110
|
+
}), !connected && /*#__PURE__*/_jsx(DeleteDIDSpacesGateWay, {
|
|
111
|
+
spaceGateway: spaceGateway,
|
|
112
|
+
onDelete: onDelete
|
|
113
|
+
})]
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
SpaceItemAction.propTypes = {
|
|
118
|
+
spaceGateway: PropTypes.shape({
|
|
119
|
+
name: PropTypes.string.isRequired,
|
|
120
|
+
url: PropTypes.string.isRequired,
|
|
121
|
+
protected: PropTypes.bool,
|
|
122
|
+
endpoint: PropTypes.string.isRequired
|
|
123
|
+
}).isRequired,
|
|
124
|
+
connected: PropTypes.bool.isRequired,
|
|
125
|
+
enableSwitchToSpace: PropTypes.bool,
|
|
126
|
+
onDelete: PropTypes.func,
|
|
127
|
+
onConnect: PropTypes.func
|
|
128
|
+
};
|
|
129
|
+
SpaceItemAction.defaultProps = {
|
|
130
|
+
onDelete: () => {},
|
|
131
|
+
onConnect: () => {},
|
|
132
|
+
enableSwitchToSpace: true
|
|
133
|
+
};
|
|
134
|
+
export default SpaceItemAction;
|