@abtnode/ux 1.16.17-beta-2679e686 → 1.16.17-beta-6f0c7674

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.
@@ -3,12 +3,17 @@ import styled from '@emotion/styled';
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { useMemo, useState } from 'react';
5
5
  import AddIcon from '@mui/icons-material/Add';
6
+ import DiamondIcon from '@mui/icons-material/Diamond';
6
7
  import ExpandLess from '@mui/icons-material/ExpandLess';
7
8
  import ExpandMore from '@mui/icons-material/ExpandMore';
8
9
  import Alert from '@mui/material/Alert';
9
10
  import Box from '@mui/material/Box';
11
+ import Card from '@mui/material/Card';
12
+ import CardContent from '@mui/material/CardContent';
10
13
  import IconButton from '@mui/material/IconButton';
14
+ import Popover from '@mui/material/Popover';
11
15
  import Tooltip from '@mui/material/Tooltip';
16
+ import Typography from '@mui/material/Typography';
12
17
  import useTheme from '@mui/material/styles/useTheme';
13
18
  import { encode as encodeBase32 } from '@abtnode/util/lib/base32';
14
19
  import { isDidDomain } from '@abtnode/util/lib/url-evaluation';
@@ -17,6 +22,8 @@ import Empty from '@arcblock/ux/lib/Empty';
17
22
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
18
23
  import { isInProgress } from '@blocklet/meta/lib/util';
19
24
  import Spinner from '@mui/material/CircularProgress';
25
+ import DidAddress from '../../did-address';
26
+ import { useBlockletContext } from '../../contexts/blocklet';
20
27
  import { useNodeContext } from '../../contexts/node';
21
28
  import { withPermission } from '../../permission';
22
29
  import { BlockletAdminRoles, getSystemDomains, sortDomains } from '../../util';
@@ -26,7 +33,6 @@ import DomainActions from '../router/domain-actions';
26
33
  import DomainStatus from '../router/domain-status';
27
34
  import { DomainType } from '../types';
28
35
  import { isServerless } from '../util';
29
- import { useBlockletContext } from '../../contexts/blocklet';
30
36
  import { jsx as _jsx } from "react/jsx-runtime";
31
37
  import { jsxs as _jsxs } from "react/jsx-runtime";
32
38
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -60,6 +66,7 @@ function DomainList({
60
66
  const {
61
67
  t
62
68
  } = useLocaleContext();
69
+ const [domainInfoAnchorEl, setDomainInfoAnchorEl] = useState(null);
63
70
  const [showAllDomains, setShowAllDomains] = useState(false);
64
71
  const theme = useTheme();
65
72
  const hasMutatePermission = useMemo(() => {
@@ -69,6 +76,12 @@ function DomainList({
69
76
  }
70
77
  return res;
71
78
  }, [hasPermission, inService, blocklet]);
79
+ const handlePopoverOpen = event => {
80
+ setDomainInfoAnchorEl(event.currentTarget);
81
+ };
82
+ const handlePopoverClose = () => {
83
+ setDomainInfoAnchorEl(null);
84
+ };
72
85
  const {
73
86
  site
74
87
  } = blocklet;
@@ -76,6 +89,7 @@ function DomainList({
76
89
  const displayDomains = [];
77
90
  const hiddenDomains = [];
78
91
  const pidBase32 = encodeBase32(blocklet.appPid);
92
+ const appPk = blocklet.environments?.find(x => x.key === 'BLOCKLET_APP_PK')?.value;
79
93
  const systemDomains = getSystemDomains(domains);
80
94
  domains.forEach(domain => {
81
95
  const value = domain.value || '';
@@ -97,6 +111,8 @@ function DomainList({
97
111
  id: site.id,
98
112
  title: t('router.domain.add.title'),
99
113
  teamDid: blocklet.meta?.did,
114
+ appId: blocklet.appPid,
115
+ appPk: appPk,
100
116
  systemDomains: systemDomains?.map(x => x.value),
101
117
  children: ({
102
118
  open
@@ -146,6 +162,92 @@ function DomainList({
146
162
  target: "_blank",
147
163
  children: domain.value
148
164
  })
165
+ }), domain.type === 'nft-domain' && /*#__PURE__*/_jsxs(_Fragment, {
166
+ children: [/*#__PURE__*/_jsx(DiamondIcon, {
167
+ onMouseEnter: handlePopoverOpen,
168
+ onMouseLeave: handlePopoverClose,
169
+ style: {
170
+ cursor: 'pointer',
171
+ fill: theme.palette.primary.main
172
+ }
173
+ }), /*#__PURE__*/_jsx(Popover, {
174
+ id: "mouse-over-popover",
175
+ style: {
176
+ pointerEvents: 'none'
177
+ },
178
+ open: Boolean(domainInfoAnchorEl),
179
+ anchorEl: domainInfoAnchorEl,
180
+ anchorOrigin: {
181
+ vertical: 'bottom',
182
+ horizontal: 'left'
183
+ },
184
+ transformOrigin: {
185
+ vertical: 'top',
186
+ horizontal: 'left'
187
+ },
188
+ onClose: handlePopoverClose,
189
+ disableRestoreFocus: true,
190
+ children: /*#__PURE__*/_jsx(Card, {
191
+ children: /*#__PURE__*/_jsxs(CardContent, {
192
+ style: {
193
+ display: 'flex',
194
+ flexDirection: 'column'
195
+ },
196
+ children: [/*#__PURE__*/_jsxs(Typography, {
197
+ component: "div",
198
+ style: {
199
+ display: 'flex',
200
+ alignItems: 'center'
201
+ },
202
+ children: [/*#__PURE__*/_jsx(DiamondIcon, {
203
+ style: {
204
+ fill: theme.palette.primary.main
205
+ }
206
+ }), /*#__PURE__*/_jsx(Typography, {
207
+ component: "span",
208
+ style: {
209
+ marginLeft: '8px',
210
+ fontSize: '18px',
211
+ fontWeight: 'bolder'
212
+ },
213
+ children: t('router.domainAlias.nftDomain')
214
+ })]
215
+ }), /*#__PURE__*/_jsxs(Typography, {
216
+ component: "div",
217
+ style: {
218
+ display: 'flex',
219
+ marginTop: '12px'
220
+ },
221
+ children: [/*#__PURE__*/_jsx(Typography, {
222
+ component: "span",
223
+ style: {
224
+ width: '80px',
225
+ marginRight: '8px'
226
+ },
227
+ children: t('common.domain')
228
+ }), /*#__PURE__*/_jsx(Typography, {
229
+ component: "span",
230
+ children: domain.value
231
+ })]
232
+ }), /*#__PURE__*/_jsxs(Typography, {
233
+ component: "div",
234
+ style: {
235
+ display: 'flex'
236
+ },
237
+ children: [/*#__PURE__*/_jsx(Typography, {
238
+ component: "span",
239
+ style: {
240
+ width: '80px',
241
+ marginRight: '8px'
242
+ },
243
+ children: "NFT"
244
+ }), /*#__PURE__*/_jsx(DidAddress, {
245
+ did: domain.nftDid
246
+ })]
247
+ })]
248
+ })
249
+ })
250
+ })]
149
251
  }), /*#__PURE__*/_jsx(DomainStatus, {
150
252
  domain: domain,
151
253
  filters: ['http']
@@ -419,7 +419,8 @@ function BlockletEnvironment({
419
419
  loading: loading,
420
420
  options: languages,
421
421
  initialValue: customLanguages ? customLanguages.value.split(',') : ['en', 'zh'],
422
- onSubmit: value => onSubmitConfig('BLOCKLET_APP_LANGUAGES', value)
422
+ onSubmit: value => onSubmitConfig('BLOCKLET_APP_LANGUAGES', value),
423
+ helperText: t('blocklet.config.selectLanguagesTip')
423
424
  })]
424
425
  }), /*#__PURE__*/_jsx(Box, {
425
426
  className: "config-form",
@@ -1,13 +1,12 @@
1
1
  /* eslint-disable react/no-unstable-nested-components */
2
2
  import SvgIcon from '@mui/material/SvgIcon';
3
- import FormControlLabel from '@mui/material/FormControlLabel';
4
3
  import StarsIcon from '@mui/icons-material/Stars';
5
4
  import PropTypes from 'prop-types';
6
5
  import Box from '@mui/material/Box';
7
6
  import Datatable from '@arcblock/ux/lib/Datatable';
8
7
  import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
9
8
  import Address from '@arcblock/did-connect/lib/Address';
10
- import { useContext, useRef, useState } from 'react';
9
+ import { useContext, useRef } from 'react';
11
10
  import { useCreation, useMemoizedFn } from 'ahooks';
12
11
  import Button from '@arcblock/ux/lib/Button';
13
12
  import Toast from '@arcblock/ux/lib/Toast';
@@ -17,7 +16,6 @@ import { useNodeContext } from '../../contexts/node';
17
16
  import useConfirm from '../../hooks/confirm';
18
17
  import FederatedDetailDialog from './federated-detail-dialog';
19
18
  import FederatedInviteDialog from './federated-invite-dialog';
20
- import SwitchControl from '../component/switch-control';
21
19
  import { jsx as _jsx } from "react/jsx-runtime";
22
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
21
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -44,9 +42,7 @@ function FederatedSiteList({
44
42
  api
45
43
  } = useNodeContext();
46
44
  const federatedSites = blocklet.settings.federated?.sites || [];
47
- const federatedConfig = blocklet.settings.federated?.config || {
48
- autoLogin: false
49
- };
45
+ const federatedConfig = blocklet.settings.federated?.config || {};
50
46
  const isMaster = federatedConfig.isMaster !== false;
51
47
  const viewDetail = useMemoizedFn(row => {
52
48
  federatedDetailDialogRef.current?.open(row);
@@ -236,23 +232,6 @@ function FederatedSiteList({
236
232
  Toast.error(t('federated.failedToGetFederatedLoginLink'));
237
233
  }
238
234
  }, [blocklet.site?.domainAliases?.[0]?.href]);
239
- const [checked, setChecked] = useState(federatedConfig.autoLogin || false);
240
- const changeAutoLogin = useMemoizedFn(() => {
241
- confirmApi.open({
242
- title: checked ? t('federated.disableFederatedAutoLogin') : t('federated.enableFederatedAutoLogin'),
243
- content: checked ? t('federated.disableFederatedAutoLoginDescription') : t('federated.enableFederatedAutoLoginDescription'),
244
- async onConfirm(close) {
245
- await api.configFederated({
246
- input: {
247
- did: blocklet.appPid,
248
- autoLogin: !checked
249
- }
250
- });
251
- setChecked(prevValue => !prevValue);
252
- close();
253
- }
254
- });
255
- }, [setChecked, checked]);
256
235
  const quitFederatedLogin = useMemoizedFn(() => {
257
236
  confirmApi.open({
258
237
  title: t('federated.quitFederatedLogin'),
@@ -323,25 +302,7 @@ function FederatedSiteList({
323
302
  customButtons: customButtons,
324
303
  title: /*#__PURE__*/_jsx(Box, {
325
304
  className: "table-toolbar-left",
326
- children: mode === 'master' ? t('oauth.federated') : /*#__PURE__*/_jsx(FormControlLabel, {
327
- sx: {
328
- ml: 0,
329
- '& span.MuiSwitch-switchBase': {
330
- display: 'flex'
331
- },
332
- '& span.MuiSwitch-track': {
333
- display: 'block'
334
- }
335
- },
336
- control: /*#__PURE__*/_jsx(SwitchControl, {
337
- checked: checked,
338
- style: {
339
- marginRight: '6px'
340
- },
341
- onChange: changeAutoLogin
342
- }),
343
- label: t('federated.enableFederatedAutoLogin')
344
- })
305
+ children: t('oauth.federated')
345
306
  }),
346
307
  options: tableOptions
347
308
  }), confirmHolder, /*#__PURE__*/_jsx(FederatedInviteDialog, {
@@ -1,17 +1,15 @@
1
- import PropTypes from 'prop-types';
2
- import { useState } from 'react';
3
1
  import { isDidDomain } from '@abtnode/util/lib/url-evaluation';
4
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
3
  import AddIcon from '@mui/icons-material/CallMerge';
6
4
  import Spinner from '@mui/material/CircularProgress';
7
5
  import MenuItem from '@mui/material/MenuItem';
8
- import TextField from '@mui/material/TextField';
9
- import Typography from '@mui/material/Typography';
6
+ import PropTypes from 'prop-types';
7
+ import useSetState from 'react-use/lib/useSetState';
10
8
  import Confirm from '../../../confirm';
11
9
  import { useNodeContext } from '../../../contexts/node';
12
- import { formatError, sleep } from '../../../util';
13
- import DNSTip from '../dns-tip';
14
- import { parseDomainFromURL, validateDomain } from '../util';
10
+ import { sleep } from '../../../util';
11
+ import { parseDomainFromURL } from '../util';
12
+ import AddDomain from '../add-domain';
15
13
  import { jsx as _jsx } from "react/jsx-runtime";
16
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -20,7 +18,9 @@ export default function AddDomainAlias({
20
18
  children,
21
19
  title,
22
20
  teamDid,
23
- systemDomains
21
+ systemDomains,
22
+ appId,
23
+ appPk
24
24
  }) {
25
25
  const {
26
26
  t
@@ -28,18 +28,24 @@ export default function AddDomainAlias({
28
28
  const {
29
29
  api
30
30
  } = useNodeContext();
31
- const [loading, setLoading] = useState(false);
32
- const [confirmSetting, setConfirmSetting] = useState(null);
31
+ const [state, setState] = useSetState({
32
+ loading: false,
33
+ confirmSetting: null
34
+ });
33
35
  const cnameDomain = systemDomains.find(item => isDidDomain(item));
34
36
  const onCancel = () => {
35
- setLoading(false);
36
- setConfirmSetting(null);
37
+ setState({
38
+ loading: false,
39
+ confirmSetting: null
40
+ });
37
41
  };
38
42
  const onConfirm = async params => {
39
- if (loading) {
43
+ if (state.loading) {
40
44
  return;
41
45
  }
42
- setLoading(true);
46
+ setState({
47
+ loading: true
48
+ });
43
49
  try {
44
50
  await api.addDomainAlias({
45
51
  input: {
@@ -49,73 +55,41 @@ export default function AddDomainAlias({
49
55
  }
50
56
  });
51
57
  await sleep(2000);
52
- setConfirmSetting(null);
53
- } finally {
54
- setLoading(false);
55
- }
56
- };
57
- const onEnter = async (params, confirm, setError) => {
58
- try {
59
- await confirm(params);
60
- } catch (err) {
61
- setError(formatError(err));
58
+ setState({
59
+ confirmSetting: null
60
+ });
62
61
  } finally {
63
- setLoading(false);
62
+ setState({
63
+ loading: false
64
+ });
64
65
  }
65
66
  };
66
67
  const setting = {
67
68
  title: title || t('router.domainAlias.add.title'),
68
69
  // eslint-disable-next-line react/no-unstable-nested-components
69
- description: (params, setParams, setError) => /*#__PURE__*/_jsxs(Typography, {
70
- component: "div",
71
- children: [/*#__PURE__*/_jsx(TextField, {
72
- label: t('router.domainAlias.add.domainDescription'),
73
- helperText: t('router.domainAlias.add.helperText'),
74
- autoComplete: "off",
75
- variant: "outlined",
76
- name: "domain",
77
- "data-cy": "add-domain",
78
- fullWidth: true,
79
- autoFocus: true,
80
- inputProps: {
81
- 'data-cy': 'domain-name-input'
82
- },
83
- value: params.domain,
84
- style: {
85
- marginBottom: 8
86
- },
87
- margin: "dense",
88
- onChange: e => {
89
- const domain = e.target.value.trim();
90
- const errMsg = validateDomain(domain, t);
70
+ description: function Description(params, setParams, setError) {
71
+ return /*#__PURE__*/_jsx(AddDomain, {
72
+ siteId: id,
73
+ teamDid: teamDid,
74
+ cnameDomain: cnameDomain,
75
+ onSuccess: () => setState({
76
+ confirmSetting: null
77
+ }),
78
+ onInputDomain: ({
79
+ domain,
80
+ error
81
+ }) => {
91
82
  setParams({
92
83
  ...params,
93
84
  domain,
94
- __disableConfirm: !!errMsg
85
+ __disableConfirm: !!error
95
86
  });
96
- if (errMsg) {
97
- setError(errMsg);
98
- } else {
99
- setError('');
100
- }
87
+ setError(error);
101
88
  },
102
- onKeyPress: e => {
103
- if (e.key === 'Enter') {
104
- e.preventDefault();
105
- const domain = e.target.value.trim();
106
- const errMsg = validateDomain(domain, t);
107
- if (errMsg) {
108
- setError(errMsg);
109
- } else {
110
- onEnter(params, onConfirm, setError);
111
- }
112
- }
113
- }
114
- }), /*#__PURE__*/_jsx(DNSTip, {
115
- domain: params.domain,
116
- resolvedTarget: cnameDomain
117
- })]
118
- }),
89
+ appId: appId,
90
+ appPk: appPk
91
+ });
92
+ },
119
93
  confirm: t('common.confirm'),
120
94
  cancel: t('common.cancel'),
121
95
  params: {
@@ -127,18 +101,19 @@ export default function AddDomainAlias({
127
101
  };
128
102
  const onMenuItemClick = e => {
129
103
  e.stopPropagation();
130
- // eslint-disable-next-line no-unused-expressions
131
- setConfirmSetting(setting);
104
+ setState({
105
+ confirmSetting: setting
106
+ });
132
107
  };
133
108
  return /*#__PURE__*/_jsxs(_Fragment, {
134
109
  children: [typeof children === 'function' ? children({
135
- loading,
110
+ loading: state.loading,
136
111
  open: onMenuItemClick
137
112
  }) : /*#__PURE__*/_jsxs(MenuItem, {
138
113
  onClick: onMenuItemClick,
139
114
  className: "rule-action",
140
115
  "data-cy": "action-add-domain-alias",
141
- children: [loading ? /*#__PURE__*/_jsx(Spinner, {
116
+ children: [state.loading ? /*#__PURE__*/_jsx(Spinner, {
142
117
  size: 16
143
118
  }) : /*#__PURE__*/_jsx(AddIcon, {
144
119
  style: {
@@ -146,16 +121,16 @@ export default function AddDomainAlias({
146
121
  marginRight: 5
147
122
  }
148
123
  }), t('router.domainAlias.add.title')]
149
- }), confirmSetting && /*#__PURE__*/_jsx(Confirm, {
150
- title: confirmSetting.title,
151
- description: confirmSetting.description,
152
- confirm: confirmSetting.confirm,
153
- cancel: confirmSetting.cancel,
154
- params: confirmSetting.params,
155
- onConfirm: confirmSetting.onConfirm,
156
- onCancel: confirmSetting.onCancel,
124
+ }), state.confirmSetting && /*#__PURE__*/_jsx(Confirm, {
125
+ title: state.confirmSetting.title,
126
+ description: state.confirmSetting.description,
127
+ confirm: state.confirmSetting.confirm,
128
+ cancel: state.confirmSetting.cancel,
129
+ params: state.confirmSetting.params,
130
+ onConfirm: state.confirmSetting.onConfirm,
131
+ onCancel: state.confirmSetting.onCancel,
157
132
  color: "primary",
158
- loading: loading,
133
+ loading: state.loading,
159
134
  maxWidth: "lg"
160
135
  })]
161
136
  });
@@ -165,10 +140,13 @@ AddDomainAlias.propTypes = {
165
140
  children: PropTypes.any,
166
141
  title: PropTypes.string,
167
142
  teamDid: PropTypes.string,
168
- systemDomains: PropTypes.arrayOf(PropTypes.string).isRequired
143
+ systemDomains: PropTypes.arrayOf(PropTypes.string).isRequired,
144
+ appId: PropTypes.string,
145
+ appPk: PropTypes.string.isRequired
169
146
  };
170
147
  AddDomainAlias.defaultProps = {
171
148
  children: null,
172
149
  title: '',
173
- teamDid: ''
150
+ teamDid: '',
151
+ appId: null
174
152
  };