Skip to content
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

Fix for logout button and process #1463

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
margin-right: 2px;
}

.logout button div{
color: white;
}

.inline-icon {
margin-right: 1em;
}
Expand Down
20 changes: 12 additions & 8 deletions src/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function App (props){
var [userDataGroups, setUserDataGroups] = useState({});
var [userDev, setUserDev] = useState(false);
// var [regStatus, setUnregStatus] = useState(false);
var [isLoggingOut, setIsLoggingOut] = useState(false);
var [APIErr, setAPIErr] = useState([]);
var [isLoading, setIsLoading] = useState(true);
var [dtloading, setDTLoading] = useState(true);
Expand Down Expand Up @@ -125,7 +126,7 @@ export function App (props){
} else if (results && results.status === 401) {
console.debug('%c◉ FAIL WITH 410 ', 'color:#00ff7b', results);
setAuthStatus(false);
setUnregStatus(true);
// setUnregStatus(true);
clearAuths();
} else if (results && results.status === 403 && results.results === "User is not a member of group HuBMAP-read") {
console.debug('%c◉ UNREG ', 'color:#00ff7b', results );
Expand Down Expand Up @@ -254,9 +255,9 @@ export function App (props){


function clearAuths() {
console.debug('%c◉ CLEAR AUTHS ', 'color:#00ff7b' );
if(process.env.REACT_APP_URL == "http://localhost:8585"){
console.debug('%c◉ clearAuths start ', 'color:#00ff7b' );
// console.debug('%c◉ CLEAR AUTHS ', 'color:#00ff7b' );
if(process.env.REACT_APP_URL === "http://localhost:8585"){
// console.debug('%c◉ clearAuths start ', 'color:#00ff7b' );
return new Promise((resolve) => {
setTimeout(() => { // Give it a chance to cleaer the local storage
localStorage.removeItem("info");
Expand All @@ -269,9 +270,10 @@ export function App (props){
}
}

function Logout(){
clearAuths().then((response) => {
console.debug('%c◉ response', 'color:#00ff7b',response );
function Logout(e){
setIsLoggingOut(true);
clearAuths(e).then((response) => {
console.debug('%c◉ response', 'color:#00ff7b',response );
window.location.replace(`${process.env.REACT_APP_DATAINGEST_API_URL}/logout`)
})
};
Expand Down Expand Up @@ -366,6 +368,7 @@ export function App (props){
<Navigation
login={authStatus}
logout={Logout}
isLoggingOut={isLoggingOut}
app_info={ app_info_storage}
userGroups={userGroups}
userDataGroups={userDataGroups}
Expand Down Expand Up @@ -433,8 +436,9 @@ export function App (props){
</Grid>

</Box>
</Drawer>


</Drawer>
{ !isLoading && bannerShow && (
<div className="alert alert-info" role="alert">
<h2>{bannerTitle}</h2>
Expand Down
9 changes: 4 additions & 5 deletions src/src/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import MenuItem from '@mui/material/MenuItem';
import Dialog from '@mui/material/Dialog';
import DialogContent from '@mui/material/DialogContent';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
import LoadingButton from '@mui/lab/LoadingButton';

import UploadsForm from "./components/uploads/createUploads";

Expand Down Expand Up @@ -443,12 +444,10 @@ export const Navigation = (props) => {
Edit Profile
</Button>
</span>
<span className="logout">
<Button
onClick={() => props.logout()}
className="nav-link" >
<span className="logout" >
<LoadingButton loading={props.isLoggingOut} color='info' onClick={(e) => props.logout(e)}>
Log Out
</Button>
</LoadingButton>
</span>
{}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/src/assets/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
margin-right: 2px;
}

.logout button div{
color: white;
}

.inline-icon {
margin-right: 1em;
}
Expand Down
Loading