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:
2 files changed
+52
-23
No files matched your search
@@ -6,33 +6,19 @@ import SettingsIcon from "../../../../../assets/icons/settings-bold.svg?react";
|
|||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
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 theme = useTheme();
|
||||||
|
const location = useLocation();
|
||||||
|
const currentPath = location.pathname;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
if (currentPath === "/status/public") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
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
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(2)}
|
||||||
@@ -66,8 +52,51 @@ const ControlsHeader = ({ statusPage, deleteStatusPage, isDeleting }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</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>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ControlsHeader.propTypes = {
|
||||||
|
statusPage: PropTypes.object,
|
||||||
|
deleteStatusPage: PropTypes.func,
|
||||||
|
isDeleting: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
export default ControlsHeader;
|
export default ControlsHeader;
|
||||||
@@ -70,5 +70,5 @@ const StatusBar = ({ monitors }) => {
|
|||||||
export default StatusBar;
|
export default StatusBar;
|
||||||
|
|
||||||
StatusBar.propTypes = {
|
StatusBar.propTypes = {
|
||||||
status: PropTypes.object.isRequired,
|
status: PropTypes.object,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user