@abtnode/ux 1.16.8-beta-ca58a421 → 1.16.8-beta-81db8efa

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.
@@ -82,6 +82,7 @@ function AuditLog(_ref2) {
82
82
  }), ' ', "- ", log.action]
83
83
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
84
84
  className: "log-content",
85
+ maxWidth: "lg",
85
86
  color: "textPrimary",
86
87
  component: "div",
87
88
  "data-color-mode": "light",
@@ -550,7 +550,7 @@ function AddComponent(_ref2) {
550
550
  if (config) {
551
551
  doc = _objectSpread(_objectSpread({}, doc), {}, {
552
552
  pathPrefix: config.mountPoint,
553
- title: config.meta.title,
553
+ title: title || '',
554
554
  componentName: config.meta.name,
555
555
  // use history's environments
556
556
  hasEnvironmentsStep: false
@@ -824,22 +824,6 @@ function AddComponent(_ref2) {
824
824
  value: (0, _util2.formatMountPoint)(pathPrefix)
825
825
  }));
826
826
  }
827
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
828
- label: t('common.title'),
829
- autoComplete: "off",
830
- variant: "outlined",
831
- fullWidth: true,
832
- style: {
833
- marginBottom: 32
834
- },
835
- margin: "normal",
836
- value: params.title,
837
- onChange: e => {
838
- const title = e.target.value;
839
- setParams(_objectSpread(_objectSpread({}, params), {}, {
840
- title
841
- }));
842
- }
843
827
  }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
844
828
  type: "error",
845
829
  style: {
@@ -51,24 +51,6 @@ function ComponentSetting(_ref) {
51
51
  if (blocklet.status === 'unknown' && (0, _util.isInstalling)(blocklet.status)) {
52
52
  return null;
53
53
  }
54
- const onSubmitTitle = async value => {
55
- setLoading(true);
56
- try {
57
- setLoading(false);
58
- await api.updateComponentTitle({
59
- input: {
60
- rootDid,
61
- did: blocklet.meta.did,
62
- title: value
63
- }
64
- });
65
- } catch (err) {
66
- setLoading(false);
67
- err.message = (0, _util.formatError)(err);
68
- _toast.default.error(err.message);
69
- throw err;
70
- }
71
- };
72
54
  const onSubmitMountPoint = async value => {
73
55
  setLoading(true);
74
56
  try {
@@ -99,19 +81,9 @@ function ComponentSetting(_ref) {
99
81
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Div, _objectSpread(_objectSpread({
100
82
  component: "div"
101
83
  }, rest), {}, {
102
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
103
85
  mt: 3,
104
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
105
- label: t('common.title'),
106
- style: {
107
- marginTop: -24
108
- },
109
- disabled: loading || disabled,
110
- loading: loading,
111
- required: true,
112
- initialValue: blocklet.meta.title,
113
- onSubmit: onSubmitTitle
114
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
86
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
115
87
  label: t('blocklet.component.mountPoint'),
116
88
  style: {
117
89
  marginTop: -24
@@ -124,7 +96,7 @@ function ComponentSetting(_ref) {
124
96
  onChange: handleMountPointChange,
125
97
  helperText: mountPointHelperText,
126
98
  formatterBeforeSubmit: value => (0, _urlPathFriendly.default)(value)
127
- })]
99
+ })
128
100
  })
129
101
  }));
130
102
  }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
8
+ var _Switch = _interopRequireDefault(require("@arcblock/ux/lib/Switch"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ var _templateObject;
11
+ const _excluded = ["labelProps", "className", "style"];
12
+ /**
13
+ * 该组件的对 UX 中 iOS 风格的 Switch 组件包装, 统一布局
14
+ * 具体参考: https://github.com/ArcBlock/blocklet-server/issues/4809
15
+ *
16
+ * - label 在左, 切换器在右
17
+ * - 整体宽度控制, 宽屏下 max-width 为 300px 避免 label 与 switch 相隔太远, 窄屏下 100% 宽度
18
+ */
19
+ /**
20
+ * @description
21
+ * @param {{
22
+ * labelProps: object,
23
+ * className: string;
24
+ * style: import('react').CSSProperties
25
+ * } & import('@mui/material').SwitchProps} { labelProps, className, style, ...rest }
26
+ * @return {*}
27
+ */
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
30
+ 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; }
31
+ 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; }
32
+ 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; }
33
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
34
+ 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); }
35
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
36
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
+ function SwitchControl(_ref) {
38
+ let {
39
+ labelProps,
40
+ className,
41
+ style
42
+ } = _ref,
43
+ rest = _objectWithoutProperties(_ref, _excluded);
44
+ const _labelProps = _objectSpread(_objectSpread({}, labelProps), {}, {
45
+ labelPlacement: (labelProps === null || labelProps === void 0 ? void 0 : labelProps.labelPlacement) || 'start'
46
+ });
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
48
+ className: className,
49
+ style: style,
50
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, _objectSpread({
51
+ labelProps: _labelProps
52
+ }, rest))
53
+ });
54
+ }
55
+ SwitchControl.propTypes = _Switch.default.propTypes;
56
+ SwitchControl.defaultProps = _Switch.default.defaultProps;
57
+ const Root = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-width: 300px;\n > label {\n display: flex;\n justify-content: space-between;\n width: 100%;\n margin-left: 0;\n margin-right: 0;\n }\n ", " {\n max-width: 100%;\n }\n"])), _ref2 => {
58
+ let {
59
+ theme
60
+ } = _ref2;
61
+ return theme.breakpoints.down('sm');
62
+ });
63
+ var _default = SwitchControl;
64
+ exports.default = _default;
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _material = require("@mui/material");
8
+ var _pick = _interopRequireDefault(require("lodash/pick"));
9
+ var _ahooks = require("ahooks");
10
+ var _reactHookForm = require("react-hook-form");
11
+ var _context = require("@arcblock/ux/lib/Locale/context");
12
+ var _isEmail = _interopRequireDefault(require("validator/lib/isEmail"));
13
+ var _isURL = _interopRequireDefault(require("validator/lib/isURL"));
14
+ var _isPort = _interopRequireDefault(require("validator/lib/isPort"));
15
+ var _node = require("../../contexts/node");
16
+ var _blocklet = require("../../contexts/blocklet");
17
+ var _toast = _interopRequireDefault(require("../../toast"));
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ 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; }
21
+ 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; }
22
+ 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; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
+ 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); }
25
+ const defaultFormValues = {
26
+ enabled: false,
27
+ from: '',
28
+ host: '',
29
+ port: '',
30
+ user: '',
31
+ password: ''
32
+ };
33
+ function NotificationEmail() {
34
+ var _blocklet$meta, _blocklet$settings, _blocklet$settings$no;
35
+ const {
36
+ api
37
+ } = (0, _node.useNodeContext)();
38
+ const {
39
+ blocklet
40
+ } = (0, _blocklet.useBlockletContext)();
41
+ const {
42
+ t
43
+ } = (0, _context.useLocaleContext)();
44
+ const did = blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did;
45
+ const config = Object.assign(_objectSpread({}, defaultFormValues), (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : (_blocklet$settings$no = _blocklet$settings.notification) === null || _blocklet$settings$no === void 0 ? void 0 : _blocklet$settings$no.email) || {});
46
+ const {
47
+ handleSubmit,
48
+ control,
49
+ formState,
50
+ watch,
51
+ reset
52
+ } = (0, _reactHookForm.useForm)({
53
+ defaultValues: (0, _pick.default)(config, Object.keys(defaultFormValues))
54
+ });
55
+ const enabled = watch('enabled');
56
+ const onSubmit = (0, _ahooks.useMemoizedFn)(async data => {
57
+ try {
58
+ var _blockletChanged$sett, _blockletChanged$sett2;
59
+ const {
60
+ blocklet: blockletChanged
61
+ } = await api.configNotification({
62
+ input: {
63
+ did,
64
+ notification: JSON.stringify({
65
+ email: data
66
+ })
67
+ }
68
+ });
69
+ const defaultValues = Object.assign(_objectSpread({}, defaultFormValues), (blockletChanged === null || blockletChanged === void 0 ? void 0 : (_blockletChanged$sett = blockletChanged.settings) === null || _blockletChanged$sett === void 0 ? void 0 : (_blockletChanged$sett2 = _blockletChanged$sett.notification) === null || _blockletChanged$sett2 === void 0 ? void 0 : _blockletChanged$sett2.email) || {});
70
+ // 将当前表单的默认值重置为新的数据,这样能够修正页面的 isDirty 数据
71
+ reset(defaultValues);
72
+ _toast.default.success(t('oauth.saveSuccess'));
73
+ } catch (err) {
74
+ _toast.default.error(err.message || t('oauth.saveFailed'));
75
+ }
76
+ });
77
+ const validateFrom = (0, _ahooks.useMemoizedFn)(value => {
78
+ const val = value === null || value === void 0 ? void 0 : value.trim();
79
+ if (!val) {
80
+ return t('notification.email.fromRequired');
81
+ }
82
+ if (!(0, _isEmail.default)(val)) {
83
+ return t('notification.email.fromInvalid');
84
+ }
85
+ return true;
86
+ });
87
+ const validateHost = (0, _ahooks.useMemoizedFn)(value => {
88
+ const val = value === null || value === void 0 ? void 0 : value.trim();
89
+ if (!val) {
90
+ return t('notification.email.hostRequired');
91
+ }
92
+ if (!(0, _isURL.default)(val, {
93
+ require_host: false,
94
+ protocols: []
95
+ })) {
96
+ return t('notification.email.hostInvalid');
97
+ }
98
+ return true;
99
+ });
100
+ const validatePort = (0, _ahooks.useMemoizedFn)(val => {
101
+ if (!val) {
102
+ return t('notification.email.portRequired');
103
+ }
104
+ if (!(0, _isPort.default)(val)) {
105
+ return t('notification.email.portInvalid');
106
+ }
107
+ return true;
108
+ });
109
+ const validateUser = (0, _ahooks.useMemoizedFn)(val => {
110
+ if (!(val !== null && val !== void 0 && val.trim())) {
111
+ return t('notification.email.userRequired');
112
+ }
113
+ return true;
114
+ });
115
+ const validatePassword = (0, _ahooks.useMemoizedFn)(val => {
116
+ if (!(val !== null && val !== void 0 && val.trim())) {
117
+ return t('notification.email.passportRequired');
118
+ }
119
+ return true;
120
+ });
121
+ const noop = (0, _ahooks.useMemoizedFn)(() => true);
122
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
124
+ onSubmit: handleSubmit(onSubmit),
125
+ disabled: true,
126
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
127
+ name: "enabled",
128
+ control: control,
129
+ render: _ref => {
130
+ let {
131
+ field
132
+ } = _ref;
133
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControlLabel, {
134
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Switch, _objectSpread({
135
+ checked: field.value
136
+ }, field)),
137
+ label: t('notification.email.enable'),
138
+ sx: {
139
+ marginBottom: '8px'
140
+ }
141
+ });
142
+ }
143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
144
+ name: "from",
145
+ control: control,
146
+ rules: {
147
+ validate: enabled ? validateFrom : noop
148
+ },
149
+ render: _ref2 => {
150
+ var _formState$errors$fie;
151
+ let {
152
+ field
153
+ } = _ref2;
154
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
155
+ fullWidth: true,
156
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
157
+ label: t('notification.email.from'),
158
+ error: !!formState.errors[field.name],
159
+ helperText: ((_formState$errors$fie = formState.errors[field.name]) === null || _formState$errors$fie === void 0 ? void 0 : _formState$errors$fie.message) || ' ',
160
+ disabled: !enabled
161
+ }))
162
+ });
163
+ }
164
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
165
+ name: "host",
166
+ control: control,
167
+ rules: {
168
+ validate: enabled ? validateHost : noop
169
+ },
170
+ render: _ref3 => {
171
+ var _formState$errors$fie2;
172
+ let {
173
+ field
174
+ } = _ref3;
175
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
176
+ fullWidth: true,
177
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
178
+ error: !!formState.errors[field.name],
179
+ label: t('notification.email.host'),
180
+ helperText: ((_formState$errors$fie2 = formState.errors[field.name]) === null || _formState$errors$fie2 === void 0 ? void 0 : _formState$errors$fie2.message) || ' ',
181
+ disabled: !enabled
182
+ }))
183
+ });
184
+ }
185
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
186
+ name: "port",
187
+ control: control,
188
+ rules: {
189
+ validate: enabled ? validatePort : noop
190
+ },
191
+ render: _ref4 => {
192
+ var _formState$errors$fie3;
193
+ let {
194
+ field
195
+ } = _ref4;
196
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
197
+ fullWidth: true,
198
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
199
+ type: "number",
200
+ error: !!formState.errors[field.name],
201
+ label: t('notification.email.port'),
202
+ helperText: ((_formState$errors$fie3 = formState.errors[field.name]) === null || _formState$errors$fie3 === void 0 ? void 0 : _formState$errors$fie3.message) || ' ',
203
+ disabled: !enabled
204
+ }))
205
+ });
206
+ }
207
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
208
+ name: "user",
209
+ control: control,
210
+ rules: {
211
+ validate: enabled ? validateUser : noop
212
+ },
213
+ render: _ref5 => {
214
+ var _formState$errors$fie4;
215
+ let {
216
+ field
217
+ } = _ref5;
218
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
219
+ fullWidth: true,
220
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
221
+ error: !!formState.errors[field.name],
222
+ label: t('notification.email.user'),
223
+ helperText: ((_formState$errors$fie4 = formState.errors[field.name]) === null || _formState$errors$fie4 === void 0 ? void 0 : _formState$errors$fie4.message) || ' ',
224
+ disabled: !enabled
225
+ }))
226
+ });
227
+ }
228
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
229
+ name: "password",
230
+ control: control,
231
+ rules: {
232
+ validate: enabled ? validatePassword : noop
233
+ },
234
+ render: _ref6 => {
235
+ var _formState$errors$fie5;
236
+ let {
237
+ field
238
+ } = _ref6;
239
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
240
+ fullWidth: true,
241
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
242
+ type: "password",
243
+ error: !!formState.errors[field.name],
244
+ label: t('notification.email.password'),
245
+ helperText: ((_formState$errors$fie5 = formState.errors[field.name]) === null || _formState$errors$fie5 === void 0 ? void 0 : _formState$errors$fie5.message) || ' ',
246
+ disabled: !enabled
247
+ }))
248
+ });
249
+ }
250
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
251
+ type: "submit",
252
+ variant: "contained",
253
+ onSubmit: handleSubmit(onSubmit),
254
+ disabled: !formState.isDirty,
255
+ children: t('oauth.save')
256
+ })]
257
+ })
258
+ });
259
+ }
260
+ var _default = NotificationEmail;
261
+ exports.default = _default;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
8
+ var _material = require("@mui/material");
9
+ var _ahooks = require("ahooks");
10
+ var _react = require("react");
11
+ var _email = _interopRequireDefault(require("./email"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ const tabs = [{
15
+ label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
16
+ textAlign: "center",
17
+ width: "100%",
18
+ children: "Email"
19
+ }),
20
+ value: 'email'
21
+ }, {
22
+ label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
23
+ textAlign: "center",
24
+ width: "100%",
25
+ children: "More"
26
+ }),
27
+ value: 'more'
28
+ }];
29
+ function BlockletNotification() {
30
+ const [currentTab, setCurrentTab] = (0, _react.useState)(tabs[0].value);
31
+ const contents = (0, _ahooks.useCreation)(() => ({
32
+ email: /*#__PURE__*/(0, _jsxRuntime.jsx)(_email.default, {}),
33
+ more: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
34
+ children: "TBD"
35
+ })
36
+ }), []);
37
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
38
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tabs.default, {
39
+ tabs: tabs,
40
+ current: currentTab,
41
+ onChange: setCurrentTab
42
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
43
+ marginTop: "10px",
44
+ children: contents[currentTab]
45
+ })]
46
+ });
47
+ }
48
+ var _default = BlockletNotification;
49
+ exports.default = _default;
@@ -14,6 +14,7 @@ var _material = require("@mui/material");
14
14
  var _TuneRounded = _interopRequireDefault(require("@mui/icons-material/TuneRounded"));
15
15
  var _Key = _interopRequireDefault(require("@mui/icons-material/Key"));
16
16
  var _Login = _interopRequireDefault(require("@mui/icons-material/Login"));
17
+ var _NotificationsNone = _interopRequireDefault(require("@mui/icons-material/NotificationsNone"));
17
18
  var _SettingsOutlined = _interopRequireDefault(require("@mui/icons-material/SettingsOutlined"));
18
19
  var _ChevronRight = _interopRequireDefault(require("@mui/icons-material/ChevronRight"));
19
20
  var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
@@ -22,6 +23,7 @@ var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
22
23
  var _util = require("@blocklet/meta/lib/util");
23
24
  var _bundleAvatar = _interopRequireDefault(require("../bundle-avatar"));
24
25
  var _configuration = _interopRequireDefault(require("../configuration"));
26
+ var _notification = _interopRequireDefault(require("../notification"));
25
27
  var _index = _interopRequireDefault(require("../access/index"));
26
28
  var _node = require("../../contexts/node");
27
29
  var _oauth = _interopRequireDefault(require("../oauth"));
@@ -149,6 +151,26 @@ function BlockletPreferences(_ref) {
149
151
  })]
150
152
  }, "oauth"),
151
153
  value: 'oauth'
154
+ }, {
155
+ label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
156
+ display: "flex",
157
+ alignItems: "center",
158
+ "data-cy": "configuration-tab-notification",
159
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationsNone.default, {
160
+ sx: {
161
+ fontSize: 24
162
+ }
163
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
164
+ ml: "16px",
165
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
166
+ style: {
167
+ color: '#222'
168
+ },
169
+ children: t('common.notification')
170
+ })
171
+ })]
172
+ }, "notification"),
173
+ value: 'notification'
152
174
  }, {
153
175
  label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
154
176
  display: "flex",
@@ -200,6 +222,8 @@ function BlockletPreferences(_ref) {
200
222
  content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.default, {});
201
223
  } else if (current === 'oauth') {
202
224
  content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_oauth.default, {});
225
+ } else if (current === 'notification') {
226
+ content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_notification.default, {});
203
227
  } else {
204
228
  // eslint-disable-next-line no-nested-ternary
205
229
  const pathPrefix = inService ? _constant.WELLKNOWN_SERVICE_PATH_PREFIX : process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
@@ -132,7 +132,8 @@ function AddDIDSpacesGateWay(_ref) {
132
132
  e.preventDefault();
133
133
  await onConfirm();
134
134
  }
135
- }
135
+ },
136
+ autoFocus: true
136
137
  })
137
138
  })
138
139
  })
@@ -23,6 +23,7 @@ var _blocklet = require("../../../lib/contexts/blocklet");
23
23
  var _toast = _interopRequireDefault(require("../../toast"));
24
24
  var _switchDidSpaces = _interopRequireDefault(require("./switch-did-spaces"));
25
25
  var _spaces = require("../../util/spaces");
26
+ var _switchControl = _interopRequireDefault(require("../component/switch-control"));
26
27
  var _jsxRuntime = require("react/jsx-runtime");
27
28
  var _templateObject;
28
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -315,22 +316,19 @@ function Storage() {
315
316
  children: t('storage.spaces.strategy.backupNow')
316
317
  })
317
318
  })]
318
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
319
- marginTop: "16px",
320
- display: "flex",
321
- alignItems: "center",
322
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
323
- flex: 1,
324
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
325
- children: [t('storage.spaces.strategy.autoBackup'), ": "]
326
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
327
- title: "coming soon",
328
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Switch, {
329
- size: "small",
330
- disabled: true
319
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_switchControl.default, {
320
+ name: "enable-auto-backup",
321
+ disabled: true,
322
+ labelProps: {
323
+ label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
324
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
325
+ children: t('storage.spaces.strategy.autoBackup')
331
326
  })
332
- })]
333
- })
327
+ })
328
+ },
329
+ style: {
330
+ marginTop: 16
331
+ }
334
332
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
335
333
  marginTop: "16px",
336
334
  display: "flex",
@@ -89,10 +89,15 @@ function SwitchDIDSpaces(_ref) {
89
89
  const {
90
90
  api: nodeApi
91
91
  } = (0, _node.useNodeContext)();
92
- const [selectedGateway, setSelectedGateway] = (0, _react.useState)({});
92
+ const prodSpacesGateway = {
93
+ name: 'Prod DID Spaces',
94
+ url: 'https://www.didspaces.com/app',
95
+ protected: true
96
+ };
97
+ const [selectedGateway, setSelectedGateway] = (0, _react.useState)(prodSpacesGateway);
93
98
  const [connectedGateway, setConnectedGateway] = (0, _react.useState)(null);
94
99
  (0, _ahooks.useAsyncEffect)(async () => {
95
- var _spaceGateways$find;
100
+ var _spaceGateways$find, _spaceGateways$find2;
96
101
  const {
97
102
  spaceGateways: _spaceGateways
98
103
  } = await nodeApi.getBlockletSpaceGateways({
@@ -100,16 +105,9 @@ function SwitchDIDSpaces(_ref) {
100
105
  did: blocklet.meta.did
101
106
  }
102
107
  });
103
- setSpaceGateways([{
104
- name: 'Prod DID Spaces',
105
- url: 'https://www.didspaces.com/app',
106
- protected: true
107
- }, ...(_spaceGateways !== null && _spaceGateways !== void 0 ? _spaceGateways : [])]);
108
+ setSpaceGateways([prodSpacesGateway, ...(_spaceGateways !== null && _spaceGateways !== void 0 ? _spaceGateways : [])]);
108
109
  setConnectedGateway((_spaceGateways$find = _spaceGateways.find(spaceGateway => spaceBackupEndpoint.includes(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.url))) !== null && _spaceGateways$find !== void 0 ? _spaceGateways$find : {});
109
- if ((0, _lodash.isEmpty)(selectedGateway)) {
110
- var _spaceGateways$find2;
111
- setSelectedGateway((_spaceGateways$find2 = _spaceGateways.find(spaceGateway => spaceBackupEndpoint.includes(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.url))) !== null && _spaceGateways$find2 !== void 0 ? _spaceGateways$find2 : {});
112
- }
110
+ setSelectedGateway((_spaceGateways$find2 = _spaceGateways.find(spaceGateway => spaceBackupEndpoint.includes(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.url))) !== null && _spaceGateways$find2 !== void 0 ? _spaceGateways$find2 : prodSpacesGateway);
113
111
  }, [blocklet]);
114
112
 
115
113
  /**
@@ -112,8 +112,7 @@ function useBlocklet(_ref) {
112
112
  blocklet: data
113
113
  } = await client.getBlocklet({
114
114
  input: {
115
- did,
116
- attachRuntimeInfo: false
115
+ did
117
116
  }
118
117
  });
119
118
  if (data) {
package/lib/locales/en.js CHANGED
@@ -210,6 +210,7 @@ module.exports = {
210
210
  noData: 'No records to display',
211
211
  notice: 'Unexpected bad things will happen if you don’t read this!',
212
212
  noticeTitle: 'Notice',
213
+ notification: 'Notification',
213
214
  open: 'Open',
214
215
  management: 'Management',
215
216
  os: 'Operating System',
@@ -295,7 +296,7 @@ module.exports = {
295
296
  normal: 'Normal',
296
297
  gateway: 'Gateway',
297
298
  verifyNFT: 'Verify NFT',
298
- errorMessage: 'Error Message:',
299
+ errorMessage: 'Error Message: ',
299
300
  slugifyHint: 'The actual mount point will be: {value}',
300
301
  strategy: 'Strategy',
301
302
  auto: 'Auto',
@@ -750,7 +751,23 @@ module.exports = {
750
751
  viewAll: 'View All',
751
752
  showRead: 'Show Read',
752
753
  markAllAsRead: 'Mark All as Read',
753
- markAsRead: 'Mark As Read'
754
+ markAsRead: 'Mark As Read',
755
+ email: {
756
+ enable: 'Enable email notification',
757
+ from: 'Email sender',
758
+ host: 'SMTP server host',
759
+ port: 'SMTP server port',
760
+ user: 'SMTP server username',
761
+ password: 'SMTP server user password',
762
+ fromRequired: 'Email sender is required',
763
+ fromInvalid: 'Email sender is invalid',
764
+ hostRequired: 'SMTP server host is required',
765
+ hostInvalid: 'SMTP server host is invalid',
766
+ portRequired: 'SMTP server port is required',
767
+ portInvalid: 'SMTP server port is invalid, port should be between 1 and 65535',
768
+ userRequired: 'SMTP server username is required',
769
+ passwordRequired: 'SMTP server user password is required'
770
+ }
754
771
  },
755
772
  router: {
756
773
  routerSetting: 'Domains & URLs',
@@ -1210,7 +1227,8 @@ module.exports = {
1210
1227
  launchFailed: 'Failed to launch the Blocklet, please try again',
1211
1228
  installedButStopped: 'The Blocklet is installed successfully, but cannot be started. You can start it manually after resolving blocking issues',
1212
1229
  installedButError: 'The Blocklet is successfully installed, but failed to start',
1213
- upgradeFailed: 'Upgrade Failed'
1230
+ upgradeFailed: 'Upgrade Failed',
1231
+ restoreFailed: 'Failed to restore blocklet, please try again'
1214
1232
  },
1215
1233
  steps: {
1216
1234
  introduction: 'Introduction',
@@ -1317,7 +1335,7 @@ module.exports = {
1317
1335
  authorize: {
1318
1336
  title: 'Connect {appName} to DID Spaces',
1319
1337
  scan: 'Use your DID Wallet to scan the QR code below to allow the app {appName} to connect to DID Spaces',
1320
- success: 'Connection successful'
1338
+ success: 'Connected successfully'
1321
1339
  },
1322
1340
  backup: 'Backup',
1323
1341
  backupSuccessfully: 'Backup successfully',
@@ -1358,8 +1376,8 @@ module.exports = {
1358
1376
  title: 'Backup progress'
1359
1377
  },
1360
1378
  record: {
1361
- title: 'Backup record',
1362
- emptyData: 'No record'
1379
+ title: 'Backup records',
1380
+ emptyData: 'No records'
1363
1381
  },
1364
1382
  notYet: "You don't have a backup in progress yet..."
1365
1383
  }
package/lib/locales/zh.js CHANGED
@@ -215,6 +215,7 @@ module.exports = {
215
215
  noData: '暂无数据',
216
216
  notice: '请确认下面的信息',
217
217
  noticeTitle: '提示',
218
+ notification: '通知',
218
219
  open: '打开',
219
220
  management: '管理',
220
221
  os: '操作系统',
@@ -753,7 +754,23 @@ module.exports = {
753
754
  viewAll: '查看所有动态',
754
755
  showRead: '显示已读',
755
756
  markAllAsRead: '全部标记为已读',
756
- markAsRead: '标记为已读'
757
+ markAsRead: '标记为已读',
758
+ email: {
759
+ enable: '是否开启 Email 通知',
760
+ from: '发件人邮箱',
761
+ host: 'SMTP 服务地址',
762
+ port: 'SMTP 服务端口',
763
+ user: 'SMTP 服务用户名',
764
+ password: 'SMTP 服务用户密码',
765
+ fromRequired: '请输入发件人邮箱',
766
+ fromInvalid: '发件人邮箱格式不正确',
767
+ hostRequired: '请输入 SMTP 服务地址',
768
+ hostInvalid: '请输入 SMTP 服务地址格式不正确',
769
+ portRequired: '请输入 SMTP 服务端口',
770
+ portInvalid: '请输入 SMTP 服务端口,端口号应该在 0-65535 之间',
771
+ userRequired: '请输入 SMTP 服务用户名',
772
+ passwordRequired: '请输入 SMTP 服务用户密码'
773
+ }
757
774
  },
758
775
  router: {
759
776
  routerSetting: '域名和网址',
@@ -1215,7 +1232,8 @@ module.exports = {
1215
1232
  launchFailed: '启动应用失败,请重试',
1216
1233
  installedButStopped: '应用安装成功,但是无法启动,解决启动问题之后后可手动启动',
1217
1234
  installedButError: '应用已经安装,但是运行出错了',
1218
- upgradeFailed: '更新失败'
1235
+ upgradeFailed: '更新失败',
1236
+ restoreFailed: '还原应用失败,请重试'
1219
1237
  },
1220
1238
  steps: {
1221
1239
  introduction: '简介',
@@ -257,12 +257,12 @@ function Passports(_ref2) {
257
257
  className: "status-icons",
258
258
  children: [!!appIdList.length && !appIdList.includes(x.issuer.id) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExternalIssuerIcon.default, {}), x.revoked && /*#__PURE__*/(0, _jsxRuntime.jsx)(_RevokeIcon.default, {})]
259
259
  })]
260
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
260
+ }), x.expirationDate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
261
261
  className: "title",
262
262
  display: "flex",
263
263
  alignItems: "center",
264
264
  children: t('team.passport.validUntil', {
265
- date: x.expirationDate || '-'
265
+ date: x.expirationDate
266
266
  })
267
267
  }), !!appIdList.length && !appIdList.includes(x.issuer.id) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
268
268
  className: "tip",
package/lib/util/index.js CHANGED
@@ -263,6 +263,11 @@ function formatTime(date) {
263
263
  function formatDateTime(date) {
264
264
  return (0, _dayjs.default)(date).format('YYYY-MM-DD HH:mm');
265
265
  }
266
+ /**
267
+ *
268
+ * @param { {message: string} | {errors: {message: string}[] }} error
269
+ * @returns {string}
270
+ */
266
271
  const formatError = error => {
267
272
  if (Array.isArray(error.errors)) {
268
273
  return error.errors.map(x => x.message).join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.8-beta-ca58a421",
3
+ "version": "1.16.8-beta-81db8efa",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,6 +13,7 @@
13
13
  "lint": "eslint src",
14
14
  "lint:fix": "eslint src --fix",
15
15
  "prepublishOnly": "npm run build",
16
+ "prebuild": "rm -fr lib/",
16
17
  "build": "babel src --out-dir lib --copy-files",
17
18
  "watch": "babel src --out-dir lib -w --copy-files",
18
19
  "coverage": "npm run test -- --coverage",
@@ -22,22 +23,22 @@
22
23
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
23
24
  "license": "MIT",
24
25
  "dependencies": {
25
- "@abtnode/auth": "1.16.8-beta-ca58a421",
26
- "@abtnode/constant": "1.16.8-beta-ca58a421",
27
- "@abtnode/util": "1.16.8-beta-ca58a421",
26
+ "@abtnode/auth": "1.16.8-beta-81db8efa",
27
+ "@abtnode/constant": "1.16.8-beta-81db8efa",
28
+ "@abtnode/util": "1.16.8-beta-81db8efa",
28
29
  "@ahooksjs/use-url-state": "^3.5.1",
29
30
  "@arcblock/did": "^1.18.78",
30
- "@arcblock/did-connect": "^2.5.37",
31
+ "@arcblock/did-connect": "^2.5.39",
31
32
  "@arcblock/did-motif": "^1.1.10",
32
- "@arcblock/icons": "^2.5.37",
33
- "@arcblock/react-hooks": "^2.5.37",
34
- "@arcblock/terminal": "^2.5.37",
35
- "@arcblock/ux": "^2.5.37",
36
- "@blocklet/constant": "1.16.8-beta-ca58a421",
33
+ "@arcblock/icons": "^2.5.39",
34
+ "@arcblock/react-hooks": "^2.5.39",
35
+ "@arcblock/terminal": "^2.5.39",
36
+ "@arcblock/ux": "^2.5.39",
37
+ "@blocklet/constant": "1.16.8-beta-81db8efa",
37
38
  "@blocklet/launcher-layout": "2.0.39",
38
39
  "@blocklet/list": "^0.11.24",
39
- "@blocklet/meta": "1.16.8-beta-ca58a421",
40
- "@blocklet/ui-react": "^2.5.37",
40
+ "@blocklet/meta": "1.16.8-beta-81db8efa",
41
+ "@blocklet/ui-react": "^2.5.39",
41
42
  "@emotion/react": "^11.10.4",
42
43
  "@emotion/styled": "^11.10.4",
43
44
  "@iconify/react": "^4.0.0",
@@ -82,7 +83,8 @@
82
83
  "react-sortable-tree-theme-material-ui": "^1.0.16",
83
84
  "react-use": "^17.4.0",
84
85
  "ufo": "^1.0.1",
85
- "url-join": "^4.0.1"
86
+ "url-join": "^4.0.1",
87
+ "validator": "^13.9.0"
86
88
  },
87
89
  "devDependencies": {
88
90
  "@babel/cli": "^7.19.3",
@@ -92,5 +94,5 @@
92
94
  "@babel/preset-react": "^7.18.6",
93
95
  "babel-plugin-inline-react-svg": "^1.1.2"
94
96
  },
95
- "gitHead": "d0f724c8082572a01b6e9287df6c3d0663ec9c57"
97
+ "gitHead": "8c4e3190de79a1fb2aaa14646255d938324cc5c2"
96
98
  }