@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.
Files changed (213) 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 +1313 -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/selected/index.js +94 -0
  32. package/es/blocklet/component/setting.js +109 -0
  33. package/es/blocklet/component/sortable-tree.js +126 -0
  34. package/es/blocklet/component/space-connector.js +199 -0
  35. package/es/blocklet/component/space-selector.js +178 -0
  36. package/es/blocklet/component/start.js +101 -0
  37. package/es/blocklet/component/store-blocklet-list.js +200 -0
  38. package/es/blocklet/component/switch-control.js +57 -0
  39. package/es/blocklet/config-navigation.js +331 -0
  40. package/es/blocklet/configuration.js +603 -0
  41. package/es/blocklet/disk-info.js +75 -0
  42. package/es/blocklet/icons.js +18 -0
  43. package/es/blocklet/install-from-url.js +337 -0
  44. package/es/blocklet/log.js +90 -0
  45. package/es/blocklet/migration.js +149 -0
  46. package/es/blocklet/mode.js +19 -0
  47. package/es/blocklet/notification/email.js +257 -0
  48. package/es/blocklet/notification/index.js +49 -0
  49. package/es/blocklet/oauth/auth0.js +145 -0
  50. package/es/blocklet/oauth/common-settings.js +133 -0
  51. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  52. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  53. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  54. package/es/blocklet/oauth/federated-site-list.js +338 -0
  55. package/es/blocklet/oauth/federated.js +81 -0
  56. package/es/blocklet/oauth/index.js +69 -0
  57. package/es/blocklet/overview.js +293 -0
  58. package/es/blocklet/page-group.js +19 -0
  59. package/es/blocklet/preferences/app-sk.js +142 -0
  60. package/es/blocklet/preferences/index.js +305 -0
  61. package/es/blocklet/purchase/common.js +95 -0
  62. package/es/blocklet/purchase/component-purchase.js +237 -0
  63. package/es/blocklet/purchase/index.js +4 -0
  64. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  65. package/es/blocklet/router/action/add-rule.js +211 -0
  66. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  67. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  68. package/es/blocklet/router/action/delete-rule.js +108 -0
  69. package/es/blocklet/router/action/update-rule.js +209 -0
  70. package/es/blocklet/router/domain-actions.js +64 -0
  71. package/es/blocklet/router/domain-status.js +88 -0
  72. package/es/blocklet/router/rule-actions.js +66 -0
  73. package/es/blocklet/router/rule-list.js +190 -0
  74. package/es/blocklet/router/util.js +131 -0
  75. package/es/blocklet/runtime-info.js +68 -0
  76. package/es/blocklet/status.js +91 -0
  77. package/es/blocklet/storage/action.js +134 -0
  78. package/es/blocklet/storage/backups.js +241 -0
  79. package/es/blocklet/storage/connect-to.js +372 -0
  80. package/es/blocklet/storage/connected.js +198 -0
  81. package/es/blocklet/storage/delete.js +113 -0
  82. package/es/blocklet/storage/disconnect.js +243 -0
  83. package/es/blocklet/storage/index.js +19 -0
  84. package/es/blocklet/storage/item.js +558 -0
  85. package/es/blocklet/storage/preview-nft.js +286 -0
  86. package/es/blocklet/transfer-owner.js +198 -0
  87. package/es/blocklet/types.js +18 -0
  88. package/es/blocklet/util.js +145 -0
  89. package/es/blocklet/version.js +141 -0
  90. package/es/card-selector.js +134 -0
  91. package/es/certificate.js +105 -0
  92. package/es/chain.js +13 -0
  93. package/es/click-to-copy.js +22 -0
  94. package/es/confirm.js +149 -0
  95. package/es/contexts/audit-log.js +152 -0
  96. package/es/contexts/blocklet.js +10 -0
  97. package/es/contexts/deleting-blocklets.js +70 -0
  98. package/es/contexts/node.js +17 -0
  99. package/es/contexts/session.js +8 -0
  100. package/es/contexts/team.js +10 -0
  101. package/es/delete-confirm.js +121 -0
  102. package/es/did-address.js +46 -0
  103. package/es/dot.js +14 -0
  104. package/es/exchange-passport.js +102 -0
  105. package/es/form/form-select-input.js +184 -0
  106. package/es/form/form-text-input.js +178 -0
  107. package/es/form/form-wrapper.js +88 -0
  108. package/es/form/input-triggers.js +98 -0
  109. package/es/form/required.js +8 -0
  110. package/es/hooks/blocklet.js +229 -0
  111. package/es/hooks/confirm.js +90 -0
  112. package/es/hooks/mobile-width.js +11 -0
  113. package/es/hooks/url-evaluation.js +155 -0
  114. package/es/hooks/use-app-logo.js +16 -0
  115. package/es/hooks/use-backup-progress.js +31 -0
  116. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  117. package/es/hooks/use-bundle-logo.js +27 -0
  118. package/es/hooks/use-navigation.js +347 -0
  119. package/es/hooks/use-passport-id.js +14 -0
  120. package/es/hooks/use-subscription.js +22 -0
  121. package/es/icons/empty-space-nft.svg +59 -0
  122. package/es/icons/empty-spaces-nft.svg +58 -0
  123. package/es/icons/long-arrow.svg +5 -0
  124. package/es/icons/space-connected.svg +3 -0
  125. package/es/icons/space-disconnect.svg +3 -0
  126. package/es/index.js +3 -0
  127. package/es/invitation/invitation-app.js +58 -0
  128. package/es/invitation/invitation-login.js +68 -0
  129. package/es/invitation/invitation-passport.js +146 -0
  130. package/es/invitation/invitation-receive.js +138 -0
  131. package/es/invitation/invitation-success.js +93 -0
  132. package/es/invitation/invitation-user.js +90 -0
  133. package/es/invitation/invitation.js +90 -0
  134. package/es/issue-passport.js +142 -0
  135. package/es/launch-blocklet/content-layout.js +58 -0
  136. package/es/launch-blocklet/page-header.js +43 -0
  137. package/es/layout/addon.js +114 -0
  138. package/es/layout/feedback.js +55 -0
  139. package/es/locales/en.js +1541 -0
  140. package/es/locales/index.js +9 -0
  141. package/es/locales/zh.js +1544 -0
  142. package/es/logs/clock.js +11 -0
  143. package/es/logs/download.js +132 -0
  144. package/es/logs/log-terminal.js +253 -0
  145. package/es/lost-passport.js +452 -0
  146. package/es/nav-logo.js +219 -0
  147. package/es/passport-tag.js +43 -0
  148. package/es/permission.js +57 -0
  149. package/es/relative-time.js +53 -0
  150. package/es/result-message.js +11 -0
  151. package/es/schema-form/color-input.js +98 -0
  152. package/es/schema-form/common-prop-types.js +13 -0
  153. package/es/schema-form/index.js +215 -0
  154. package/es/schema-form/passport-input.js +55 -0
  155. package/es/schema-form/text-input.js +57 -0
  156. package/es/store/add.js +179 -0
  157. package/es/store/delete.js +96 -0
  158. package/es/store/item.js +76 -0
  159. package/es/subscription.js +144 -0
  160. package/es/table-icons.js +34 -0
  161. package/es/table.js +52 -0
  162. package/es/tag.js +21 -0
  163. package/es/team/members/actions.js +89 -0
  164. package/es/team/members/index.js +636 -0
  165. package/es/team/members/invitations.js +188 -0
  166. package/es/team/members/invite-member.js +208 -0
  167. package/es/team/members/issue-passport.js +152 -0
  168. package/es/team/members/member.js +408 -0
  169. package/es/team/members/passport-issuances.js +155 -0
  170. package/es/team/members/passports.js +364 -0
  171. package/es/team/members/toggle-user-approval.js +122 -0
  172. package/es/team/members/transfer-node.js +256 -0
  173. package/es/team/members/util.js +14 -0
  174. package/es/team/passports/color.js +127 -0
  175. package/es/team/passports/detail.js +312 -0
  176. package/es/team/passports/index.js +282 -0
  177. package/es/team/passports/mutate-role.js +198 -0
  178. package/es/team/passports/trusted-factories.js +221 -0
  179. package/es/team/passports/trusted-factory.js +343 -0
  180. package/es/team/passports/trusted-issuer.js +296 -0
  181. package/es/team/passports/trusted-issuers.js +226 -0
  182. package/es/team/search-input.js +46 -0
  183. package/es/team/styles/dialog.js +72 -0
  184. package/es/team/styles/list-header.js +31 -0
  185. package/es/util/api.js +6 -0
  186. package/es/util/constants.js +2 -0
  187. package/es/util/index.js +598 -0
  188. package/es/util/mode.js +4 -0
  189. package/es/util/space-gateway.js +51 -0
  190. package/es/util/spaces.js +160 -0
  191. package/es/who-can-access/config.js +38 -0
  192. package/es/wrap-locale.js +15 -0
  193. package/lib/blocklet/component/add.js +5 -0
  194. package/lib/blocklet/component/selected/index.js +47 -0
  195. package/lib/blocklet/component/space-connector.js +1 -1
  196. package/lib/blocklet/component/space-selector.js +1 -1
  197. package/lib/blocklet/storage/backups.js +1 -1
  198. package/lib/blocklet/storage/connect-to.js +6 -7
  199. package/lib/blocklet/storage/connected.js +1 -1
  200. package/lib/blocklet/storage/disconnect.js +1 -1
  201. package/lib/blocklet/storage/index.js +1 -1
  202. package/lib/blocklet/storage/item.js +1 -1
  203. package/lib/card-selector.js +14 -14
  204. package/lib/invitation/invitation-passport.js +7 -6
  205. package/lib/invitation/invitation-receive.js +1 -1
  206. package/lib/locales/en.js +12 -5
  207. package/lib/locales/zh.js +10 -3
  208. package/lib/lost-passport.js +2 -2
  209. package/lib/schema-form/passport-input.js +12 -11
  210. package/lib/team/passports/color.js +14 -14
  211. package/lib/team/passports/trusted-factory.js +1 -1
  212. package/lib/util/spaces.js +13 -1
  213. package/package.json +88 -21
@@ -0,0 +1,122 @@
1
+ import { useState } from 'react';
2
+ import styled from '@emotion/styled';
3
+ import PropTypes from 'prop-types';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import Box from '@mui/material/Box';
6
+ import EditIcon from '@mui/icons-material/Edit';
7
+ import { getDisplayName } from '@blocklet/meta/lib/util';
8
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
+ import Dialog from '@arcblock/ux/lib/Dialog';
10
+ import Tabs from '@arcblock/ux/lib/Tabs';
11
+ import { isInstalling } from '../../util';
12
+ import ComponentEnvironment from './environment';
13
+ import ComponentSetting from './setting';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
16
+ export default function ComponentConfiguration({
17
+ blocklet,
18
+ ancestors,
19
+ children
20
+ }) {
21
+ const [showDialog, setShowDialog] = useState('');
22
+ const {
23
+ t
24
+ } = useLocaleContext();
25
+ const isComponent = !!ancestors.length;
26
+ const [tab, setTab] = useState('settings');
27
+ const name = isComponent ? getDisplayName(blocklet, true) : t('blocklet.component.container');
28
+ if (isInstalling(blocklet.status)) {
29
+ return null;
30
+ }
31
+ if (blocklet.status === 'unknown' && isInstalling(blocklet.status)) {
32
+ return null;
33
+ }
34
+ const onClose = () => {
35
+ setShowDialog(false);
36
+ };
37
+ const onOpen = e => {
38
+ e.stopPropagation();
39
+ // eslint-disable-next-line no-unused-expressions
40
+ setShowDialog(true);
41
+ };
42
+ const tabConfigs = {
43
+ settings: {
44
+ label: t('blocklet.component.setting'),
45
+ value: 'settings',
46
+ component: /*#__PURE__*/_jsx(ComponentSetting, {
47
+ blocklet: blocklet,
48
+ ancestors: ancestors
49
+ })
50
+ },
51
+ environments: {
52
+ label: t('common.environment'),
53
+ value: 'environments',
54
+ component: /*#__PURE__*/_jsx(ComponentEnvironment, {
55
+ blocklet: blocklet,
56
+ ancestors: ancestors
57
+ })
58
+ }
59
+ };
60
+ const tabs = Object.values(tabConfigs).map(({
61
+ label,
62
+ value
63
+ }) => ({
64
+ label,
65
+ value
66
+ }));
67
+ const onTabChange = newTab => {
68
+ setTab(newTab);
69
+ };
70
+ const tabConfig = tabConfigs[tab] || tabConfigs.settings;
71
+ return [typeof children === 'function' ? children({
72
+ open: onOpen
73
+ }) : /*#__PURE__*/_jsx(IconButton, {
74
+ onClick: onOpen,
75
+ "data-cy": "action-config-component",
76
+ children: /*#__PURE__*/_jsx(EditIcon, {})
77
+ }), showDialog && /*#__PURE__*/_jsx(StyledDialog, {
78
+ open: true,
79
+ fullWidth: true,
80
+ maxWidth: "md",
81
+ title: name,
82
+ onClose: onClose,
83
+ PaperProps: {
84
+ style: {
85
+ minHeight: 'auto'
86
+ }
87
+ },
88
+ children: isComponent ? /*#__PURE__*/_jsxs(Box, {
89
+ mt: 1,
90
+ children: [/*#__PURE__*/_jsx(Tabs, {
91
+ tabs: tabs,
92
+ current: tab,
93
+ onChange: onTabChange,
94
+ scrollButtons: "auto"
95
+ }), tabConfig.component]
96
+ }) : /*#__PURE__*/_jsx(ComponentEnvironment, {
97
+ blocklet: blocklet,
98
+ ancestors: ancestors
99
+ })
100
+ })];
101
+ }
102
+ ComponentConfiguration.propTypes = {
103
+ blocklet: PropTypes.object.isRequired,
104
+ ancestors: PropTypes.array,
105
+ children: PropTypes.any
106
+ };
107
+ ComponentConfiguration.defaultProps = {
108
+ ancestors: [],
109
+ children: null
110
+ };
111
+ const StyledDialog = styled(Dialog)`
112
+ .MuiDialogContent-root {
113
+ padding-top: 0;
114
+ margin-top: -32px;
115
+ }
116
+ .MuiToolbar-root {
117
+ padding-right: 12px;
118
+ }
119
+ .ux-dialog_right {
120
+ padding-right: 20px;
121
+ }
122
+ `;
@@ -0,0 +1,134 @@
1
+ import { useState, useContext, useEffect } from 'react';
2
+ import styled from '@emotion/styled';
3
+ import PropTypes from 'prop-types';
4
+ import DeleteIcon from '@mui/icons-material/Delete';
5
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
6
+ import IconButton from '@mui/material/IconButton';
7
+ import Tooltip from '@mui/material/Tooltip';
8
+ import Typography from '@mui/material/Typography';
9
+ import Radio from '@mui/material/Radio';
10
+ import RadioGroup from '@mui/material/RadioGroup';
11
+ import FormControlLabel from '@mui/material/FormControlLabel';
12
+ import Confirm from '../../confirm';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
16
+ export default function DeleteComponent({
17
+ component,
18
+ remove,
19
+ disabled,
20
+ tip,
21
+ showConfirm,
22
+ hideBtn,
23
+ onCancel
24
+ }) {
25
+ const {
26
+ t
27
+ } = useContext(LocaleContext);
28
+ const [loading, setLoading] = useState(false);
29
+ const [deleteSetting, setDeleteSetting] = useState(null);
30
+ const deleteComponent = async param => {
31
+ setLoading(true);
32
+ await remove(param.component, param.removeType);
33
+ setLoading(false);
34
+ setDeleteSetting(null);
35
+ };
36
+ const componentDisabled = disabled || loading;
37
+ const doShowConfirm = () => {
38
+ setDeleteSetting({
39
+ title: `${t('common.delete')} ${component.meta.title || component.meta.name}`,
40
+ // eslint-disable-next-line react/no-unstable-nested-components
41
+ description: (params, setParams) => /*#__PURE__*/_jsxs(Typography, {
42
+ component: "div",
43
+ children: [/*#__PURE__*/_jsx(Typography, {
44
+ gutterBottom: true,
45
+ children: t('blocklet.action.removeComponentDescription')
46
+ }), /*#__PURE__*/_jsxs(RadioGroup, {
47
+ name: "removeType",
48
+ value: params.removeType,
49
+ onChange: e => setParams({
50
+ ...params,
51
+ removeType: e.target.value
52
+ }),
53
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
54
+ value: "keepData",
55
+ control: /*#__PURE__*/_jsx(Radio, {}),
56
+ label: t('blocklet.action.removeComponentKeepData')
57
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
58
+ value: "complete",
59
+ control: /*#__PURE__*/_jsx(Radio, {}),
60
+ label: t('blocklet.action.removeComponentComplete')
61
+ })]
62
+ })]
63
+ }),
64
+ confirm: t('common.confirm'),
65
+ cancel: t('common.cancel'),
66
+ params: {
67
+ component,
68
+ removeType: 'keepData'
69
+ },
70
+ onConfirm: deleteComponent,
71
+ onCancel: () => {
72
+ setDeleteSetting(null);
73
+ onCancel();
74
+ }
75
+ });
76
+ };
77
+ useEffect(() => {
78
+ if (showConfirm) {
79
+ doShowConfirm();
80
+ } else {
81
+ setLoading(false);
82
+ setDeleteSetting(null);
83
+ }
84
+ // eslint-disable-next-line react-hooks/exhaustive-deps
85
+ }, [showConfirm]);
86
+ const btn = /*#__PURE__*/_jsx(StyledButton, {
87
+ size: "small",
88
+ disabled: componentDisabled,
89
+ onClick: () => doShowConfirm,
90
+ "data-cy": "delete-component-btn",
91
+ children: /*#__PURE__*/_jsx(DeleteIcon, {
92
+ disabled: componentDisabled
93
+ })
94
+ });
95
+ const btnWithToolTip = /*#__PURE__*/_jsx(Tooltip, {
96
+ title: tip || t('common.delete'),
97
+ children: /*#__PURE__*/_jsx("span", {
98
+ children: btn
99
+ })
100
+ });
101
+ return /*#__PURE__*/_jsxs(_Fragment, {
102
+ children: [!hideBtn && btnWithToolTip, deleteSetting && /*#__PURE__*/_jsx(Confirm, {
103
+ title: deleteSetting.title,
104
+ description: deleteSetting.description,
105
+ confirm: deleteSetting.confirm,
106
+ cancel: deleteSetting.cancel,
107
+ params: deleteSetting.params,
108
+ onConfirm: deleteSetting.onConfirm,
109
+ onCancel: deleteSetting.onCancel
110
+ })]
111
+ });
112
+ }
113
+ DeleteComponent.propTypes = {
114
+ component: PropTypes.object.isRequired,
115
+ remove: PropTypes.func,
116
+ onCancel: PropTypes.func,
117
+ disabled: PropTypes.bool,
118
+ showConfirm: PropTypes.bool,
119
+ hideBtn: PropTypes.bool,
120
+ tip: PropTypes.string
121
+ };
122
+ DeleteComponent.defaultProps = {
123
+ remove: async () => {},
124
+ disabled: false,
125
+ showConfirm: false,
126
+ hideBtn: false,
127
+ onCancel: () => {},
128
+ tip: ''
129
+ };
130
+ const StyledButton = styled(IconButton)`
131
+ &.Mui-disabled {
132
+ opacity: 0.5;
133
+ }
134
+ `;
@@ -0,0 +1,370 @@
1
+ /* eslint-disable react/no-unstable-nested-components */
2
+ /* eslint-disable react/prop-types */
3
+ import { useContext } from 'react';
4
+ import styled from '@emotion/styled';
5
+ import PropTypes from 'prop-types';
6
+ import MaterialTable from '@material-table/core';
7
+ import TextField from '@mui/material/TextField';
8
+ import Alert from '@mui/material/Alert';
9
+ import { BLOCKLET_CONFIGURABLE_KEY, CHAIN_PROP_MAP } from '@blocklet/constant';
10
+ import { getComponentMissingConfigs, getSharedConfigObj } from '@blocklet/meta/lib/util';
11
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
12
+ import Toast from '@arcblock/ux/lib/Toast';
13
+ import ClickToCopy from '../../click-to-copy';
14
+ import { useNodeContext } from '../../contexts/node';
15
+ import tableIcons from '../../table-icons';
16
+ import TableStyle from '../../table';
17
+ import Permission from '../../permission';
18
+ import { formatError, isInstalling, isValidClusterSize, isBlockletDev, BlockletAdminRoles } from '../../util';
19
+ import blockletIcons from '../icons';
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ const getDescription = (data, t) => {
23
+ let {
24
+ description
25
+ } = data;
26
+ if (Object.values(CHAIN_PROP_MAP).includes(data.key)) {
27
+ if (description) {
28
+ description = `${description} (${t('blocklet.config.sharedToAllComponents')})`;
29
+ } else {
30
+ description = t('blocklet.config.sharedToAllComponents');
31
+ }
32
+ }
33
+ return description && /*#__PURE__*/_jsx("div", {
34
+ style: {
35
+ marginLeft: 12
36
+ },
37
+ children: description
38
+ });
39
+ };
40
+ export default function ComponentEnvironment({
41
+ blocklet,
42
+ ancestors
43
+ }) {
44
+ const node = useNodeContext();
45
+ const {
46
+ inService
47
+ } = node;
48
+ const {
49
+ t
50
+ } = useContext(LocaleContext);
51
+ const dids = [...ancestors.map(x => x.meta.did), blocklet.meta.did];
52
+ const onConfigChanged = () => Toast.success(t('blocklet.config.changedTip'));
53
+ const isConfigEditable = x => x.custom;
54
+ if (isInstalling(blocklet.status)) {
55
+ return null;
56
+ }
57
+ if (blocklet.status === 'unknown' && isInstalling(blocklet.status)) {
58
+ return null;
59
+ }
60
+ const onAddConfig = async data => {
61
+ if (!data.key.trim() || !data.value.trim()) {
62
+ Toast.error(t('blocklet.config.environment.keyValueRequired'));
63
+ return;
64
+ }
65
+ if (data.key.startsWith('BLOCKLET_') || data.key.startsWith('COMPONENT_')) {
66
+ Toast.error(t('blocklet.config.environment.invalidKey'));
67
+ return;
68
+ }
69
+ data.custom = true;
70
+ const result = await node.api.configBlocklet({
71
+ input: {
72
+ did: dids,
73
+ configs: [data]
74
+ }
75
+ });
76
+ if (result.code === 'ok') {
77
+ onConfigChanged(result.blocklet);
78
+ }
79
+ };
80
+ const onEditConfig = async (newData, oldData) => {
81
+ // only required field can't be empty
82
+ if (newData.required && (!newData.key.trim() || !newData.value.trim())) {
83
+ Toast.error(t('blocklet.config.environment.keyValueRequired'));
84
+ return;
85
+ }
86
+ if (newData.key.startsWith('BLOCKLET_') && !BLOCKLET_CONFIGURABLE_KEY[newData.key]) {
87
+ Toast.error(t('blocklet.config.environment.invalidKey'));
88
+ return;
89
+ }
90
+ if (newData.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
91
+ const errMessage = isValidClusterSize(newData);
92
+ if (errMessage) {
93
+ Toast.error(errMessage);
94
+ return;
95
+ }
96
+ }
97
+ const configs = [newData];
98
+ if (newData.key !== oldData.key) {
99
+ if (!newData.custom) {
100
+ Toast.error('Only key of custom env can be changed');
101
+ return;
102
+ }
103
+ configs.push({
104
+ key: oldData.key,
105
+ custom: true
106
+ });
107
+ }
108
+ try {
109
+ const result = await node.api.configBlocklet({
110
+ input: {
111
+ did: dids,
112
+ configs
113
+ }
114
+ });
115
+ if (result.code === 'ok') {
116
+ onConfigChanged(result.blocklet);
117
+ }
118
+ } catch (err) {
119
+ Toast.error(formatError(err));
120
+ }
121
+ };
122
+ const onDeleteConfig = async data => {
123
+ if (data.required) {
124
+ Toast.error(t('blocklet.config.environment.deleteForbidden'));
125
+ return;
126
+ }
127
+ if (!data.custom) {
128
+ Toast.error('Only key of custom env can be changed');
129
+ return;
130
+ }
131
+ const result = await node.api.configBlocklet({
132
+ input: {
133
+ did: dids,
134
+ configs: [{
135
+ key: data.key,
136
+ custom: true
137
+ }]
138
+ }
139
+ });
140
+ if (result.code === 'ok') {
141
+ onConfigChanged(result.blocklet);
142
+ }
143
+ };
144
+
145
+ // configs
146
+ const componentConfigs = (blocklet.configs || []).filter(x => !BLOCKLET_CONFIGURABLE_KEY[x.key]);
147
+ const sharedConfigObj = getSharedConfigObj(blocklet, ancestors);
148
+ const missingRequiredConfigs = getComponentMissingConfigs(blocklet, ancestors);
149
+ const configs = componentConfigs.map(x => ({
150
+ ...x,
151
+ value: Object.values(CHAIN_PROP_MAP).includes(x.key) && Object.keys(sharedConfigObj).includes(x.key) ? sharedConfigObj[x.key] : sharedConfigObj[x.key] || x.value
152
+ }));
153
+ const hasBWAConfig = configs.some(x => x.key && x.key.startsWith('BWA_'));
154
+ const action = {
155
+ onRowAdd: onAddConfig,
156
+ onRowUpdate: onEditConfig,
157
+ onRowDelete: onDeleteConfig,
158
+ // environment declare in blocklet.yml can't be deleted, only custom env can be deleted
159
+ isDeletable: isConfigEditable
160
+ };
161
+ const onColumns = () => [{
162
+ title: t('common.key'),
163
+ field: 'key',
164
+ initialEditValue: 'Key',
165
+ width: '30%',
166
+ render: d => /*#__PURE__*/_jsx(ClickToCopy, {
167
+ value: d.value,
168
+ style: {
169
+ color: d.required && !d.value ? '#ff4436' : '#222222',
170
+ fontWeight: d.required ? 'bold' : 'normal'
171
+ },
172
+ children: d.key
173
+ }),
174
+ editComponent: props => {
175
+ const {
176
+ value,
177
+ rowData,
178
+ onChange
179
+ } = props;
180
+ return /*#__PURE__*/_jsx(EditDiv, {
181
+ children: /*#__PURE__*/_jsx(TextField, {
182
+ fullWidth: true,
183
+ size: "small",
184
+ disabled: isConfigEditable(rowData) === false,
185
+ value: value,
186
+ onChange: e => onChange(e.target.value),
187
+ variant: "outlined",
188
+ label: "Key",
189
+ placeholder: t('blocklet.config.environment.key'),
190
+ margin: "dense",
191
+ autoFocus: true
192
+ })
193
+ });
194
+ }
195
+ }, {
196
+ title: t('common.value'),
197
+ field: 'value',
198
+ initialEditValue: 'Value',
199
+ width: 'calc((100% - (96px + 30%)) / 1)',
200
+ render: d => {
201
+ if (!d.value) {
202
+ return null;
203
+ }
204
+ if (d.secure) {
205
+ return '******';
206
+ }
207
+ return /*#__PURE__*/_jsx(ClickToCopy, {
208
+ unstyled: true,
209
+ value: d.value,
210
+ style: {
211
+ wordBreak: 'break-all'
212
+ },
213
+ children: d.value
214
+ });
215
+ },
216
+ // eslint-disable-next-line no-shadow
217
+ editComponent: props => {
218
+ const {
219
+ value,
220
+ rowData,
221
+ onChange
222
+ } = props;
223
+ return /*#__PURE__*/_jsxs(EditDiv, {
224
+ children: [/*#__PURE__*/_jsx(TextField, {
225
+ fullWidth: true,
226
+ size: "small",
227
+ value: value === '__encrypted__' ? '' : value,
228
+ onChange: e => onChange(e.target.value),
229
+ variant: "outlined",
230
+ label: t('common.value'),
231
+ placeholder: t('blocklet.config.environment.value'),
232
+ margin: "dense",
233
+ autoFocus: true
234
+ }), getDescription(rowData, t)]
235
+ });
236
+ }
237
+ }];
238
+ return /*#__PURE__*/_jsxs(Div, {
239
+ children: [!!missingRequiredConfigs.length && /*#__PURE__*/_jsx(Alert, {
240
+ severity: "error",
241
+ style: {
242
+ marginTop: 24
243
+ },
244
+ children: t('blocklet.config.missingRequired')
245
+ }), hasBWAConfig && /*#__PURE__*/_jsx(Alert, {
246
+ severity: "info",
247
+ children: t('blocklet.config.environment.tip')
248
+ }), /*#__PURE__*/_jsx(Permission, {
249
+ permission: inService ? '' : 'mutate_blocklets',
250
+ role: inService ? BlockletAdminRoles : [],
251
+ children: hasPermission => /*#__PURE__*/_jsx(TableStyle, {
252
+ className: isBlockletDev(blocklet) ? 'readonly-block config-table' : 'config-table',
253
+ "data-disabled-text": t('blocklet.config.disabledText'),
254
+ children: /*#__PURE__*/_jsx(MaterialTable, {
255
+ title: /*#__PURE__*/_jsx("h4", {
256
+ children: t('common.environment')
257
+ }),
258
+ columns: onColumns(),
259
+ icons: {
260
+ ...blockletIcons,
261
+ ...tableIcons
262
+ },
263
+ options: {
264
+ emptyRowsWhenPaging: false,
265
+ actionsColumnIndex: -1,
266
+ tableLayout: 'auto',
267
+ maxBodyHeight: '100%',
268
+ paging: false,
269
+ search: false
270
+ },
271
+ localization: {
272
+ header: {
273
+ actions: t('common.actions')
274
+ },
275
+ body: {
276
+ emptyDataSourceMessage: t('common.noData')
277
+ }
278
+ },
279
+ data: configs,
280
+ editable: hasPermission ? action : {}
281
+ })
282
+ })
283
+ })]
284
+ });
285
+ }
286
+ ComponentEnvironment.propTypes = {
287
+ blocklet: PropTypes.object.isRequired,
288
+ ancestors: PropTypes.array
289
+ };
290
+ ComponentEnvironment.defaultProps = {
291
+ ancestors: []
292
+ };
293
+ const Div = styled.div`
294
+ .readonly-block {
295
+ position: relative;
296
+ &::after {
297
+ content: attr(data-disabled-text);
298
+ position: absolute;
299
+ display: flex;
300
+ align-items: center;
301
+ justify-content: center;
302
+ top: 0;
303
+ bottom: 0;
304
+ left: 0;
305
+ right: 0;
306
+ background-color: rgba(230, 230, 230, 0.7);
307
+ font-size: 24px;
308
+ letter-spacing: 2px;
309
+ color: #e33371;
310
+ padding: 20px;
311
+ word-break: break-all;
312
+ word-wrap: break-word;
313
+ z-index: 10;
314
+ }
315
+ }
316
+ .config-table {
317
+ margin-bottom: 24px;
318
+ position: relative;
319
+ .hide-control {
320
+ position: absolute;
321
+ top: 10px;
322
+ left: 200px;
323
+ @media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
324
+ left: 160px;
325
+ }
326
+ }
327
+
328
+ .MuiToolbar-root {
329
+ display: flex;
330
+ }
331
+
332
+ .MuiTableRow-head {
333
+ display: none;
334
+ }
335
+
336
+ &.hide-header {
337
+ .MuiToolbar-root {
338
+ display: none;
339
+ }
340
+ }
341
+ }
342
+
343
+ .accordion {
344
+ margin-bottom: 16px;
345
+ &:last-of-type {
346
+ margin-bottom: 0;
347
+ }
348
+ padding: 8px 0 8px 0px;
349
+ &.MuiAccordion-root {
350
+ background: transparent;
351
+ box-shadow: none;
352
+ border: 1px solid #ddd;
353
+ border-radius: 4px;
354
+ &::before,
355
+ &::after {
356
+ height: 0;
357
+ }
358
+ .MuiAccordionSummary-root {
359
+ padding-left: 0;
360
+ }
361
+ .accordion-title {
362
+ font-weight: bold;
363
+ padding-left: 16px;
364
+ }
365
+ }
366
+ }
367
+ `;
368
+ const EditDiv = styled.div`
369
+ height: 60px;
370
+ `;