@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,124 @@
1
+ import PropTypes from 'prop-types';
2
+ import Box from '@mui/material/Box';
3
+ import Chip from '@mui/material/Chip';
4
+ import FormControl from '@mui/material/FormControl';
5
+ import FormHelperText from '@mui/material/FormHelperText';
6
+ import InputLabel from '@mui/material/InputLabel';
7
+ import ListItemText from '@mui/material/ListItemText';
8
+ import MenuItem from '@mui/material/MenuItem';
9
+ import OutlinedInput from '@mui/material/OutlinedInput';
10
+ import Select from '@mui/material/Select';
11
+ import Typography from '@mui/material/Typography';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ function SimpleSelect({
15
+ fullWidth,
16
+ multiple,
17
+ required,
18
+ label,
19
+ placeholer,
20
+ options,
21
+ helperText,
22
+ error,
23
+ margin,
24
+ ...rest
25
+ }) {
26
+ const defaultOption = options.find(item => item.value === rest.value);
27
+ const defaultValue = defaultOption?.title;
28
+ return /*#__PURE__*/_jsxs(FormControl, {
29
+ margin: margin,
30
+ fullWidth: fullWidth,
31
+ error: error,
32
+ children: [/*#__PURE__*/_jsx(InputLabel, {
33
+ children: `${label}${required ? '*' : ''}`
34
+ }), /*#__PURE__*/_jsxs(Select, {
35
+ multiple: multiple,
36
+ input: /*#__PURE__*/_jsx(OutlinedInput, {
37
+ defaultValue: defaultValue,
38
+ sx: {
39
+ flex: 1
40
+ },
41
+ required: required,
42
+ label: label,
43
+ inputProps: {
44
+ margin
45
+ }
46
+ }),
47
+ renderValue: selected => {
48
+ if (multiple) {
49
+ return /*#__PURE__*/_jsx(Box, {
50
+ sx: {
51
+ display: 'flex',
52
+ flexWrap: 'wrap',
53
+ gap: 0.5
54
+ },
55
+ children: selected.map(value => {
56
+ const option = options.find(item => item.value === value);
57
+ return option && option.title && /*#__PURE__*/_jsx(Chip, {
58
+ size: "small",
59
+ label: option.title
60
+ }, value);
61
+ })
62
+ });
63
+ }
64
+ const option = options.find(item => item.value === selected);
65
+ return option && option.title && /*#__PURE__*/_jsxs(Box, {
66
+ children: [/*#__PURE__*/_jsx(Typography, {
67
+ component: "span",
68
+ children: option.title
69
+ }), /*#__PURE__*/_jsx(Typography, {
70
+ marginLeft: 1,
71
+ component: "span",
72
+ variant: "body2",
73
+ color: "text.secondary",
74
+ children: option.description
75
+ })]
76
+ });
77
+ },
78
+ ...rest,
79
+ children: [/*#__PURE__*/_jsx(MenuItem, {
80
+ disabled: true,
81
+ children: /*#__PURE__*/_jsx("em", {
82
+ children: placeholer
83
+ })
84
+ }), !multiple && /*#__PURE__*/_jsx(MenuItem, {
85
+ value: "",
86
+ children: "None"
87
+ }), options.map(option => option && option.value && /*#__PURE__*/_jsxs(MenuItem, {
88
+ value: option.value,
89
+ children: [/*#__PURE__*/_jsx(ListItemText, {
90
+ children: option.title
91
+ }), option.description && /*#__PURE__*/_jsx(Typography, {
92
+ variant: "body2",
93
+ color: "text.secondary",
94
+ children: option.description
95
+ })]
96
+ }, option.value))]
97
+ }), /*#__PURE__*/_jsx(FormHelperText, {
98
+ children: helperText
99
+ })]
100
+ });
101
+ }
102
+ SimpleSelect.propTypes = {
103
+ error: PropTypes.bool,
104
+ required: PropTypes.bool,
105
+ multiple: PropTypes.bool,
106
+ fullWidth: PropTypes.bool,
107
+ label: PropTypes.string,
108
+ placeholer: PropTypes.string,
109
+ options: PropTypes.array,
110
+ helperText: PropTypes.string,
111
+ margin: PropTypes.string
112
+ };
113
+ SimpleSelect.defaultProps = {
114
+ error: false,
115
+ required: false,
116
+ multiple: false,
117
+ fullWidth: false,
118
+ label: '',
119
+ placeholer: '',
120
+ options: [],
121
+ helperText: '',
122
+ margin: ''
123
+ };
124
+ export default SimpleSelect;
@@ -0,0 +1,155 @@
1
+ import { useState, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
+ import TextField from '@mui/material/TextField';
6
+ import MenuItem from '@mui/material/MenuItem';
7
+ import { NODE_MODES } from '@abtnode/constant';
8
+ import Button from '@arcblock/ux/lib/Button';
9
+ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
10
+ import Typography from '@mui/material/Typography';
11
+ import useLocalStorage from 'react-use/lib/useLocalStorage';
12
+ import { STORAGE_KEY_STORE_BLOCKLET, STORAGE_KEY_STORE_SERVER } from '../../util/constants';
13
+ import { useNodeContext } from '../../contexts/node';
14
+ import { useBlockletContext } from '../../contexts/blocklet';
15
+ import AddStore from '../../store/add';
16
+ import StoreItem from '../../store/item';
17
+ import { getStoreList } from '../../util';
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
21
+ export default function SelectStore({
22
+ onChange,
23
+ loading,
24
+ children,
25
+ extra
26
+ }) {
27
+ const {
28
+ t
29
+ } = useLocaleContext();
30
+ const {
31
+ info: nodeInfo,
32
+ inService
33
+ } = useNodeContext();
34
+ const {
35
+ blocklet
36
+ } = useBlockletContext();
37
+ const [open, setOpen] = useState(false);
38
+ const storeSelectRef = useRef(null);
39
+ const storageKey = inService ? STORAGE_KEY_STORE_BLOCKLET : STORAGE_KEY_STORE_SERVER;
40
+ const [storeUrl, setStoreUrl] = useLocalStorage(storageKey);
41
+ const {
42
+ storeList,
43
+ teamDid
44
+ } = getStoreList({
45
+ fromBlocklet: inService,
46
+ blocklet,
47
+ nodeInfo
48
+ });
49
+ const currentRegistry = storeUrl && storeList.find(x => storeUrl === x.url) || storeList[0];
50
+ const isServerlessMode = nodeInfo.mode === NODE_MODES.SERVERLESS;
51
+ return /*#__PURE__*/_jsxs(_Fragment, {
52
+ children: [/*#__PURE__*/_jsxs(SelectStoreTitle, {
53
+ children: [/*#__PURE__*/_jsx(Button, {
54
+ ref: storeSelectRef,
55
+ color: "secondary",
56
+ "data-cy": "add-component-select-store",
57
+ endIcon: /*#__PURE__*/_jsx(ArrowDropDownIcon, {
58
+ color: "secondary"
59
+ }),
60
+ onClick: () => {
61
+ setOpen(true);
62
+ },
63
+ style: {
64
+ padding: '0 2px'
65
+ },
66
+ children: /*#__PURE__*/_jsx(Typography, {
67
+ color: "secondary",
68
+ children: currentRegistry.name
69
+ })
70
+ }), /*#__PURE__*/_jsx(Typography, {
71
+ color: "secondary",
72
+ children: extra
73
+ })]
74
+ }), /*#__PURE__*/_jsxs(TextField, {
75
+ id: "mui-registry-select",
76
+ select: true,
77
+ autoComplete: "off",
78
+ variant: "outlined",
79
+ name: "did",
80
+ helperText: t('blocklet.component.selectRegistryTip'),
81
+ "data-cy": "component-registry-select",
82
+ fullWidth: true,
83
+ value: currentRegistry,
84
+ autoFocus: true,
85
+ onChange: e => {
86
+ const newRegistry = e.target.value;
87
+ setStoreUrl(newRegistry.url);
88
+ onChange(newRegistry);
89
+ },
90
+ SelectProps: {
91
+ open,
92
+ MenuProps: {
93
+ anchorEl: storeSelectRef.current
94
+ },
95
+ renderValue: item => {
96
+ return item?.name;
97
+ },
98
+ onClose: () => {
99
+ setOpen(false);
100
+ }
101
+ },
102
+ style: {
103
+ display: 'none'
104
+ },
105
+ margin: "normal",
106
+ children: [storeList?.map(x => {
107
+ return /*#__PURE__*/_jsx(MenuItem, {
108
+ value: x,
109
+ "data-cy": x.url,
110
+ children: /*#__PURE__*/_jsx(StoreItem, {
111
+ teamDid: teamDid,
112
+ store: x,
113
+ onDelete: () => {
114
+ if (storeUrl === x.url) {
115
+ setStoreUrl(storeList[0]?.url);
116
+ }
117
+ }
118
+ })
119
+ }, x.url);
120
+ }), !isServerlessMode && /*#__PURE__*/_jsx(AddStore, {
121
+ disabled: loading,
122
+ storeList: storeList,
123
+ teamDid: teamDid,
124
+ onAdd: url => {
125
+ setStoreUrl(url);
126
+ }
127
+ })]
128
+ }), children({
129
+ currentRegistry
130
+ })]
131
+ });
132
+ }
133
+ SelectStore.propTypes = {
134
+ onChange: PropTypes.func,
135
+ loading: PropTypes.bool,
136
+ children: PropTypes.any.isRequired,
137
+ extra: PropTypes.node
138
+ };
139
+ SelectStore.defaultProps = {
140
+ onChange: () => {},
141
+ loading: false,
142
+ extra: ''
143
+ };
144
+ const SelectStoreTitle = styled.div`
145
+ display: flex;
146
+ justify-content: space-between;
147
+ align-items: center;
148
+ margin-bottom: 16px;
149
+
150
+ span {
151
+ font-size: 16px;
152
+ color: ${props => props.theme.palette.common.black};
153
+ // font-weight: bold;
154
+ }
155
+ `;
@@ -0,0 +1,109 @@
1
+ import { useState } from 'react';
2
+ import styled from '@emotion/styled';
3
+ import PropTypes from 'prop-types';
4
+ import Box from '@mui/material/Box';
5
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
+ import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
7
+ import Toast from '@arcblock/ux/lib/Toast';
8
+ import FormTextInput from '../../form/form-text-input';
9
+ import { useNodeContext } from '../../contexts/node';
10
+ import { withPermission } from '../../permission';
11
+ import { isInstalling, formatError, BlockletAdminRoles, formatMountPoint } from '../../util';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ function ComponentSetting({
14
+ blocklet,
15
+ ancestors,
16
+ hasPermission,
17
+ ...rest
18
+ }) {
19
+ const {
20
+ t
21
+ } = useLocaleContext();
22
+ const {
23
+ api
24
+ } = useNodeContext();
25
+ const isRoot = !ancestors.length;
26
+ const rootDid = isRoot ? blocklet.meta.did : ancestors.map(x => x.meta.did)[0];
27
+ const [loading, setLoading] = useState('');
28
+ const [mountPointHelperText, setMountPointHelperText] = useState('');
29
+ const disabled = loading || !hasPermission;
30
+ if (!rootDid) {
31
+ return null;
32
+ }
33
+ if (blocklet.status === 'unknown' && isInstalling(blocklet.status)) {
34
+ return null;
35
+ }
36
+ const onSubmitMountPoint = async value => {
37
+ setLoading(true);
38
+ try {
39
+ const input = {
40
+ rootDid,
41
+ mountPoint: urlPathFriendly(value)
42
+ };
43
+ if (!isRoot) {
44
+ input.did = blocklet.meta.did;
45
+ }
46
+ await api.updateComponentMountPoint({
47
+ input
48
+ });
49
+ setLoading(false);
50
+ return true;
51
+ } catch (err) {
52
+ setLoading(false);
53
+ err.message = formatError(err);
54
+ Toast.error(err.message);
55
+ throw err;
56
+ }
57
+ };
58
+ const handleMountPointChange = value => {
59
+ setMountPointHelperText(t('common.slugifyHint', {
60
+ value: formatMountPoint(value)
61
+ }));
62
+ };
63
+ return /*#__PURE__*/_jsx(Div, {
64
+ component: "div",
65
+ ...rest,
66
+ children: /*#__PURE__*/_jsx(Box, {
67
+ mt: 3,
68
+ children: /*#__PURE__*/_jsx(FormTextInput, {
69
+ label: t('blocklet.component.mountPoint'),
70
+ style: {
71
+ marginTop: -24
72
+ },
73
+ disabled: loading || disabled,
74
+ loading: loading,
75
+ required: true,
76
+ initialValue: blocklet.mountPoint,
77
+ onSubmit: onSubmitMountPoint,
78
+ onChange: handleMountPointChange,
79
+ helperText: mountPointHelperText,
80
+ formatterBeforeSubmit: value => urlPathFriendly(value)
81
+ })
82
+ })
83
+ });
84
+ }
85
+ const ComponentSettingInDaemon = withPermission(ComponentSetting, 'mutate_blocklets');
86
+ const ComponentSettingInService = withPermission(ComponentSetting, '', BlockletAdminRoles);
87
+ export default function ComponentSettingWithPermission(props) {
88
+ const {
89
+ inService
90
+ } = useNodeContext();
91
+ if (inService) {
92
+ return /*#__PURE__*/_jsx(ComponentSettingInService, {
93
+ ...props
94
+ });
95
+ }
96
+ return /*#__PURE__*/_jsx(ComponentSettingInDaemon, {
97
+ ...props
98
+ });
99
+ }
100
+ ComponentSetting.propTypes = {
101
+ blocklet: PropTypes.object.isRequired,
102
+ ancestors: PropTypes.array,
103
+ hasPermission: PropTypes.bool
104
+ };
105
+ ComponentSetting.defaultProps = {
106
+ ancestors: [],
107
+ hasPermission: false
108
+ };
109
+ const Div = styled.div``;
@@ -0,0 +1,126 @@
1
+ import { isValidElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { SortableTreeWithoutDndContext as ReactSortableTree } from 'react-sortable-tree';
4
+ import MaterialTheme from 'react-sortable-tree-theme-material-ui';
5
+ import { Icon } from '@iconify/react';
6
+ import isObject from 'lodash/isObject';
7
+ import isEqual from 'lodash/isEqual';
8
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
+ import Box from '@mui/material/Box';
10
+ import Typography from '@mui/material/Typography';
11
+ import { HTML5Backend } from 'react-dnd-html5-backend';
12
+ import { DndProvider } from 'react-dnd';
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
+ function checkCanDrop({
17
+ prevPath,
18
+ nextPath
19
+ }) {
20
+ const prevLen = prevPath.length;
21
+ const nextLen = nextPath.length;
22
+ if (prevLen === nextLen) {
23
+ if (isEqual(prevPath.slice(0, prevLen - 1), nextPath.slice(0, nextLen - 1))) {
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+ function TreeTitle({
30
+ treeNode
31
+ }) {
32
+ const {
33
+ locale
34
+ } = useLocaleContext();
35
+ function renderTitle() {
36
+ const {
37
+ title,
38
+ subtitle
39
+ } = treeNode;
40
+ let titleShow = title;
41
+ let subtitleShow = subtitle;
42
+ if (isObject(title)) {
43
+ titleShow = title[locale];
44
+ }
45
+ if (! /*#__PURE__*/isValidElement(subtitle) && isObject(subtitle)) {
46
+ subtitleShow = subtitle[locale];
47
+ }
48
+ return /*#__PURE__*/_jsxs(Box, {
49
+ display: "flex",
50
+ alignItems: "center",
51
+ children: [/*#__PURE__*/_jsx(Typography, {
52
+ variant: "subtitle1",
53
+ fontSize: 16,
54
+ children: titleShow
55
+ }), subtitle && /*#__PURE__*/_jsx(Typography, {
56
+ variant: "body2",
57
+ color: "gray",
58
+ ml: 1.5,
59
+ children: subtitleShow
60
+ })]
61
+ });
62
+ }
63
+ return /*#__PURE__*/_jsxs(_Fragment, {
64
+ children: [treeNode.icon && /*#__PURE__*/_jsx(Icon, {
65
+ style: {
66
+ marginRight: 4
67
+ },
68
+ icon: treeNode.icon
69
+ }), renderTitle()]
70
+ });
71
+ }
72
+ TreeTitle.propTypes = {
73
+ treeNode: PropTypes.object.isRequired
74
+ };
75
+ function SortableTree({
76
+ treeData,
77
+ setTreeData,
78
+ renderActions
79
+ }) {
80
+ const expandedData = treeData.map(item => ({
81
+ ...item,
82
+ expanded: true
83
+ }));
84
+
85
+ // HACK: 兼容 mui-datatables 中的 react-dnd 使用
86
+ const dndProps = {};
87
+ if (typeof window !== 'undefined') {
88
+ dndProps.context = window;
89
+ }
90
+ return /*#__PURE__*/_jsx(DndProvider, {
91
+ backend: HTML5Backend,
92
+ ...dndProps,
93
+ children: /*#__PURE__*/_jsx(ReactSortableTree, {
94
+ generateNodeProps: rowInfo => {
95
+ return {
96
+ buttons: renderActions({
97
+ data: rowInfo.node,
98
+ className: 'list-item-actions'
99
+ }),
100
+ icons: /*#__PURE__*/_jsx(Icon, {
101
+ icon: "ic:round-drag-indicator"
102
+ }),
103
+ title: /*#__PURE__*/_jsx(TreeTitle, {
104
+ treeNode: rowInfo.node
105
+ })
106
+ };
107
+ },
108
+ maxDepth: 2,
109
+ isVirtualized: false,
110
+ treeData: expandedData,
111
+ onChange: setTreeData,
112
+ canDrop: checkCanDrop,
113
+ theme: MaterialTheme
114
+ })
115
+ });
116
+ }
117
+ SortableTree.propTypes = {
118
+ treeData: PropTypes.object.isRequired,
119
+ setTreeData: PropTypes.func,
120
+ renderActions: PropTypes.func
121
+ };
122
+ SortableTree.defaultProps = {
123
+ setTreeData: () => {},
124
+ renderActions: () => {}
125
+ };
126
+ export default SortableTree;