asab_webui_shell 25.1.11 → 25.1.13
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/components/locationReplace.js +4 -16
- package/dist/config/ConfigReducer.js +1 -1
- package/dist/config/ConfigService.js +116 -137
- package/dist/containers/AdvancedMode/reducer.js +2 -2
- package/dist/containers/Alerts/index.js +18 -30
- package/dist/containers/Alerts/reducer.js +5 -6
- package/dist/containers/Application.js +531 -663
- package/dist/containers/AttentionRequired/reducer.js +2 -2
- package/dist/containers/FullscreenMode/reducer.js +2 -2
- package/dist/containers/Header/ApplicationScreenTitle/ApplicationScreenTitle.js +15 -16
- package/dist/containers/Header/ApplicationScreenTitle/index.js +6 -6
- package/dist/containers/Header/Help/HelpButton.js +17 -27
- package/dist/containers/Header/Help/HelpService.js +13 -24
- package/dist/containers/Header/Preview/PreviewFlag.js +6 -5
- package/dist/containers/Header/Preview/PreviewService.js +13 -24
- package/dist/containers/Header/index.js +15 -17
- package/dist/containers/Header/reducer.js +4 -4
- package/dist/containers/Navigation/index.js +35 -55
- package/dist/containers/Navigation/reducer.js +7 -13
- package/dist/containers/RouteErrorHandler/ErrorContainer.js +17 -19
- package/dist/containers/RouteErrorHandler/index.js +28 -44
- package/dist/containers/Router/ApplicationRouter.js +14 -16
- package/dist/containers/Router/index.js +26 -42
- package/dist/containers/Router/reducer.js +3 -3
- package/dist/containers/Sidebar/NavbarBrand.js +14 -23
- package/dist/containers/Sidebar/SidebarBottomItem.js +16 -15
- package/dist/containers/Sidebar/SidebarIcon.js +9 -7
- package/dist/containers/Sidebar/SidebarItem.js +70 -85
- package/dist/containers/Sidebar/SidebarItemRenderer.js +20 -20
- package/dist/containers/Sidebar/index.js +20 -36
- package/dist/containers/Sidebar/reducer.js +3 -3
- package/dist/containers/Sidepanel/Sidepanel.js +18 -26
- package/dist/containers/Toast/ToastComponent.js +12 -12
- package/dist/containers/Toast/ToastContainer.js +19 -30
- package/dist/containers/Toast/reducer.js +3 -6
- package/dist/index.js +5 -5
- package/dist/modules/about/AboutScreen.js +30 -38
- package/dist/modules/about/index.js +8 -26
- package/dist/modules/auth/api.js +110 -156
- package/dist/modules/auth/components/SessionExpirationAlert.js +10 -9
- package/dist/modules/auth/header.js +25 -23
- package/dist/modules/auth/index.js +440 -692
- package/dist/modules/auth/reducer.js +2 -2
- package/dist/modules/auth/screens/AccessControlScreen.js +24 -25
- package/dist/modules/auth/screens/InvitationScreen.js +89 -128
- package/dist/modules/i18n/dropdown.js +24 -23
- package/dist/modules/i18n/index.js +20 -33
- package/dist/modules/i18n/reducer.js +2 -2
- package/dist/modules/i18n/service.js +48 -102
- package/dist/modules/tenant/TenantDropdown.js +28 -27
- package/dist/modules/tenant/access/AccessDeniedCard.js +28 -54
- package/dist/modules/tenant/index.js +16 -29
- package/dist/modules/tenant/reducer.js +1 -1
- package/dist/modules/tenant/service.js +123 -207
- package/dist/screens/InvalidRouteScreen.js +10 -9
- package/dist/screens/SuspenseScreen.js +11 -20
- package/dist/screens/UnauthorizedAccessScreen.js +18 -21
- package/dist/services/AttentionRequiredService.js +117 -142
- package/dist/services/BrandingService.js +63 -80
- package/dist/services/HeaderService.js +47 -66
- package/dist/services/ReduxService.js +11 -17
- package/dist/services/TitleService.js +13 -24
- package/dist/theme/ThemeButton.js +13 -10
- package/dist/theme/ThemeReducer.js +1 -1
- package/dist/theme/ThemeService.js +25 -38
- package/package.json +1 -1
|
@@ -4,225 +4,141 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
exports.default = void 0;
|
|
9
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
9
|
var _asab_webui_components = require("asab_webui_components");
|
|
16
10
|
var _actions = require("./actions");
|
|
17
11
|
var _locationReplace = require("../../components/locationReplace");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var TenantService = exports["default"] = /*#__PURE__*/function (_Service) {
|
|
21
|
-
function TenantService(app) {
|
|
22
|
-
var _this;
|
|
12
|
+
class TenantService extends _asab_webui_components.Service {
|
|
13
|
+
constructor(app) {
|
|
23
14
|
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'TenantService';
|
|
24
|
-
(
|
|
25
|
-
_this = _callSuper(this, TenantService, [app, name]);
|
|
15
|
+
super(app, name);
|
|
26
16
|
// Tenant data cache
|
|
27
|
-
|
|
28
|
-
return _this;
|
|
17
|
+
this.TenantDataCache = {};
|
|
29
18
|
}
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!(tenants != null)) {
|
|
43
|
-
_context.next = 6;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
tenants_list = [];
|
|
47
|
-
for (i = 0; tenants[i] != undefined; i++) {
|
|
48
|
-
tenants_list.push(tenants[i]);
|
|
49
|
-
}
|
|
50
|
-
_context.next = 6;
|
|
51
|
-
return this.setTenants(tenants_list);
|
|
52
|
-
case 6:
|
|
53
|
-
case "end":
|
|
54
|
-
return _context.stop();
|
|
55
|
-
}
|
|
56
|
-
}, _callee, this);
|
|
57
|
-
}));
|
|
58
|
-
function initialize() {
|
|
59
|
-
return _initialize.apply(this, arguments);
|
|
19
|
+
initialize() {
|
|
20
|
+
var _this = this;
|
|
21
|
+
return (0, _asyncToGenerator2.default)(function* () {
|
|
22
|
+
// If the tenant list is in the configuration, use it
|
|
23
|
+
// This is useful when tenants are present but auth not
|
|
24
|
+
var tenants = _this.App.Config.get('tenants');
|
|
25
|
+
if (tenants != null) {
|
|
26
|
+
var tenants_list = [];
|
|
27
|
+
for (var i = 0; tenants[i] != undefined; i++) {
|
|
28
|
+
tenants_list.push(tenants[i]);
|
|
29
|
+
}
|
|
30
|
+
yield _this.setTenants(tenants_list);
|
|
60
31
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/*
|
|
64
|
-
setTenants updates the current active tenant and the list of available tenants
|
|
65
|
-
and dispatches that information into the application store
|
|
66
|
-
*/
|
|
67
|
-
}, {
|
|
68
|
-
key: "setTenants",
|
|
69
|
-
value: (function () {
|
|
70
|
-
var _setTenants = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(availableTenants) {
|
|
71
|
-
var authorizedTenant,
|
|
72
|
-
tenantFromUrl,
|
|
73
|
-
currentTenant,
|
|
74
|
-
_args2 = arguments;
|
|
75
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
76
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
77
|
-
case 0:
|
|
78
|
-
authorizedTenant = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : undefined;
|
|
79
|
-
// Extract the current tenant from URL params
|
|
80
|
-
tenantFromUrl = this._extractTenantFromUrl();
|
|
81
|
-
/* If tenant has not been provided in access URL, insert the authorized tenant
|
|
82
|
-
or the first available tenant into the URL and reload the application */
|
|
83
|
-
if (!(tenantFromUrl == null)) {
|
|
84
|
-
_context2.next = 13;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
if (!authorizedTenant) {
|
|
88
|
-
_context2.next = 9;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
_context2.next = 6;
|
|
92
|
-
return (0, _locationReplace.locationReplace)("".concat(window.location.pathname, "?tenant=").concat(authorizedTenant).concat(window.location.hash));
|
|
93
|
-
case 6:
|
|
94
|
-
return _context2.abrupt("return");
|
|
95
|
-
case 9:
|
|
96
|
-
if (!(availableTenants && availableTenants.length > 0)) {
|
|
97
|
-
_context2.next = 13;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
_context2.next = 12;
|
|
101
|
-
return (0, _locationReplace.locationReplace)("".concat(window.location.pathname, "?tenant=").concat(availableTenants[0]).concat(window.location.hash));
|
|
102
|
-
case 12:
|
|
103
|
-
return _context2.abrupt("return");
|
|
104
|
-
case 13:
|
|
105
|
-
if (!(!availableTenants || availableTenants.length == 0)) {
|
|
106
|
-
_context2.next = 17;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
_context2.next = 16;
|
|
110
|
-
return (0, _locationReplace.locationReplace)(window.location.pathname + window.location.hash);
|
|
111
|
-
case 16:
|
|
112
|
-
return _context2.abrupt("return");
|
|
113
|
-
case 17:
|
|
114
|
-
if (availableTenants) {
|
|
115
|
-
if (!availableTenants.includes(tenantFromUrl)) {
|
|
116
|
-
// Display Invalid tenant alert message only when authorization is disabled
|
|
117
|
-
if (this.App.Config.get('authorization') === 'disabled') {
|
|
118
|
-
this.App.addAlert('danger', 'ASABTenantModule|Invalid tenant', 40000, true);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
currentTenant = tenantFromUrl;
|
|
122
|
-
// Sort available tenants
|
|
123
|
-
availableTenants.sort(function (a, b) {
|
|
124
|
-
var _a$toString, _b$toString;
|
|
125
|
-
var tenantA = (a === null || a === void 0 || (_a$toString = a.toString()) === null || _a$toString === void 0 ? void 0 : _a$toString.toLowerCase()) || '';
|
|
126
|
-
var tenantB = (b === null || b === void 0 || (_b$toString = b.toString()) === null || _b$toString === void 0 ? void 0 : _b$toString.toLowerCase()) || '';
|
|
127
|
-
return tenantA.localeCompare(tenantB);
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
currentTenant = undefined;
|
|
131
|
-
}
|
|
32
|
+
})();
|
|
33
|
+
}
|
|
132
34
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
35
|
+
/*
|
|
36
|
+
setTenants updates the current active tenant and the list of available tenants
|
|
37
|
+
and dispatches that information into the application store
|
|
38
|
+
*/
|
|
39
|
+
setTenants(availableTenants) {
|
|
40
|
+
var _arguments = arguments,
|
|
41
|
+
_this2 = this;
|
|
42
|
+
return (0, _asyncToGenerator2.default)(function* () {
|
|
43
|
+
var authorizedTenant = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : undefined;
|
|
44
|
+
// Extract the current tenant from URL params
|
|
45
|
+
var tenantFromUrl = _this2._extractTenantFromUrl();
|
|
46
|
+
|
|
47
|
+
/* If tenant has not been provided in access URL, insert the authorized tenant
|
|
48
|
+
or the first available tenant into the URL and reload the application */
|
|
49
|
+
if (tenantFromUrl == null) {
|
|
50
|
+
if (authorizedTenant) {
|
|
51
|
+
yield (0, _locationReplace.locationReplace)("".concat(window.location.pathname, "?tenant=").concat(authorizedTenant).concat(window.location.hash));
|
|
52
|
+
return;
|
|
53
|
+
} else if (availableTenants && availableTenants.length > 0) {
|
|
54
|
+
yield (0, _locationReplace.locationReplace)("".concat(window.location.pathname, "?tenant=").concat(availableTenants[0]).concat(window.location.hash));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
147
57
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
case 0:
|
|
163
|
-
currentTenant = this.getCurrentTenant(); // If tenant data being cached already, then return the data
|
|
164
|
-
if (!this.TenantDataCache[currentTenant]) {
|
|
165
|
-
_context3.next = 3;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
return _context3.abrupt("return", this.TenantDataCache[currentTenant]);
|
|
169
|
-
case 3:
|
|
170
|
-
tenantData = {};
|
|
171
|
-
if (!currentTenant) {
|
|
172
|
-
_context3.next = 19;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
SeaCatAuthAPI = this.App.axiosCreate('seacat-auth');
|
|
176
|
-
_context3.prev = 6;
|
|
177
|
-
_context3.next = 9;
|
|
178
|
-
return SeaCatAuthAPI.get("/tenant/".concat(currentTenant));
|
|
179
|
-
case 9:
|
|
180
|
-
response = _context3.sent;
|
|
181
|
-
tenantData = response.data;
|
|
182
|
-
this.TenantDataCache[currentTenant] = tenantData;
|
|
183
|
-
_context3.next = 19;
|
|
184
|
-
break;
|
|
185
|
-
case 14:
|
|
186
|
-
_context3.prev = 14;
|
|
187
|
-
_context3.t0 = _context3["catch"](6);
|
|
188
|
-
console.warn("Tenant service can't retrieve data for ".concat(currentTenant));
|
|
189
|
-
console.error(_context3.t0);
|
|
190
|
-
// Remove data from the TenantDataCache eventually
|
|
191
|
-
delete this.TenantDataCache[currentTenant];
|
|
192
|
-
case 19:
|
|
193
|
-
return _context3.abrupt("return", tenantData);
|
|
194
|
-
case 20:
|
|
195
|
-
case "end":
|
|
196
|
-
return _context3.stop();
|
|
58
|
+
|
|
59
|
+
// In case the list of available tenants is empty or undefined, remove the tenant parameter from URL
|
|
60
|
+
if (!availableTenants || availableTenants.length == 0) {
|
|
61
|
+
yield (0, _locationReplace.locationReplace)(window.location.pathname + window.location.hash);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Check if the tenant from URL is in the list of avaliable tenants
|
|
66
|
+
var currentTenant;
|
|
67
|
+
if (availableTenants) {
|
|
68
|
+
if (!availableTenants.includes(tenantFromUrl)) {
|
|
69
|
+
// Display Invalid tenant alert message only when authorization is disabled
|
|
70
|
+
if (_this2.App.Config.get('authorization') === 'disabled') {
|
|
71
|
+
_this2.App.addAlert('danger', 'ASABTenantModule|Invalid tenant', 40000, true);
|
|
197
72
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
73
|
+
}
|
|
74
|
+
currentTenant = tenantFromUrl;
|
|
75
|
+
// Sort available tenants
|
|
76
|
+
availableTenants.sort((a, b) => {
|
|
77
|
+
var _a$toString, _b$toString;
|
|
78
|
+
var tenantA = (a === null || a === void 0 || (_a$toString = a.toString()) === null || _a$toString === void 0 ? void 0 : _a$toString.toLowerCase()) || '';
|
|
79
|
+
var tenantB = (b === null || b === void 0 || (_b$toString = b.toString()) === null || _b$toString === void 0 ? void 0 : _b$toString.toLowerCase()) || '';
|
|
80
|
+
return tenantA.localeCompare(tenantB);
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
currentTenant = undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Dispatch tenants obtained from userinfo
|
|
87
|
+
_this2.App.Store.dispatch({
|
|
88
|
+
type: _actions.types.TENANTS_CHANGED,
|
|
89
|
+
tenants_list: availableTenants,
|
|
90
|
+
current: currentTenant
|
|
91
|
+
});
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
getTenantData() method is used for returning the tenant data
|
|
97
|
+
It requires SeaCat Auth service
|
|
98
|
+
*/
|
|
99
|
+
getTenantData() {
|
|
100
|
+
var _this3 = this;
|
|
101
|
+
return (0, _asyncToGenerator2.default)(function* () {
|
|
102
|
+
var currentTenant = _this3.getCurrentTenant();
|
|
103
|
+
// If tenant data being cached already, then return the data
|
|
104
|
+
if (_this3.TenantDataCache[currentTenant]) {
|
|
105
|
+
return _this3.TenantDataCache[currentTenant];
|
|
202
106
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
107
|
+
var tenantData = {};
|
|
108
|
+
if (currentTenant) {
|
|
109
|
+
var SeaCatAuthAPI = _this3.App.axiosCreate('seacat-auth');
|
|
110
|
+
try {
|
|
111
|
+
var response = yield SeaCatAuthAPI.get("/tenant/".concat(currentTenant));
|
|
112
|
+
tenantData = response.data;
|
|
113
|
+
_this3.TenantDataCache[currentTenant] = tenantData;
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.warn("Tenant service can't retrieve data for ".concat(currentTenant));
|
|
116
|
+
console.error(e);
|
|
117
|
+
// Remove data from the TenantDataCache eventually
|
|
118
|
+
delete _this3.TenantDataCache[currentTenant];
|
|
119
|
+
}
|
|
214
120
|
}
|
|
215
|
-
return
|
|
216
|
-
}
|
|
121
|
+
return tenantData;
|
|
122
|
+
})();
|
|
123
|
+
}
|
|
217
124
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return tenant;
|
|
125
|
+
// getCurrentTenant() method is used for obtaining current tenant
|
|
126
|
+
getCurrentTenant() {
|
|
127
|
+
var state = this.App.Store.getState();
|
|
128
|
+
var currentTenant = state.tenant.current;
|
|
129
|
+
// If current tenant is not in redux store yet, get it from the URL params
|
|
130
|
+
if (!currentTenant) {
|
|
131
|
+
currentTenant = this._extractTenantFromUrl();
|
|
226
132
|
}
|
|
227
|
-
|
|
228
|
-
}
|
|
133
|
+
return currentTenant;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Extract tenant from URL params
|
|
137
|
+
_extractTenantFromUrl() {
|
|
138
|
+
var search = window.location.search;
|
|
139
|
+
var params = new URLSearchParams(search);
|
|
140
|
+
var tenant = params.get('tenant');
|
|
141
|
+
return tenant;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.default = TenantService;
|
|
@@ -4,27 +4,28 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports.default = InvalidRouteScreen;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactI18next = require("react-i18next");
|
|
10
10
|
var _reactstrap = require("reactstrap");
|
|
11
11
|
require("./InvalidRouteScreen.scss");
|
|
12
12
|
function InvalidRouteScreen(props) {
|
|
13
|
-
var
|
|
14
|
-
t
|
|
15
|
-
|
|
13
|
+
var {
|
|
14
|
+
t
|
|
15
|
+
} = (0, _reactI18next.useTranslation)();
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement(_reactstrap.Container, {
|
|
16
17
|
className: "invalid-route-container h-100",
|
|
17
18
|
fluid: true
|
|
18
|
-
}, /*#__PURE__*/_react
|
|
19
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Card, {
|
|
19
20
|
className: "invalid-route-card"
|
|
20
|
-
}, /*#__PURE__*/_react
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.CardBody, {
|
|
21
22
|
className: "text-center invalid-route-cardbody"
|
|
22
|
-
}, /*#__PURE__*/_react
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Row, {
|
|
23
24
|
className: "justify-content-center"
|
|
24
|
-
}, /*#__PURE__*/_react
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Col, null, /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("i", {
|
|
25
26
|
className: "bi bi-emoji-frown fs-1 text-primary",
|
|
26
27
|
title: t("InvalidRouteScreen|Nothing here")
|
|
27
|
-
})), /*#__PURE__*/_react
|
|
28
|
+
})), /*#__PURE__*/_react.default.createElement("p", {
|
|
28
29
|
className: "card-text"
|
|
29
30
|
}, t("InvalidRouteScreen|Sorry, we can't find the page you are looking for.")))))));
|
|
30
31
|
}
|
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
6
|
+
exports.default = SuspenseScreen;
|
|
10
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
8
|
var _reactRedux = require("react-redux");
|
|
12
9
|
var _asab_webui_components = require("asab_webui_components");
|
|
13
10
|
var _reactstrap = require("reactstrap");
|
|
14
11
|
var _BrandImage = require("../components/branding/BrandImage");
|
|
15
12
|
require("./SuspenseScreen.scss");
|
|
16
|
-
function
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
14
|
function SuspenseScreen(props) {
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setBrandImage = _useState2[1];
|
|
23
|
-
var theme = (0, _reactRedux.useSelector)(function (state) {
|
|
24
|
-
return state.theme;
|
|
25
|
-
});
|
|
26
|
-
(0, _react.useEffect)(function () {
|
|
15
|
+
var [brandImage, setBrandImage] = (0, _react.useState)(undefined);
|
|
16
|
+
var theme = (0, _reactRedux.useSelector)(state => state.theme);
|
|
17
|
+
(0, _react.useEffect)(() => {
|
|
27
18
|
setBrandImage((0, _BrandImage.getBrandImage)(props, theme));
|
|
28
19
|
}, [theme]);
|
|
29
|
-
return /*#__PURE__*/_react
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_reactstrap.Container, {
|
|
30
21
|
className: "h-100",
|
|
31
22
|
fluid: true
|
|
32
|
-
}, /*#__PURE__*/_react
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
33
24
|
className: "h-100 suspense-content-wrapper"
|
|
34
|
-
}, /*#__PURE__*/_react
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Col, null, /*#__PURE__*/_react.default.createElement(_reactstrap.Row, {
|
|
35
26
|
className: "justify-content-center mb-4"
|
|
36
|
-
}, brandImage ? /*#__PURE__*/_react
|
|
27
|
+
}, brandImage ? /*#__PURE__*/_react.default.createElement("img", {
|
|
37
28
|
className: "suspense-img",
|
|
38
29
|
src: brandImage === null || brandImage === void 0 ? void 0 : brandImage.full,
|
|
39
30
|
alt: "Loading..."
|
|
40
|
-
}) : /*#__PURE__*/_react
|
|
31
|
+
}) : /*#__PURE__*/_react.default.createElement("h2", {
|
|
41
32
|
className: "text-center text-primary"
|
|
42
|
-
}, "Loading...")), /*#__PURE__*/_react
|
|
33
|
+
}, "Loading...")), /*#__PURE__*/_react.default.createElement(_asab_webui_components.Spinner, null))));
|
|
43
34
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
6
|
+
exports.default = UnauthorizedAccessScreen;
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _reactI18next = require("react-i18next");
|
|
10
9
|
var _reactRedux = require("react-redux");
|
|
11
10
|
var _reactstrap = require("reactstrap");
|
|
12
11
|
require("./UnauthorizedAccessScreen.scss");
|
|
13
|
-
function
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
13
|
/*
|
|
16
14
|
Unauthorized Access screen can be displayed only when:
|
|
17
15
|
- AuthModule is present within the application
|
|
@@ -22,19 +20,18 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
22
20
|
screen.
|
|
23
21
|
*/
|
|
24
22
|
function UnauthorizedAccessScreen(props) {
|
|
25
|
-
var
|
|
26
|
-
t
|
|
27
|
-
|
|
23
|
+
var {
|
|
24
|
+
t
|
|
25
|
+
} = (0, _reactI18next.useTranslation)();
|
|
26
|
+
var resources = (0, _reactRedux.useSelector)(state => {
|
|
28
27
|
var _state$auth;
|
|
29
28
|
return (_state$auth = state.auth) !== null && _state$auth !== void 0 && _state$auth.resources ? state.auth.resources : [];
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
// Check if auth module is active. If not, return the original component
|
|
33
32
|
// Check for desired resource. If present or user is superuser, return the original component
|
|
34
|
-
var isAuthorized = props.resource === "*" || props.app.Modules.filter(
|
|
35
|
-
|
|
36
|
-
}).length === 0 || resources.indexOf(props.resource) !== -1 || resources.indexOf("authz:superuser") !== -1;
|
|
37
|
-
(0, _react.useLayoutEffect)(function () {
|
|
33
|
+
var isAuthorized = props.resource === "*" || props.app.Modules.filter(obj => obj.Name === "AuthModule").length === 0 || resources.indexOf(props.resource) !== -1 || resources.indexOf("authz:superuser") !== -1;
|
|
34
|
+
(0, _react.useLayoutEffect)(() => {
|
|
38
35
|
// Determine if the component should be in print-ready or print-unauthorized state
|
|
39
36
|
if (!isAuthorized) {
|
|
40
37
|
document.body.setAttribute('print-ready', 'true');
|
|
@@ -45,7 +42,7 @@ function UnauthorizedAccessScreen(props) {
|
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
// Cleanup function to remove the attributes when the component unmounts
|
|
48
|
-
return
|
|
45
|
+
return () => {
|
|
49
46
|
document.body.removeAttribute('print-ready');
|
|
50
47
|
document.body.removeAttribute('print-unauthorized');
|
|
51
48
|
};
|
|
@@ -53,27 +50,27 @@ function UnauthorizedAccessScreen(props) {
|
|
|
53
50
|
|
|
54
51
|
// If user is authorized, let them see the screen content
|
|
55
52
|
if (isAuthorized) {
|
|
56
|
-
return /*#__PURE__*/_react
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.routeComponent);
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
// Else return the Not authorized screen
|
|
60
|
-
return /*#__PURE__*/_react
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_reactstrap.Container, {
|
|
61
58
|
className: "unauthorized-container h-100",
|
|
62
59
|
fluid: true
|
|
63
|
-
}, /*#__PURE__*/_react
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Card, {
|
|
64
61
|
className: "unauthorized-card"
|
|
65
|
-
}, /*#__PURE__*/_react
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.CardBody, {
|
|
66
63
|
className: "text-center unauthorized-cardbody"
|
|
67
|
-
}, /*#__PURE__*/_react
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Row, {
|
|
68
65
|
className: "justify-content-center"
|
|
69
|
-
}, /*#__PURE__*/_react
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Col, null, /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("i", {
|
|
70
67
|
className: "bi bi-exclamation-triangle text-danger fs-1",
|
|
71
68
|
title: t("UnauthorizedAccessScreen|Unauthorized access")
|
|
72
|
-
})), props.resource ? /*#__PURE__*/_react
|
|
69
|
+
})), props.resource ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
73
70
|
className: "card-text"
|
|
74
|
-
}, t("UnauthorizedAccessScreen|You are not authorized to access this part of the application. Please ask your application administrator for following resource"), ":"), /*#__PURE__*/_react
|
|
71
|
+
}, t("UnauthorizedAccessScreen|You are not authorized to access this part of the application. Please ask your application administrator for following resource"), ":"), /*#__PURE__*/_react.default.createElement("h5", {
|
|
75
72
|
className: "card-title"
|
|
76
|
-
}, props.resource)) : /*#__PURE__*/_react
|
|
73
|
+
}, props.resource)) : /*#__PURE__*/_react.default.createElement("p", {
|
|
77
74
|
className: "card-text"
|
|
78
75
|
}, t("UnauthorizedAccessScreen|You are not authorized to access this part of the application.")))))));
|
|
79
76
|
}
|