@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.
@@ -0,0 +1,258 @@
1
+ import Connect from '@arcblock/did-connect/lib/Connect';
2
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
+ import DiamondIcon from '@mui/icons-material/Diamond';
4
+ import EditIcon from '@mui/icons-material/Edit';
5
+ import OpenInNewIcon from '@mui/icons-material/OpenInNew';
6
+ import Box from '@mui/material/Box';
7
+ import Button from '@arcblock/ux/lib/Button';
8
+ import Link from '@mui/material/Link';
9
+ import TextField from '@mui/material/TextField';
10
+ import useTheme from '@mui/material/styles/useTheme';
11
+ import noop from 'lodash/noop';
12
+ import PropTypes from 'prop-types';
13
+ import useSetState from 'react-use/lib/useSetState';
14
+ import joinURL from 'url-join';
15
+ import { validateDomain } from '../../../lib/util';
16
+ import { useNodeContext } from '../../contexts/node';
17
+ import { sleep } from '../../util';
18
+ import { axios } from '../../util/api';
19
+ import DNSTip from './dns-tip';
20
+ import { parseDomainFromURL } from './util';
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ export default function AddDomain({
24
+ siteId,
25
+ teamDid,
26
+ cnameDomain,
27
+ defaultCustomDomain,
28
+ onInputDomain,
29
+ appId,
30
+ appPk,
31
+ onSuccess,
32
+ ...props
33
+ }) {
34
+ const theme = useTheme();
35
+ const {
36
+ t,
37
+ locale
38
+ } = useLocaleContext();
39
+ const {
40
+ api,
41
+ info
42
+ } = useNodeContext();
43
+ const [state, setState] = useSetState({
44
+ domain: defaultCustomDomain,
45
+ error: null,
46
+ type: info?.nftDomainUrl ? 'nftDomain' : 'inputDomain',
47
+ showNFTDomainAuth: false
48
+ });
49
+ let nftDomainURL = '';
50
+ if (info.nftDomainUrl) {
51
+ nftDomainURL = joinURL(info.nftDomainUrl, '/api');
52
+ }
53
+ const handleAuthSuccess = async ({
54
+ domain,
55
+ nftDid,
56
+ chainHost
57
+ }) => {
58
+ try {
59
+ await api.addDomainAlias({
60
+ input: {
61
+ id: siteId,
62
+ type: 'nft-domain',
63
+ domainAlias: parseDomainFromURL(domain),
64
+ nftDid,
65
+ chainHost,
66
+ teamDid
67
+ }
68
+ });
69
+ await sleep(2000);
70
+ setState({
71
+ confirmSetting: null,
72
+ showNFTDomainAuth: false
73
+ });
74
+ onSuccess({
75
+ domain,
76
+ type: state.type
77
+ });
78
+ } finally {
79
+ setState({
80
+ openAuthNFTDomain: false
81
+ });
82
+ }
83
+ };
84
+ const domainTypes = {
85
+ inputDomain: {
86
+ name: t('router.domainAlias.inputDomain'),
87
+ icon: /*#__PURE__*/_jsx(EditIcon, {}),
88
+ component: /*#__PURE__*/_jsxs(Box, {
89
+ children: [/*#__PURE__*/_jsx(TextField, {
90
+ style: {
91
+ marginTop: '8px'
92
+ },
93
+ label: t('router.domainAlias.add.domainDescription'),
94
+ helperText: state.error || t('router.domainAlias.add.helperText'),
95
+ inputProps: {
96
+ 'data-cy': 'domain-name-input'
97
+ },
98
+ fullWidth: true,
99
+ value: state.domain,
100
+ onChange: e => {
101
+ const {
102
+ value
103
+ } = e.target;
104
+ setState({
105
+ domain: value
106
+ });
107
+ const errMessage = validateDomain(value, locale);
108
+ setState({
109
+ domain: value,
110
+ error: errMessage
111
+ });
112
+ onInputDomain({
113
+ domain: value,
114
+ error: errMessage
115
+ });
116
+ },
117
+ autoFocus: true,
118
+ size: "small",
119
+ variant: "outlined",
120
+ error: !!state.error
121
+ }), /*#__PURE__*/_jsx(DNSTip, {
122
+ domain: state.domain,
123
+ resolvedTarget: cnameDomain,
124
+ style: {
125
+ marginTop: '8px'
126
+ }
127
+ })]
128
+ })
129
+ }
130
+ };
131
+ if (info?.nftDomainUrl) {
132
+ domainTypes.nftDomain = {
133
+ name: t('router.domainAlias.nftDomain'),
134
+ icon: /*#__PURE__*/_jsx(DiamondIcon, {}),
135
+ component: /*#__PURE__*/_jsxs(Box, {
136
+ sx: {
137
+ marginTop: '12px'
138
+ },
139
+ children: [/*#__PURE__*/_jsxs(Box, {
140
+ sx: {
141
+ maxWidth: '640px',
142
+ color: 'text.secondary',
143
+ fontSize: '14px'
144
+ },
145
+ children: [/*#__PURE__*/_jsx("div", {
146
+ children: t('router.domainAlias.addDomainNFT.tips')
147
+ }), /*#__PURE__*/_jsxs("div", {
148
+ children: [t('router.domainAlias.addDomainNFT.buyTip'), /*#__PURE__*/_jsxs(Link, {
149
+ href: info.nftDomainUrl,
150
+ sx: {
151
+ fontSize: '14px',
152
+ display: 'inline-flex',
153
+ alignItems: 'center'
154
+ },
155
+ target: "_blank",
156
+ children: [/*#__PURE__*/_jsx("i", {
157
+ children: t('router.domainAlias.addDomainNFT.buy')
158
+ }), /*#__PURE__*/_jsx(OpenInNewIcon, {
159
+ fontSize: "small"
160
+ })]
161
+ })]
162
+ })]
163
+ }), /*#__PURE__*/_jsx(Button, {
164
+ sx: {
165
+ marginTop: '8px'
166
+ },
167
+ onClick: () => setState({
168
+ showNFTDomainAuth: true
169
+ }),
170
+ variant: "contained",
171
+ children: t('router.domainAlias.addDomainNFT.showNFT')
172
+ }), /*#__PURE__*/_jsx(Connect, {
173
+ open: state.showNFTDomainAuth,
174
+ popup: true,
175
+ useSocket: false,
176
+ action: "authorize",
177
+ baseUrl: nftDomainURL,
178
+ checkFn: axios.create({
179
+ baseURL: nftDomainURL
180
+ }).get,
181
+ extraParams: {
182
+ delegatee: appId,
183
+ delegateePk: appPk
184
+ },
185
+ onSuccess: handleAuthSuccess,
186
+ onClose: () => setState({
187
+ showNFTDomainAuth: false
188
+ }),
189
+ checkTimeout: 60 * 5000,
190
+ showDownload: false,
191
+ messages: {
192
+ title: t('router.domainAlias.addDomainNFT.connect.title'),
193
+ scan: t('router.domainAlias.addDomainNFT.connect.scan'),
194
+ confirm: t('router.domainAlias.addDomainNFT.connect.confirm'),
195
+ success: t('router.domainAlias.addDomainNFT.connect.success')
196
+ }
197
+ })]
198
+ })
199
+ };
200
+ }
201
+ const inputDomainTypes = Object.keys(domainTypes);
202
+ inputDomainTypes.sort(x => {
203
+ // 优先展示 nft domain
204
+ if (x === 'inputDomain') {
205
+ return 1;
206
+ }
207
+ return -1;
208
+ });
209
+ return /*#__PURE__*/_jsxs(Box, {
210
+ ...props,
211
+ children: [/*#__PURE__*/_jsx(Box, {
212
+ sx: {
213
+ display: 'flex',
214
+ justifyContent: 'flex-start',
215
+ gap: '16px'
216
+ },
217
+ children: inputDomainTypes.map(type => /*#__PURE__*/_jsxs(Box, {
218
+ sx: {
219
+ width: '128px',
220
+ height: '64px',
221
+ padding: '8px',
222
+ cursor: 'pointer',
223
+ borderRadius: '8px',
224
+ display: 'flex',
225
+ flexDirection: 'column',
226
+ justifyContent: 'center',
227
+ alignItems: 'flex-start',
228
+ color: type === state.type ? theme.palette.primary.main : theme.palette.common.main,
229
+ border: `1px solid ${type === state.type ? theme.palette.primary.main : '#E0E0E0'}`
230
+ },
231
+ onClick: () => setState({
232
+ type
233
+ }),
234
+ children: [domainTypes[type].icon, domainTypes[type].name]
235
+ }, type))
236
+ }), /*#__PURE__*/_jsx(Box, {
237
+ marginTop: "12px",
238
+ children: domainTypes[state.type]?.component
239
+ })]
240
+ });
241
+ }
242
+ AddDomain.propTypes = {
243
+ siteId: PropTypes.string.isRequired,
244
+ teamDid: PropTypes.string.isRequired,
245
+ cnameDomain: PropTypes.string.isRequired,
246
+ defaultCustomDomain: PropTypes.string,
247
+ onInputDomain: PropTypes.func,
248
+ onSuccess: PropTypes.func,
249
+ appId: PropTypes.string,
250
+ appPk: PropTypes.string
251
+ };
252
+ AddDomain.defaultProps = {
253
+ defaultCustomDomain: '',
254
+ onInputDomain: noop,
255
+ onSuccess: noop,
256
+ appId: '',
257
+ appPk: ''
258
+ };
package/es/confirm.js CHANGED
@@ -113,7 +113,10 @@ export default function ConfirmDialog({
113
113
  "data-cy": "submit-confirm-dialog",
114
114
  autoFocus: true,
115
115
  children: [(loading || inputLoading) && /*#__PURE__*/_jsx(Spinner, {
116
- size: 16
116
+ size: 16,
117
+ sx: {
118
+ mr: 1
119
+ }
117
120
  }), confirm]
118
121
  })]
119
122
  })]
@@ -9,6 +9,7 @@ import MenuItem from '@mui/material/MenuItem';
9
9
  import Select from '@mui/material/Select';
10
10
  import Chip from '@mui/material/Chip';
11
11
  import { useTheme } from '@mui/material/styles';
12
+ import FormHelperText from '@mui/material/FormHelperText';
12
13
  import Required from './required';
13
14
  import FormWrapper from './form-wrapper';
14
15
  import InputTriggers from './input-triggers';
@@ -41,6 +42,7 @@ export default function FormSelectInput({
41
42
  triggers,
42
43
  options,
43
44
  formatterBeforeSubmit,
45
+ helperText,
44
46
  ...rest
45
47
  }) {
46
48
  const theme = useTheme();
@@ -154,6 +156,8 @@ export default function FormSelectInput({
154
156
  disabled: disabled
155
157
  })
156
158
  })]
159
+ }), editing && helperText && /*#__PURE__*/_jsx(FormHelperText, {
160
+ children: helperText
157
161
  })]
158
162
  })
159
163
  });
@@ -168,6 +172,7 @@ FormSelectInput.propTypes = {
168
172
  disabled: PropTypes.bool,
169
173
  triggers: PropTypes.array,
170
174
  options: PropTypes.array,
175
+ helperText: PropTypes.string,
171
176
  formatterBeforeSubmit: PropTypes.func
172
177
  };
173
178
  FormSelectInput.defaultProps = {
@@ -180,5 +185,6 @@ FormSelectInput.defaultProps = {
180
185
  disabled: false,
181
186
  triggers: [],
182
187
  options: [],
188
+ helperText: '',
183
189
  formatterBeforeSubmit: x => x.join(',')
184
190
  };
@@ -1,26 +1,28 @@
1
- import { useCallback, useState } from 'react';
1
+ import { useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from '@emotion/styled';
4
4
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
- import DidConnect from '@arcblock/did-connect/lib/Connect';
6
5
  import DidButton from '@arcblock/did-connect/lib/Button';
7
- import { getWebWalletUrl } from '@arcblock/did-connect/lib/utils';
6
+ import { getFederatedEnabled, getMaster } from '@arcblock/ux/lib/Util/federated';
7
+ import { AUTH_SERVICE_PREFIX, API_DID_PREFIX } from '@arcblock/did-connect/lib/constant';
8
+ import joinURL from 'url-join';
8
9
  import { formatDateTime } from '../util';
9
10
  import usePassportId from '../hooks/use-passport-id';
11
+ import { useSessionContext } from '../contexts/session';
10
12
  import { jsx as _jsx } from "react/jsx-runtime";
11
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
- import { Fragment as _Fragment } from "react/jsx-runtime";
13
14
  function InvitationReceive({
14
15
  invitation,
15
- checkFn,
16
16
  onLogin,
17
17
  onReceive
18
18
  }) {
19
- const [open, setOpen] = useState(false);
20
19
  const {
21
20
  t,
22
21
  locale
23
22
  } = useLocaleContext();
23
+ const {
24
+ connectApi
25
+ } = useSessionContext();
24
26
  const {
25
27
  getPassportId
26
28
  } = usePassportId();
@@ -36,60 +38,60 @@ function InvitationReceive({
36
38
  componentId
37
39
  };
38
40
  const onClose = useCallback(() => {
39
- setOpen(false);
40
- }, []);
41
+ connectApi.close();
42
+ }, [connectApi]);
41
43
  const onSuccess = useCallback((...args) => {
42
- setOpen(false);
44
+ connectApi.close();
43
45
  onLogin(...args);
44
- }, [onLogin]);
46
+ }, [onLogin, connectApi]);
45
47
  const onClickReceive = useCallback(() => {
46
48
  if (typeof onReceive === 'function') {
47
49
  onReceive();
48
50
  return;
49
51
  }
50
- setOpen(true);
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, []);
53
- return /*#__PURE__*/_jsxs(_Fragment, {
54
- children: [/*#__PURE__*/_jsxs(Root, {
55
- children: [/*#__PURE__*/_jsx(DidButton, {
56
- size: "large",
57
- variant: "contained",
58
- className: "invite-receive__button",
59
- "data-cy": "invite-receive-passport",
60
- color: "primary",
61
- onClick: onClickReceive,
62
- children: t('invite.receive')
63
- }), /*#__PURE__*/_jsxs("div", {
64
- className: "invite-receive__until",
65
- children: [t('invite.validUntil'), formatDateTime(invitation.expireDate, locale)]
66
- })]
67
- }), /*#__PURE__*/_jsx(DidConnect, {
68
- popup: true,
69
- open: open,
70
- className: "connect",
71
- action: "invite",
72
- checkFn: checkFn,
52
+ const masterSite = getMaster();
53
+ const federatedEnabled = getFederatedEnabled();
54
+ const baseUrl = federatedEnabled ? masterSite.appUrl : window.location.origin;
55
+ connectApi.openPopup({
56
+ action: 'invite',
57
+ className: 'connect',
73
58
  forceConnected: false,
74
59
  autoConnect: false,
75
- checkTimeout: 10 * 60 * 1000,
76
- onSuccess: onSuccess,
77
- onClose: onClose,
78
- locale: locale,
79
- webWalletUrl: getWebWalletUrl(),
60
+ locale,
61
+ extraParams,
62
+ baseUrl: window.location.origin,
63
+ prefix: joinURL(window.location.origin, AUTH_SERVICE_PREFIX, API_DID_PREFIX),
80
64
  messages: {
81
65
  title: t('receive.dialog.title'),
82
66
  scan: t('receive.dialog.scan'),
83
67
  confirm: t('receive.dialog.confirm'),
84
68
  success: t('receive.dialog.success')
85
69
  },
86
- extraParams: extraParams
70
+ onSuccess,
71
+ onClose
72
+ }, {
73
+ baseUrl,
74
+ locale
75
+ });
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
77
+ }, [connectApi.openPopup]);
78
+ return /*#__PURE__*/_jsxs(Root, {
79
+ children: [/*#__PURE__*/_jsx(DidButton, {
80
+ size: "large",
81
+ variant: "contained",
82
+ className: "invite-receive__button",
83
+ "data-cy": "invite-receive-passport",
84
+ color: "primary",
85
+ onClick: onClickReceive,
86
+ children: t('invite.receive')
87
+ }), /*#__PURE__*/_jsxs("div", {
88
+ className: "invite-receive__until",
89
+ children: [t('invite.validUntil'), formatDateTime(invitation.expireDate, locale)]
87
90
  })]
88
91
  });
89
92
  }
90
93
  InvitationReceive.propTypes = {
91
94
  invitation: PropTypes.object.isRequired,
92
- checkFn: PropTypes.func.isRequired,
93
95
  onLogin: PropTypes.func,
94
96
  onReceive: PropTypes.func
95
97
  };
package/es/locales/en.js CHANGED
@@ -410,6 +410,7 @@ module.exports = {
410
410
  description: 'Blocklet instance wallet type, will change the derived DID'
411
411
  },
412
412
  languages: 'Supported Languages',
413
+ selectLanguagesTip: 'Adjust the order by removing and re-adding',
413
414
  passportColor: 'Passport Color',
414
415
  appUrl: 'Blocklet URL',
415
416
  access: {
@@ -734,6 +735,8 @@ module.exports = {
734
735
  registerUrlPlaceholder: 'Input the URL of your preferred Blocklet Launcher, you can use the official one safely',
735
736
  webWalletUrl: 'DID Wallet URL',
736
737
  webWalletUrlPlaceholder: 'Please input the URL of your hosted "DID Wallet", you can use the official one safely',
738
+ nftDomainUrl: 'NFT Domain URL',
739
+ nftDomainUrlPlaceholder: 'Please input the URL of your hosted "NFT Domain", you can use the official one safely',
737
740
  enableWelcomePage: 'Enable welcome page',
738
741
  welcome: {
739
742
  switchLabel: 'Welcome Page'
@@ -919,12 +922,29 @@ module.exports = {
919
922
  }
920
923
  },
921
924
  domainAlias: {
925
+ inputDomain: 'Input Domain',
926
+ nftDomain: 'NFT Domain',
922
927
  add: {
923
928
  title: 'Add Additional Domain',
924
929
  domainDescription: 'Please provide a valid domain name',
925
930
  forceTip: 'Force add if domain name already exists',
926
931
  helperText: 'If an HTTP or HTTPS URL is entered, it will be automatically converted into a domain name.'
927
932
  },
933
+ addCustomDomain: {
934
+ name: 'Custom Domain'
935
+ },
936
+ addDomainNFT: {
937
+ showNFT: 'Show NFT',
938
+ tips: 'NFT Domain will do the domain name resolution automatically, no need to configure it manually, and the application will update the resolution record of the domain name automatically when needed.',
939
+ connect: {
940
+ title: 'Please show your Domain NFT',
941
+ scan: 'Scan following QR code with DID Wallet to authorize to blocklet to use your domain',
942
+ confirm: 'Confirm on your DID Wallet',
943
+ success: 'Authorization Successfully'
944
+ },
945
+ buyTip: "If your don't have domain yet, ",
946
+ buy: 'buy it now!'
947
+ },
928
948
  delete: {
929
949
  title: 'Delete',
930
950
  description: 'After removing a domain alias, access to that alias may not be handled properly.'
package/es/locales/zh.js CHANGED
@@ -414,6 +414,7 @@ module.exports = {
414
414
  description: '应用钱包类型,会影响派生出来的 DID'
415
415
  },
416
416
  languages: '支持的语言',
417
+ selectLanguagesTip: '通过删除再添加来调整顺序',
417
418
  passportColor: '通行证颜色',
418
419
  appUrl: '应用访问地址',
419
420
  access: {
@@ -738,6 +739,8 @@ module.exports = {
738
739
  registerUrlPlaceholder: '你可以使用自己运行的"应用启动器", 也可以使用官方提供的版本',
739
740
  webWalletUrl: 'DID Wallet 地址',
740
741
  webWalletUrlPlaceholder: '你可以使用自己运行的 "DID Wallet", 也可以使用官方提供的版本',
742
+ nftDomainUrl: 'NFT Domain 地址',
743
+ nftDomainUrlPlaceholder: '你可以选择其它的 NFT Domain 服务器, 也可以使用官方提供的版本',
741
744
  upgrade: {
742
745
  title: '升级节点 {version}',
743
746
  description: '在升级期间,节点将会进入维护模式几分钟。',
@@ -922,12 +925,30 @@ module.exports = {
922
925
  }
923
926
  },
924
927
  domainAlias: {
928
+ inputDomain: '输入域名',
929
+ nftDomain: 'NFT 域名',
925
930
  add: {
926
931
  title: '添加额外域名',
927
932
  domainDescription: '请填写有效的域名',
928
933
  forceTip: '当域名已存在时强制添加',
929
934
  helperText: '如果输入 HTTP 或者 HTTPS URL, 则会被自动转换为域名。'
930
935
  },
936
+ addCustomDomain: {
937
+ name: '自定义域名'
938
+ },
939
+ addDomainNFT: {
940
+ name: 'NFT 域名',
941
+ showNFT: '出示 NFT',
942
+ tips: 'NFT 域名会自动完成域名解析,无需手动配置,并且应用会在需要的时候自动更新该域名的解析记录。',
943
+ connect: {
944
+ title: '请出示域名 NFT',
945
+ scan: '用 DID 钱包扫描下面的二维码, 出示域名 NFT',
946
+ confirm: '在您的 DID 钱包上确认',
947
+ success: '授权成功'
948
+ },
949
+ buyTip: '如果还没有域名 NFT, ',
950
+ buy: '现在购买!'
951
+ },
931
952
  delete: {
932
953
  title: '删除',
933
954
  description: '删除别名将会删除域名别用该站点下的所有流量转发规则,是否继续?'
@@ -460,6 +460,9 @@ export default function MemberList({
460
460
  children: [/*#__PURE__*/_jsxs(Box, {
461
461
  className: "main",
462
462
  display: "flex",
463
+ sx: {
464
+ mt: inService ? 4 : 0
465
+ },
463
466
  children: [/*#__PURE__*/_jsx("div", {
464
467
  className: "left",
465
468
  children: /*#__PURE__*/_jsx("div", {
@@ -76,6 +76,9 @@ export default function PassportList({
76
76
  };
77
77
  const filteredRoles = roles.filter(x => !search || x.title.includes(search) || x.name.includes(search));
78
78
  return /*#__PURE__*/_jsxs(Div, {
79
+ sx: {
80
+ mt: inService ? 6 : 0
81
+ },
79
82
  children: [/*#__PURE__*/_jsxs(ListHeader, {
80
83
  children: [/*#__PURE__*/_jsx("div", {
81
84
  className: "left",
@@ -244,7 +247,7 @@ export default function PassportList({
244
247
  })]
245
248
  });
246
249
  }
247
- const Div = styled.div`
250
+ const Div = styled(Box)`
248
251
  .list {
249
252
  .item {
250
253
  padding: 12px;