@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b

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.
Files changed (202) hide show
  1. package/es/actions.js +97 -0
  2. package/es/analytics/card.js +92 -0
  3. package/es/analytics/chart.js +96 -0
  4. package/es/analytics/cpu.js +36 -0
  5. package/es/analytics/disk.js +111 -0
  6. package/es/analytics/memory.js +72 -0
  7. package/es/analytics/runtime.js +173 -0
  8. package/es/analytics/traffic.js +259 -0
  9. package/es/blocklet/access/config-access.js +307 -0
  10. package/es/blocklet/access/index.js +216 -0
  11. package/es/blocklet/actions.js +474 -0
  12. package/es/blocklet/add-cert.js +177 -0
  13. package/es/blocklet/agreement-app.js +21 -0
  14. package/es/blocklet/agreement.js +127 -0
  15. package/es/blocklet/app-avatar.js +57 -0
  16. package/es/blocklet/audit-logs.js +259 -0
  17. package/es/blocklet/blocklet-source.js +48 -0
  18. package/es/blocklet/bundle-avatar.js +64 -0
  19. package/es/blocklet/component/add.js +1308 -0
  20. package/es/blocklet/component/configuration.js +122 -0
  21. package/es/blocklet/component/delete.js +134 -0
  22. package/es/blocklet/component/environment.js +370 -0
  23. package/es/blocklet/component/index.js +975 -0
  24. package/es/blocklet/component/line.js +20 -0
  25. package/es/blocklet/component/navigation/locale-tabs.js +225 -0
  26. package/es/blocklet/component/navigation/navigation-actions.js +112 -0
  27. package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
  28. package/es/blocklet/component/navigation/navigation-preview.js +101 -0
  29. package/es/blocklet/component/navigation/simple-select.js +124 -0
  30. package/es/blocklet/component/select-store.js +155 -0
  31. package/es/blocklet/component/setting.js +109 -0
  32. package/es/blocklet/component/sortable-tree.js +126 -0
  33. package/es/blocklet/component/space-connector.js +199 -0
  34. package/es/blocklet/component/space-selector.js +178 -0
  35. package/es/blocklet/component/start.js +101 -0
  36. package/es/blocklet/component/store-blocklet-list.js +200 -0
  37. package/es/blocklet/component/switch-control.js +57 -0
  38. package/es/blocklet/config-navigation.js +331 -0
  39. package/es/blocklet/configuration.js +603 -0
  40. package/es/blocklet/disk-info.js +75 -0
  41. package/es/blocklet/icons.js +18 -0
  42. package/es/blocklet/install-from-url.js +337 -0
  43. package/es/blocklet/log.js +90 -0
  44. package/es/blocklet/migration.js +149 -0
  45. package/es/blocklet/mode.js +19 -0
  46. package/es/blocklet/notification/email.js +257 -0
  47. package/es/blocklet/notification/index.js +49 -0
  48. package/es/blocklet/oauth/auth0.js +145 -0
  49. package/es/blocklet/oauth/common-settings.js +133 -0
  50. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  51. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  52. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  53. package/es/blocklet/oauth/federated-site-list.js +338 -0
  54. package/es/blocklet/oauth/federated.js +81 -0
  55. package/es/blocklet/oauth/index.js +69 -0
  56. package/es/blocklet/overview.js +293 -0
  57. package/es/blocklet/page-group.js +19 -0
  58. package/es/blocklet/preferences/app-sk.js +142 -0
  59. package/es/blocklet/preferences/index.js +305 -0
  60. package/es/blocklet/purchase/common.js +95 -0
  61. package/es/blocklet/purchase/component-purchase.js +237 -0
  62. package/es/blocklet/purchase/index.js +4 -0
  63. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  64. package/es/blocklet/router/action/add-rule.js +211 -0
  65. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  66. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  67. package/es/blocklet/router/action/delete-rule.js +108 -0
  68. package/es/blocklet/router/action/update-rule.js +209 -0
  69. package/es/blocklet/router/domain-actions.js +64 -0
  70. package/es/blocklet/router/domain-status.js +88 -0
  71. package/es/blocklet/router/rule-actions.js +66 -0
  72. package/es/blocklet/router/rule-list.js +190 -0
  73. package/es/blocklet/router/util.js +131 -0
  74. package/es/blocklet/runtime-info.js +68 -0
  75. package/es/blocklet/status.js +91 -0
  76. package/es/blocklet/storage/action.js +134 -0
  77. package/es/blocklet/storage/backups.js +241 -0
  78. package/es/blocklet/storage/connect-to.js +373 -0
  79. package/es/blocklet/storage/connected.js +198 -0
  80. package/es/blocklet/storage/delete.js +113 -0
  81. package/es/blocklet/storage/disconnect.js +243 -0
  82. package/es/blocklet/storage/index.js +19 -0
  83. package/es/blocklet/storage/item.js +558 -0
  84. package/es/blocklet/storage/preview-nft.js +286 -0
  85. package/es/blocklet/transfer-owner.js +198 -0
  86. package/es/blocklet/types.js +18 -0
  87. package/es/blocklet/util.js +145 -0
  88. package/es/blocklet/version.js +141 -0
  89. package/es/card-selector.js +134 -0
  90. package/es/certificate.js +105 -0
  91. package/es/chain.js +13 -0
  92. package/es/click-to-copy.js +22 -0
  93. package/es/confirm.js +149 -0
  94. package/es/contexts/audit-log.js +152 -0
  95. package/es/contexts/blocklet.js +10 -0
  96. package/es/contexts/deleting-blocklets.js +70 -0
  97. package/es/contexts/node.js +17 -0
  98. package/es/contexts/session.js +8 -0
  99. package/es/contexts/team.js +10 -0
  100. package/es/delete-confirm.js +121 -0
  101. package/es/did-address.js +46 -0
  102. package/es/dot.js +14 -0
  103. package/es/exchange-passport.js +102 -0
  104. package/es/form/form-select-input.js +184 -0
  105. package/es/form/form-text-input.js +178 -0
  106. package/es/form/form-wrapper.js +88 -0
  107. package/es/form/input-triggers.js +98 -0
  108. package/es/form/required.js +8 -0
  109. package/es/hooks/blocklet.js +229 -0
  110. package/es/hooks/confirm.js +90 -0
  111. package/es/hooks/mobile-width.js +11 -0
  112. package/es/hooks/url-evaluation.js +155 -0
  113. package/es/hooks/use-app-logo.js +16 -0
  114. package/es/hooks/use-backup-progress.js +31 -0
  115. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  116. package/es/hooks/use-bundle-logo.js +27 -0
  117. package/es/hooks/use-navigation.js +347 -0
  118. package/es/hooks/use-passport-id.js +14 -0
  119. package/es/hooks/use-subscription.js +22 -0
  120. package/es/icons/empty-space-nft.svg +59 -0
  121. package/es/icons/empty-spaces-nft.svg +58 -0
  122. package/es/icons/long-arrow.svg +5 -0
  123. package/es/icons/space-connected.svg +3 -0
  124. package/es/icons/space-disconnect.svg +3 -0
  125. package/es/index.js +3 -0
  126. package/es/invitation/invitation-app.js +58 -0
  127. package/es/invitation/invitation-login.js +68 -0
  128. package/es/invitation/invitation-passport.js +144 -0
  129. package/es/invitation/invitation-receive.js +138 -0
  130. package/es/invitation/invitation-success.js +93 -0
  131. package/es/invitation/invitation-user.js +90 -0
  132. package/es/invitation/invitation.js +90 -0
  133. package/es/issue-passport.js +142 -0
  134. package/es/launch-blocklet/content-layout.js +58 -0
  135. package/es/launch-blocklet/page-header.js +43 -0
  136. package/es/layout/addon.js +114 -0
  137. package/es/layout/feedback.js +55 -0
  138. package/es/locales/en.js +1534 -0
  139. package/es/locales/index.js +9 -0
  140. package/es/locales/zh.js +1537 -0
  141. package/es/logs/clock.js +11 -0
  142. package/es/logs/download.js +132 -0
  143. package/es/logs/log-terminal.js +253 -0
  144. package/es/lost-passport.js +452 -0
  145. package/es/nav-logo.js +219 -0
  146. package/es/passport-tag.js +43 -0
  147. package/es/permission.js +57 -0
  148. package/es/relative-time.js +53 -0
  149. package/es/result-message.js +11 -0
  150. package/es/schema-form/color-input.js +98 -0
  151. package/es/schema-form/common-prop-types.js +13 -0
  152. package/es/schema-form/index.js +215 -0
  153. package/es/schema-form/passport-input.js +54 -0
  154. package/es/schema-form/text-input.js +57 -0
  155. package/es/store/add.js +179 -0
  156. package/es/store/delete.js +96 -0
  157. package/es/store/item.js +76 -0
  158. package/es/subscription.js +144 -0
  159. package/es/table-icons.js +34 -0
  160. package/es/table.js +52 -0
  161. package/es/tag.js +21 -0
  162. package/es/team/members/actions.js +89 -0
  163. package/es/team/members/index.js +636 -0
  164. package/es/team/members/invitations.js +188 -0
  165. package/es/team/members/invite-member.js +208 -0
  166. package/es/team/members/issue-passport.js +152 -0
  167. package/es/team/members/member.js +408 -0
  168. package/es/team/members/passport-issuances.js +155 -0
  169. package/es/team/members/passports.js +364 -0
  170. package/es/team/members/toggle-user-approval.js +122 -0
  171. package/es/team/members/transfer-node.js +256 -0
  172. package/es/team/members/util.js +14 -0
  173. package/es/team/passports/color.js +126 -0
  174. package/es/team/passports/detail.js +312 -0
  175. package/es/team/passports/index.js +282 -0
  176. package/es/team/passports/mutate-role.js +198 -0
  177. package/es/team/passports/trusted-factories.js +221 -0
  178. package/es/team/passports/trusted-factory.js +343 -0
  179. package/es/team/passports/trusted-issuer.js +296 -0
  180. package/es/team/passports/trusted-issuers.js +226 -0
  181. package/es/team/search-input.js +46 -0
  182. package/es/team/styles/dialog.js +72 -0
  183. package/es/team/styles/list-header.js +31 -0
  184. package/es/util/api.js +6 -0
  185. package/es/util/constants.js +2 -0
  186. package/es/util/index.js +598 -0
  187. package/es/util/mode.js +4 -0
  188. package/es/util/space-gateway.js +51 -0
  189. package/es/util/spaces.js +151 -0
  190. package/es/who-can-access/config.js +38 -0
  191. package/es/wrap-locale.js +15 -0
  192. package/lib/blocklet/component/space-connector.js +1 -1
  193. package/lib/blocklet/component/space-selector.js +1 -1
  194. package/lib/blocklet/storage/backups.js +1 -1
  195. package/lib/blocklet/storage/connect-to.js +1 -1
  196. package/lib/blocklet/storage/connected.js +1 -1
  197. package/lib/blocklet/storage/disconnect.js +1 -1
  198. package/lib/blocklet/storage/index.js +1 -1
  199. package/lib/blocklet/storage/item.js +1 -1
  200. package/lib/invitation/invitation-receive.js +1 -1
  201. package/lib/team/passports/trusted-factory.js +1 -1
  202. package/package.json +81 -18
@@ -0,0 +1,603 @@
1
+ import React, { useState, useContext } from 'react';
2
+ import styled from '@emotion/styled';
3
+ import PropTypes from 'prop-types';
4
+ import get from 'lodash/get';
5
+ import isEqual from 'lodash/isEqual';
6
+ import Box from '@mui/material/Box';
7
+ import useTheme from '@mui/material/styles/useTheme';
8
+ import Switch from '@mui/material/Switch';
9
+ import Divider from '@mui/material/Divider';
10
+ import AddIcon from '@mui/icons-material/Add';
11
+ import IconButton from '@mui/material/IconButton';
12
+ import Tooltip from '@mui/material/Tooltip';
13
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
14
+ import Button from '@arcblock/ux/lib/Button';
15
+ import Empty from '@arcblock/ux/lib/Empty';
16
+ import LockIcon from '@arcblock/icons/lib/LockIcon';
17
+ import LoopIcon from '@mui/icons-material/Loop';
18
+ import { EVENTS } from '@abtnode/constant';
19
+ import { BLOCKLET_CONFIGURABLE_KEY, SUPPORTED_LANGUAGES } from '@blocklet/constant';
20
+ import { getWhoCanAccess, isInProgress } from '@blocklet/meta/lib/util';
21
+ import Toast from '@arcblock/ux/lib/Toast';
22
+ import FormTextInput from '../form/form-text-input';
23
+ import FormSelectInput from '../form/form-select-input';
24
+ import { useNodeContext } from '../contexts/node';
25
+ import { isInstalling, isValidClusterSize, BlockletAdminRoles, sortDomains } from '../util';
26
+ import { enableDebug } from '../util/mode';
27
+ import Permission, { withPermission } from '../permission';
28
+ import AddDomainAlias from './router/action/add-domain-alias';
29
+ import DomainStatus from './router/domain-status';
30
+ import DomainActions from './router/domain-actions';
31
+ import AppSk from './preferences/app-sk';
32
+ import AddCert from './add-cert';
33
+ import TransferOwner from './transfer-owner';
34
+ import { jsx as _jsx } from "react/jsx-runtime";
35
+ import { jsxs as _jsxs } from "react/jsx-runtime";
36
+ const languages = Object.keys(SUPPORTED_LANGUAGES).map(x => ({
37
+ code: x,
38
+ name: SUPPORTED_LANGUAGES[x].nativeName
39
+ }));
40
+ function BlockletEnvironment({
41
+ blocklet,
42
+ onUpdate,
43
+ hasPermission,
44
+ ...rest
45
+ }) {
46
+ const node = useNodeContext();
47
+ const {
48
+ t
49
+ } = useContext(LocaleContext);
50
+ const [cpuCores, setCpuCores] = useState('');
51
+ const [loading, setLoading] = useState('');
52
+ const [showTransferOwner, setShowTransferOwner] = useState(false);
53
+ const whoCanAccess = getWhoCanAccess(blocklet);
54
+ const publicToStore = blocklet?.settings?.publicToStore;
55
+ const theme = useTheme();
56
+ const disabled = loading || !hasPermission;
57
+ const {
58
+ inService,
59
+ ws: {
60
+ useSubscription
61
+ }
62
+ } = node;
63
+ const {
64
+ did
65
+ } = blocklet.meta;
66
+ const {
67
+ site
68
+ } = blocklet;
69
+ const domains = sortDomains(site?.domainAliases);
70
+ const clusterMode = get(blocklet.meta, 'capabilities.clusterMode', false);
71
+ useSubscription(EVENTS.NODE_RUNTIME_INFO, res => {
72
+ if (clusterMode) {
73
+ setCpuCores(get(res, 'cpu.physicalCores', ''));
74
+ }
75
+ });
76
+ if (isInstalling(blocklet.status)) {
77
+ return null;
78
+ }
79
+
80
+ // configurable blocklet environment
81
+ const customDelete = blocklet.environments.find(x => x.key === 'BLOCKLET_DELETABLE');
82
+ const deletable = !customDelete || customDelete.value === 'yes';
83
+ const customLanguages = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LANGUAGES');
84
+ const customUrl = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_URL');
85
+ const customLogoSquare = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO_SQUARE');
86
+ const customLogoRect = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO_RECT');
87
+ const customLogoFavicon = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO_FAVICON');
88
+ const customLogoDeprecated = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO');
89
+ const configurableEnvs = [{
90
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_NAME,
91
+ description: t('blocklet.config.name'),
92
+ value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_NAME').value
93
+ }, {
94
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_DESCRIPTION,
95
+ description: t('blocklet.config.description'),
96
+ value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_DESCRIPTION').value
97
+ }, {
98
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL,
99
+ description: t('blocklet.config.appUrl'),
100
+ value: customUrl ? customUrl.value : ''
101
+ }, {
102
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_SQUARE,
103
+ description: t('blocklet.config.logoSquare'),
104
+ value: customLogoSquare ? customLogoSquare.value : ''
105
+ }, {
106
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_RECT,
107
+ description: t('blocklet.config.logoRect'),
108
+ value: customLogoRect ? customLogoRect.value : ''
109
+ }, {
110
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_FAVICON,
111
+ description: t('blocklet.config.logoFavicon'),
112
+ value: customLogoFavicon ? customLogoFavicon.value : ''
113
+ }, {
114
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO,
115
+ description: t('blocklet.config.logo'),
116
+ value: customLogoDeprecated ? customLogoDeprecated.value : ''
117
+ }];
118
+ if (clusterMode) {
119
+ const exist = blocklet.configs.find(x => x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE);
120
+ const value = exist ? exist.value : cpuCores;
121
+ configurableEnvs.push({
122
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE,
123
+ description: t('blocklet.config.clusterSize'),
124
+ value,
125
+ cpuCores
126
+ });
127
+ }
128
+ const onPublicToStoreChange = async e => {
129
+ if (loading) {
130
+ return;
131
+ }
132
+ setLoading(true);
133
+ try {
134
+ const {
135
+ checked
136
+ } = e.target;
137
+ const {
138
+ blocklet: data
139
+ } = await node.api.configPublicToStore({
140
+ input: {
141
+ did: blocklet.meta.did,
142
+ publicToStore: checked
143
+ }
144
+ });
145
+ onUpdate(data);
146
+ } catch (err) {
147
+ Toast.error(err.message);
148
+ } finally {
149
+ setLoading(false);
150
+ }
151
+ };
152
+ const onSubmitConfig = async (key, value) => {
153
+ if (key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
154
+ const errMessage = isValidClusterSize({
155
+ value,
156
+ cpuCores
157
+ });
158
+ if (errMessage) {
159
+ Toast.error(errMessage);
160
+ return;
161
+ }
162
+ }
163
+ const params = [{
164
+ key,
165
+ value
166
+ }];
167
+ try {
168
+ setLoading(true);
169
+ const {
170
+ blocklet: data
171
+ } = await node.api.configBlocklet({
172
+ input: {
173
+ did: blocklet.meta.did,
174
+ configs: params
175
+ }
176
+ });
177
+ onUpdate(data);
178
+ } catch (err) {
179
+ Toast.error(err.message);
180
+ } finally {
181
+ setLoading(false);
182
+ }
183
+ };
184
+ const onDeletableChange = async e => {
185
+ if (loading) {
186
+ return;
187
+ }
188
+ setLoading(true);
189
+ try {
190
+ const {
191
+ checked
192
+ } = e.target;
193
+ const {
194
+ blocklet: data
195
+ } = await node.api.configBlocklet({
196
+ input: {
197
+ did: blocklet.meta.did,
198
+ configs: [{
199
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_DELETABLE,
200
+ value: checked ? 'no' : 'yes'
201
+ }]
202
+ }
203
+ });
204
+ onUpdate(data);
205
+ } catch (err) {
206
+ Toast.error(err.message);
207
+ } finally {
208
+ setLoading(false);
209
+ }
210
+ };
211
+ const onUpdateCors = async value => {
212
+ const oldValue = site.corsAllowedOrigins || [];
213
+ const newValue = value.split(',').map(x => x.trim()).filter(Boolean);
214
+ if (isEqual(oldValue, newValue)) {
215
+ return false;
216
+ }
217
+ try {
218
+ setLoading(true);
219
+ const corsAllowedOrigins = newValue.length ? newValue : ['__none__'];
220
+ await node.api.updateRoutingSite({
221
+ input: {
222
+ id: site.id,
223
+ corsAllowedOrigins,
224
+ teamDid: blocklet.meta.did
225
+ }
226
+ });
227
+ setLoading(false);
228
+ } catch (err) {
229
+ Toast.error(err.message);
230
+ setLoading(false);
231
+ return false;
232
+ }
233
+ return true;
234
+ };
235
+ const onAppSkChange = async value => {
236
+ if (loading) {
237
+ return;
238
+ }
239
+ setLoading(true);
240
+ try {
241
+ const {
242
+ blocklet: data
243
+ } = await node.api.configBlocklet({
244
+ input: {
245
+ did: blocklet.meta.did,
246
+ configs: [{
247
+ key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SK,
248
+ value
249
+ }]
250
+ }
251
+ });
252
+ onUpdate(data);
253
+ } catch (err) {
254
+ Toast.error(err.message);
255
+ } finally {
256
+ setLoading(false);
257
+ }
258
+ };
259
+ return /*#__PURE__*/_jsxs(Div, {
260
+ ...rest,
261
+ children: [configurableEnvs.map(item => /*#__PURE__*/_jsxs(Box, {
262
+ className: "config-form",
263
+ mt: 2,
264
+ children: [/*#__PURE__*/_jsx(Box, {
265
+ className: "config-label",
266
+ fontSize: 14,
267
+ mb: 0,
268
+ children: item.description
269
+ }), /*#__PURE__*/_jsx(FormTextInput, {
270
+ style: {
271
+ marginTop: 0
272
+ },
273
+ disabled: loading || disabled,
274
+ loading: loading,
275
+ initialValue: item.value,
276
+ onSubmit: value => onSubmitConfig(item.key, value)
277
+ })]
278
+ })), /*#__PURE__*/_jsx(Box, {
279
+ className: "config-form",
280
+ children: whoCanAccess === 'all' && blocklet.source === 'registry' && /*#__PURE__*/_jsxs(Box, {
281
+ className: "config-item",
282
+ children: [/*#__PURE__*/_jsxs(Box, {
283
+ className: "config-label",
284
+ children: [t('blocklet.config.access.publicToStore'), /*#__PURE__*/_jsx(Box, {
285
+ className: "config-desc",
286
+ children: t('blocklet.config.access.publicInstanceTip')
287
+ })]
288
+ }), /*#__PURE__*/_jsx(Switch, {
289
+ disabled: disabled,
290
+ checked: publicToStore,
291
+ defaultChecked: true,
292
+ onChange: onPublicToStoreChange
293
+ })]
294
+ })
295
+ }), /*#__PURE__*/_jsx(Box, {
296
+ className: "config-form",
297
+ component: Divider,
298
+ my: 3
299
+ }), /*#__PURE__*/_jsxs(Box, {
300
+ className: "config-form",
301
+ mt: 2,
302
+ children: [/*#__PURE__*/_jsx(Box, {
303
+ className: "config-label",
304
+ fontSize: 14,
305
+ mb: 0,
306
+ children: t('blocklet.config.languages')
307
+ }), /*#__PURE__*/_jsx(FormSelectInput, {
308
+ style: {
309
+ marginTop: 0
310
+ },
311
+ disabled: loading || disabled,
312
+ loading: loading,
313
+ options: languages,
314
+ initialValue: customLanguages ? customLanguages.value.split(',') : ['en', 'zh'],
315
+ onSubmit: value => onSubmitConfig('BLOCKLET_APP_LANGUAGES', value)
316
+ })]
317
+ }), /*#__PURE__*/_jsx(Box, {
318
+ className: "config-form",
319
+ component: Divider,
320
+ my: 3
321
+ }), /*#__PURE__*/_jsxs(Box, {
322
+ className: "config-form",
323
+ children: [/*#__PURE__*/_jsxs(Box, {
324
+ display: "flex",
325
+ justifyContent: "space-between",
326
+ alignItems: "center",
327
+ children: [/*#__PURE__*/_jsx("div", {
328
+ className: "config-label",
329
+ children: t('common.domain')
330
+ }), /*#__PURE__*/_jsx(Box, {
331
+ display: "flex",
332
+ alignItems: "center",
333
+ children: /*#__PURE__*/_jsx(AddDomainAlias, {
334
+ id: site.id,
335
+ title: t('router.domain.add.title'),
336
+ teamDid: did,
337
+ children: ({
338
+ open
339
+ }) => /*#__PURE__*/_jsxs(Button, {
340
+ style: {
341
+ marginLeft: 16
342
+ },
343
+ variant: "contained",
344
+ color: "primary",
345
+ "data-cy": "add-domain-alias",
346
+ onClick: open,
347
+ disabled: isInProgress(blocklet.status),
348
+ children: [/*#__PURE__*/_jsx(AddIcon, {
349
+ style: {
350
+ fontSize: '1.3em',
351
+ marginRight: 4
352
+ }
353
+ }), t('common.add')]
354
+ })
355
+ })
356
+ })]
357
+ }), domains.map((domain, index) => /*#__PURE__*/_jsxs(Box, {
358
+ display: "flex",
359
+ alignItems: "center",
360
+ justifyContent: "space-between",
361
+ mt: index ? 0 : 1,
362
+ children: [/*#__PURE__*/_jsxs(Box, {
363
+ display: "flex",
364
+ alignItems: "center",
365
+ justifyContent: "space-between",
366
+ children: [/*#__PURE__*/_jsx(DomainStatus, {
367
+ domain: domain,
368
+ filters: ['domain']
369
+ }, `${domain.value}-domain`), /*#__PURE__*/_jsx(Box, {
370
+ ml: 2,
371
+ mr: 0.5,
372
+ children: domain.value
373
+ }), /*#__PURE__*/_jsx(DomainStatus, {
374
+ domain: domain,
375
+ filters: ['http']
376
+ }, `${domain.value}-http`), /*#__PURE__*/_jsx("span", {
377
+ style: {
378
+ marginLeft: 12
379
+ }
380
+ }), /*#__PURE__*/_jsx(AddCert, {
381
+ domain: domain.value,
382
+ domainStatus: domain.domainStatus,
383
+ did: blocklet.meta.did,
384
+ children: ({
385
+ open
386
+ }) => /*#__PURE__*/_jsx(Button, {
387
+ size: "small",
388
+ onClick: e => open(e),
389
+ children: t('router.cert.genLetsEncryptCert.title')
390
+ })
391
+ })]
392
+ }), hasPermission && !domain.isProtected ? /*#__PURE__*/_jsx(DomainActions, {
393
+ site: site,
394
+ domain: domain,
395
+ blocklet: blocklet
396
+ }) : /*#__PURE__*/_jsx(Tooltip, {
397
+ title: t('blocklet.router.domainLockTooltip'),
398
+ placement: "top",
399
+ children: /*#__PURE__*/_jsx(IconButton, {
400
+ disabled: true,
401
+ size: "large",
402
+ style: {
403
+ pointerEvents: 'auto',
404
+ // padding replace to margin, fix the tooltip position
405
+ paddingTop: 0,
406
+ paddingBottom: 0,
407
+ margin: '12px 0'
408
+ },
409
+ children: /*#__PURE__*/_jsx(LockIcon, {
410
+ style: {
411
+ fill: theme.palette.text.disabled
412
+ }
413
+ })
414
+ })
415
+ })]
416
+ }, domain.value)), !domains.length && /*#__PURE__*/_jsx(Box, {
417
+ mt: 4,
418
+ children: /*#__PURE__*/_jsx(Empty, {
419
+ children: t('common.empty')
420
+ })
421
+ })]
422
+ }), /*#__PURE__*/_jsx(Box, {
423
+ className: "config-form",
424
+ component: Divider,
425
+ my: 3
426
+ }), /*#__PURE__*/_jsx(Box, {
427
+ className: "config-form",
428
+ mt: 2,
429
+ children: /*#__PURE__*/_jsx(Box, {
430
+ className: "config-label",
431
+ mb: 0,
432
+ children: t('common.security')
433
+ })
434
+ }), /*#__PURE__*/_jsxs(Box, {
435
+ className: "config-form",
436
+ mt: 2,
437
+ children: [/*#__PURE__*/_jsx(Box, {
438
+ className: "config-label",
439
+ fontSize: 14,
440
+ mb: 0,
441
+ children: t('router.domainSecurity.cors.title')
442
+ }), /*#__PURE__*/_jsx(Box, {
443
+ mb: 1.5,
444
+ className: "config-desc",
445
+ children: t('router.domainSecurity.cors.description', {
446
+ name: 'the blocklet'
447
+ })
448
+ }), /*#__PURE__*/_jsx(FormTextInput, {
449
+ style: {
450
+ marginTop: 0
451
+ },
452
+ disabled: loading || disabled,
453
+ loading: loading,
454
+ initialValue: (site.corsAllowedOrigins || []).join(', '),
455
+ onSubmit: onUpdateCors
456
+ })]
457
+ }), /*#__PURE__*/_jsx(Box, {
458
+ className: "config-form",
459
+ component: Divider,
460
+ my: 3
461
+ }), /*#__PURE__*/_jsx(Box, {
462
+ mb: 2,
463
+ className: "config-label",
464
+ fontSize: 20,
465
+ children: t('blocklet.config.dangerZone')
466
+ }), /*#__PURE__*/_jsxs(Box, {
467
+ px: 2,
468
+ py: 1,
469
+ sx: {
470
+ border: '1px solid red',
471
+ borderRadius: 2
472
+ },
473
+ children: [/*#__PURE__*/_jsx(Box, {
474
+ className: "config-form",
475
+ mt: 2,
476
+ children: !inService && /*#__PURE__*/_jsxs(Box, {
477
+ className: "config-item",
478
+ children: [/*#__PURE__*/_jsxs(Box, {
479
+ className: "config-label",
480
+ children: [t('blocklet.config.deletable.name'), /*#__PURE__*/_jsx(Box, {
481
+ className: "config-desc",
482
+ children: deletable ? t('blocklet.config.deletable.disable') : t('blocklet.config.deletable.enable')
483
+ })]
484
+ }), /*#__PURE__*/_jsx(Switch, {
485
+ disabled: disabled,
486
+ checked: !deletable,
487
+ defaultChecked: true,
488
+ onChange: onDeletableChange
489
+ })]
490
+ })
491
+ }), /*#__PURE__*/_jsxs(Box, {
492
+ className: "config-form",
493
+ mt: 2,
494
+ children: [/*#__PURE__*/_jsx(Box, {
495
+ className: "config-label",
496
+ fontSize: 14,
497
+ mb: 0,
498
+ children: t('blocklet.config.sk')
499
+ }), /*#__PURE__*/_jsx(AppSk, {
500
+ disabled: loading || disabled,
501
+ loading: loading,
502
+ initialValue: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_SK').value,
503
+ onChange: onAppSkChange
504
+ })]
505
+ }), inService &&
506
+ /*#__PURE__*/
507
+ // eslint-disable-next-line jsx-a11y/aria-role
508
+ _jsx(Permission, {
509
+ role: "owner",
510
+ children: isOwner => (isOwner || enableDebug) && /*#__PURE__*/_jsxs(Box, {
511
+ className: "config-form",
512
+ mt: 2,
513
+ children: [/*#__PURE__*/_jsxs(Box, {
514
+ className: "config-item",
515
+ children: [/*#__PURE__*/_jsx(Box, {
516
+ className: "config-label",
517
+ mb: 0,
518
+ children: t('team.transferApp.name')
519
+ }), /*#__PURE__*/_jsxs(Button, {
520
+ style: {
521
+ flexShrink: 0
522
+ },
523
+ variant: "contained",
524
+ edge: "end",
525
+ color: "error",
526
+ size: "small",
527
+ "data-cy": "transfer-app",
528
+ onClick: () => setShowTransferOwner(true),
529
+ children: [/*#__PURE__*/_jsx(LoopIcon, {
530
+ style: {
531
+ fontSize: '1.3em',
532
+ marginRight: 4
533
+ }
534
+ }), t('team.transferApp.name')]
535
+ })]
536
+ }), showTransferOwner && /*#__PURE__*/_jsx(TransferOwner, {
537
+ onCancel: () => setShowTransferOwner(false),
538
+ onSuccess: () => setShowTransferOwner(false)
539
+ })]
540
+ })
541
+ })]
542
+ })]
543
+ });
544
+ }
545
+ const BlockletEnvironmentInDaemon = withPermission(BlockletEnvironment, 'mutate_blocklets');
546
+ const BlockletEnvironmentInService = withPermission(BlockletEnvironment, '', BlockletAdminRoles);
547
+ export default function BlockletEnvironmentWithPermission(props) {
548
+ const {
549
+ inService
550
+ } = useNodeContext();
551
+ if (inService) {
552
+ return /*#__PURE__*/_jsx(BlockletEnvironmentInService, {
553
+ ...props
554
+ });
555
+ }
556
+ return /*#__PURE__*/_jsx(BlockletEnvironmentInDaemon, {
557
+ ...props
558
+ });
559
+ }
560
+ BlockletEnvironment.propTypes = {
561
+ blocklet: PropTypes.object.isRequired,
562
+ onUpdate: PropTypes.func,
563
+ hasPermission: PropTypes.bool
564
+ };
565
+ BlockletEnvironment.defaultProps = {
566
+ onUpdate: () => {},
567
+ hasPermission: false
568
+ };
569
+ const Div = styled.div`
570
+ padding-top: 24px;
571
+ .config-form {
572
+ flex-grow: 1;
573
+ overflow-y: auto;
574
+ ${props => props.theme.breakpoints.down('md')} {
575
+ width: 100%;
576
+ flex-shrink: 0;
577
+ padding: 0 24px;
578
+ transform: translate(0, 0);
579
+ max-height: 60vh;
580
+ }
581
+ }
582
+
583
+ .config-item {
584
+ display: flex;
585
+ align-items: center;
586
+ justify-content: space-between;
587
+ margin: 16px 0;
588
+ }
589
+
590
+ .config-label {
591
+ font-weight: bold;
592
+ }
593
+
594
+ .config-desc {
595
+ font-weight: normal;
596
+ font-size: 12px;
597
+ color: #666;
598
+ }
599
+
600
+ .form-item {
601
+ margin-top: 0;
602
+ }
603
+ `;
@@ -0,0 +1,75 @@
1
+ /* eslint-disable react/jsx-one-expression-per-line */
2
+ import { useContext } from 'react';
3
+ import styled from '@emotion/styled';
4
+ import PropTypes from 'prop-types';
5
+ import filesize from 'filesize';
6
+ import Typography from '@mui/material/Typography';
7
+ import Link from '@mui/material/Link';
8
+ import InfoRow from '@arcblock/ux/lib/InfoRow';
9
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ export default function BlockletDiskInfo({
13
+ blocklet,
14
+ ...rest
15
+ }) {
16
+ const {
17
+ t
18
+ } = useContext(LocaleContext);
19
+ if (!blocklet.diskInfo) {
20
+ return /*#__PURE__*/_jsx(Typography, {
21
+ children: t('blocklet.diskInfo.empty')
22
+ });
23
+ }
24
+ const renderDiskInfo = (dir, size, handler) => /*#__PURE__*/_jsxs(Typography, {
25
+ children: [handler ?
26
+ /*#__PURE__*/
27
+ /* eslint-disable-next-line no-script-url, jsx-a11y/anchor-is-valid */
28
+ _jsx(Link, {
29
+ style: {
30
+ cursor: 'pointer'
31
+ },
32
+ onClick: handler,
33
+ underline: "hover",
34
+ children: dir
35
+ }) : dir, ' ', /*#__PURE__*/_jsx("strong", {
36
+ children: size ? filesize(size) : 'empty'
37
+ })]
38
+ });
39
+ const env = blocklet.environments.reduce((acc, x) => {
40
+ acc[x.key] = x.value;
41
+ return acc;
42
+ }, {});
43
+ const rows = [{
44
+ key: 'appDir',
45
+ name: t('blocklet.diskInfo.appDir'),
46
+ value: renderDiskInfo(env.BLOCKLET_APP_DIR, blocklet.diskInfo.app)
47
+ }, {
48
+ key: 'dataDir',
49
+ name: t('blocklet.diskInfo.dataDir'),
50
+ value: renderDiskInfo(env.BLOCKLET_DATA_DIR, blocklet.diskInfo.data)
51
+ }, {
52
+ key: 'logDir',
53
+ name: t('blocklet.diskInfo.logDir'),
54
+ value: renderDiskInfo(env.BLOCKLET_LOG_DIR, blocklet.diskInfo.log)
55
+ }, {
56
+ key: 'cacheDir',
57
+ name: t('blocklet.diskInfo.cacheDir'),
58
+ value: renderDiskInfo(env.BLOCKLET_CACHE_DIR, blocklet.diskInfo.cache)
59
+ }];
60
+ return /*#__PURE__*/_jsx(Div, {
61
+ component: "div",
62
+ ...rest,
63
+ children: rows.map(row => /*#__PURE__*/_jsx(InfoRow, {
64
+ valueComponent: "div",
65
+ nameWidth: 120,
66
+ name: row.name,
67
+ children: row.value
68
+ }, row.key))
69
+ });
70
+ }
71
+ BlockletDiskInfo.propTypes = {
72
+ blocklet: PropTypes.object.isRequired
73
+ };
74
+ BlockletDiskInfo.defaultProps = {};
75
+ const Div = styled(Typography)``;
@@ -0,0 +1,18 @@
1
+ import Remove from '@mui/icons-material/Delete';
2
+ import Start from '@mui/icons-material/PlayArrow';
3
+ import Stop from '@mui/icons-material/Stop';
4
+ import Restart from '@mui/icons-material/Replay';
5
+ import Reload from '@mui/icons-material/Autorenew';
6
+ import Config from '@mui/icons-material/Settings';
7
+ import Log from '@mui/icons-material/Receipt';
8
+ import Group from '@mui/icons-material/Group';
9
+ export default {
10
+ Start,
11
+ Stop,
12
+ Restart,
13
+ Reload,
14
+ Remove,
15
+ Config,
16
+ Log,
17
+ Group
18
+ };