Merge pull request #871 from bluewave-labs/fix/pagespeed-demo-rendering
Add conditional rendering to PageSpeed pages for non admin users
This commit is contained in:
4 files changed
+42
-34
No files matched your search
+9
-6
@@ -19,13 +19,13 @@ import SetNewPassword from "./Pages/Auth/SetNewPassword";
|
|||||||
import NewPasswordConfirmed from "./Pages/Auth/NewPasswordConfirmed";
|
import NewPasswordConfirmed from "./Pages/Auth/NewPasswordConfirmed";
|
||||||
import ProtectedRoute from "./Components/ProtectedRoute";
|
import ProtectedRoute from "./Components/ProtectedRoute";
|
||||||
import Details from "./Pages/Monitors/Details";
|
import Details from "./Pages/Monitors/Details";
|
||||||
import Maintenance from "./Pages/Maintenance";
|
// import Maintenance from "./Pages/Maintenance";
|
||||||
import withAdminCheck from "./HOC/withAdminCheck";
|
import withAdminCheck from "./HOC/withAdminCheck";
|
||||||
import withAdminProp from "./HOC/withAdminProp";
|
import withAdminProp from "./HOC/withAdminProp";
|
||||||
import Configure from "./Pages/Monitors/Configure";
|
import Configure from "./Pages/Monitors/Configure";
|
||||||
import PageSpeed from "./Pages/PageSpeed";
|
import PageSpeed from "./Pages/PageSpeed";
|
||||||
import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed";
|
import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed";
|
||||||
import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenanceWindow";
|
// import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenanceWindow";
|
||||||
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
||||||
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
||||||
import { ThemeProvider } from "@emotion/react";
|
import { ThemeProvider } from "@emotion/react";
|
||||||
@@ -37,9 +37,10 @@ import { CssBaseline } from "@mui/material";
|
|||||||
function App() {
|
function App() {
|
||||||
const AdminCheckedRegister = withAdminCheck(Register);
|
const AdminCheckedRegister = withAdminCheck(Register);
|
||||||
const MonitorsWithAdminProp = withAdminProp(Monitors);
|
const MonitorsWithAdminProp = withAdminProp(Monitors);
|
||||||
const DetailsWithAdminProp = withAdminProp(Details);
|
const MonitorDetailsWithAdminProp = withAdminProp(Details);
|
||||||
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
||||||
const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
const PageSpeedDetailsWithAdminProp = withAdminProp(PageSpeedDetails);
|
||||||
|
// const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
||||||
const SettingsWithAdminProp = withAdminProp(Settings);
|
const SettingsWithAdminProp = withAdminProp(Settings);
|
||||||
|
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
@@ -64,7 +65,7 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/monitors/:monitorId/"
|
path="/monitors/:monitorId/"
|
||||||
element={<ProtectedRoute Component={DetailsWithAdminProp} />}
|
element={<ProtectedRoute Component={MonitorDetailsWithAdminProp} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/monitors/configure/:monitorId/"
|
path="/monitors/configure/:monitorId/"
|
||||||
@@ -117,7 +118,9 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="pagespeed/:monitorId"
|
path="pagespeed/:monitorId"
|
||||||
element={<ProtectedRoute Component={PageSpeedDetails} />}
|
element={
|
||||||
|
<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="pagespeed/configure/:monitorId"
|
path="pagespeed/configure/:monitorId"
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ const PageSpeedConfigure = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Editting...
|
Editing...
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import PieChart from "./Charts/PieChart";
|
|||||||
import useUtils from "../../Monitors/utils";
|
import useUtils from "../../Monitors/utils";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const PageSpeedDetails = () => {
|
const PageSpeedDetails = ({ isAdmin }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
||||||
@@ -157,25 +157,27 @@ const PageSpeedDetails = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
{isAdmin && (
|
||||||
variant="contained"
|
<Button
|
||||||
color="secondary"
|
variant="contained"
|
||||||
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
|
color="secondary"
|
||||||
sx={{
|
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
|
||||||
ml: "auto",
|
sx={{
|
||||||
alignSelf: "flex-end",
|
ml: "auto",
|
||||||
px: theme.spacing(5),
|
alignSelf: "flex-end",
|
||||||
"& svg": {
|
px: theme.spacing(5),
|
||||||
mr: theme.spacing(3),
|
"& svg": {
|
||||||
"& path": {
|
mr: theme.spacing(3),
|
||||||
stroke: theme.palette.other.icon,
|
"& path": {
|
||||||
|
stroke: theme.palette.other.icon,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<SettingsIcon />
|
||||||
<SettingsIcon />
|
Configure
|
||||||
Configure
|
</Button>
|
||||||
</Button>
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" gap={theme.spacing(8)}>
|
<Stack direction="row" gap={theme.spacing(8)}>
|
||||||
<StatBox>
|
<StatBox>
|
||||||
@@ -393,6 +395,7 @@ const PageSpeedDetails = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PageSpeedDetails.propTypes = {
|
PageSpeedDetails.propTypes = {
|
||||||
|
isAdmin: PropTypes.bool,
|
||||||
push: PropTypes.func,
|
push: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -87,14 +87,16 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
mt={theme.spacing(5)}
|
mt={theme.spacing(5)}
|
||||||
>
|
>
|
||||||
<Greeting type="pagespeed" />
|
<Greeting type="pagespeed" />
|
||||||
<Button
|
{isAdmin && (
|
||||||
variant="contained"
|
<Button
|
||||||
color="primary"
|
variant="contained"
|
||||||
onClick={() => navigate("/pagespeed/create")}
|
color="primary"
|
||||||
sx={{ whiteSpace: "nowrap" }}
|
onClick={() => navigate("/pagespeed/create")}
|
||||||
>
|
sx={{ whiteSpace: "nowrap" }}
|
||||||
Create new
|
>
|
||||||
</Button>
|
Create new
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Grid container spacing={theme.spacing(12)}>
|
<Grid container spacing={theme.spacing(12)}>
|
||||||
|
|||||||
Reference in new issue
Block a user