From 0a11de47d77cb442885294b140feb68ccb0206fa Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 30 Aug 2024 10:09:38 -0700 Subject: [PATCH] Add admin guard to settings route, conditionally render config option --- Client/src/App.jsx | 3 +- Client/src/Pages/Settings/index.jsx | 66 ++++++++++++++++------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Client/src/App.jsx b/Client/src/App.jsx index 88e1e7019..783f28330 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -39,6 +39,7 @@ function App() { const DetailsWithAdminProp = withAdminProp(Details); const PageSpeedWithAdminProp = withAdminProp(PageSpeed); const MaintenanceWithAdminProp = withAdminProp(Maintenance); + const SettingsWithAdminProp = withAdminProp(Settings); const mode = useSelector((state) => state.ui.mode); @@ -90,7 +91,7 @@ function App() { /> } + element={} /> { +import PropTypes from "prop-types"; +const Settings = ({ isAdmin }) => { const theme = useTheme(); const { user, authToken } = useSelector((state) => state.auth); const { isLoading } = useSelector((state) => state.uptimeMonitors); @@ -102,37 +103,39 @@ const Settings = () => { /> - - - History and monitoring - - Define here for how long you want to keep the data. You can also - remove all past data. - - - - logger.warn("Disabled")} - /> + {isAdmin && ( + - Clear all stats. This is irreversible. - + History and monitoring + + Define here for how long you want to keep the data. You can also + remove all past data. + - - + + logger.warn("Disabled")} + /> + + Clear all stats. This is irreversible. + + + + + )} About @@ -163,4 +166,7 @@ const Settings = () => { ); }; +Settings.propTypes = { + isAdmin: PropTypes.bool, +}; export default Settings;