-
Notifications
You must be signed in to change notification settings - Fork 902
ATLAS-5062: UI:Fix for improving logout mechanism in Atlas UI code base. #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,35 +16,54 @@ | |
| */ | ||
|
|
||
| import { useState, useEffect } from "react"; | ||
| import { useNavigate } from "react-router-dom"; | ||
| import errorIcon from "/img/error-404-icon.png"; | ||
| import { Stack, Typography } from "@mui/material"; | ||
| import { CustomButton } from "@components/muiComponents"; | ||
| import { useLocation } from "react-router-dom"; | ||
| import { useNavigate } from "react-router-dom"; | ||
|
|
||
|
|
||
| export const ErrorPage = (props: { errorCode: string }) => { | ||
| let navigate = useNavigate(); | ||
| const [errorCode, setErrorCode] = useState<string | null>(null); | ||
| const location = useLocation(); | ||
| const code = location.state?.errorCode || props.errorCode || "404"; | ||
|
|
||
| const [errorCode, setErrorCode] = useState<string>(""); | ||
| const [errorInfo, setErrorInfo] = useState<any>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (props.errorCode == "checkSSOTrue") { | ||
| if (code == "checkSSOTrue") { | ||
| setErrorCode("Sign Out Is Not Complete!"); | ||
| setErrorInfo( | ||
| <Typography> | ||
| Authentication to this instance of Ranger is managed externally(for | ||
| example,Apache Knox). You can still open this instance of Ranger from | ||
| Authentication to this instance of Atlas is managed externally(for | ||
| example,Apache Knox). You can still open this instance of Atlas from | ||
| the same web browser without re-authentication.To prevent | ||
| additionalPage not found (404). access to Ranger, | ||
| additionalPage not found (404). access to Atlas, | ||
| <strong>close all browser windows and exit the browser</strong>. | ||
| </Typography> | ||
| ); | ||
|
Comment on lines
34
to
45
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| if (props.errorCode == "404") { | ||
| else if (code == "404") { | ||
| setErrorCode("Page not found (404)."); | ||
| setErrorInfo("Sorry, this page isn't here or has moved."); | ||
| } | ||
| }); | ||
|
|
||
| const handleBackWithReload = () => { | ||
| localStorage.setItem("doGoBackAfterReload", "true"); | ||
| window.location.reload(); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| if (localStorage.getItem("doGoBackAfterReload") === "true") { | ||
| localStorage.removeItem("doGoBackAfterReload"); | ||
| setTimeout(() => { | ||
| window.history.back(); | ||
| }, 1000); | ||
| } | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Stack | ||
| data-id="pageNotFoundPage" | ||
|
|
@@ -74,7 +93,7 @@ export const ErrorPage = (props: { errorCode: string }) => { | |
| </Stack> | ||
| </Stack> | ||
| <Stack direction="row" spacing={2} className="mt-2"> | ||
| {props.errorCode !== "checkSSOTrue" && ( | ||
| {code !== "checkSSOTrue" && ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit; <CustomButton
size="small"
variant="contained"
color="primary"
onClick={
code === "checkSSOTrue"
? handleBackWithReload
: () => navigate("/search")
}
>
{code === "checkSSOTrue" ? "Go Back" : "Return to Dashboard"}
</CustomButton> |
||
| <CustomButton | ||
| size="small" | ||
| variant="contained" | ||
|
|
@@ -84,6 +103,16 @@ export const ErrorPage = (props: { errorCode: string }) => { | |
| Return to Dashboard | ||
| </CustomButton> | ||
| )} | ||
| {code == "checkSSOTrue" && ( | ||
| <CustomButton | ||
| size="small" | ||
| variant="contained" | ||
| color="primary" | ||
| onClick={handleBackWithReload} | ||
| > | ||
| Go Back | ||
| </CustomButton> | ||
| )} | ||
| </Stack> | ||
| </Stack> | ||
| </Stack> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {{!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --}} | ||
|
|
||
| <div data-id="pageNotFoundPage" class="new-error-page"> | ||
| <div class="new-error-box"> | ||
| <div class="error-white-bg"> | ||
| <div class="new-icon-box"> | ||
| <img src="img/error-404-icon.png" style="margin-top:5px"> | ||
| </div> | ||
| <div class="new-description-box"> | ||
| <h4 class="m-t-xs m-b-xs" data-id="msg"></h4> | ||
| <div data-id="moreInfo"></div> | ||
| </div> | ||
| <div class="m-t-md"> | ||
| <a href="javascript:;" class="btn btn-primary btn-sm" data-id="goBack"> | ||
| <i class="fa-fw fa fa-long-arrow-left"></i> Go back | ||
| </a> | ||
| <a href="#/" class="btn btn-sm" data-id="home">Home</a> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to create the logoutUtil?