From 41b4092428d454fbb9aaad9aa1696f31747f2f0d Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 1 Jun 2023 20:19:27 +0100 Subject: [PATCH] make redirect work --- .../API/{StatusPageSSO.tsx => StatusPageSSO.ts} | 0 StatusPage/src/Pages/Accounts/SSO.tsx | 9 +++++++++ StatusPage/src/Pages/Overview/Overview.tsx | 13 +++++++++++++ 3 files changed, 22 insertions(+) rename Identity/API/{StatusPageSSO.tsx => StatusPageSSO.ts} (100%) diff --git a/Identity/API/StatusPageSSO.tsx b/Identity/API/StatusPageSSO.ts similarity index 100% rename from Identity/API/StatusPageSSO.tsx rename to Identity/API/StatusPageSSO.ts diff --git a/StatusPage/src/Pages/Accounts/SSO.tsx b/StatusPage/src/Pages/Accounts/SSO.tsx index 8e7cd844dfb..814620bafdf 100644 --- a/StatusPage/src/Pages/Accounts/SSO.tsx +++ b/StatusPage/src/Pages/Accounts/SSO.tsx @@ -8,6 +8,7 @@ import { DASHBOARD_API_URL, FILE_URL, IDENTITY_URL } from 'CommonUI/src/Config'; import ObjectID from 'Common/Types/ObjectID'; import StatusPageSSO from 'Model/Models/StatusPageSso'; import PageLoader from 'CommonUI/src/Components/Loader/PageLoader'; +import LocalStorage from 'CommonUI/src/Utils/LocalStorage'; export interface ComponentProps { statusPageId: ObjectID | null; @@ -42,6 +43,14 @@ const LoginPage: FunctionComponent = ( ); } + if (Navigation.getQueryStringByName('redirectUrl')) { + // save this to local storage, so in the overview page. We can redirect to this page. + LocalStorage.setItem( + 'redirectUrl', + Navigation.getQueryStringByName('redirectUrl') + ); + } + if (isLoading) { return ; } diff --git a/StatusPage/src/Pages/Overview/Overview.tsx b/StatusPage/src/Pages/Overview/Overview.tsx index 9b4d1400486..e77d3858244 100644 --- a/StatusPage/src/Pages/Overview/Overview.tsx +++ b/StatusPage/src/Pages/Overview/Overview.tsx @@ -54,6 +54,19 @@ import MarkdownViewer from 'CommonUI/src/Components/Markdown.tsx/MarkdownViewer' const Overview: FunctionComponent = ( props: PageComponentProps ): ReactElement => { + if (LocalStorage.getItem('redirectUrl')) { + // const get item + + const redirectUrl: string = LocalStorage.getItem( + 'redirectUrl' + ) as string; + + // clear local storage. + LocalStorage.removeItem('redirectUrl'); + + Navigation.navigate(new Route(redirectUrl)); + } + const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); const [