@devtron-labs/devtron-fe-common-lib 0.0.7-beta-34 → 0.0.7-beta-36
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/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var ReactDOM = require('react-dom');
|
|
6
|
-
var reactRouter = require('react-router');
|
|
7
6
|
var reactRouterDom = require('react-router-dom');
|
|
8
7
|
|
|
9
8
|
function _interopNamespaceDefault(e) {
|
|
@@ -38,6 +37,9 @@ var PATTERNS = {
|
|
|
38
37
|
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
|
|
39
38
|
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
40
39
|
};
|
|
40
|
+
var URLS = {
|
|
41
|
+
LOGIN_SSO: '/login/sso',
|
|
42
|
+
};
|
|
41
43
|
var ROUTES = {
|
|
42
44
|
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
43
45
|
};
|
|
@@ -302,6 +304,10 @@ var responseMessages = {
|
|
|
302
304
|
598: 'Network read timeout error',
|
|
303
305
|
599: 'Network connect timeout error',
|
|
304
306
|
};
|
|
307
|
+
function handleLogout() {
|
|
308
|
+
var continueParam = "".concat(window.location.pathname.replace(process.env.PUBLIC_URL, '')).concat(window.location.search);
|
|
309
|
+
window.location.href = "".concat(window.location.origin).concat(process.env.PUBLIC_URL).concat(URLS.LOGIN_SSO, "?continue=").concat(continueParam);
|
|
310
|
+
}
|
|
305
311
|
function handleServerError(contentType, response) {
|
|
306
312
|
return __awaiter(this, void 0, void 0, function () {
|
|
307
313
|
var code, status, serverError, responseBody;
|
|
@@ -363,6 +369,7 @@ function fetchAPI(url, type, data, signal, preventAutoLogout, isMultipartRequest
|
|
|
363
369
|
});
|
|
364
370
|
}
|
|
365
371
|
else {
|
|
372
|
+
handleLogout();
|
|
366
373
|
return [2 /*return*/, { code: 401, status: 'Unauthorized', result: [] }];
|
|
367
374
|
}
|
|
368
375
|
case 1:
|
|
@@ -1966,9 +1973,9 @@ function GenericEmptyState(_a) {
|
|
|
1966
1973
|
}
|
|
1967
1974
|
|
|
1968
1975
|
function ErrorScreenNotFound() {
|
|
1969
|
-
var
|
|
1976
|
+
var push = reactRouterDom.useHistory().push;
|
|
1970
1977
|
var redirectToHome = function () {
|
|
1971
|
-
|
|
1978
|
+
push('/app/list');
|
|
1972
1979
|
};
|
|
1973
1980
|
var renderGenerateButton = function () {
|
|
1974
1981
|
return (jsxRuntime.jsx("button", __assign({ className: "flex cta h-32", onClick: redirectToHome, "data-testid": "empty-screen-take-me-home" }, { children: ERROR_EMPTY_SCREEN.TAKE_BACK_HOME })));
|
|
@@ -16470,6 +16477,7 @@ exports.TippyCustomized = TippyCustomized;
|
|
|
16470
16477
|
exports.ToastBody = ToastBody;
|
|
16471
16478
|
exports.ToastBody3 = ToastBody3;
|
|
16472
16479
|
exports.ToastBodyWithButton = ToastBodyWithButton;
|
|
16480
|
+
exports.URLS = URLS;
|
|
16473
16481
|
exports.VisibleModal = VisibleModal;
|
|
16474
16482
|
exports.VisibleModal2 = VisibleModal2;
|
|
16475
16483
|
exports.get = get;
|
package/package.json
CHANGED
package/src/Common/Api.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerErrors } from './ServerError'
|
|
2
|
-
import { RequestTimeout, Host } from './Constants'
|
|
2
|
+
import { RequestTimeout, Host, URLS } from './Constants'
|
|
3
3
|
import { ResponseType, APIOptions } from './Types'
|
|
4
4
|
|
|
5
5
|
const responseMessages = {
|
|
@@ -73,6 +73,11 @@ const responseMessages = {
|
|
|
73
73
|
599: 'Network connect timeout error',
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function handleLogout() {
|
|
77
|
+
const continueParam = `${window.location.pathname.replace(process.env.PUBLIC_URL, '')}${window.location.search}`
|
|
78
|
+
window.location.href = `${window.location.origin}${process.env.PUBLIC_URL}${URLS.LOGIN_SSO}?continue=${continueParam}`
|
|
79
|
+
}
|
|
80
|
+
|
|
76
81
|
async function handleServerError(contentType, response) {
|
|
77
82
|
//Test for HTTP Status Code
|
|
78
83
|
let code: number = response.status
|
|
@@ -126,6 +131,7 @@ async function fetchAPI(
|
|
|
126
131
|
],
|
|
127
132
|
})
|
|
128
133
|
} else {
|
|
134
|
+
handleLogout()
|
|
129
135
|
return { code: 401, status: 'Unauthorized', result: [] }
|
|
130
136
|
}
|
|
131
137
|
} else if (response.status >= 300 && response.status <= 599) {
|
package/src/Common/Constants.ts
CHANGED
|
@@ -14,6 +14,10 @@ export const PATTERNS = {
|
|
|
14
14
|
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export const URLS = {
|
|
18
|
+
LOGIN_SSO: '/login/sso',
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
export const ROUTES = {
|
|
18
22
|
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
19
23
|
}
|
|
@@ -44,8 +48,8 @@ export const ERROR_EMPTY_SCREEN = {
|
|
|
44
48
|
TAKE_BACK_HOME: 'Take me home',
|
|
45
49
|
ONLY_FOR_SUPERADMIN: 'Information on this page is available only to superadmin users.',
|
|
46
50
|
NOT_AUTHORIZED: 'Not authorized',
|
|
47
|
-
UNAUTHORIZED:'unauthorized',
|
|
48
|
-
FORBIDDEN:'forbidden',
|
|
51
|
+
UNAUTHORIZED: 'unauthorized',
|
|
52
|
+
FORBIDDEN: 'forbidden',
|
|
49
53
|
REQUIRED_MANAGER_ACCESS:
|
|
50
54
|
'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
|
|
51
55
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import notFound from '../Assets/Img/ic-empty-error@2x.png'
|
|
3
|
-
import { useHistory } from 'react-router'
|
|
3
|
+
import { useHistory } from 'react-router-dom'
|
|
4
4
|
import { ERROR_EMPTY_SCREEN } from './Constants'
|
|
5
5
|
import GenericEmptyState from './EmptyState/GenericEmptyState'
|
|
6
6
|
|
|
7
7
|
function ErrorScreenNotFound() {
|
|
8
|
-
const
|
|
8
|
+
const {push} = useHistory()
|
|
9
9
|
const redirectToHome = () => {
|
|
10
|
-
|
|
10
|
+
push('/app/list')
|
|
11
11
|
}
|
|
12
12
|
const renderGenerateButton = () => {
|
|
13
13
|
return (
|