@abtnode/ux 1.15.17 → 1.16.0-beta-8ee536d7
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/lib/actions.js +111 -0
- package/lib/blocklet/access/config-access.js +303 -0
- package/lib/blocklet/access/index.js +221 -0
- package/lib/blocklet/actions.js +438 -0
- package/lib/blocklet/add-cert.js +191 -0
- package/lib/blocklet/agreement-app.js +30 -0
- package/lib/blocklet/agreement.js +72 -0
- package/lib/blocklet/app-avatar.js +74 -0
- package/lib/blocklet/audit-logs.js +197 -0
- package/lib/blocklet/blocklet-source.js +56 -0
- package/lib/blocklet/bundle-avatar.js +80 -0
- package/lib/blocklet/component/add.js +1063 -0
- package/lib/blocklet/component/configuration.js +124 -0
- package/lib/blocklet/component/delete.js +117 -0
- package/lib/blocklet/component/environment.js +289 -0
- package/lib/blocklet/component/expiration.js +53 -0
- package/lib/blocklet/component/index.js +804 -0
- package/lib/blocklet/component/line.js +28 -0
- package/lib/blocklet/component/navigation/locale-tabs.js +218 -0
- package/lib/blocklet/component/navigation/navigation-actions.js +120 -0
- package/lib/blocklet/component/navigation/navigation-dialog.js +620 -0
- package/lib/blocklet/component/navigation/navigation-preview.js +102 -0
- package/lib/blocklet/component/navigation/simple-select.js +131 -0
- package/lib/blocklet/component/select-store.js +153 -0
- package/lib/blocklet/component/setting.js +151 -0
- package/lib/blocklet/component/sortable-tree.js +138 -0
- package/lib/blocklet/component/space-gateway-selector.js +174 -0
- package/lib/blocklet/component/store-blocklet-list.js +205 -0
- package/lib/blocklet/config-navigation.js +344 -0
- package/lib/blocklet/configuration.js +574 -0
- package/lib/blocklet/disk-info.js +91 -0
- package/lib/blocklet/icons.js +26 -0
- package/lib/blocklet/install-from-url.js +347 -0
- package/lib/blocklet/log.js +62 -0
- package/lib/blocklet/migration.js +153 -0
- package/lib/blocklet/mode.js +35 -0
- package/lib/blocklet/monitor.js +186 -0
- package/lib/blocklet/overview.js +236 -0
- package/lib/blocklet/preferences/app-sk.js +131 -0
- package/lib/blocklet/preferences/index.js +238 -0
- package/lib/blocklet/preferences/wallet-type.js +107 -0
- package/lib/blocklet/purchase/common.js +103 -0
- package/lib/blocklet/purchase/component-purchase.js +253 -0
- package/lib/blocklet/purchase/index.js +13 -0
- package/lib/blocklet/router/action/add-domain-alias.js +173 -0
- package/lib/blocklet/router/action/add-rule.js +204 -0
- package/lib/blocklet/router/action/config-routing-rule.js +129 -0
- package/lib/blocklet/router/action/delete-domain-alias.js +107 -0
- package/lib/blocklet/router/action/delete-rule.js +114 -0
- package/lib/blocklet/router/action/update-rule.js +203 -0
- package/lib/blocklet/router/domain-actions.js +71 -0
- package/lib/blocklet/router/domain-status.js +96 -0
- package/lib/blocklet/router/rule-actions.js +77 -0
- package/lib/blocklet/router/rule-list.js +181 -0
- package/lib/blocklet/router/util.js +146 -0
- package/lib/blocklet/runtime-info.js +87 -0
- package/lib/blocklet/status.js +105 -0
- package/lib/blocklet/storage.js +322 -0
- package/lib/blocklet/types.js +25 -0
- package/lib/blocklet/util.js +233 -0
- package/lib/blocklet/version.js +156 -0
- package/lib/card-selector.js +109 -0
- package/lib/certificate.js +110 -0
- package/lib/click-to-copy.js +38 -0
- package/lib/confirm.js +149 -0
- package/lib/contexts/audit-log.js +141 -0
- package/lib/contexts/blocklet.js +19 -0
- package/lib/contexts/deleting-blocklets.js +78 -0
- package/lib/contexts/node.js +30 -0
- package/lib/contexts/session.js +20 -0
- package/lib/contexts/team.js +19 -0
- package/lib/delete-confirm.js +127 -0
- package/lib/did-address.js +77 -0
- package/lib/dot.js +18 -0
- package/lib/form/form-text-input.js +266 -0
- package/lib/form/form-wrapper.js +13 -0
- package/lib/form/required.js +13 -0
- package/lib/hooks/blocklet.js +231 -0
- package/lib/hooks/mobile-width.js +19 -0
- package/lib/hooks/url-evaluation.js +168 -0
- package/lib/hooks/use-app-logo.js +25 -0
- package/lib/hooks/use-bundle-logo.js +36 -0
- package/lib/hooks/use-navigation.js +355 -0
- package/lib/hooks/use-passport-id.js +21 -0
- package/lib/hooks/use-subscription.js +28 -0
- package/lib/icons/long-arrow.svg +5 -0
- package/lib/index.js +0 -3
- package/lib/invitation/invitation-app.js +51 -0
- package/lib/invitation/invitation-login.js +47 -0
- package/lib/invitation/invitation-passport.js +130 -0
- package/lib/invitation/invitation-receive.js +108 -0
- package/lib/invitation/invitation-success.js +82 -0
- package/lib/invitation/invitation-user.js +79 -0
- package/lib/invitation/invitation.js +80 -0
- package/lib/issue-passport.js +84 -84
- package/lib/launch-blocklet/content-layout.js +33 -0
- package/lib/launch-blocklet/page-header.js +38 -0
- package/lib/layout/addon.js +100 -0
- package/lib/layout/feedback.js +55 -0
- package/lib/locales/en.js +1221 -10
- package/lib/locales/index.js +3 -4
- package/lib/locales/zh.js +1232 -15
- package/lib/logs/clock.js +19 -0
- package/lib/logs/download.js +139 -0
- package/lib/logs/log-terminal.js +183 -0
- package/lib/lost-passport.js +207 -192
- package/lib/monitor/card.js +73 -0
- package/lib/monitor/cpu.js +109 -0
- package/lib/monitor/disk.js +122 -0
- package/lib/monitor/memory.js +144 -0
- package/lib/nav-logo.js +120 -0
- package/lib/passport-tag.js +43 -0
- package/lib/permission.js +70 -0
- package/lib/relative-time.js +61 -0
- package/lib/schema-form/color-input.js +105 -0
- package/lib/schema-form/common-prop-types.js +21 -0
- package/lib/schema-form/index.js +229 -0
- package/lib/schema-form/passport-input.js +66 -0
- package/lib/schema-form/text-input.js +72 -0
- package/lib/store/add.js +185 -0
- package/lib/store/delete.js +102 -0
- package/lib/store/item.js +84 -0
- package/lib/table-icons.js +42 -0
- package/lib/table.js +13 -0
- package/lib/tag.js +37 -0
- package/lib/team/members/actions.js +99 -0
- package/lib/team/members/index.js +503 -0
- package/lib/team/members/invitations.js +196 -0
- package/lib/team/members/invite-member.js +212 -0
- package/lib/team/members/issue-passport.js +155 -0
- package/lib/team/members/member.js +300 -0
- package/lib/team/members/passport-issuances.js +154 -0
- package/lib/team/members/passports.js +336 -0
- package/lib/team/members/toggle-user-approval.js +128 -0
- package/lib/team/members/transfer-node.js +262 -0
- package/lib/team/members/util.js +20 -0
- package/lib/team/passports/color.js +132 -0
- package/lib/team/passports/detail.js +271 -0
- package/lib/team/passports/index.js +233 -0
- package/lib/team/passports/mutate-role.js +204 -0
- package/lib/team/passports/trusted-issuer.js +297 -0
- package/lib/team/passports/trusted-issuers.js +240 -0
- package/lib/team/search-input.js +38 -0
- package/lib/team/styles/dialog.js +13 -0
- package/lib/team/styles/list-header.js +13 -0
- package/lib/toast.js +86 -0
- package/lib/util/api.js +21 -0
- package/lib/util/constants.js +10 -0
- package/lib/util/index.js +703 -0
- package/lib/util/locales.js +28 -0
- package/lib/util/mode.js +11 -0
- package/lib/who-can-access/config.js +46 -0
- package/lib/wrap-locale.js +12 -13
- package/package.json +71 -17
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ComponentConfiguration;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
11
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
12
|
+
var _Edit = _interopRequireDefault(require("@mui/icons-material/Edit"));
|
|
13
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
14
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
15
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
16
|
+
var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
|
|
17
|
+
var _util2 = require("../../util");
|
|
18
|
+
var _environment = _interopRequireDefault(require("./environment"));
|
|
19
|
+
var _setting = _interopRequireDefault(require("./setting"));
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
var _templateObject;
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
24
|
+
function ComponentConfiguration(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
blocklet,
|
|
27
|
+
ancestors,
|
|
28
|
+
children
|
|
29
|
+
} = _ref;
|
|
30
|
+
const [showDialog, setShowDialog] = (0, _react.useState)('');
|
|
31
|
+
const {
|
|
32
|
+
t
|
|
33
|
+
} = (0, _context.useLocaleContext)();
|
|
34
|
+
const isRoot = !ancestors.map(x => x.meta.did)[0];
|
|
35
|
+
const isLevel1 = ancestors.length === 1;
|
|
36
|
+
const [tab, setTab] = (0, _react.useState)('settings');
|
|
37
|
+
const name = ancestors.concat(blocklet).slice(1).map(x => (0, _util.getDisplayName)(x, true)).join(' / ');
|
|
38
|
+
if ((0, _util2.isInstalling)(blocklet.status)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (blocklet.status === 'unknown' && (0, _util2.isInstalling)(blocklet.status)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const onClose = () => {
|
|
45
|
+
setShowDialog(false);
|
|
46
|
+
};
|
|
47
|
+
const onOpen = e => {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
// eslint-disable-next-line no-unused-expressions
|
|
50
|
+
setShowDialog(true);
|
|
51
|
+
};
|
|
52
|
+
const tabConfigs = {
|
|
53
|
+
settings: {
|
|
54
|
+
label: t('blocklet.component.setting'),
|
|
55
|
+
value: 'settings',
|
|
56
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_setting.default, {
|
|
57
|
+
blocklet: blocklet,
|
|
58
|
+
ancestors: ancestors
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
environments: {
|
|
62
|
+
label: t('common.environment'),
|
|
63
|
+
value: 'environments',
|
|
64
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_environment.default, {
|
|
65
|
+
blocklet: blocklet,
|
|
66
|
+
ancestors: ancestors
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const tabs = Object.values(tabConfigs).map(_ref2 => {
|
|
71
|
+
let {
|
|
72
|
+
label,
|
|
73
|
+
value
|
|
74
|
+
} = _ref2;
|
|
75
|
+
return {
|
|
76
|
+
label,
|
|
77
|
+
value
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const onTabChange = newTab => {
|
|
81
|
+
setTab(newTab);
|
|
82
|
+
};
|
|
83
|
+
const tabConfig = tabConfigs[tab] || tabConfigs.settings;
|
|
84
|
+
return [typeof children === 'function' ? children({
|
|
85
|
+
open: onOpen
|
|
86
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
87
|
+
onClick: onOpen,
|
|
88
|
+
"data-cy": "action-config-component",
|
|
89
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Edit.default, {})
|
|
90
|
+
}), showDialog && /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDialog, {
|
|
91
|
+
open: true,
|
|
92
|
+
fullWidth: true,
|
|
93
|
+
maxWidth: "md",
|
|
94
|
+
title: name,
|
|
95
|
+
onClose: onClose,
|
|
96
|
+
PaperProps: {
|
|
97
|
+
style: {
|
|
98
|
+
minHeight: 'auto'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
children: isRoot || isLevel1 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
102
|
+
mt: 1,
|
|
103
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tabs.default, {
|
|
104
|
+
tabs: tabs,
|
|
105
|
+
current: tab,
|
|
106
|
+
onChange: onTabChange,
|
|
107
|
+
scrollButtons: "auto"
|
|
108
|
+
}), tabConfig.component]
|
|
109
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_environment.default, {
|
|
110
|
+
blocklet: blocklet,
|
|
111
|
+
ancestors: ancestors
|
|
112
|
+
})
|
|
113
|
+
})];
|
|
114
|
+
}
|
|
115
|
+
ComponentConfiguration.propTypes = {
|
|
116
|
+
blocklet: _propTypes.default.object.isRequired,
|
|
117
|
+
ancestors: _propTypes.default.array,
|
|
118
|
+
children: _propTypes.default.any
|
|
119
|
+
};
|
|
120
|
+
ComponentConfiguration.defaultProps = {
|
|
121
|
+
ancestors: [],
|
|
122
|
+
children: null
|
|
123
|
+
};
|
|
124
|
+
const StyledDialog = (0, _styled.default)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiDialogContent-root {\n padding-top: 0;\n margin-top: -32px;\n }\n .MuiToolbar-root {\n padding-right: 12px;\n }\n .ux-dialog_right {\n padding-right: 20px;\n }\n"])));
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DeleteComponent;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
|
|
11
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
12
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
13
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
14
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
15
|
+
var _Radio = _interopRequireDefault(require("@mui/material/Radio"));
|
|
16
|
+
var _RadioGroup = _interopRequireDefault(require("@mui/material/RadioGroup"));
|
|
17
|
+
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
18
|
+
var _confirm = _interopRequireDefault(require("../../confirm"));
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
var _templateObject;
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
27
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
|
+
function DeleteComponent(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
component,
|
|
31
|
+
remove,
|
|
32
|
+
disabled,
|
|
33
|
+
tip
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
t
|
|
37
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
38
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
39
|
+
const [deleteSetting, setDeleteSetting] = (0, _react.useState)(null);
|
|
40
|
+
const deleteComponent = async param => {
|
|
41
|
+
setLoading(true);
|
|
42
|
+
await remove(param.component, param.removeType);
|
|
43
|
+
setLoading(false);
|
|
44
|
+
setDeleteSetting(null);
|
|
45
|
+
};
|
|
46
|
+
const componentDisabled = disabled || loading;
|
|
47
|
+
const btn = /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, {
|
|
48
|
+
disabled: componentDisabled,
|
|
49
|
+
onClick: () => setDeleteSetting({
|
|
50
|
+
title: t('blocklet.component.delete'),
|
|
51
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
52
|
+
description: (params, setParams) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
53
|
+
component: "div",
|
|
54
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
55
|
+
gutterBottom: true,
|
|
56
|
+
children: t('blocklet.action.removeComponentDescription')
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_RadioGroup.default, {
|
|
58
|
+
name: "removeType",
|
|
59
|
+
value: params.removeType,
|
|
60
|
+
onChange: e => setParams(_objectSpread(_objectSpread({}, params), {}, {
|
|
61
|
+
removeType: e.target.value
|
|
62
|
+
})),
|
|
63
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
64
|
+
value: "keepData",
|
|
65
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.default, {}),
|
|
66
|
+
label: t('blocklet.action.removeComponentKeepData')
|
|
67
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
68
|
+
value: "complete",
|
|
69
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.default, {}),
|
|
70
|
+
label: t('blocklet.action.removeComponentComplete')
|
|
71
|
+
})]
|
|
72
|
+
})]
|
|
73
|
+
}),
|
|
74
|
+
confirm: t('common.confirm'),
|
|
75
|
+
cancel: t('common.cancel'),
|
|
76
|
+
params: {
|
|
77
|
+
component,
|
|
78
|
+
removeType: 'keepData'
|
|
79
|
+
},
|
|
80
|
+
onConfirm: deleteComponent,
|
|
81
|
+
onCancel: () => setDeleteSetting(null)
|
|
82
|
+
}),
|
|
83
|
+
"data-cy": "delete-component-btn",
|
|
84
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Delete.default, {
|
|
85
|
+
disabled: componentDisabled
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
const btnWithToolTip = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
89
|
+
title: tip || t('common.delete'),
|
|
90
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
91
|
+
children: btn
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
95
|
+
children: [btnWithToolTip, deleteSetting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
96
|
+
title: deleteSetting.title,
|
|
97
|
+
description: deleteSetting.description,
|
|
98
|
+
confirm: deleteSetting.confirm,
|
|
99
|
+
cancel: deleteSetting.cancel,
|
|
100
|
+
params: deleteSetting.params,
|
|
101
|
+
onConfirm: deleteSetting.onConfirm,
|
|
102
|
+
onCancel: deleteSetting.onCancel
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
DeleteComponent.propTypes = {
|
|
107
|
+
component: _propTypes.default.object.isRequired,
|
|
108
|
+
remove: _propTypes.default.func,
|
|
109
|
+
disabled: _propTypes.default.bool,
|
|
110
|
+
tip: _propTypes.default.string
|
|
111
|
+
};
|
|
112
|
+
DeleteComponent.defaultProps = {
|
|
113
|
+
remove: async () => {},
|
|
114
|
+
disabled: false,
|
|
115
|
+
tip: ''
|
|
116
|
+
};
|
|
117
|
+
const StyledButton = (0, _styled.default)(_IconButton.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.Mui-disabled {\n opacity: 0.5;\n }\n"])));
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ComponentEnvironment;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _core = _interopRequireDefault(require("@material-table/core"));
|
|
11
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
12
|
+
var _Alert = _interopRequireDefault(require("@mui/material/Alert"));
|
|
13
|
+
var _constant = require("@blocklet/constant");
|
|
14
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
15
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
16
|
+
var _clickToCopy = _interopRequireDefault(require("../../click-to-copy"));
|
|
17
|
+
var _toast = _interopRequireDefault(require("../../toast"));
|
|
18
|
+
var _node = require("../../contexts/node");
|
|
19
|
+
var _tableIcons = _interopRequireDefault(require("../../table-icons"));
|
|
20
|
+
var _table = _interopRequireDefault(require("../../table"));
|
|
21
|
+
var _permission = _interopRequireDefault(require("../../permission"));
|
|
22
|
+
var _util2 = require("../../util");
|
|
23
|
+
var _icons = _interopRequireDefault(require("../icons"));
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
var _templateObject, _templateObject2;
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
32
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
33
|
+
function ComponentEnvironment(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
blocklet,
|
|
36
|
+
ancestors
|
|
37
|
+
} = _ref;
|
|
38
|
+
const node = (0, _node.useNodeContext)();
|
|
39
|
+
const {
|
|
40
|
+
inService
|
|
41
|
+
} = node;
|
|
42
|
+
const {
|
|
43
|
+
t
|
|
44
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
45
|
+
const dids = [...ancestors.map(x => x.meta.did), blocklet.meta.did];
|
|
46
|
+
const onConfigChanged = () => _toast.default.success(t('blocklet.config.changedTip'));
|
|
47
|
+
const isConfigEditable = x => x.custom;
|
|
48
|
+
if ((0, _util2.isInstalling)(blocklet.status)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (blocklet.status === 'unknown' && (0, _util2.isInstalling)(blocklet.status)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const onAddConfig = async data => {
|
|
55
|
+
if (!data.key.trim() || !data.value.trim()) {
|
|
56
|
+
_toast.default.error(t('blocklet.config.environment.keyValueRequired'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (data.key.startsWith('BLOCKLET_') || data.key.startsWith('COMPONENT_')) {
|
|
60
|
+
_toast.default.error(t('blocklet.config.environment.invalidKey'));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
data.custom = true;
|
|
64
|
+
const result = await node.api.configBlocklet({
|
|
65
|
+
input: {
|
|
66
|
+
did: dids,
|
|
67
|
+
configs: [data]
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (result.code === 'ok') {
|
|
71
|
+
onConfigChanged(result.blocklet);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const onEditConfig = async (newData, oldData) => {
|
|
75
|
+
// only required field can't be empty
|
|
76
|
+
if (newData.required && (!newData.key.trim() || !newData.value.trim())) {
|
|
77
|
+
_toast.default.error(t('blocklet.config.environment.keyValueRequired'));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (newData.key.startsWith('BLOCKLET_') && !_constant.BLOCKLET_CONFIGURABLE_KEY[newData.key]) {
|
|
81
|
+
_toast.default.error(t('blocklet.config.environment.invalidKey'));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (newData.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
|
|
85
|
+
const errMessage = (0, _util2.isValidClusterSize)(newData);
|
|
86
|
+
if (errMessage) {
|
|
87
|
+
_toast.default.error(errMessage);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const configs = [newData];
|
|
92
|
+
if (newData.key !== oldData.key) {
|
|
93
|
+
if (!newData.custom) {
|
|
94
|
+
_toast.default.error('Only key of custom env can be changed');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
configs.push({
|
|
98
|
+
key: oldData.key,
|
|
99
|
+
custom: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const result = await node.api.configBlocklet({
|
|
104
|
+
input: {
|
|
105
|
+
did: dids,
|
|
106
|
+
configs
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (result.code === 'ok') {
|
|
110
|
+
onConfigChanged(result.blocklet);
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_toast.default.error((0, _util2.formatError)(err));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const onDeleteConfig = async data => {
|
|
117
|
+
if (data.required) {
|
|
118
|
+
_toast.default.error(t('blocklet.config.environment.deleteForbidden'));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!data.custom) {
|
|
122
|
+
_toast.default.error('Only key of custom env can be changed');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const result = await node.api.configBlocklet({
|
|
126
|
+
input: {
|
|
127
|
+
did: dids,
|
|
128
|
+
configs: [{
|
|
129
|
+
key: data.key,
|
|
130
|
+
custom: true
|
|
131
|
+
}]
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (result.code === 'ok') {
|
|
135
|
+
onConfigChanged(result.blocklet);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// configs
|
|
140
|
+
const componentConfigs = (blocklet.configs || []).filter(x => !_constant.BLOCKLET_CONFIGURABLE_KEY[x.key]);
|
|
141
|
+
const sharedConfigObj = (0, _util.getSharedConfigObj)(blocklet, ancestors);
|
|
142
|
+
const missingRequiredConfigs = (0, _util.getComponentMissingConfigs)(blocklet, ancestors);
|
|
143
|
+
const configs = componentConfigs.map(x => _objectSpread(_objectSpread({}, x), {}, {
|
|
144
|
+
value: sharedConfigObj[x.key] || x.value
|
|
145
|
+
}));
|
|
146
|
+
const hasBWAConfig = configs.some(x => x.key && x.key.startsWith('BWA_'));
|
|
147
|
+
const action = {
|
|
148
|
+
onRowAdd: onAddConfig,
|
|
149
|
+
onRowUpdate: onEditConfig,
|
|
150
|
+
onRowDelete: onDeleteConfig,
|
|
151
|
+
// environment declare in blocklet.yml can't be deleted, only custom env can be deleted
|
|
152
|
+
isDeletable: isConfigEditable
|
|
153
|
+
};
|
|
154
|
+
const onColumns = () => [{
|
|
155
|
+
title: t('common.key'),
|
|
156
|
+
field: 'key',
|
|
157
|
+
initialEditValue: 'Key',
|
|
158
|
+
width: '30%',
|
|
159
|
+
render: d => /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
|
|
160
|
+
value: d.value,
|
|
161
|
+
style: {
|
|
162
|
+
color: d.required && !d.value ? '#ff4436' : '#222222',
|
|
163
|
+
fontWeight: d.required ? 'bold' : 'normal'
|
|
164
|
+
},
|
|
165
|
+
children: d.key
|
|
166
|
+
}),
|
|
167
|
+
editComponent: props => {
|
|
168
|
+
const {
|
|
169
|
+
value,
|
|
170
|
+
rowData,
|
|
171
|
+
onChange: _onChange
|
|
172
|
+
} = props;
|
|
173
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(EditDiv, {
|
|
174
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
175
|
+
fullWidth: true,
|
|
176
|
+
size: "small",
|
|
177
|
+
disabled: isConfigEditable(rowData) === false,
|
|
178
|
+
value: value,
|
|
179
|
+
onChange: e => _onChange(e.target.value),
|
|
180
|
+
variant: "outlined",
|
|
181
|
+
label: "Key",
|
|
182
|
+
placeholder: t('blocklet.config.environment.key'),
|
|
183
|
+
margin: "dense",
|
|
184
|
+
autoFocus: true
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
title: t('common.value'),
|
|
190
|
+
field: 'value',
|
|
191
|
+
initialEditValue: 'Value',
|
|
192
|
+
width: 'calc((100% - (96px + 30%)) / 1)',
|
|
193
|
+
render: d => {
|
|
194
|
+
if (d.secure) {
|
|
195
|
+
return '******';
|
|
196
|
+
}
|
|
197
|
+
if (!d.value) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
|
|
201
|
+
unstyled: true,
|
|
202
|
+
value: d.value,
|
|
203
|
+
style: {
|
|
204
|
+
wordBreak: 'break-all'
|
|
205
|
+
},
|
|
206
|
+
children: d.value
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
// eslint-disable-next-line no-shadow
|
|
210
|
+
editComponent: props => {
|
|
211
|
+
const {
|
|
212
|
+
value,
|
|
213
|
+
rowData,
|
|
214
|
+
onChange: _onChange2
|
|
215
|
+
} = props;
|
|
216
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(EditDiv, {
|
|
217
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
218
|
+
fullWidth: true,
|
|
219
|
+
size: "small",
|
|
220
|
+
value: value === '__encrypted__' ? '' : value,
|
|
221
|
+
onChange: e => _onChange2(e.target.value),
|
|
222
|
+
variant: "outlined",
|
|
223
|
+
label: t('common.value'),
|
|
224
|
+
placeholder: t('blocklet.config.environment.value'),
|
|
225
|
+
margin: "dense",
|
|
226
|
+
autoFocus: true
|
|
227
|
+
}), rowData.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
228
|
+
style: {
|
|
229
|
+
marginLeft: 12
|
|
230
|
+
},
|
|
231
|
+
children: rowData.description
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}];
|
|
236
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
|
|
237
|
+
children: [!!missingRequiredConfigs.length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
238
|
+
severity: "error",
|
|
239
|
+
style: {
|
|
240
|
+
marginTop: 24
|
|
241
|
+
},
|
|
242
|
+
children: t('blocklet.config.missingRequired')
|
|
243
|
+
}), hasBWAConfig && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
244
|
+
severity: "info",
|
|
245
|
+
children: t('blocklet.config.environment.tip')
|
|
246
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
|
|
247
|
+
permission: inService ? '' : 'mutate_blocklets',
|
|
248
|
+
role: inService ? _util2.BlockletAdminRoles : [],
|
|
249
|
+
children: hasPermission => /*#__PURE__*/(0, _jsxRuntime.jsx)(_table.default, {
|
|
250
|
+
className: (0, _util2.isBlockletDev)(blocklet) ? 'readonly-block config-table' : 'config-table',
|
|
251
|
+
"data-disabled-text": t('blocklet.config.disabledText'),
|
|
252
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.default, {
|
|
253
|
+
title: /*#__PURE__*/(0, _jsxRuntime.jsx)("h4", {
|
|
254
|
+
children: t('common.environment')
|
|
255
|
+
}),
|
|
256
|
+
columns: onColumns(),
|
|
257
|
+
icons: _objectSpread(_objectSpread({}, _icons.default), _tableIcons.default),
|
|
258
|
+
options: {
|
|
259
|
+
emptyRowsWhenPaging: false,
|
|
260
|
+
actionsColumnIndex: -1,
|
|
261
|
+
tableLayout: 'auto',
|
|
262
|
+
maxBodyHeight: '100%',
|
|
263
|
+
paging: false,
|
|
264
|
+
search: false
|
|
265
|
+
},
|
|
266
|
+
localization: {
|
|
267
|
+
header: {
|
|
268
|
+
actions: t('common.actions')
|
|
269
|
+
},
|
|
270
|
+
body: {
|
|
271
|
+
emptyDataSourceMessage: t('common.noData')
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
data: configs,
|
|
275
|
+
editable: hasPermission ? action : {}
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
})]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
ComponentEnvironment.propTypes = {
|
|
282
|
+
blocklet: _propTypes.default.object.isRequired,
|
|
283
|
+
ancestors: _propTypes.default.array
|
|
284
|
+
};
|
|
285
|
+
ComponentEnvironment.defaultProps = {
|
|
286
|
+
ancestors: []
|
|
287
|
+
};
|
|
288
|
+
const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .readonly-block {\n position: relative;\n &::after {\n content: attr(data-disabled-text);\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: rgba(230, 230, 230, 0.7);\n font-size: 24px;\n letter-spacing: 2px;\n color: #e33371;\n padding: 20px;\n word-break: break-all;\n word-wrap: break-word;\n z-index: 10;\n }\n }\n .config-table {\n margin-bottom: 24px;\n position: relative;\n .hide-control {\n position: absolute;\n top: 10px;\n left: 200px;\n @media (max-width: ", "px) {\n left: 160px;\n }\n }\n\n .MuiToolbar-root {\n display: flex;\n }\n\n .MuiTableRow-head {\n display: none;\n }\n\n &.hide-header {\n .MuiToolbar-root {\n display: none;\n }\n }\n }\n\n .accordion {\n margin-bottom: 16px;\n &:last-of-type {\n margin-bottom: 0;\n }\n padding: 8px 0 8px 0px;\n &.MuiAccordion-root {\n background: transparent;\n box-shadow: none;\n border: 1px solid #ddd;\n border-radius: 4px;\n &::before,\n &::after {\n height: 0;\n }\n .MuiAccordionSummary-root {\n padding-left: 0;\n }\n .accordion-title {\n font-weight: bold;\n padding-left: 16px;\n }\n }\n }\n"])), props => props.theme.breakpoints.values.sm);
|
|
289
|
+
const EditDiv = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 60px;\n"])));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
9
|
+
var _last = _interopRequireDefault(require("lodash/last"));
|
|
10
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
11
|
+
var _useAsync = _interopRequireDefault(require("react-use/lib/useAsync"));
|
|
12
|
+
var _RelativeTime = _interopRequireDefault(require("@arcblock/ux/lib/RelativeTime"));
|
|
13
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
14
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
15
|
+
var _Link = _interopRequireDefault(require("@mui/material/Link"));
|
|
16
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
17
|
+
var _util = require("../../util");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function Expiration(_ref) {
|
|
21
|
+
var _state$value, _state$value$data, _state$value$data$val;
|
|
22
|
+
let {
|
|
23
|
+
controller
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
t,
|
|
27
|
+
locale
|
|
28
|
+
} = (0, _context.useLocaleContext)();
|
|
29
|
+
const state = (0, _useAsync.default)(async () => (0, _util.getAsset)(controller.chainHost, controller.nftId));
|
|
30
|
+
if (state.loading) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
const expirationDate = (0, _last.default)((0, _get.default)(state.value, 'data.value.expirationDate', []));
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
35
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_RelativeTime.default, {
|
|
36
|
+
value: expirationDate,
|
|
37
|
+
locale: locale
|
|
38
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
39
|
+
style: {
|
|
40
|
+
marginLeft: '5px'
|
|
41
|
+
},
|
|
42
|
+
variant: "contained",
|
|
43
|
+
component: _Link.default,
|
|
44
|
+
href: (0, _urlJoin.default)((_state$value = state.value) === null || _state$value === void 0 ? void 0 : (_state$value$data = _state$value.data) === null || _state$value$data === void 0 ? void 0 : (_state$value$data$val = _state$value$data.value) === null || _state$value$data$val === void 0 ? void 0 : _state$value$data$val.launcherUrl, "/instances/".concat(controller.nftId, "/renewal?locale=").concat(locale, "&return-url=").concat(encodeURIComponent(window.location.href))),
|
|
45
|
+
children: t('common.renew')
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
Expiration.propTypes = {
|
|
50
|
+
controller: _propTypes.default.object.isRequired
|
|
51
|
+
};
|
|
52
|
+
var _default = Expiration;
|
|
53
|
+
exports.default = _default;
|