@abtnode/ux 1.16.20 → 1.16.21-beta-edf184e1

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.
@@ -0,0 +1,316 @@
1
+ /* eslint-disable react/jsx-one-expression-per-line */
2
+ /* eslint-disable operator-linebreak */
3
+ import { useState, useContext } from 'react';
4
+ import styled from '@emotion/styled';
5
+ import { Link } from 'react-router-dom';
6
+ import PropTypes from 'prop-types';
7
+ import { format } from 'timeago.js';
8
+ import List from '@mui/material/List';
9
+ import ListItem from '@mui/material/ListItem';
10
+ import ListItemText from '@mui/material/ListItemText';
11
+ import Spinner from '@mui/material/CircularProgress';
12
+ import ListItemAvatar from '@mui/material/ListItemAvatar';
13
+ import Tooltip from '@mui/material/Tooltip';
14
+ import Avatar from '@mui/material/Avatar';
15
+ import Divider from '@mui/material/Divider';
16
+ import Typography from '@mui/material/Typography';
17
+ import Checkbox from '@mui/material/Checkbox';
18
+ import FormControlLabel from '@mui/material/FormControlLabel';
19
+ import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
20
+ import IconButton from '@mui/material/IconButton';
21
+ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
22
+ import Box from '@mui/material/Box';
23
+ import Pagination from '@mui/lab/Pagination';
24
+ import Button from '@arcblock/ux/lib/Button';
25
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
26
+ import NotificationTag from './tag';
27
+ import { BlockletAdminRoles, formatLocale, formatToDatetime } from '../util';
28
+ import Permission from '../permission';
29
+ import { useNodeContext } from '../contexts/node';
30
+ import { jsx as _jsx } from "react/jsx-runtime";
31
+ import { jsxs as _jsxs } from "react/jsx-runtime";
32
+ import { Fragment as _Fragment } from "react/jsx-runtime";
33
+ export default function NotificationsPage({
34
+ api,
35
+ paging,
36
+ loading,
37
+ notifications,
38
+ updateNotifications,
39
+ teamDid
40
+ }) {
41
+ const {
42
+ inService
43
+ } = useNodeContext();
44
+ const [showRead, setShowRead] = useState(true);
45
+ const [isMarkingAll, setIsMarkingAll] = useState(false);
46
+ const {
47
+ t,
48
+ locale
49
+ } = useContext(LocaleContext);
50
+ const onUnreadNotifications = async () => {
51
+ setIsMarkingAll(true);
52
+ const ids = notifications.filter(x => x.read === false).map(x => x.id).join(',');
53
+ if (inService) {
54
+ await api.readBlockletNotifications({
55
+ input: {
56
+ id: ids,
57
+ teamDid
58
+ }
59
+ });
60
+ } else {
61
+ await api.readNotifications({
62
+ input: {
63
+ id: ids
64
+ }
65
+ });
66
+ }
67
+ updateNotifications();
68
+ setIsMarkingAll(false);
69
+ };
70
+ const markAsRead = async id => {
71
+ if (inService) {
72
+ await api.readBlockletNotifications({
73
+ input: {
74
+ id,
75
+ teamDid
76
+ }
77
+ });
78
+ } else {
79
+ await api.readNotifications({
80
+ input: {
81
+ id
82
+ }
83
+ });
84
+ }
85
+ updateNotifications();
86
+ };
87
+ const filtered = showRead ? notifications : notifications.filter(x => x.read === false);
88
+ const hasUnRead = notifications.filter(x => x.read === false).length > 0;
89
+ const itemTitle = x => /*#__PURE__*/_jsxs("div", {
90
+ className: "title",
91
+ children: [x.title, ' ', /*#__PURE__*/_jsx("span", {
92
+ className: "time-ago",
93
+ title: formatToDatetime(x.createdAt, locale),
94
+ children: format(new Date(x.createdAt), formatLocale(locale))
95
+ })]
96
+ });
97
+ return /*#__PURE__*/_jsxs(Div, {
98
+ children: [/*#__PURE__*/_jsxs(Typography, {
99
+ component: "h2",
100
+ variant: "h4",
101
+ className: "page-header",
102
+ color: "textPrimary",
103
+ children: [t('notification.title'), /*#__PURE__*/_jsxs(Typography, {
104
+ component: "span",
105
+ className: "notification-actions",
106
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
107
+ control: /*#__PURE__*/_jsx(Checkbox, {
108
+ checked: showRead,
109
+ onChange: () => setShowRead(!showRead),
110
+ name: "showRead",
111
+ color: "primary"
112
+ }),
113
+ label: t('notification.showRead')
114
+ }), /*#__PURE__*/_jsx(Permission, {
115
+ permission: inService ? '' : 'mutate_notification',
116
+ role: inService ? BlockletAdminRoles : [],
117
+ children: hasUnRead && /*#__PURE__*/_jsxs(Button, {
118
+ disabled: isMarkingAll,
119
+ onClick: onUnreadNotifications,
120
+ className: "",
121
+ children: [isMarkingAll && /*#__PURE__*/_jsx(Spinner, {
122
+ size: 16,
123
+ style: {
124
+ marginRight: '1em'
125
+ }
126
+ }), t('notification.markAllAsRead')]
127
+ })
128
+ })]
129
+ })]
130
+ }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsxs(List, {
131
+ className: "notification-list",
132
+ children: [loading && /*#__PURE__*/_jsx(Spinner, {
133
+ size: [32, 20],
134
+ style: {
135
+ opacity: '0.8',
136
+ zIndex: 10000,
137
+ position: 'fixed',
138
+ top: 30,
139
+ left: '50%',
140
+ marginLeft: -16
141
+ }
142
+ }), filtered.length === 0 && /*#__PURE__*/_jsx(Typography, {
143
+ component: "p",
144
+ variant: "body1",
145
+ className: "notification-tip",
146
+ children: t('notification.empty')
147
+ }), filtered.length > 0 && filtered.map(x => {
148
+ if (x.action) {
149
+ return /*#__PURE__*/_jsxs(ListItem, {
150
+ component: Link,
151
+ to: x.action,
152
+ alignItems: "flex-start",
153
+ disabled: x.read,
154
+ children: [/*#__PURE__*/_jsx(ListItemAvatar, {
155
+ className: "list-item-avatar",
156
+ children: /*#__PURE__*/_jsxs(_Fragment, {
157
+ children: [/*#__PURE__*/_jsx(Avatar, {
158
+ children: x.entityType.substr(0, 1).toUpperCase()
159
+ }), /*#__PURE__*/_jsx(NotificationTag, {
160
+ className: "notification-tag",
161
+ status: x.severity
162
+ })]
163
+ })
164
+ }), /*#__PURE__*/_jsx(ListItemText, {
165
+ className: "list-item-text",
166
+ classes: {
167
+ secondary: 'list-item-secondary-text'
168
+ },
169
+ primary: itemTitle(x),
170
+ secondary: x.description
171
+ }), x.read === false && /*#__PURE__*/_jsx(ListItemSecondaryAction, {
172
+ children: /*#__PURE__*/_jsx(Tooltip, {
173
+ title: t('notification.markAsRead'),
174
+ children: /*#__PURE__*/_jsx(IconButton, {
175
+ edge: "end",
176
+ "aria-label": "delete",
177
+ onClick: () => markAsRead(x.id),
178
+ size: "large",
179
+ children: /*#__PURE__*/_jsx(VisibilityOffIcon, {})
180
+ })
181
+ })
182
+ })]
183
+ }, x.id);
184
+ }
185
+ return /*#__PURE__*/_jsxs(ListItem, {
186
+ alignItems: "flex-start",
187
+ disabled: x.read,
188
+ children: [/*#__PURE__*/_jsx(ListItemAvatar, {
189
+ className: "list-item-avatar",
190
+ children: /*#__PURE__*/_jsxs(_Fragment, {
191
+ children: [/*#__PURE__*/_jsx(Avatar, {
192
+ children: x.entityType.substr(0, 1).toUpperCase()
193
+ }), /*#__PURE__*/_jsx(NotificationTag, {
194
+ className: "notification-tag",
195
+ status: x.severity
196
+ })]
197
+ })
198
+ }), /*#__PURE__*/_jsx(ListItemText, {
199
+ className: "list-item-text",
200
+ classes: {
201
+ secondary: 'list-item-secondary-text'
202
+ },
203
+ primary: itemTitle(x),
204
+ secondary: x.description
205
+ }), x.read === false && /*#__PURE__*/_jsx(ListItemSecondaryAction, {
206
+ children: /*#__PURE__*/_jsx(Tooltip, {
207
+ title: t('notification.markAsRead'),
208
+ children: /*#__PURE__*/_jsx(IconButton, {
209
+ edge: "end",
210
+ "aria-label": "delete",
211
+ onClick: () => markAsRead(x.id),
212
+ size: "large",
213
+ children: /*#__PURE__*/_jsx(VisibilityOffIcon, {})
214
+ })
215
+ })
216
+ })]
217
+ }, x.id);
218
+ })]
219
+ }), !!filtered.length && paging.pageCount > 1 && /*#__PURE__*/_jsx(Box, {
220
+ mt: 2,
221
+ display: "flex",
222
+ justifyContent: "flex-end",
223
+ children: /*#__PURE__*/_jsx(Pagination, {
224
+ disabled: loading,
225
+ count: paging.pageCount,
226
+ page: paging.page,
227
+ onChange: (e, value) => {
228
+ updateNotifications({
229
+ page: value
230
+ });
231
+ }
232
+ })
233
+ })]
234
+ });
235
+ }
236
+ const Div = styled.div`
237
+ min-height: 60vh;
238
+
239
+ .page-header {
240
+ display: flex;
241
+ justify-content: space-between;
242
+ align-items: center;
243
+
244
+ .notification-actions {
245
+ width: auto;
246
+ display: flex;
247
+ justify-content: space-between;
248
+ }
249
+ }
250
+
251
+ .page-content {
252
+ margin-top: 16px;
253
+ }
254
+
255
+ .list-item-avatar {
256
+ display: flex;
257
+ flex-direction: column;
258
+ align-items: center;
259
+ min-width: 80px;
260
+
261
+ .notification-tag {
262
+ margin-top: 4px;
263
+ }
264
+ }
265
+
266
+ .MuiListItem-root:not(.Mui-disabled) {
267
+ .MuiAvatar-root {
268
+ background: ${props => props.theme.palette.primary.light};
269
+ }
270
+ }
271
+
272
+ .list-item-text {
273
+ .title {
274
+ display: flex;
275
+ align-items: center;
276
+ .time-ago {
277
+ background: #bdbdbd;
278
+ font-size: 11px;
279
+ margin-left: 8px;
280
+ color: #f7f8f8;
281
+ border-radius: 3px;
282
+ padding: 1px 4px;
283
+ }
284
+ }
285
+ }
286
+ .Mui-disabled .list-item-text .title .time-ago {
287
+ background: #666;
288
+ }
289
+
290
+ .list-item-secondary-text {
291
+ word-break: break-word;
292
+ }
293
+ `;
294
+ NotificationsPage.propTypes = {
295
+ loading: PropTypes.bool,
296
+ paging: PropTypes.objectOf(PropTypes.any),
297
+ api: PropTypes.shape({
298
+ readNotifications: PropTypes.func.isRequired,
299
+ readBlockletNotifications: PropTypes.func.isRequired
300
+ }).isRequired,
301
+ notifications: PropTypes.arrayOf(PropTypes.shape({
302
+ id: PropTypes.string,
303
+ read: PropTypes.bool,
304
+ entityType: PropTypes.string,
305
+ title: PropTypes.string,
306
+ createdAt: PropTypes.string,
307
+ description: PropTypes.string
308
+ }).isRequired).isRequired,
309
+ updateNotifications: PropTypes.func.isRequired,
310
+ teamDid: PropTypes.string
311
+ };
312
+ NotificationsPage.defaultProps = {
313
+ paging: false,
314
+ loading: false,
315
+ teamDid: ''
316
+ };
@@ -0,0 +1,28 @@
1
+ import PropTypes from 'prop-types';
2
+ import Tag from '@arcblock/ux/lib/Tag';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function NotificationTag({
5
+ status,
6
+ ...rest
7
+ }) {
8
+ const map = {
9
+ warning: 'warning',
10
+ error: 'error',
11
+ info: 'primary'
12
+ };
13
+ if (!status || status === 'info' || status === 'success') {
14
+ return null;
15
+ }
16
+ return /*#__PURE__*/_jsx(Tag, {
17
+ type: map[status],
18
+ style: {
19
+ borderRadius: 5,
20
+ border: '1px solid #ccc'
21
+ },
22
+ ...rest,
23
+ children: status
24
+ });
25
+ }
26
+ NotificationTag.propTypes = {
27
+ status: PropTypes.string.isRequired
28
+ };
@@ -20,7 +20,7 @@ var _constant2 = require("@blocklet/constant");
20
20
  var _util = require("@blocklet/meta/lib/util");
21
21
  var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
22
22
  var _formTextInput = _interopRequireDefault(require("../form/form-text-input"));
23
- var _formSelectInput = _interopRequireDefault(require("../form/form-select-input"));
23
+ var _formAutocompleteInput = _interopRequireDefault(require("../form/form-autocomplete-input"));
24
24
  var _node = require("../contexts/node");
25
25
  var _util2 = require("../util");
26
26
  var _mode = require("../util/mode");
@@ -46,8 +46,10 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
46
46
  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; }
47
47
  const languages = Object.keys(_constant2.SUPPORTED_LANGUAGES).map(x => ({
48
48
  code: x,
49
- name: _constant2.SUPPORTED_LANGUAGES[x].nativeName
49
+ name: _constant2.SUPPORTED_LANGUAGES[x].nativeName,
50
+ enName: _constant2.SUPPORTED_LANGUAGES[x].name
50
51
  }));
52
+ const languagesFilterKeys = ['name', 'enName', 'code'];
51
53
  function BlockletEnvironment(_ref) {
52
54
  var _blocklet$settings;
53
55
  let {
@@ -370,16 +372,19 @@ function BlockletEnvironment(_ref) {
370
372
  fontSize: 14,
371
373
  mb: 0,
372
374
  children: t('blocklet.config.languages')
373
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_formSelectInput.default, {
375
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_formAutocompleteInput.default, {
374
376
  style: {
375
377
  marginTop: 0
376
378
  },
377
379
  disabled: loading || disabled,
378
380
  loading: loading,
379
381
  options: languages,
382
+ noEmpty: true,
380
383
  initialValue: customLanguages ? customLanguages.value.split(',') : ['en', 'zh'],
381
384
  onSubmit: value => onSubmitConfig('BLOCKLET_APP_LANGUAGES', value),
382
- helperText: t('blocklet.config.selectLanguagesTip')
385
+ helperText: t('blocklet.config.selectLanguagesTip'),
386
+ placeholder: t('common.search'),
387
+ filterKeys: languagesFilterKeys
383
388
  })]
384
389
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
385
390
  className: "config-form",
@@ -12,10 +12,11 @@ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
14
14
  var _confirm = _interopRequireDefault(require("../../../confirm"));
15
+ var _domain = require("../../../contexts/domain");
15
16
  var _node = require("../../../contexts/node");
16
17
  var _util = require("../../../util");
17
- var _util2 = require("../util");
18
18
  var _addDomain = _interopRequireDefault(require("../add-domain"));
19
+ var _util2 = require("../util");
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -23,7 +24,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
23
24
  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; }
24
25
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
25
26
  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); }
26
- function AddDomainAlias(_ref) {
27
+ function AddDomainAliasComponent(_ref) {
27
28
  let {
28
29
  id,
29
30
  children,
@@ -44,6 +45,7 @@ function AddDomainAlias(_ref) {
44
45
  confirmSetting: null
45
46
  });
46
47
  const cnameDomain = systemDomains.find(item => (0, _urlEvaluation.isDidDomain)(item));
48
+ const domainContext = (0, _domain.useDomainContext)();
47
49
  const onCancel = () => {
48
50
  setState({
49
51
  loading: false,
@@ -58,10 +60,16 @@ function AddDomainAlias(_ref) {
58
60
  loading: true
59
61
  });
60
62
  try {
63
+ const domain = (0, _util2.parseDomainFromURL)(params.domain);
64
+ const validateResult = await domainContext.validateDomain(domain);
65
+ if (!validateResult) {
66
+ // eslint-disable-next-line consistent-return
67
+ return false;
68
+ }
61
69
  await api.addDomainAlias({
62
70
  input: {
63
71
  id,
64
- domainAlias: (0, _util2.parseDomainFromURL)(params.domain),
72
+ domainAlias: domain,
65
73
  teamDid
66
74
  }
67
75
  });
@@ -69,6 +77,10 @@ function AddDomainAlias(_ref) {
69
77
  setState({
70
78
  confirmSetting: null
71
79
  });
80
+ } catch (error) {
81
+ domainContext.setError(error.message);
82
+ // eslint-disable-next-line consistent-return
83
+ return false; // 防止 Dialog 关闭
72
84
  } finally {
73
85
  setState({
74
86
  loading: false
@@ -140,13 +152,14 @@ function AddDomainAlias(_ref) {
140
152
  params: state.confirmSetting.params,
141
153
  onConfirm: state.confirmSetting.onConfirm,
142
154
  onCancel: state.confirmSetting.onCancel,
155
+ displayError: false,
143
156
  color: "primary",
144
157
  loading: state.loading,
145
158
  maxWidth: "lg"
146
159
  })]
147
160
  });
148
161
  }
149
- AddDomainAlias.propTypes = {
162
+ AddDomainAliasComponent.propTypes = {
150
163
  id: _propTypes.default.string.isRequired,
151
164
  children: _propTypes.default.any,
152
165
  title: _propTypes.default.string,
@@ -155,9 +168,14 @@ AddDomainAlias.propTypes = {
155
168
  appId: _propTypes.default.string,
156
169
  appPk: _propTypes.default.string.isRequired
157
170
  };
158
- AddDomainAlias.defaultProps = {
171
+ AddDomainAliasComponent.defaultProps = {
159
172
  children: null,
160
173
  title: '',
161
174
  teamDid: '',
162
175
  appId: null
163
- };
176
+ };
177
+ function AddDomainAlias(props) {
178
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_domain.DomainProvider, {
179
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddDomainAliasComponent, _objectSpread({}, props))
180
+ });
181
+ }
@@ -7,15 +7,18 @@ exports.default = AddDomain;
7
7
  var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
8
8
  var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
9
9
  var _context = require("@arcblock/ux/lib/Locale/context");
10
+ var _InfoOutlined = _interopRequireDefault(require("@mui/icons-material/InfoOutlined"));
10
11
  var _OpenInNew = _interopRequireDefault(require("@mui/icons-material/OpenInNew"));
11
12
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
12
13
  var _Link = _interopRequireDefault(require("@mui/material/Link"));
13
14
  var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
15
+ var _useTheme = _interopRequireDefault(require("@mui/material/styles/useTheme"));
14
16
  var _noop = _interopRequireDefault(require("lodash/noop"));
15
17
  var _trim = _interopRequireDefault(require("lodash/trim"));
16
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
19
  var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
18
20
  var _urlJoin = _interopRequireDefault(require("url-join"));
21
+ var _domain = require("../../contexts/domain");
19
22
  var _node = require("../../contexts/node");
20
23
  var _util = require("../../util");
21
24
  var _api = require("../../util/api");
@@ -54,11 +57,14 @@ function AddDomain(_ref) {
54
57
  api,
55
58
  info
56
59
  } = (0, _node.useNodeContext)();
60
+ const domainContext = (0, _domain.useDomainContext)();
61
+ const theme = (0, _useTheme.default)();
57
62
  const [state, setState] = (0, _useSetState.default)({
58
63
  domain: defaultCustomDomain,
59
64
  error: null,
60
65
  type: info !== null && info !== void 0 && info.nftDomainUrl ? 'nftDomain' : 'inputDomain',
61
- showNFTDomainAuth: false
66
+ showNFTDomainAuth: false,
67
+ showDnsTip: false
62
68
  });
63
69
  let nftDomainURL = '';
64
70
  if (info.nftDomainUrl) {
@@ -100,25 +106,28 @@ function AddDomain(_ref) {
100
106
  });
101
107
  }
102
108
  };
109
+ const error = state.error || domainContext.error; // TODO: state error 可能不需要了
110
+
103
111
  const domainTypes = {
104
112
  inputDomain: {
105
113
  name: t('router.domainAlias.inputDomain'),
106
114
  component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
107
115
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
108
116
  label: t('router.domainAlias.add.domainDescription'),
109
- helperText: state.error || t('router.domainAlias.add.helperText'),
117
+ helperText: error || t('router.domainAlias.add.helperText'),
110
118
  inputProps: {
111
119
  'data-cy': 'domain-name-input'
112
120
  },
113
121
  fullWidth: true,
114
122
  disabled: disabled,
115
123
  value: state.domain,
124
+ size: "small",
125
+ variant: "outlined",
126
+ error: !!error,
116
127
  onChange: e => {
117
128
  var _e$target;
118
129
  const value = (0, _trim.default)((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
119
- setState({
120
- domain: value
121
- });
130
+ domainContext.setDomain(value);
122
131
  const errMessage = (0, _util.validateDomain)(value, locale);
123
132
  setState({
124
133
  domain: value,
@@ -131,20 +140,35 @@ function AddDomain(_ref) {
131
140
  },
132
141
  autoFocus: autoFocus,
133
142
  onBlur: () => {
134
- if (!state.domain) {
143
+ if (!domainContext.domain) {
135
144
  setState({
136
145
  error: null
137
146
  });
147
+ domainContext.setError(null);
138
148
  }
149
+ }
150
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
151
+ sx: {
152
+ cursor: 'pointer',
153
+ fontSize: '14px',
154
+ display: 'flex',
155
+ alignItems: 'center',
156
+ gap: '4px',
157
+ marginTop: '8px',
158
+ lineHeight: 1,
159
+ color: theme.palette.primary.main
139
160
  },
140
- size: "small",
141
- variant: "outlined",
142
- error: !!state.error
143
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dnsTip.default, {
161
+ onClick: () => setState({
162
+ showDnsTip: !state.showDnsTip
163
+ }),
164
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoOutlined.default, {
165
+ fontSize: "1em"
166
+ }), t('router.domainAlias.showTipHint')]
167
+ }), state.showDnsTip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dnsTip.default, {
144
168
  domain: state.domain,
145
169
  resolvedTarget: cnameDomain,
146
170
  style: {
147
- marginTop: '8px'
171
+ marginTop: '4px'
148
172
  }
149
173
  })]
150
174
  })
@@ -237,6 +261,10 @@ function AddDomain(_ref) {
237
261
  var _domainTypes$type, _domainTypes$type2;
238
262
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
239
263
  children: [inputDomainTypes.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
264
+ sx: {
265
+ fontWeight: 700,
266
+ color: theme.palette.text.primary
267
+ },
240
268
  children: "".concat(t("optionsOrder.".concat(index + 1)), ": ").concat((_domainTypes$type = domainTypes[type]) === null || _domainTypes$type === void 0 ? void 0 : _domainTypes$type.name)
241
269
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
242
270
  sx: {
package/lib/confirm.js CHANGED
@@ -22,7 +22,7 @@ var _util = require("./util");
22
22
  var _mobileWidth = _interopRequireDefault(require("./hooks/mobile-width"));
23
23
  var _jsxRuntime = require("react/jsx-runtime");
24
24
  var _templateObject;
25
- const _excluded = ["title", "description", "showCancel", "cancel", "confirm", "color", "params", "onCancel", "onConfirm", "loading"];
25
+ const _excluded = ["title", "description", "showCancel", "cancel", "confirm", "color", "params", "onCancel", "onConfirm", "loading", "displayError"];
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
28
28
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -43,7 +43,8 @@ function ConfirmDialog(_ref) {
43
43
  params: initialParams,
44
44
  onCancel,
45
45
  onConfirm,
46
- loading: inputLoading
46
+ loading: inputLoading,
47
+ displayError
47
48
  } = _ref,
48
49
  rest = _objectWithoutProperties(_ref, _excluded);
49
50
  const [params, setParams] = (0, _react.useState)(initialParams);
@@ -58,7 +59,10 @@ function ConfirmDialog(_ref) {
58
59
  if (typeof cb === 'function') {
59
60
  setLoading(true);
60
61
  try {
61
- await cb(params);
62
+ const res = await cb(params);
63
+ if (res === false) {
64
+ return;
65
+ }
62
66
  setOpen(false);
63
67
  } catch (err) {
64
68
  setError((0, _util.formatError)(err));
@@ -96,7 +100,7 @@ function ConfirmDialog(_ref) {
96
100
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogContentText.default, {
97
101
  component: "div",
98
102
  children: d
99
- }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
103
+ }), !!error && displayError && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
100
104
  severity: "error",
101
105
  style: {
102
106
  width: '100%',
@@ -151,7 +155,8 @@ ConfirmDialog.propTypes = {
151
155
  // This object holds states managed in the dialog
152
156
  onCancel: _propTypes.default.func,
153
157
  onConfirm: _propTypes.default.func.isRequired,
154
- loading: _propTypes.default.bool
158
+ loading: _propTypes.default.bool,
159
+ displayError: _propTypes.default.bool
155
160
  };
156
161
  ConfirmDialog.defaultProps = {
157
162
  onCancel: () => {},
@@ -160,6 +165,7 @@ ConfirmDialog.defaultProps = {
160
165
  confirm: 'Confirm',
161
166
  color: 'error',
162
167
  params: {},
163
- loading: false
168
+ loading: false,
169
+ displayError: true
164
170
  };
165
171
  const StyledDialog = (0, _styled.default)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .delete-actions .Mui-disabled {\n color: rgba(0, 0, 0, 0.26) !important;\n box-shadow: none;\n background-color: rgba(0, 0, 0, 0.12) !important;\n }\n"])));