2022-05-04 19:10:19 +10:00
|
|
|
|
import { useAtom } from "jotai";
|
2022-05-05 15:46:00 +10:00
|
|
|
|
import { FallbackProps } from "react-error-boundary";
|
|
|
|
|
|
import { Link } from "react-router-dom";
|
2022-05-04 19:10:19 +10:00
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
Stack,
|
|
|
|
|
|
Avatar,
|
|
|
|
|
|
Alert,
|
|
|
|
|
|
Divider,
|
|
|
|
|
|
Link as MuiLink,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
} from "@mui/material";
|
2022-09-27 16:17:44 +10:00
|
|
|
|
import LockIcon from "@mui/icons-material/LockOutlined";
|
2022-05-04 19:10:19 +10:00
|
|
|
|
|
|
|
|
|
|
import EmptyState from "@src/components/EmptyState";
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
2022-07-18 14:40:46 +10:00
|
|
|
|
projectScope,
|
2022-05-04 19:10:19 +10:00
|
|
|
|
currentUserAtom,
|
|
|
|
|
|
userRolesAtom,
|
2022-07-18 14:40:46 +10:00
|
|
|
|
} from "@src/atoms/projectScope";
|
2022-05-04 19:10:19 +10:00
|
|
|
|
import { WIKI_LINKS } from "@src/constants/externalLinks";
|
|
|
|
|
|
import { ROUTES } from "@src/constants/routes";
|
|
|
|
|
|
|
2022-05-05 15:46:00 +10:00
|
|
|
|
export default function AccessDenied({ resetErrorBoundary }: FallbackProps) {
|
2022-07-18 14:40:46 +10:00
|
|
|
|
const [currentUser] = useAtom(currentUserAtom, projectScope);
|
|
|
|
|
|
const [userRoles] = useAtom(userRolesAtom, projectScope);
|
2022-05-04 19:10:19 +10:00
|
|
|
|
|
|
|
|
|
|
if (!currentUser) window.location.reload();
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<EmptyState
|
2022-07-20 14:50:23 +10:00
|
|
|
|
role="alert"
|
2022-05-04 19:10:19 +10:00
|
|
|
|
fullScreen
|
2022-09-27 16:17:44 +10:00
|
|
|
|
Icon={LockIcon}
|
2022-05-04 19:10:19 +10:00
|
|
|
|
message="Access denied"
|
|
|
|
|
|
description={
|
|
|
|
|
|
<>
|
|
|
|
|
|
<div style={{ textAlign: "left", width: "100%" }}>
|
|
|
|
|
|
<Stack
|
|
|
|
|
|
direction="row"
|
|
|
|
|
|
spacing={1.25}
|
|
|
|
|
|
alignItems="flex-start"
|
|
|
|
|
|
sx={{ mt: 2 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Avatar src={currentUser?.photoURL || ""} />
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Typography>{currentUser?.displayName}</Typography>
|
|
|
|
|
|
<Typography variant="button">{currentUser?.email}</Typography>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
|
|
|
|
{(!userRoles || userRoles.length === 0) && (
|
|
|
|
|
|
<Alert severity="warning" sx={{ mt: 2 }}>
|
|
|
|
|
|
Your account has no roles set
|
|
|
|
|
|
</Alert>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Typography>
|
|
|
|
|
|
You do not have access to this project. Please contact the project
|
|
|
|
|
|
owner.
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
2022-05-05 15:46:00 +10:00
|
|
|
|
<Button
|
|
|
|
|
|
component={Link}
|
|
|
|
|
|
to={ROUTES.signOut}
|
|
|
|
|
|
onClick={() => resetErrorBoundary()}
|
|
|
|
|
|
>
|
|
|
|
|
|
Sign out
|
|
|
|
|
|
</Button>
|
2022-05-04 19:10:19 +10:00
|
|
|
|
|
|
|
|
|
|
<Divider flexItem sx={{ typography: "overline" }}>
|
|
|
|
|
|
OR
|
|
|
|
|
|
</Divider>
|
|
|
|
|
|
|
|
|
|
|
|
<Typography>
|
|
|
|
|
|
If you are the project owner, please follow{" "}
|
|
|
|
|
|
<MuiLink
|
|
|
|
|
|
href={WIKI_LINKS.setupRoles}
|
|
|
|
|
|
target="_blank"
|
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
|
>
|
|
|
|
|
|
these instructions
|
|
|
|
|
|
</MuiLink>{" "}
|
|
|
|
|
|
to set up this project’s security rules.
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
position: "fixed",
|
|
|
|
|
|
top: 0,
|
|
|
|
|
|
left: 0,
|
|
|
|
|
|
right: 0,
|
|
|
|
|
|
bottom: 0,
|
|
|
|
|
|
bgcolor: "background.default",
|
|
|
|
|
|
zIndex: 9999,
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|