Merge pull request #1692 from bluewave-labs/fix/fe/status-page-permission

fix: don't render control buttons for public status page
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-02-04 16:02:40 -08:00
commit ff47af95fa
2 files changed
+52 -23

No files matched your search

@@ -6,33 +6,19 @@ import SettingsIcon from "../../../../../assets/icons/settings-bold.svg?react";
//Utils
import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom";
import { useLocation } from "react-router-dom";
import PropTypes from "prop-types";
const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
const Controls = ({ deleteStatusPage, isDeleting }) => {
const theme = useTheme();
const location = useLocation();
const currentPath = location.pathname;
const navigate = useNavigate();
if (currentPath === "/status/public") {
return null;
}
return (
<Stack
alignSelf="flex-start"
direction="row"
width="100%"
gap={theme.spacing(2)}
justifyContent="space-between"
alignItems="flex-end"
>
<Stack
direction="row"
gap={theme.spacing(8)}
alignItems="flex-end"
>
<Image
shouldRender={statusPage?.logo?.data ? true : false}
alt={"Company logo"}
maxWidth={"100px"}
base64={statusPage?.logo?.data}
/>
<Typography variant="h2">{statusPage?.companyName}</Typography>
</Stack>
<Stack
direction="row"
gap={theme.spacing(2)}
@@ -66,8 +52,51 @@ const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
</Button>
</Box>
</Stack>
);
};
Controls.propTypes = {
deleteStatusPage: PropTypes.func,
isDeleting: PropTypes.bool,
};
const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
const theme = useTheme();
return (
<Stack
alignSelf="flex-start"
direction="row"
width="100%"
gap={theme.spacing(2)}
justifyContent="space-between"
alignItems="flex-end"
>
<Stack
direction="row"
gap={theme.spacing(8)}
alignItems="flex-end"
>
<Image
shouldRender={statusPage?.logo?.data ? true : false}
alt={"Company logo"}
maxWidth={"100px"}
base64={statusPage?.logo?.data}
/>
<Typography variant="h2">{statusPage?.companyName}</Typography>
</Stack>
<Controls
deleteStatusPage={deleteStatusPage}
isDeleting={isDeleting}
/>
</Stack>
);
};
ControlsHeader.propTypes = {
statusPage: PropTypes.object,
deleteStatusPage: PropTypes.func,
isDeleting: PropTypes.bool,
};
export default ControlsHeader;
@@ -70,5 +70,5 @@ const StatusBar = ({ monitors }) => {
export default StatusBar;
StatusBar.propTypes = {
status: PropTypes.object.isRequired,
status: PropTypes.object,
};