asab_webui_shell 27.8.2 → 27.8.4
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/dist/containers/Alerts/alerts.scss +10 -3
- package/dist/containers/Alerts/index.js +6 -1
- package/dist/containers/Router/ApplicationRouter.js +7 -0
- package/dist/containers/Sidebar/SidebarItem.js +13 -27
- package/dist/containers/Sidebar/SidebarItemRenderer.js +10 -1
- package/dist/containers/Sidebar/utils/sidebarRouteMatch.js +35 -0
- package/dist/containers/Sidebar/utils/sidebarRouteMatch.jsx +27 -0
- package/dist/modules/auth/components/SessionExpirationAlert.js +1 -0
- package/dist/screens/UnsupportedBrowserScreen.js +57 -0
- package/dist/screens/UnsupportedBrowserScreen.jsx +58 -0
- package/dist/screens/UnsupportedBrowserScreen.scss +32 -0
- package/dist/utils/browserSupport.js +95 -0
- package/dist/utils/browserSupport.jsx +95 -0
- package/package.json +1 -1
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
position: fixed;
|
|
3
3
|
z-index: 1500;
|
|
4
4
|
top: 40px;
|
|
5
|
+
left: 0;
|
|
6
|
+
right: 0;
|
|
7
|
+
width: 60rem;
|
|
8
|
+
max-width: 90%;
|
|
9
|
+
margin-left: auto;
|
|
10
|
+
margin-right: auto;
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
/* Move the alerts bit lower after the session expires */
|
|
13
|
+
&.session-expired {
|
|
14
|
+
top: 120px;
|
|
15
|
+
}
|
|
9
16
|
}
|
|
@@ -21,6 +21,10 @@ function AlertsComponent(props) {
|
|
|
21
21
|
setSeconds = _useState2[1];
|
|
22
22
|
var store = props.app.AppStore;
|
|
23
23
|
var alerts = (0, _asab_webui_components.useAppSelector)(state => state.alerts.alerts);
|
|
24
|
+
var sessionExpired = (0, _asab_webui_components.useAppSelector)(state => {
|
|
25
|
+
var _state$auth;
|
|
26
|
+
return (_state$auth = state.auth) === null || _state$auth === void 0 ? void 0 : _state$auth.sessionExpired;
|
|
27
|
+
});
|
|
24
28
|
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
25
29
|
t = _useTranslation.t;
|
|
26
30
|
|
|
@@ -55,7 +59,8 @@ function AlertsComponent(props) {
|
|
|
55
59
|
};
|
|
56
60
|
}, [seconds]);
|
|
57
61
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
58
|
-
id: "alerts"
|
|
62
|
+
id: "alerts",
|
|
63
|
+
className: sessionExpired ? 'session-expired' : undefined
|
|
59
64
|
}, alerts.map(alert => {
|
|
60
65
|
if (alert.component === null) {
|
|
61
66
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Alert, {
|
|
@@ -13,6 +13,8 @@ var _actions = require("../../actions");
|
|
|
13
13
|
var _RouteErrorHandler = _interopRequireDefault(require("../RouteErrorHandler"));
|
|
14
14
|
var _UnauthorizedAccessScreen = _interopRequireDefault(require("../../screens/UnauthorizedAccessScreen"));
|
|
15
15
|
var _InvalidRouteScreen = _interopRequireDefault(require("../../screens/InvalidRouteScreen"));
|
|
16
|
+
var _browserSupport = require("../../utils/browserSupport.js");
|
|
17
|
+
var _UnsupportedBrowserScreen = require("../../screens/UnsupportedBrowserScreen.js");
|
|
16
18
|
var cache;
|
|
17
19
|
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
18
20
|
// TODO: properly isolate authorization screen from the Application (should be injected when needed and only when AuthModule is enabled)
|
|
@@ -22,6 +24,11 @@ function ApplicationRouter(props) {
|
|
|
22
24
|
var _state$router;
|
|
23
25
|
return (_state$router = state.router) === null || _state$router === void 0 ? void 0 : _state$router.routes;
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
// Verify browser support only if browserSupportCheck is not disabled
|
|
29
|
+
if (props.app.Config.get('browserSupportCheck') !== false && !(0, _browserSupport.isBrowserSupported)()) {
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_UnsupportedBrowserScreen.UnsupportedBrowserScreen, null);
|
|
31
|
+
}
|
|
25
32
|
return /*#__PURE__*/_react.default.createElement(_reactRouter.Routes, null, routes && routes.map((route, idx) => {
|
|
26
33
|
return route.component ? /*#__PURE__*/_react.default.createElement(_reactRouter.Route, {
|
|
27
34
|
key: idx,
|
|
@@ -12,6 +12,7 @@ var _reactI18next = require("react-i18next");
|
|
|
12
12
|
var _reactstrap = require("reactstrap");
|
|
13
13
|
var _asab_webui_components = require("asab_webui_components");
|
|
14
14
|
var _SidebarIcon = _interopRequireDefault(require("./SidebarIcon"));
|
|
15
|
+
var _sidebarRouteMatch = require("./utils/sidebarRouteMatch.js");
|
|
15
16
|
var cache;
|
|
16
17
|
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
17
18
|
var SidebarItem = _ref => {
|
|
@@ -35,15 +36,19 @@ var SidebarItem = _ref => {
|
|
|
35
36
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
36
37
|
isActive = _useState2[0],
|
|
37
38
|
setActive = _useState2[1];
|
|
39
|
+
// Collapse parent only after a real navigation (not on mount / Strict Mode double-invoke)
|
|
40
|
+
var prevPathname = (0, _react.useRef)(location.pathname);
|
|
38
41
|
var lowercasedItemName = item === null || item === void 0 || (_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.toLowerCase();
|
|
39
42
|
// Attention requred flag
|
|
40
43
|
var itemBeacon = beacon === null || beacon === void 0 ? void 0 : beacon["beacon.".concat(lowercasedItemName)];
|
|
41
44
|
(0, _react.useEffect)(() => {
|
|
42
45
|
// TODO: refactor the handling of active and open states, since it does not behave as expected in some cases
|
|
43
|
-
|
|
46
|
+
var pathnameChanged = prevPathname.current !== location.pathname;
|
|
47
|
+
prevPathname.current = location.pathname;
|
|
48
|
+
if (pathnameChanged && isOpen && !isActive && !(0, _sidebarRouteMatch.matchesOpenFor)(location.pathname, openFor)) {
|
|
44
49
|
setOpen(false);
|
|
45
50
|
}
|
|
46
|
-
setActive(Boolean(item.url && (location.pathname === item.url || location.pathname.startsWith(item.url + '/'))) || matchesOpenFor(location.pathname, item.openFor));
|
|
51
|
+
setActive(Boolean(item.url && (location.pathname === item.url || location.pathname.startsWith(item.url + '/'))) || (0, _sidebarRouteMatch.matchesOpenFor)(location.pathname, item.openFor));
|
|
47
52
|
}, [location]);
|
|
48
53
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
49
54
|
className: "nav-item"
|
|
@@ -81,8 +86,10 @@ var SidebarCollapsibleItem = _ref2 => {
|
|
|
81
86
|
disabled = _ref2.disabled,
|
|
82
87
|
isSmallResolution = _ref2.isSmallResolution,
|
|
83
88
|
_ref2$beacon = _ref2.beacon,
|
|
84
|
-
beacon = _ref2$beacon === void 0 ? undefined : _ref2$beacon
|
|
85
|
-
|
|
89
|
+
beacon = _ref2$beacon === void 0 ? undefined : _ref2$beacon,
|
|
90
|
+
_ref2$defaultOpen = _ref2.defaultOpen,
|
|
91
|
+
defaultOpen = _ref2$defaultOpen === void 0 ? false : _ref2$defaultOpen;
|
|
92
|
+
var _useState3 = (0, _react.useState)(defaultOpen),
|
|
86
93
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
87
94
|
isOpen = _useState4[0],
|
|
88
95
|
setOpen = _useState4[1];
|
|
@@ -104,17 +111,8 @@ var SidebarCollapsibleItem = _ref2 => {
|
|
|
104
111
|
|
|
105
112
|
// Should collapsed item uncollapse
|
|
106
113
|
(0, _react.useEffect)(() => {
|
|
107
|
-
if (item.children && !isOpen) {
|
|
108
|
-
|
|
109
|
-
setOpen(true);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
for (var child of item.children) {
|
|
113
|
-
if (location.pathname.includes(child.url)) {
|
|
114
|
-
setOpen(true);
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
114
|
+
if (item.children && !isOpen && (0, _sidebarRouteMatch.collapsibleMatchesRoute)(location.pathname, item)) {
|
|
115
|
+
setOpen(true);
|
|
118
116
|
}
|
|
119
117
|
}, [isOpen]);
|
|
120
118
|
var onClickOpen = e => {
|
|
@@ -193,16 +191,4 @@ var childBeacon = (data, key) => {
|
|
|
193
191
|
return data[key] ? {
|
|
194
192
|
[key]: data[key]
|
|
195
193
|
} : {};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// Optional item.openFor patterns, e.g. ['/route/*'] - keeps parent open on matching routes
|
|
199
|
-
var matchesOpenFor = (pathname, patterns) => {
|
|
200
|
-
var _patterns$some;
|
|
201
|
-
return (_patterns$some = patterns === null || patterns === void 0 ? void 0 : patterns.some(p => {
|
|
202
|
-
if (p.endsWith('*')) {
|
|
203
|
-
var prefix = p.slice(0, -1);
|
|
204
|
-
return pathname.startsWith(prefix) || pathname === prefix.slice(0, -1);
|
|
205
|
-
}
|
|
206
|
-
return pathname === p || pathname.startsWith(p + '/');
|
|
207
|
-
})) !== null && _patterns$some !== void 0 ? _patterns$some : false;
|
|
208
194
|
};
|
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.SidebarItemRenderer = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactRouter = require("react-router");
|
|
9
10
|
var _SidebarItem = require("./SidebarItem");
|
|
11
|
+
var _sidebarRouteMatch = require("./utils/sidebarRouteMatch.js");
|
|
10
12
|
var SidebarItemRenderer = _ref => {
|
|
11
13
|
var sidebarItems = _ref.sidebarItems,
|
|
12
14
|
sessionExpired = _ref.sessionExpired,
|
|
@@ -14,6 +16,12 @@ var SidebarItemRenderer = _ref => {
|
|
|
14
16
|
isSmallResolution = _ref$isSmallResolutio === void 0 ? undefined : _ref$isSmallResolutio,
|
|
15
17
|
_ref$beacon = _ref.beacon,
|
|
16
18
|
beacon = _ref$beacon === void 0 ? undefined : _ref$beacon;
|
|
19
|
+
var location = (0, _reactRouter.useLocation)();
|
|
20
|
+
/*
|
|
21
|
+
Default-open the first collapsible unless some other sidebar item already owns the route.
|
|
22
|
+
If the first item itself matches (e.g. its child), start open to avoid a closed-then-open flash.
|
|
23
|
+
*/
|
|
24
|
+
var otherItemOwnsRoute = sidebarItems === null || sidebarItems === void 0 ? void 0 : sidebarItems.slice(1).some(item => (0, _sidebarRouteMatch.navItemMatchesRoute)(location.pathname, item));
|
|
17
25
|
return /*#__PURE__*/_react.default.createElement("nav", {
|
|
18
26
|
className: "nav flex-column"
|
|
19
27
|
}, sidebarItems.map((item, idx) => item.children ? /*#__PURE__*/_react.default.createElement(_SidebarItem.SidebarCollapsibleItem, {
|
|
@@ -21,7 +29,8 @@ var SidebarItemRenderer = _ref => {
|
|
|
21
29
|
item: item,
|
|
22
30
|
disabled: sessionExpired,
|
|
23
31
|
isSmallResolution: isSmallResolution,
|
|
24
|
-
beacon: beacon
|
|
32
|
+
beacon: beacon,
|
|
33
|
+
defaultOpen: idx === 0 && !otherItemOwnsRoute
|
|
25
34
|
}) : /*#__PURE__*/_react.default.createElement(_SidebarItem.SidebarItem, {
|
|
26
35
|
key: idx,
|
|
27
36
|
item: item,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.navItemMatchesRoute = exports.matchesOpenFor = exports.collapsibleMatchesRoute = void 0;
|
|
7
|
+
// Optional item.openFor patterns, e.g. ['/route/*'] - keeps parent open on matching routes
|
|
8
|
+
var matchesOpenFor = (pathname, patterns) => {
|
|
9
|
+
var _patterns$some;
|
|
10
|
+
return (_patterns$some = patterns === null || patterns === void 0 ? void 0 : patterns.some(p => {
|
|
11
|
+
if (p.endsWith('*')) {
|
|
12
|
+
var prefix = p.slice(0, -1);
|
|
13
|
+
return pathname.startsWith(prefix) || pathname === prefix.slice(0, -1);
|
|
14
|
+
}
|
|
15
|
+
return pathname === p || pathname.startsWith(p + '/');
|
|
16
|
+
})) !== null && _patterns$some !== void 0 ? _patterns$some : false;
|
|
17
|
+
};
|
|
18
|
+
exports.matchesOpenFor = matchesOpenFor;
|
|
19
|
+
var collapsibleMatchesRoute = (pathname, item) => {
|
|
20
|
+
if (!(item !== null && item !== void 0 && item.children)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (matchesOpenFor(pathname, item.openFor)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return item.children.some(child => child.url && pathname.includes(child.url));
|
|
27
|
+
};
|
|
28
|
+
exports.collapsibleMatchesRoute = collapsibleMatchesRoute;
|
|
29
|
+
var navItemMatchesRoute = (pathname, item) => {
|
|
30
|
+
if (item !== null && item !== void 0 && item.children) {
|
|
31
|
+
return collapsibleMatchesRoute(pathname, item);
|
|
32
|
+
}
|
|
33
|
+
return Boolean((item === null || item === void 0 ? void 0 : item.url) && (pathname === item.url || pathname.startsWith(item.url + '/'))) || matchesOpenFor(pathname, item === null || item === void 0 ? void 0 : item.openFor);
|
|
34
|
+
};
|
|
35
|
+
exports.navItemMatchesRoute = navItemMatchesRoute;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Optional item.openFor patterns, e.g. ['/route/*'] - keeps parent open on matching routes
|
|
2
|
+
export const matchesOpenFor = (pathname, patterns) =>
|
|
3
|
+
patterns?.some((p) => {
|
|
4
|
+
if (p.endsWith('*')) {
|
|
5
|
+
const prefix = p.slice(0, -1);
|
|
6
|
+
return pathname.startsWith(prefix) || pathname === prefix.slice(0, -1);
|
|
7
|
+
}
|
|
8
|
+
return pathname === p || pathname.startsWith(p + '/');
|
|
9
|
+
}) ?? false;
|
|
10
|
+
|
|
11
|
+
export const collapsibleMatchesRoute = (pathname, item) => {
|
|
12
|
+
if (!item?.children) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (matchesOpenFor(pathname, item.openFor)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return item.children.some((child) => child.url && pathname.includes(child.url));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const navItemMatchesRoute = (pathname, item) => {
|
|
22
|
+
if (item?.children) {
|
|
23
|
+
return collapsibleMatchesRoute(pathname, item);
|
|
24
|
+
}
|
|
25
|
+
return Boolean(item?.url && (pathname === item.url || pathname.startsWith(item.url + '/')))
|
|
26
|
+
|| matchesOpenFor(pathname, item?.openFor);
|
|
27
|
+
};
|
|
@@ -17,6 +17,7 @@ function SessionExpirationAlert(_ref) {
|
|
|
17
17
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Alert, {
|
|
18
18
|
key: alert.key,
|
|
19
19
|
color: alert.level,
|
|
20
|
+
className: "shadow",
|
|
20
21
|
fade: true,
|
|
21
22
|
isOpen: !alert.acked
|
|
22
23
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h5", null, t(alert.message)), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.UnsupportedBrowserScreen = UnsupportedBrowserScreen;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
11
|
+
var _reactstrap = require("reactstrap");
|
|
12
|
+
var _asab_webui_components = require("asab_webui_components");
|
|
13
|
+
var _browserSupport = require("../utils/browserSupport.js");
|
|
14
|
+
require("./UnsupportedBrowserScreen.scss");
|
|
15
|
+
/*
|
|
16
|
+
Shown in #app-main when the browser fails to match supported browser criteria.
|
|
17
|
+
Header and Sidebar stay mounted so the user can still log out.
|
|
18
|
+
Skipped when config browserSupportCheck is set to false
|
|
19
|
+
*/
|
|
20
|
+
function UnsupportedBrowserScreen() {
|
|
21
|
+
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
22
|
+
t = _useTranslation.t;
|
|
23
|
+
var browser = (0, _browserSupport.getBrowserLabel)();
|
|
24
|
+
var message = browser ? t('UnsupportedBrowserScreen|We are sorry for the inconvenience. Your browser ({{browser}}) is not supported. Please upgrade to a newer version or use another modern browser (Chrome, Firefox, Edge, or Safari).', {
|
|
25
|
+
browser
|
|
26
|
+
}) : t('UnsupportedBrowserScreen|We are sorry for the inconvenience. Your browser is not supported. Please upgrade to a newer version or use another modern browser (Chrome, Firefox, Edge, or Safari).');
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_reactstrap.Container, {
|
|
28
|
+
className: "unsupported-browser-container h-100"
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Card, {
|
|
30
|
+
className: "unsupported-browser-card"
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.CardBody, {
|
|
32
|
+
className: "text-center unsupported-browser-cardbody"
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Row, {
|
|
34
|
+
className: "justify-content-center"
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Col, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
+
className: "unsupported-browser-img-container"
|
|
37
|
+
}, /*#__PURE__*/_react.default.createElement(_asab_webui_components.FlowbiteIllustration, {
|
|
38
|
+
name: "error",
|
|
39
|
+
className: "pb-4",
|
|
40
|
+
title: t('UnsupportedBrowserScreen|Browser not supported')
|
|
41
|
+
})), /*#__PURE__*/_react.default.createElement("h4", {
|
|
42
|
+
className: "mb-2"
|
|
43
|
+
}, t('UnsupportedBrowserScreen|Browser not supported')), /*#__PURE__*/_react.default.createElement("p", {
|
|
44
|
+
className: "card-text mb-2"
|
|
45
|
+
}, message), /*#__PURE__*/_react.default.createElement("p", {
|
|
46
|
+
className: "mb-1"
|
|
47
|
+
}, t('UnsupportedBrowserScreen|Minimum supported versions:')), /*#__PURE__*/_react.default.createElement("ul", {
|
|
48
|
+
className: "list-unstyled mb-0 unsupported-browser-versions"
|
|
49
|
+
}, Object.entries(_browserSupport.MIN_SUPPORTED).map(_ref => {
|
|
50
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
51
|
+
name = _ref2[0],
|
|
52
|
+
version = _ref2[1];
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
54
|
+
key: name
|
|
55
|
+
}, name, " ", version, "+");
|
|
56
|
+
})))))));
|
|
57
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Container, Row, Col,
|
|
6
|
+
Card, CardBody
|
|
7
|
+
} from 'reactstrap';
|
|
8
|
+
|
|
9
|
+
import { FlowbiteIllustration } from 'asab_webui_components';
|
|
10
|
+
import { getBrowserLabel, MIN_SUPPORTED } from '../utils/browserSupport.jsx';
|
|
11
|
+
import './UnsupportedBrowserScreen.scss';
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Shown in #app-main when the browser fails to match supported browser criteria.
|
|
15
|
+
Header and Sidebar stay mounted so the user can still log out.
|
|
16
|
+
Skipped when config browserSupportCheck is set to false
|
|
17
|
+
*/
|
|
18
|
+
export function UnsupportedBrowserScreen() {
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
const browser = getBrowserLabel();
|
|
21
|
+
|
|
22
|
+
const message = browser
|
|
23
|
+
? t(
|
|
24
|
+
'UnsupportedBrowserScreen|We are sorry for the inconvenience. Your browser ({{browser}}) is not supported. Please upgrade to a newer version or use another modern browser (Chrome, Firefox, Edge, or Safari).',
|
|
25
|
+
{ browser }
|
|
26
|
+
)
|
|
27
|
+
: t(
|
|
28
|
+
'UnsupportedBrowserScreen|We are sorry for the inconvenience. Your browser is not supported. Please upgrade to a newer version or use another modern browser (Chrome, Firefox, Edge, or Safari).'
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Container className="unsupported-browser-container h-100">
|
|
33
|
+
<Card className="unsupported-browser-card">
|
|
34
|
+
<CardBody className="text-center unsupported-browser-cardbody">
|
|
35
|
+
<Row className="justify-content-center">
|
|
36
|
+
<Col>
|
|
37
|
+
<div className="unsupported-browser-img-container">
|
|
38
|
+
<FlowbiteIllustration
|
|
39
|
+
name="error"
|
|
40
|
+
className="pb-4"
|
|
41
|
+
title={t('UnsupportedBrowserScreen|Browser not supported')}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
<h4 className="mb-2">{t('UnsupportedBrowserScreen|Browser not supported')}</h4>
|
|
45
|
+
<p className="card-text mb-2">{message}</p>
|
|
46
|
+
<p className="mb-1">{t('UnsupportedBrowserScreen|Minimum supported versions:')}</p>
|
|
47
|
+
<ul className="list-unstyled mb-0 unsupported-browser-versions">
|
|
48
|
+
{Object.entries(MIN_SUPPORTED).map(([name, version]) => (
|
|
49
|
+
<li key={name}>{name} {version}+</li>
|
|
50
|
+
))}
|
|
51
|
+
</ul>
|
|
52
|
+
</Col>
|
|
53
|
+
</Row>
|
|
54
|
+
</CardBody>
|
|
55
|
+
</Card>
|
|
56
|
+
</Container>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.unsupported-browser-container {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.unsupported-browser-card {
|
|
6
|
+
height: 80%;
|
|
7
|
+
width: 50%;
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 50%;
|
|
10
|
+
left: 50%;
|
|
11
|
+
transform: translate(-50%, -50%);
|
|
12
|
+
border: 1px solid var(--bs-danger);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.unsupported-browser-cardbody {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
overflow: auto;
|
|
20
|
+
margin: 1rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.unsupported-browser-img-container {
|
|
24
|
+
height: 75%;
|
|
25
|
+
max-height: 50vh;
|
|
26
|
+
|
|
27
|
+
svg,
|
|
28
|
+
img {
|
|
29
|
+
max-height: 28vh;
|
|
30
|
+
width: auto;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MIN_SUPPORTED = void 0;
|
|
8
|
+
exports.getBrowserLabel = getBrowserLabel;
|
|
9
|
+
exports.isBrowserSupported = isBrowserSupported;
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
/*
|
|
12
|
+
Browser support detection utility
|
|
13
|
+
Browser support: version floors first, feature probes as fallback.
|
|
14
|
+
A known family below MIN_SUPPORTED is unsupported.
|
|
15
|
+
Unknown user agents and versions at/above the floor are decided by probes.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// First supported version per detected family. Bump when a new engine floor is required.
|
|
19
|
+
var MIN_SUPPORTED = exports.MIN_SUPPORTED = {
|
|
20
|
+
Safari: '16.4',
|
|
21
|
+
// lookbehind
|
|
22
|
+
Chrome: '62',
|
|
23
|
+
Firefox: '78',
|
|
24
|
+
Edge: '79',
|
|
25
|
+
Opera: '49'
|
|
26
|
+
};
|
|
27
|
+
var DETECTORS = [[/Edg(?:e|A|iOS)?\/(\d+(?:\.\d+)*)/, 'Edge'], [/OPR\/(\d+(?:\.\d+)*)/, 'Opera'], [/FxiOS\/(\d+(?:\.\d+)*)/, 'Firefox'], [/Firefox\/(\d+(?:\.\d+)*)/, 'Firefox'], [/CriOS\/(\d+(?:\.\d+)*)/, 'Chrome'], [/Chrome\/(\d+(?:\.\d+)*)/, 'Chrome'], [/Version\/(\d+(?:\.\d+)*).*Safari\//, 'Safari']];
|
|
28
|
+
var PROBES = [
|
|
29
|
+
// Can be extended with more probes eventually
|
|
30
|
+
() => {
|
|
31
|
+
new RegExp('(?<=x)y');
|
|
32
|
+
}];
|
|
33
|
+
|
|
34
|
+
// Returns true if the browser is supported, false otherwise
|
|
35
|
+
// Cached for the page lifetime, so capability does not change mid-session
|
|
36
|
+
var browserSupportedCache = null;
|
|
37
|
+
function isBrowserSupported() {
|
|
38
|
+
if (browserSupportedCache !== null) {
|
|
39
|
+
return browserSupportedCache;
|
|
40
|
+
}
|
|
41
|
+
var ua = typeof navigator !== 'undefined' ? navigator.userAgent || '' : '';
|
|
42
|
+
var browser = detectBrowser(ua);
|
|
43
|
+
var min = browser && MIN_SUPPORTED[browser.name];
|
|
44
|
+
if (min && versionLt(browser.version, min)) {
|
|
45
|
+
browserSupportedCache = false;
|
|
46
|
+
return browserSupportedCache;
|
|
47
|
+
}
|
|
48
|
+
for (var probe of PROBES) {
|
|
49
|
+
try {
|
|
50
|
+
probe();
|
|
51
|
+
} catch (_) {
|
|
52
|
+
browserSupportedCache = false;
|
|
53
|
+
return browserSupportedCache;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
browserSupportedCache = true;
|
|
57
|
+
return browserSupportedCache;
|
|
58
|
+
}
|
|
59
|
+
function getBrowserLabel() {
|
|
60
|
+
if (typeof navigator === 'undefined') {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
var browser = detectBrowser(navigator.userAgent || '');
|
|
64
|
+
return browser ? "".concat(browser.name, " ").concat(browser.version) : null;
|
|
65
|
+
}
|
|
66
|
+
function detectBrowser(ua) {
|
|
67
|
+
for (var _ref3 of DETECTORS) {
|
|
68
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref3, 2);
|
|
69
|
+
var re = _ref2[0];
|
|
70
|
+
var name = _ref2[1];
|
|
71
|
+
var match = ua.match(re);
|
|
72
|
+
if (match) {
|
|
73
|
+
return {
|
|
74
|
+
name,
|
|
75
|
+
version: match[1]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Version "less than" - returns true if version a is less than version b, false otherwise
|
|
83
|
+
function versionLt(a, b) {
|
|
84
|
+
var as = a.split('.');
|
|
85
|
+
var bs = b.split('.');
|
|
86
|
+
var n = Math.max(as.length, bs.length);
|
|
87
|
+
for (var i = 0; i < n; i++) {
|
|
88
|
+
var x = Number(as[i] || 0);
|
|
89
|
+
var y = Number(bs[i] || 0);
|
|
90
|
+
if (x !== y) {
|
|
91
|
+
return x < y;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Browser support detection utility
|
|
3
|
+
Browser support: version floors first, feature probes as fallback.
|
|
4
|
+
A known family below MIN_SUPPORTED is unsupported.
|
|
5
|
+
Unknown user agents and versions at/above the floor are decided by probes.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// First supported version per detected family. Bump when a new engine floor is required.
|
|
9
|
+
export const MIN_SUPPORTED = {
|
|
10
|
+
Safari: '16.4', // lookbehind
|
|
11
|
+
Chrome: '62',
|
|
12
|
+
Firefox: '78',
|
|
13
|
+
Edge: '79',
|
|
14
|
+
Opera: '49',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const DETECTORS = [
|
|
18
|
+
[/Edg(?:e|A|iOS)?\/(\d+(?:\.\d+)*)/, 'Edge'],
|
|
19
|
+
[/OPR\/(\d+(?:\.\d+)*)/, 'Opera'],
|
|
20
|
+
[/FxiOS\/(\d+(?:\.\d+)*)/, 'Firefox'],
|
|
21
|
+
[/Firefox\/(\d+(?:\.\d+)*)/, 'Firefox'],
|
|
22
|
+
[/CriOS\/(\d+(?:\.\d+)*)/, 'Chrome'],
|
|
23
|
+
[/Chrome\/(\d+(?:\.\d+)*)/, 'Chrome'],
|
|
24
|
+
[/Version\/(\d+(?:\.\d+)*).*Safari\//, 'Safari'],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const PROBES = [
|
|
28
|
+
// Can be extended with more probes eventually
|
|
29
|
+
() => {
|
|
30
|
+
new RegExp('(?<=x)y');
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// Returns true if the browser is supported, false otherwise
|
|
35
|
+
// Cached for the page lifetime, so capability does not change mid-session
|
|
36
|
+
let browserSupportedCache = null;
|
|
37
|
+
|
|
38
|
+
export function isBrowserSupported() {
|
|
39
|
+
if (browserSupportedCache !== null) {
|
|
40
|
+
return browserSupportedCache;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const ua = typeof navigator !== 'undefined' ? (navigator.userAgent || '') : '';
|
|
44
|
+
const browser = detectBrowser(ua);
|
|
45
|
+
const min = browser && MIN_SUPPORTED[browser.name];
|
|
46
|
+
if (min && versionLt(browser.version, min)) {
|
|
47
|
+
browserSupportedCache = false;
|
|
48
|
+
return browserSupportedCache;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const probe of PROBES) {
|
|
52
|
+
try {
|
|
53
|
+
probe();
|
|
54
|
+
} catch (_) {
|
|
55
|
+
browserSupportedCache = false;
|
|
56
|
+
return browserSupportedCache;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
browserSupportedCache = true;
|
|
61
|
+
return browserSupportedCache;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getBrowserLabel() {
|
|
65
|
+
if (typeof navigator === 'undefined') {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const browser = detectBrowser(navigator.userAgent || '');
|
|
69
|
+
return browser ? `${browser.name} ${browser.version}` : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function detectBrowser(ua) {
|
|
73
|
+
for (const [re, name] of DETECTORS) {
|
|
74
|
+
const match = ua.match(re);
|
|
75
|
+
if (match) {
|
|
76
|
+
return { name, version: match[1] };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Version "less than" - returns true if version a is less than version b, false otherwise
|
|
83
|
+
function versionLt(a, b) {
|
|
84
|
+
const as = a.split('.');
|
|
85
|
+
const bs = b.split('.');
|
|
86
|
+
const n = Math.max(as.length, bs.length);
|
|
87
|
+
for (let i = 0; i < n; i++) {
|
|
88
|
+
const x = Number(as[i] || 0);
|
|
89
|
+
const y = Number(bs[i] || 0);
|
|
90
|
+
if (x !== y) {
|
|
91
|
+
return x < y;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|