@abtnode/ux 1.7.3 → 1.7.6
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/lib/issue-passport.js +9 -0
- package/lib/layout/addon.js +19 -7
- package/lib/lost-passport.js +17 -2
- package/lib/util/index.js +50 -1
- package/package.json +8 -7
package/lib/issue-passport.js
CHANGED
|
@@ -25,6 +25,8 @@ var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect
|
|
|
25
25
|
|
|
26
26
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
27
27
|
|
|
28
|
+
var _constant = require("@abtnode/constant");
|
|
29
|
+
|
|
28
30
|
var _wrapLocale = _interopRequireDefault(require("./wrap-locale"));
|
|
29
31
|
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -66,11 +68,18 @@ function IssuePassport(_ref) {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
const onLogin = () => {
|
|
71
|
+
var _window$env;
|
|
72
|
+
|
|
69
73
|
try {
|
|
70
74
|
session.logout();
|
|
71
75
|
} catch (err) {// Do nothing
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
if ((((_window$env = window.env) === null || _window$env === void 0 ? void 0 : _window$env.apiPrefix) || '').startsWith(_constant.WELLKNOWN_SERVICE_PATH_PREFIX)) {
|
|
79
|
+
history.replace("".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/login"));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
history.replace('/');
|
|
75
84
|
};
|
|
76
85
|
|
package/lib/layout/addon.js
CHANGED
|
@@ -36,7 +36,11 @@ function HeaderAddon(_ref) {
|
|
|
36
36
|
let {
|
|
37
37
|
SessionContext,
|
|
38
38
|
webWalletUrl,
|
|
39
|
-
extraItems
|
|
39
|
+
extraItems,
|
|
40
|
+
showLocale,
|
|
41
|
+
showHelper,
|
|
42
|
+
showSessionManager,
|
|
43
|
+
sessionManagerProps
|
|
40
44
|
} = _ref;
|
|
41
45
|
const {
|
|
42
46
|
session
|
|
@@ -73,33 +77,41 @@ function HeaderAddon(_ref) {
|
|
|
73
77
|
w.location.href = "https://docs.arcblock.io/abtnode/".concat(locale).concat(path);
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(Div, null, extraItems.map(x => x), /*#__PURE__*/_react.default.createElement(_selector.default, {
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(Div, null, extraItems.map(x => x), showLocale && /*#__PURE__*/_react.default.createElement(_selector.default, {
|
|
77
81
|
"data-cy": "locale-addon",
|
|
78
82
|
size: 23,
|
|
79
83
|
showText: false,
|
|
80
84
|
className: "locale-addon"
|
|
81
|
-
}), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
85
|
+
}), showHelper && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
82
86
|
onClick: onHelpClick
|
|
83
87
|
}, /*#__PURE__*/_react.default.createElement(_HelpOutline.default, {
|
|
84
88
|
style: {
|
|
85
89
|
fontSize: 28
|
|
86
90
|
}
|
|
87
|
-
})), /*#__PURE__*/_react.default.createElement(_SessionManager.default, {
|
|
91
|
+
})), showSessionManager && /*#__PURE__*/_react.default.createElement(_SessionManager.default, Object.assign({
|
|
88
92
|
session: session,
|
|
89
93
|
webWalletUrl: walletUrl,
|
|
90
94
|
size: 24,
|
|
91
95
|
showRole: true
|
|
92
|
-
}));
|
|
96
|
+
}, sessionManagerProps)));
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
HeaderAddon.propTypes = {
|
|
96
100
|
SessionContext: _propTypes.default.object.isRequired,
|
|
97
101
|
webWalletUrl: _propTypes.default.string,
|
|
98
|
-
extraItems: _propTypes.default.array
|
|
102
|
+
extraItems: _propTypes.default.array,
|
|
103
|
+
showLocale: _propTypes.default.bool,
|
|
104
|
+
showSessionManager: _propTypes.default.bool,
|
|
105
|
+
showHelper: _propTypes.default.bool,
|
|
106
|
+
sessionManagerProps: _propTypes.default.object
|
|
99
107
|
};
|
|
100
108
|
HeaderAddon.defaultProps = {
|
|
101
109
|
webWalletUrl: '',
|
|
102
|
-
extraItems: []
|
|
110
|
+
extraItems: [],
|
|
111
|
+
showLocale: true,
|
|
112
|
+
showSessionManager: true,
|
|
113
|
+
showHelper: true,
|
|
114
|
+
sessionManagerProps: {}
|
|
103
115
|
};
|
|
104
116
|
|
|
105
117
|
const Div = _styledComponents.default.div.withConfig({
|
package/lib/lost-passport.js
CHANGED
|
@@ -41,6 +41,8 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
41
41
|
|
|
42
42
|
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
43
43
|
|
|
44
|
+
var _constant = require("@abtnode/constant");
|
|
45
|
+
|
|
44
46
|
var _cardSelector = _interopRequireDefault(require("./card-selector"));
|
|
45
47
|
|
|
46
48
|
var _wrapLocale = _interopRequireDefault(require("./wrap-locale"));
|
|
@@ -129,13 +131,26 @@ function LostPassport(_ref2) {
|
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
const onLogin = () => {
|
|
134
|
+
var _window$env;
|
|
135
|
+
|
|
132
136
|
try {
|
|
133
137
|
session.logout();
|
|
134
138
|
} catch (err) {// Do nothing
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
const redirect = searchParams.get('redirect')
|
|
138
|
-
|
|
141
|
+
const redirect = searchParams.get('redirect');
|
|
142
|
+
|
|
143
|
+
if (redirect) {
|
|
144
|
+
history.replace(redirect);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if ((((_window$env = window.env) === null || _window$env === void 0 ? void 0 : _window$env.apiPrefix) || '').startsWith(_constant.WELLKNOWN_SERVICE_PATH_PREFIX)) {
|
|
149
|
+
history.replace("".concat(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "/login"));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
history.replace('/');
|
|
139
154
|
};
|
|
140
155
|
|
|
141
156
|
const handleChange = event => {
|
package/lib/util/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getAccessUrl = getAccessUrl;
|
|
6
7
|
exports.sleep = sleep;
|
|
7
8
|
exports.validateDomain = void 0;
|
|
8
9
|
|
|
@@ -31,5 +32,53 @@ const validateDomain = function validateDomain(domain) {
|
|
|
31
32
|
|
|
32
33
|
return null;
|
|
33
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* get access url
|
|
37
|
+
* auto fix http/https, port, query
|
|
38
|
+
* docker friendly
|
|
39
|
+
*/
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
|
|
42
|
+
exports.validateDomain = validateDomain;
|
|
43
|
+
|
|
44
|
+
function getAccessUrl(hostname) {
|
|
45
|
+
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
46
|
+
let params = arguments.length > 2 ? arguments[2] : undefined;
|
|
47
|
+
|
|
48
|
+
if (!hostname) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let protocol = 'http';
|
|
53
|
+
|
|
54
|
+
if (window.location.protocol === 'https:') {
|
|
55
|
+
if (hostname.endsWith(_constant.DEFAULT_IP_DOMAIN_SUFFIX)) {
|
|
56
|
+
protocol = 'https';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (hostname.endsWith(_constant.DEFAULT_DID_DOMAIN)) {
|
|
60
|
+
protocol = 'https';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let port = '';
|
|
65
|
+
const browserPort = Number(window.location.port);
|
|
66
|
+
|
|
67
|
+
if (process.env.NODE_ENV !== 'development' && browserPort && ![80, 443].includes(browserPort)) {
|
|
68
|
+
port = ":".concat(browserPort);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const urlObj = new URL("".concat(protocol, "://").concat(hostname).concat(port));
|
|
72
|
+
urlObj.pathname = path;
|
|
73
|
+
const url = urlObj.href.replace(/\/$/, '');
|
|
74
|
+
|
|
75
|
+
if (!params || !Object.keys(params)) {
|
|
76
|
+
return url;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const searchParams = new URLSearchParams();
|
|
80
|
+
Object.keys(params).forEach(key => {
|
|
81
|
+
searchParams.append(key, params[key]);
|
|
82
|
+
});
|
|
83
|
+
return "".concat(url, "?").concat(searchParams.toString());
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.6",
|
|
7
7
|
"description": "UX components shared across abtnode packages",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
"lint:fix": "eslint src --fix",
|
|
15
15
|
"prepublishOnly": "npm run build",
|
|
16
16
|
"build": "babel src --out-dir lib --copy-files",
|
|
17
|
-
"watch": "babel src --out-dir lib -w --copy-files"
|
|
17
|
+
"watch": "babel src --out-dir lib -w --copy-files",
|
|
18
|
+
"test": "node tools/jest.js"
|
|
18
19
|
},
|
|
19
20
|
"keywords": [],
|
|
20
21
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.7.
|
|
24
|
-
"@arcblock/did-connect": "^1.
|
|
25
|
-
"@arcblock/ux": "^1.
|
|
26
|
-
"@blocklet/meta": "1.7.
|
|
24
|
+
"@abtnode/constant": "1.7.6",
|
|
25
|
+
"@arcblock/did-connect": "^1.17.0",
|
|
26
|
+
"@arcblock/ux": "^1.17.0",
|
|
27
|
+
"@blocklet/meta": "1.7.6",
|
|
27
28
|
"@material-ui/core": "^4.12.3",
|
|
28
29
|
"@material-ui/icons": "^4.11.2",
|
|
29
30
|
"notistack": "^1.0.6",
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"babel-plugin-inline-react-svg": "^1.1.1",
|
|
42
43
|
"babel-plugin-styled-components": "^1.10.7"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "47a9dbd6ea74419ff586336824ebb9b2fe7694aa"
|
|
45
46
|
}
|