@devtron-labs/devtron-fe-common-lib 0.0.7-beta-35 → 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/Common/Constants.d.ts +3 -0
- package/dist/index.js +9 -0
- package/package.json +1 -1
- package/src/Common/Api.ts +7 -1
- package/src/Common/Constants.ts +6 -2
package/dist/index.js
CHANGED
|
@@ -37,6 +37,9 @@ var PATTERNS = {
|
|
|
37
37
|
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
|
|
38
38
|
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
39
39
|
};
|
|
40
|
+
var URLS = {
|
|
41
|
+
LOGIN_SSO: '/login/sso',
|
|
42
|
+
};
|
|
40
43
|
var ROUTES = {
|
|
41
44
|
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
42
45
|
};
|
|
@@ -301,6 +304,10 @@ var responseMessages = {
|
|
|
301
304
|
598: 'Network read timeout error',
|
|
302
305
|
599: 'Network connect timeout error',
|
|
303
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
|
+
}
|
|
304
311
|
function handleServerError(contentType, response) {
|
|
305
312
|
return __awaiter(this, void 0, void 0, function () {
|
|
306
313
|
var code, status, serverError, responseBody;
|
|
@@ -362,6 +369,7 @@ function fetchAPI(url, type, data, signal, preventAutoLogout, isMultipartRequest
|
|
|
362
369
|
});
|
|
363
370
|
}
|
|
364
371
|
else {
|
|
372
|
+
handleLogout();
|
|
365
373
|
return [2 /*return*/, { code: 401, status: 'Unauthorized', result: [] }];
|
|
366
374
|
}
|
|
367
375
|
case 1:
|
|
@@ -16469,6 +16477,7 @@ exports.TippyCustomized = TippyCustomized;
|
|
|
16469
16477
|
exports.ToastBody = ToastBody;
|
|
16470
16478
|
exports.ToastBody3 = ToastBody3;
|
|
16471
16479
|
exports.ToastBodyWithButton = ToastBodyWithButton;
|
|
16480
|
+
exports.URLS = URLS;
|
|
16472
16481
|
exports.VisibleModal = VisibleModal;
|
|
16473
16482
|
exports.VisibleModal2 = VisibleModal2;
|
|
16474
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
|
}
|