Add conditional rendering to PageSpeed pages for non admin users

This commit is contained in:
Alex Holliday committed 2024-09-25 10:09:56 +08:00
1 parent 17deed8d43
commit e314def79a
4 files changed
+42 -34

No files matched your search

@@ -244,7 +244,7 @@ const PageSpeedConfigure = () => {
},
}}
>
Editting...
Editing...
</Typography>
</Stack>
</Box>
+22 -19
View File
@@ -32,7 +32,7 @@ import PieChart from "./Charts/PieChart";
import useUtils from "../../Monitors/utils";
import "./index.css";
const PageSpeedDetails = () => {
const PageSpeedDetails = ({ isAdmin }) => {
const theme = useTheme();
const navigate = useNavigate();
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
@@ -157,25 +157,27 @@ const PageSpeedDetails = () => {
</Typography>
</Stack>
</Box>
<Button
variant="contained"
color="secondary"
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
sx={{
ml: "auto",
alignSelf: "flex-end",
px: theme.spacing(5),
"& svg": {
mr: theme.spacing(3),
"& path": {
stroke: theme.palette.other.icon,
{isAdmin && (
<Button
variant="contained"
color="secondary"
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
sx={{
ml: "auto",
alignSelf: "flex-end",
px: theme.spacing(5),
"& svg": {
mr: theme.spacing(3),
"& path": {
stroke: theme.palette.other.icon,
},
},
},
}}
>
<SettingsIcon />
Configure
</Button>
}}
>
<SettingsIcon />
Configure
</Button>
)}
</Stack>
<Stack direction="row" gap={theme.spacing(8)}>
<StatBox>
@@ -393,6 +395,7 @@ const PageSpeedDetails = () => {
};
PageSpeedDetails.propTypes = {
isAdmin: PropTypes.bool,
push: PropTypes.func,
};
+10 -8
View File
@@ -87,14 +87,16 @@ const PageSpeed = ({ isAdmin }) => {
mt={theme.spacing(5)}
>
<Greeting type="pagespeed" />
<Button
variant="contained"
color="primary"
onClick={() => navigate("/pagespeed/create")}
sx={{ whiteSpace: "nowrap" }}
>
Create new
</Button>
{isAdmin && (
<Button
variant="contained"
color="primary"
onClick={() => navigate("/pagespeed/create")}
sx={{ whiteSpace: "nowrap" }}
>
Create new
</Button>
)}
</Stack>
</Box>
<Grid container spacing={theme.spacing(12)}>