Skip to content

Commit

Permalink
Do not unmount shell when session expires (#2473)
Browse files Browse the repository at this point in the history
* task: do not unmount shell when session is invalid

* task: use backdrop mui component
  • Loading branch information
finnar-bin authored Feb 2, 2024
1 parent b87b4af commit 92a0e44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/shell/components/load-instance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ export default connect((state) => {
languages: state.languages,
files: state.files,
role: state.userRole.systemRole.name,
auth: state.auth,
};
})(
memo(function LoadInstance(props) {
const [error, setError] = useState("");
useEffect(() => {
if (!props.auth.valid) {
return;
}

props.dispatch(fetchInstance()).then((res) => {
if (res.status !== 200) {
setError("You do not have permission to access this instance");
Expand Down Expand Up @@ -66,7 +71,7 @@ export default connect((state) => {
props.dispatch(fetchFiles("views"));
props.dispatch(fetchFiles("stylesheets"));
props.dispatch(fetchFiles("scripts"));
}, []);
}, [props.auth]);

useEffect(() => {
if (
Expand Down
15 changes: 10 additions & 5 deletions src/shell/components/private-route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Login from "shell/components/login";
import { notify } from "shell/store/notifications";
import { verify } from "shell/store/auth";
import { Staging } from "../Staging";
import { CircularProgress } from "@mui/material";
import { CircularProgress, Backdrop } from "@mui/material";

export default connect((state) => {
return {
Expand Down Expand Up @@ -70,13 +70,18 @@ export default connect((state) => {
});
return (
<>
{props.auth.valid ? (
props.children
) : (
{props.children}

<Backdrop
sx={{
zIndex: (theme) => theme.zIndex.tooltip + 10, // Needs to be on top of everything
}}
open={!props.auth.valid}
>
<Staging>
{props.auth.checking ? <CircularProgress /> : <Login />}
</Staging>
)}
</Backdrop>
</>
);
})
Expand Down

0 comments on commit 92a0e44

Please sign in to comment.