@abtnode/ux 1.16.17-beta-2679e686 → 1.16.17-beta-3232a7af
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/blocklet/component/domain-list.js +103 -1
- package/es/blocklet/configuration.js +2 -1
- package/es/blocklet/router/action/add-domain-alias.js +63 -85
- package/es/blocklet/router/add-domain.js +258 -0
- package/es/confirm.js +4 -1
- package/es/form/form-select-input.js +6 -0
- package/es/locales/en.js +20 -0
- package/es/locales/zh.js +21 -0
- package/es/team/members/index.js +3 -0
- package/es/team/passports/index.js +4 -1
- package/lib/blocklet/component/domain-list.js +104 -2
- package/lib/blocklet/configuration.js +2 -1
- package/lib/blocklet/router/action/add-domain-alias.js +62 -83
- package/lib/blocklet/router/add-domain.js +274 -0
- package/lib/confirm.js +4 -1
- package/lib/form/form-select-input.js +8 -2
- package/lib/locales/en.js +20 -0
- package/lib/locales/zh.js +21 -0
- package/lib/team/members/index.js +3 -0
- package/lib/team/passports/index.js +4 -1
- package/package.json +7 -7
|
@@ -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,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
|
|
9
|
-
import
|
|
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 {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
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 [
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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: !!
|
|
85
|
+
__disableConfirm: !!error
|
|
95
86
|
});
|
|
96
|
-
|
|
97
|
-
setError(errMsg);
|
|
98
|
-
} else {
|
|
99
|
-
setError('');
|
|
100
|
-
}
|
|
87
|
+
setError(error);
|
|
101
88
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
131
|
-
|
|
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
|
};
|
|
@@ -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 '@mui/material/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
|
})]
|