@abtnode/ux 1.8.33 → 1.8.35
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/blocklet/component/environment.js +1 -1
- package/lib/blocklet/component/index.js +61 -31
- package/lib/blocklet/component/line.js +28 -0
- package/lib/blocklet/component/setting.js +1 -1
- package/lib/blocklet/configuration.js +180 -13
- package/lib/blocklet/overview.js +127 -10
- package/lib/blocklet/router/action/add-domain-alias.js +171 -0
- package/lib/blocklet/router/action/add-rule.js +196 -0
- package/lib/blocklet/router/action/config-routing-rule.js +125 -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 +195 -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 +75 -0
- package/lib/blocklet/router/rule-list.js +179 -0
- package/lib/blocklet/router/util.js +146 -0
- package/lib/blocklet/types.js +25 -0
- package/lib/blocklet/util.js +105 -9
- package/lib/blocklet/version.js +1 -1
- package/lib/certificate.js +110 -0
- package/lib/contexts/blocklet.js +19 -0
- package/lib/delete-confirm.js +125 -0
- package/lib/form/form-text-input.js +9 -2
- package/lib/hooks/blocklet.js +171 -0
- package/lib/hooks/url-evaluation.js +157 -0
- package/lib/hooks/use-subscription.js +28 -0
- package/lib/layout/addon.js +17 -17
- package/lib/layout/feedback.js +57 -0
- package/lib/locales/en.js +6 -2
- package/lib/locales/zh.js +6 -2
- package/lib/schema-form/index.js +9 -4
- package/lib/schema-form/text-input.js +1 -1
- package/lib/team/members/index.js +23 -11
- package/lib/team/members/member.js +3 -0
- package/lib/team/passports/color.js +131 -0
- package/lib/team/passports/index.js +32 -20
- package/lib/util/index.js +70 -5
- package/package.json +12 -12
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = CancelConfirm;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
9
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
10
|
+
var _Alert = _interopRequireDefault(require("@mui/material/Alert"));
|
|
11
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
12
|
+
var _clickToCopy = _interopRequireDefault(require("./click-to-copy"));
|
|
13
|
+
var _confirm = _interopRequireDefault(require("./confirm"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function CancelConfirm(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
title: _title,
|
|
22
|
+
description: _description,
|
|
23
|
+
confirmPlaceholder,
|
|
24
|
+
cancel,
|
|
25
|
+
confirm,
|
|
26
|
+
params: initialParams,
|
|
27
|
+
onCancel,
|
|
28
|
+
onConfirm,
|
|
29
|
+
keyName
|
|
30
|
+
} = _ref;
|
|
31
|
+
const {
|
|
32
|
+
t
|
|
33
|
+
} = (0, _context.useLocaleContext)();
|
|
34
|
+
const confirmSetting = {
|
|
35
|
+
title: () => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
36
|
+
children: [_title, " (".concat(keyName, ")")]
|
|
37
|
+
}),
|
|
38
|
+
description: (params, setParams) => {
|
|
39
|
+
const setValue = value => {
|
|
40
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
41
|
+
setParams(_objectSpread(_objectSpread({}, value), {}, {
|
|
42
|
+
__disableConfirm: value.__disableConfirm
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
46
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
47
|
+
severity: "warning",
|
|
48
|
+
style: {
|
|
49
|
+
width: '100%'
|
|
50
|
+
},
|
|
51
|
+
children: t('common.notice')
|
|
52
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
|
+
style: {
|
|
54
|
+
marginTop: 24,
|
|
55
|
+
marginBottom: 24
|
|
56
|
+
},
|
|
57
|
+
dangerouslySetInnerHTML: {
|
|
58
|
+
__html: _description
|
|
59
|
+
}
|
|
60
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
61
|
+
style: {
|
|
62
|
+
marginBottom: 24
|
|
63
|
+
},
|
|
64
|
+
children: [t('common.click'), "\uFF1A", /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
|
|
65
|
+
"data-cy": "click-copy",
|
|
66
|
+
children: keyName
|
|
67
|
+
})]
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
69
|
+
component: "div",
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
71
|
+
label: confirmPlaceholder,
|
|
72
|
+
autoComplete: "off",
|
|
73
|
+
"data-cy": "delete-confirm-input",
|
|
74
|
+
variant: "outlined",
|
|
75
|
+
fullWidth: true,
|
|
76
|
+
autoFocus: true,
|
|
77
|
+
value: params.inputVal,
|
|
78
|
+
onChange: e => {
|
|
79
|
+
setValue(_objectSpread(_objectSpread({}, params), {}, {
|
|
80
|
+
inputVal: e.target.value,
|
|
81
|
+
__disableConfirm: keyName !== e.target.value
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
confirm,
|
|
89
|
+
cancel,
|
|
90
|
+
onConfirm,
|
|
91
|
+
onCancel,
|
|
92
|
+
params: _objectSpread({
|
|
93
|
+
inputVal: '',
|
|
94
|
+
__disableConfirm: true
|
|
95
|
+
}, initialParams)
|
|
96
|
+
};
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
98
|
+
title: confirmSetting.title,
|
|
99
|
+
description: confirmSetting.description,
|
|
100
|
+
confirm: confirmSetting.confirm,
|
|
101
|
+
cancel: confirmSetting.cancel,
|
|
102
|
+
params: confirmSetting.params,
|
|
103
|
+
onConfirm: confirmSetting.onConfirm,
|
|
104
|
+
onCancel: confirmSetting.onCancel
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
CancelConfirm.propTypes = {
|
|
108
|
+
title: _propTypes.default.any.isRequired,
|
|
109
|
+
keyName: _propTypes.default.any.isRequired,
|
|
110
|
+
description: _propTypes.default.any.isRequired,
|
|
111
|
+
// can be a function that renders different content based on params
|
|
112
|
+
confirmPlaceholder: _propTypes.default.any.isRequired,
|
|
113
|
+
cancel: _propTypes.default.string,
|
|
114
|
+
confirm: _propTypes.default.string,
|
|
115
|
+
params: _propTypes.default.object,
|
|
116
|
+
// This object holds states managed in the dialog
|
|
117
|
+
onCancel: _propTypes.default.func,
|
|
118
|
+
onConfirm: _propTypes.default.func.isRequired
|
|
119
|
+
};
|
|
120
|
+
CancelConfirm.defaultProps = {
|
|
121
|
+
onCancel: () => {},
|
|
122
|
+
cancel: '',
|
|
123
|
+
confirm: 'Confirm',
|
|
124
|
+
params: {}
|
|
125
|
+
};
|
|
@@ -42,8 +42,12 @@ function FormTextInput(_ref) {
|
|
|
42
42
|
const handleSubmit = async () => {
|
|
43
43
|
setLoading(true);
|
|
44
44
|
try {
|
|
45
|
-
await onSubmit(value);
|
|
46
|
-
|
|
45
|
+
const shouldUpdate = await onSubmit(value);
|
|
46
|
+
if (shouldUpdate === false) {
|
|
47
|
+
setValue(defaultValue);
|
|
48
|
+
} else {
|
|
49
|
+
setDefaultValue(value);
|
|
50
|
+
}
|
|
47
51
|
} catch (err) {
|
|
48
52
|
setValue(defaultValue);
|
|
49
53
|
} finally {
|
|
@@ -80,6 +84,9 @@ function FormTextInput(_ref) {
|
|
|
80
84
|
}, rest)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
81
85
|
px: 1,
|
|
82
86
|
className: "form-item-input slot",
|
|
87
|
+
style: {
|
|
88
|
+
whiteSpace: 'pre-wrap'
|
|
89
|
+
},
|
|
83
90
|
children: value
|
|
84
91
|
});
|
|
85
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formWrapper.default, {
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useBlocklet = useBlocklet;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
9
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
10
|
+
var _constant = require("@blocklet/constant");
|
|
11
|
+
var _toast = _interopRequireDefault(require("../toast"));
|
|
12
|
+
var _util = require("../util");
|
|
13
|
+
var _util2 = require("../blocklet/util");
|
|
14
|
+
var _urlEvaluation = require("./url-evaluation");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
20
|
+
function useBlocklet(_ref) {
|
|
21
|
+
var _blocklet$site, _blocklet$site$domain, _blocklet$meta, _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _blocklet$meta5, _blocklet$meta6, _blocklet$meta7, _blocklet$meta8;
|
|
22
|
+
let {
|
|
23
|
+
did,
|
|
24
|
+
client,
|
|
25
|
+
useSubscription,
|
|
26
|
+
getIP,
|
|
27
|
+
useLocaleContext,
|
|
28
|
+
disableSubscription
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
t,
|
|
32
|
+
locale
|
|
33
|
+
} = useLocaleContext();
|
|
34
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
35
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
36
|
+
const [loadingRuntimeInfo, setLoadingRuntimeInfo] = (0, _react.useState)(false);
|
|
37
|
+
const [blocklet, setBlocklet] = (0, _react.useState)();
|
|
38
|
+
const [domainStatus, setDomainStatus] = (0, _react.useState)({});
|
|
39
|
+
const domainListStr = blocklet !== null && blocklet !== void 0 && (_blocklet$site = blocklet.site) !== null && _blocklet$site !== void 0 && (_blocklet$site$domain = _blocklet$site.domainAliases) !== null && _blocklet$site$domain !== void 0 && _blocklet$site$domain.length ? JSON.stringify(blocklet.site.domainAliases.map(x => x.value)) : '';
|
|
40
|
+
const domains = (0, _react.useMemo)(() => {
|
|
41
|
+
var _blocklet$site2;
|
|
42
|
+
return ((blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$site2 = blocklet.site) === null || _blocklet$site2 === void 0 ? void 0 : _blocklet$site2.domainAliases) || []).map(x => x.value);
|
|
43
|
+
}, [domainListStr]); // eslint-disable-line
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
domainsAccessibility,
|
|
47
|
+
recommendedDomain
|
|
48
|
+
} = (0, _urlEvaluation.useDomainsAccessibility)(domains);
|
|
49
|
+
const refreshRuntimeInfo = async () => {
|
|
50
|
+
setLoadingRuntimeInfo(true);
|
|
51
|
+
try {
|
|
52
|
+
const {
|
|
53
|
+
blocklet: data
|
|
54
|
+
} = await client.getBlocklet({
|
|
55
|
+
input: {
|
|
56
|
+
did,
|
|
57
|
+
attachRuntimeInfo: true
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
await (0, _util2.fixBlocklet)(data, {
|
|
61
|
+
getIP
|
|
62
|
+
});
|
|
63
|
+
setBlocklet(data);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_toast.default.error(err.message);
|
|
66
|
+
} finally {
|
|
67
|
+
setLoadingRuntimeInfo(false);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const refreshBlocklet = async function refreshBlocklet() {
|
|
71
|
+
let {
|
|
72
|
+
showError = true,
|
|
73
|
+
attachRuntimeInfo = true
|
|
74
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
|
+
if (loading) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
setLoading(true);
|
|
80
|
+
setError(null);
|
|
81
|
+
const {
|
|
82
|
+
blocklet: data
|
|
83
|
+
} = await client.getBlocklet({
|
|
84
|
+
input: {
|
|
85
|
+
did,
|
|
86
|
+
attachRuntimeInfo: false
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (data) {
|
|
90
|
+
setBlocklet(oldBlocklet => {
|
|
91
|
+
(0, _util2.fixBlocklet)(data, {
|
|
92
|
+
fixRuntime: 'merge-old',
|
|
93
|
+
oldBlocklet
|
|
94
|
+
});
|
|
95
|
+
return data;
|
|
96
|
+
});
|
|
97
|
+
setLoading(false);
|
|
98
|
+
if (attachRuntimeInfo) {
|
|
99
|
+
refreshRuntimeInfo();
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
throw new Error(t('blocklet.notFound'));
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
setLoading(false);
|
|
106
|
+
setError(err);
|
|
107
|
+
if (showError) {
|
|
108
|
+
_toast.default.error(err.message);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const refreshDomainStatus = () => {
|
|
113
|
+
if (did && domainListStr) {
|
|
114
|
+
client.checkDomains({
|
|
115
|
+
input: {
|
|
116
|
+
did
|
|
117
|
+
}
|
|
118
|
+
}).catch(err => {
|
|
119
|
+
console.error(err);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
(0, _react.useEffect)(() => {
|
|
124
|
+
if (domainListStr && !disableSubscription) {
|
|
125
|
+
refreshDomainStatus();
|
|
126
|
+
}
|
|
127
|
+
}, [domainListStr, disableSubscription]); // eslint-disable-line
|
|
128
|
+
|
|
129
|
+
useSubscription(_constant.BlockletEvents.domainStatus, data => {
|
|
130
|
+
setDomainStatus(pre => _objectSpread(_objectSpread({}, pre), {}, {
|
|
131
|
+
[data.domain]: _objectSpread(_objectSpread({}, pre[data.domain]), data)
|
|
132
|
+
}));
|
|
133
|
+
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did, !disableSubscription]);
|
|
134
|
+
useSubscription(_constant.BlockletEvents.statusChange, () => refreshBlocklet({
|
|
135
|
+
attachRuntimeInfo: false
|
|
136
|
+
}), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, !disableSubscription]);
|
|
137
|
+
useSubscription(_constant.BlockletEvents.started, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did, !disableSubscription]);
|
|
138
|
+
useSubscription(_constant.BlockletEvents.startFailed, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did, !disableSubscription]);
|
|
139
|
+
useSubscription(_constant.BlockletEvents.installed, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta5 = blocklet.meta) === null || _blocklet$meta5 === void 0 ? void 0 : _blocklet$meta5.did, !disableSubscription]);
|
|
140
|
+
useSubscription(_constant.BlockletEvents.upgraded, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta6 = blocklet.meta) === null || _blocklet$meta6 === void 0 ? void 0 : _blocklet$meta6.did, !disableSubscription]);
|
|
141
|
+
useSubscription(_constant.BlockletEvents.downgraded, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta7 = blocklet.meta) === null || _blocklet$meta7 === void 0 ? void 0 : _blocklet$meta7.did, !disableSubscription]);
|
|
142
|
+
useSubscription(_constant.BlockletEvents.updated, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta8 = blocklet.meta) === null || _blocklet$meta8 === void 0 ? void 0 : _blocklet$meta8.did, !disableSubscription]);
|
|
143
|
+
const data = blocklet ? (0, _merge.default)(blocklet, {
|
|
144
|
+
site: {
|
|
145
|
+
domainAliases: blocklet.site.domainAliases.map(x => {
|
|
146
|
+
const domain = x.value;
|
|
147
|
+
const key = (0, _util.toSlotDomain)(domain);
|
|
148
|
+
x.domainStatus = (0, _omit.default)(domainStatus[key], ['domain', 'meta']);
|
|
149
|
+
x.accessibility = (0, _omit.default)(domainsAccessibility[domain], ['domain']);
|
|
150
|
+
x.href = (0, _util.getBlockletUrl)({
|
|
151
|
+
blocklet,
|
|
152
|
+
domain: x,
|
|
153
|
+
params: (0, _util.getBlockletUrlParams)(blocklet, locale)
|
|
154
|
+
});
|
|
155
|
+
return x;
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
}) : null;
|
|
159
|
+
return {
|
|
160
|
+
loading,
|
|
161
|
+
loadingRuntimeInfo,
|
|
162
|
+
error,
|
|
163
|
+
blocklet: data,
|
|
164
|
+
recommendedDomain: recommendedDomain || '',
|
|
165
|
+
actions: {
|
|
166
|
+
refreshBlocklet,
|
|
167
|
+
refreshDomainStatus,
|
|
168
|
+
setBlocklet
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useBlockletUrlEvaluation = useBlockletUrlEvaluation;
|
|
7
|
+
exports.useDomainsAccessibility = useDomainsAccessibility;
|
|
8
|
+
exports.useUrlEvaluation = useUrlEvaluation;
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
11
|
+
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
12
|
+
var _constant = require("@abtnode/constant");
|
|
13
|
+
var _urlEvaluation = require("@abtnode/util/lib/url-evaluation");
|
|
14
|
+
var _checkAccessibleBrowser = _interopRequireDefault(require("@abtnode/util/lib/url-evaluation/check-accessible-browser"));
|
|
15
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
16
|
+
var _util = require("../util");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
// 如果同一个页面中存在多个部分同时对同一个 url 检测 url 可访问性, 避免造成重复请求
|
|
22
|
+
const ping = (0, _memoize.default)(url => (0, _checkAccessibleBrowser.default)((0, _urlJoin.default)(new URL(url).origin, _constant.WELLKNOWN_PING_PREFIX)));
|
|
23
|
+
|
|
24
|
+
// url <-> evaluation cache
|
|
25
|
+
const CACHE = {};
|
|
26
|
+
function useUrlEvaluation(_ref) {
|
|
27
|
+
let {
|
|
28
|
+
urls,
|
|
29
|
+
checkAccessible = _checkAccessibleBrowser.default,
|
|
30
|
+
disableCache = false
|
|
31
|
+
} = _ref;
|
|
32
|
+
// 基于 CACHE 初始化该 hook 的状态
|
|
33
|
+
// FIXME: 最好解决源头的 material-table 渲染 BlockletInterface 时的 re-mount 问题 (#4897)
|
|
34
|
+
const initialCachedRef = (0, _react.useRef)(urls.filter(url => CACHE[url]).map(url => CACHE[url]));
|
|
35
|
+
const allCached = initialCachedRef.current.length === urls.length;
|
|
36
|
+
const [urlsState, setUrlsState] = (0, _react.useState)(allCached ? initialCachedRef.current : []);
|
|
37
|
+
const [loading, setLoading] = (0, _react.useState)(!allCached);
|
|
38
|
+
const recommendedUrlState = (0, _react.useMemo)(() => {
|
|
39
|
+
if (!loading && urlsState.length) {
|
|
40
|
+
return urlsState[0];
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}, [urlsState, loading]);
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
if ((urls === null || urls === void 0 ? void 0 : urls.length) > 0 && !allCached) {
|
|
46
|
+
const evaluate = async () => {
|
|
47
|
+
let results;
|
|
48
|
+
setLoading(true);
|
|
49
|
+
if (disableCache) {
|
|
50
|
+
results = await (0, _urlEvaluation.evaluateURLs)(urls, {
|
|
51
|
+
checkAccessible
|
|
52
|
+
});
|
|
53
|
+
results.forEach(item => {
|
|
54
|
+
CACHE[item.url] = item;
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
const misses = await (0, _urlEvaluation.evaluateURLs)(urls.filter(url => !CACHE[url]), {
|
|
58
|
+
checkAccessible
|
|
59
|
+
});
|
|
60
|
+
misses.forEach(item => {
|
|
61
|
+
CACHE[item.url] = item;
|
|
62
|
+
});
|
|
63
|
+
results = urls.map(url => CACHE[url]).sort((a, b) => b.score - a.score);
|
|
64
|
+
}
|
|
65
|
+
setUrlsState(results);
|
|
66
|
+
setLoading(false);
|
|
67
|
+
};
|
|
68
|
+
evaluate();
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
|
+
}, [urls, disableCache, allCached]);
|
|
72
|
+
return {
|
|
73
|
+
urlsState,
|
|
74
|
+
loading,
|
|
75
|
+
recommendedUrlState,
|
|
76
|
+
recommendedUrl: recommendedUrlState === null || recommendedUrlState === void 0 ? void 0 : recommendedUrlState.url
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 主要对 blocklet 访问 urls 进行评估
|
|
82
|
+
* @param {object} blocklet
|
|
83
|
+
*/
|
|
84
|
+
function useBlockletUrlEvaluation(blocklet) {
|
|
85
|
+
const {
|
|
86
|
+
locale
|
|
87
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
88
|
+
const urls = (0, _react.useMemo)(() => {
|
|
89
|
+
if (!blocklet) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
// getBlockletUrlParams 的调用是必须的, 会根据 blocklet 状态决定是否添加 "__start__" 参数, 以保证 blocklet 启动按钮可以正确的跳转到启动页面
|
|
93
|
+
return (0, _util.getBlockletUrls)({
|
|
94
|
+
blocklet,
|
|
95
|
+
params: (0, _util.getBlockletUrlParams)(blocklet, locale)
|
|
96
|
+
});
|
|
97
|
+
}, [blocklet, locale]);
|
|
98
|
+
const {
|
|
99
|
+
loading,
|
|
100
|
+
recommendedUrlState,
|
|
101
|
+
recommendedUrl
|
|
102
|
+
} = useUrlEvaluation({
|
|
103
|
+
urls,
|
|
104
|
+
checkAccessible: ping
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
urls,
|
|
108
|
+
loading,
|
|
109
|
+
recommendedUrlState,
|
|
110
|
+
recommendedUrl
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 主要对 blocklet domains 对应的 urls 进行评估, 配合 DomainStatusProvider 使用
|
|
116
|
+
* @param {string[]} domains
|
|
117
|
+
*/
|
|
118
|
+
function useDomainsAccessibility(domains) {
|
|
119
|
+
// 获取 blocklet domain 对应的访问 url
|
|
120
|
+
const urls = (0, _react.useMemo)(() => domains.map(item => (0, _util.getAccessUrl)(item)), [domains]);
|
|
121
|
+
const {
|
|
122
|
+
urlsState,
|
|
123
|
+
loading,
|
|
124
|
+
recommendedUrl
|
|
125
|
+
} = useUrlEvaluation({
|
|
126
|
+
urls,
|
|
127
|
+
checkAccessible: ping
|
|
128
|
+
});
|
|
129
|
+
let result;
|
|
130
|
+
if (loading) {
|
|
131
|
+
result = {
|
|
132
|
+
domainsAccessibility: domains.reduce((acc, cur) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
133
|
+
[cur]: {
|
|
134
|
+
loading: true
|
|
135
|
+
}
|
|
136
|
+
}), {}),
|
|
137
|
+
recommendedDomain: null
|
|
138
|
+
};
|
|
139
|
+
} else {
|
|
140
|
+
var _urlsState$find;
|
|
141
|
+
const domainsAccessibility = urlsState.reduce((acc, cur) => {
|
|
142
|
+
// 检测对象是 domain, 但检测可访问性用的是 domain 对应的 ping url, 所以需要取 hostname 作为结果
|
|
143
|
+
const domain = new URL(cur.url).hostname;
|
|
144
|
+
acc[domain] = _objectSpread(_objectSpread({}, cur), {}, {
|
|
145
|
+
domain
|
|
146
|
+
});
|
|
147
|
+
return acc;
|
|
148
|
+
}, {});
|
|
149
|
+
// 从排好优先级的 urls 中选择第一个可访问的 url 作为 recommendedDomain (对于自定义域名, 可能存在评分最高但不可访问的情况) (#5195)
|
|
150
|
+
const accessibleUrl = ((_urlsState$find = urlsState.find(item => item.accessible)) === null || _urlsState$find === void 0 ? void 0 : _urlsState$find.url) || recommendedUrl;
|
|
151
|
+
result = {
|
|
152
|
+
domainsAccessibility,
|
|
153
|
+
recommendedDomain: accessibleUrl ? new URL(accessibleUrl).hostname : null
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSubscription = useSubscription;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
9
|
+
function useSubscription(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
wsClient,
|
|
12
|
+
event,
|
|
13
|
+
cb = () => {},
|
|
14
|
+
deps = []
|
|
15
|
+
} = _ref;
|
|
16
|
+
(0, _react.useEffect)(() => {
|
|
17
|
+
// if deps has false value, do not sub
|
|
18
|
+
const shouldSub = wsClient && (!deps.length || deps.every(Boolean));
|
|
19
|
+
if (shouldSub) {
|
|
20
|
+
wsClient.on(event, cb);
|
|
21
|
+
}
|
|
22
|
+
return () => {
|
|
23
|
+
if (shouldSub) {
|
|
24
|
+
wsClient.off(event, cb);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, deps); // eslint-disable-line
|
|
28
|
+
}
|
package/lib/layout/addon.js
CHANGED
|
@@ -37,27 +37,27 @@ function HeaderAddon(_ref) {
|
|
|
37
37
|
locale
|
|
38
38
|
} = (0, _react.useContext)(_context.LocaleContext);
|
|
39
39
|
const location = (0, _reactRouterDom.useLocation)();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
'/store':
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'/
|
|
40
|
+
const defaultEndpoint = 'https://developer.blocklet.io/docs';
|
|
41
|
+
const docMap = {
|
|
42
|
+
'/store': {
|
|
43
|
+
endpoint: 'https://store.blocklet.io'
|
|
44
|
+
},
|
|
45
|
+
'/dashboard': {
|
|
46
|
+
path: '/conceptual/overview'
|
|
47
|
+
},
|
|
48
|
+
'/settings/router': {
|
|
49
|
+
path: '/conceptual/server-architecture'
|
|
50
|
+
}
|
|
49
51
|
};
|
|
50
52
|
const onHelpClick = () => {
|
|
51
53
|
const pathName = location.pathname;
|
|
52
|
-
let
|
|
53
|
-
if (pathName.indexOf('/
|
|
54
|
-
|
|
55
|
-
} else if (pathName
|
|
56
|
-
|
|
57
|
-
} else if (docPaths[pathName]) {
|
|
58
|
-
path = docPaths[pathName];
|
|
54
|
+
let doc = {};
|
|
55
|
+
if (pathName.indexOf('/store') > -1) {
|
|
56
|
+
doc = docMap['/store'];
|
|
57
|
+
} else if (docMap[pathName]) {
|
|
58
|
+
doc = docMap[pathName];
|
|
59
59
|
}
|
|
60
|
-
window.open("
|
|
60
|
+
window.open("".concat(doc.endpoint || defaultEndpoint, "/").concat(locale).concat(doc.path || ''), '_blank');
|
|
61
61
|
};
|
|
62
62
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
|
|
63
63
|
children: [extraItems.map((x, index) => /*#__PURE__*/(0, _react.cloneElement)(x, {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Feedback;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _Link = _interopRequireDefault(require("@mui/material/Link"));
|
|
10
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
/** @jsxImportSource @emotion/react */
|
|
14
|
+
|
|
15
|
+
function Feedback(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
id,
|
|
18
|
+
version,
|
|
19
|
+
bundleName
|
|
20
|
+
} = _ref;
|
|
21
|
+
const {
|
|
22
|
+
t
|
|
23
|
+
} = (0, _context.useLocaleContext)();
|
|
24
|
+
const feedbackUrl = new URL('https://github.com/blocklet/blocklet-site/issues/new');
|
|
25
|
+
feedbackUrl.searchParams.set('title', '[Feedback]');
|
|
26
|
+
feedbackUrl.searchParams.set('body', "\n\n[Enter feedback here]\n\n\n---\n#### Document Details\n* App Id: ".concat(id, "\n* App Version: ").concat(version, "\n* App Bundle Name: ").concat(bundleName, "\n* Page: ").concat(window.location.href, "\n"));
|
|
27
|
+
return (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
|
+
sx: {
|
|
29
|
+
mx: {
|
|
30
|
+
xs: 0,
|
|
31
|
+
md: 2
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
children: (0, _jsxRuntime.jsx)(_Link.default, {
|
|
35
|
+
sx: {
|
|
36
|
+
color: 'text.primary'
|
|
37
|
+
},
|
|
38
|
+
target: "_blank",
|
|
39
|
+
href: feedbackUrl.href,
|
|
40
|
+
rel: "noreferrer",
|
|
41
|
+
style: {
|
|
42
|
+
textDecoration: 'underline'
|
|
43
|
+
},
|
|
44
|
+
children: t('common.reportIssue')
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
Feedback.propTypes = {
|
|
49
|
+
id: _propTypes.default.string,
|
|
50
|
+
version: _propTypes.default.string,
|
|
51
|
+
bundleName: _propTypes.default.string
|
|
52
|
+
};
|
|
53
|
+
Feedback.defaultProps = {
|
|
54
|
+
id: '',
|
|
55
|
+
version: '',
|
|
56
|
+
bundleName: ''
|
|
57
|
+
};
|
package/lib/locales/en.js
CHANGED
|
@@ -210,6 +210,7 @@ module.exports = {
|
|
|
210
210
|
reload: 'Reload',
|
|
211
211
|
remark: 'Remark',
|
|
212
212
|
remove: 'Remove',
|
|
213
|
+
reportIssue: 'Report an issue',
|
|
213
214
|
requiredErrorText: '{name} is required',
|
|
214
215
|
resource: 'Resource',
|
|
215
216
|
restart: 'Restart',
|
|
@@ -224,6 +225,7 @@ module.exports = {
|
|
|
224
225
|
scheduleFailed: 'schedule failed',
|
|
225
226
|
scheduleSuccess: 'successfully scheduled',
|
|
226
227
|
search: 'Search',
|
|
228
|
+
security: 'Security',
|
|
227
229
|
setting: 'Settings',
|
|
228
230
|
start: 'Start',
|
|
229
231
|
status: 'Status',
|
|
@@ -728,7 +730,7 @@ module.exports = {
|
|
|
728
730
|
}
|
|
729
731
|
},
|
|
730
732
|
domainSecurity: {
|
|
731
|
-
title: '
|
|
733
|
+
title: 'Domain Security',
|
|
732
734
|
cors: {
|
|
733
735
|
title: 'Allowed CORS Domains',
|
|
734
736
|
description: 'Domain list that can send cross origin requests to {name}, comma separated, use "*" to allow anyone, which is not recommended',
|
|
@@ -955,7 +957,9 @@ module.exports = {
|
|
|
955
957
|
defaultRule: 'Default rule',
|
|
956
958
|
search: 'Search Passport',
|
|
957
959
|
searchIssuerDid: 'Search Issuer DID',
|
|
958
|
-
issueBy: 'Issue by {name}'
|
|
960
|
+
issueBy: 'Issue by {name}',
|
|
961
|
+
configColor: 'Config Passport Color',
|
|
962
|
+
color: 'Passport Color'
|
|
959
963
|
},
|
|
960
964
|
inviting: {
|
|
961
965
|
link: 'Invite Link',
|
package/lib/locales/zh.js
CHANGED
|
@@ -216,6 +216,7 @@ module.exports = {
|
|
|
216
216
|
reload: '优雅重启',
|
|
217
217
|
remark: '备注',
|
|
218
218
|
remove: '删除',
|
|
219
|
+
reportIssue: '问题反馈',
|
|
219
220
|
requiredErrorText: '{name}是必填的',
|
|
220
221
|
resource: '资源',
|
|
221
222
|
restart: '重启',
|
|
@@ -230,6 +231,7 @@ module.exports = {
|
|
|
230
231
|
scheduleFailed: '加入任务队列失败',
|
|
231
232
|
scheduleSuccess: '成功加入任务队列',
|
|
232
233
|
search: '搜索',
|
|
234
|
+
security: '安全',
|
|
233
235
|
setting: '设置',
|
|
234
236
|
start: '启动',
|
|
235
237
|
status: '状态',
|
|
@@ -732,7 +734,7 @@ module.exports = {
|
|
|
732
734
|
}
|
|
733
735
|
},
|
|
734
736
|
domainSecurity: {
|
|
735
|
-
title: '
|
|
737
|
+
title: '站点安全设置',
|
|
736
738
|
cors: {
|
|
737
739
|
title: 'CORS 域名白名单',
|
|
738
740
|
description: '此白名单显示的声明可以往 {name} 发送跨域请求的域名, 多个域名用逗号分隔, 可以用 "*" 来允许任何域名(我们不推荐这么做)',
|
|
@@ -961,7 +963,9 @@ module.exports = {
|
|
|
961
963
|
defaultRule: '默认规则',
|
|
962
964
|
search: '搜索通行证',
|
|
963
965
|
searchIssuerDid: '搜索颁发者 DID',
|
|
964
|
-
issueBy: '由 {name} 颁发'
|
|
966
|
+
issueBy: '由 {name} 颁发',
|
|
967
|
+
configColor: '设置通行证颜色',
|
|
968
|
+
color: '通行证颜色'
|
|
965
969
|
},
|
|
966
970
|
inviting: {
|
|
967
971
|
link: '邀请链接',
|