Merge pull request #1369 from bluewave-labs/refactor/routes
Refactor/routes
This commit is contained in:
11 files changed
+209
-240
No files matched your search
+3
-195
@@ -1,37 +1,8 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { Routes, Route, Navigate } from "react-router-dom";
|
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
import { ToastContainer } from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
import NotFound from "./Pages/NotFound";
|
|
||||||
import Login from "./Pages/Auth/Login";
|
|
||||||
import Register from "./Pages/Auth/Register/Register";
|
|
||||||
import Account from "./Pages/Account";
|
|
||||||
import Uptime from "./Pages/Uptime/Home";
|
|
||||||
import CreateMonitor from "./Pages/Uptime/CreateUptime";
|
|
||||||
import CreateInfrastructureMonitor from "./Pages/Infrastructure/CreateMonitor";
|
|
||||||
import Incidents from "./Pages/Incidents";
|
|
||||||
import Status from "./Pages/Status";
|
|
||||||
import Integrations from "./Pages/Integrations";
|
|
||||||
import Settings from "./Pages/Settings";
|
|
||||||
import ForgotPassword from "./Pages/Auth/ForgotPassword";
|
|
||||||
import CheckEmail from "./Pages/Auth/CheckEmail";
|
|
||||||
import SetNewPassword from "./Pages/Auth/SetNewPassword";
|
|
||||||
import NewPasswordConfirmed from "./Pages/Auth/NewPasswordConfirmed";
|
|
||||||
import ProtectedRoute from "./Components/ProtectedRoute";
|
|
||||||
import UptimeDetails from "./Pages/Uptime/Details";
|
|
||||||
import AdvancedSettings from "./Pages/AdvancedSettings";
|
|
||||||
import Maintenance from "./Pages/Maintenance";
|
|
||||||
import Configure from "./Pages/Uptime/Configure";
|
|
||||||
import PageSpeed from "./Pages/PageSpeed";
|
|
||||||
import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed";
|
|
||||||
import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenance";
|
|
||||||
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
|
||||||
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
|
||||||
import HomeLayout from "./Components/Layouts/HomeLayout";
|
|
||||||
import withAdminCheck from "./Components/HOC/withAdminCheck";
|
|
||||||
import withAdminProp from "./Components/HOC/withAdminProp";
|
|
||||||
import { ThemeProvider } from "@emotion/react";
|
import { ThemeProvider } from "@emotion/react";
|
||||||
import lightTheme from "./Utils/Theme/lightTheme";
|
import lightTheme from "./Utils/Theme/lightTheme";
|
||||||
import darkTheme from "./Utils/Theme/darkTheme";
|
import darkTheme from "./Utils/Theme/darkTheme";
|
||||||
@@ -39,18 +10,9 @@ import { CssBaseline, GlobalStyles } from "@mui/material";
|
|||||||
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
||||||
import { logger } from "./Utils/Logger"; // Import the logger
|
import { logger } from "./Utils/Logger"; // Import the logger
|
||||||
import { networkService } from "./main";
|
import { networkService } from "./main";
|
||||||
import { Infrastructure } from "./Pages/Infrastructure";
|
import { Routes } from "./Routes";
|
||||||
import InfrastructureDetails from "./Pages/Infrastructure/Details";
|
|
||||||
function App() {
|
function App() {
|
||||||
const AdminCheckedRegister = withAdminCheck(Register);
|
|
||||||
const UptimeWithAdminProp = withAdminProp(Uptime);
|
|
||||||
const UptimeDetailsWithAdminProp = withAdminProp(UptimeDetails);
|
|
||||||
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
|
||||||
const PageSpeedDetailsWithAdminProp = withAdminProp(PageSpeedDetails);
|
|
||||||
const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
|
||||||
const SettingsWithAdminProp = withAdminProp(Settings);
|
|
||||||
const AdvancedSettingsWithAdminProp = withAdminProp(AdvancedSettings);
|
|
||||||
const InfrastructureDetailsWithAdminProp = withAdminProp(InfrastructureDetails);
|
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -82,161 +44,7 @@ function App() {
|
|||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/* Extract Routes to Routes */}
|
<Routes />
|
||||||
<Routes>
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path="/"
|
|
||||||
element={<HomeLayout />}
|
|
||||||
>
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path="/"
|
|
||||||
element={<Navigate to="/uptime" />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/uptime"
|
|
||||||
element={<ProtectedRoute Component={UptimeWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/uptime/create/:monitorId?"
|
|
||||||
element={<ProtectedRoute Component={CreateMonitor} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/uptime/:monitorId/"
|
|
||||||
element={<ProtectedRoute Component={UptimeDetailsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/uptime/configure/:monitorId/"
|
|
||||||
element={<ProtectedRoute Component={Configure} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/create"
|
|
||||||
element={<ProtectedRoute Component={CreatePageSpeed} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/:monitorId"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="pagespeed/configure/:monitorId"
|
|
||||||
element={<ProtectedRoute Component={PageSpeedConfigure} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="infrastructure"
|
|
||||||
element={<ProtectedRoute Component={Infrastructure} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="infrastructure/create"
|
|
||||||
element={<ProtectedRoute Component={CreateInfrastructureMonitor} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="infrastructure/:monitorId"
|
|
||||||
element={<ProtectedRoute Component={InfrastructureDetailsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
path="incidents/:monitorId?"
|
|
||||||
element={<ProtectedRoute Component={Incidents} />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
path="status"
|
|
||||||
element={<ProtectedRoute Component={Status} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="integrations"
|
|
||||||
element={<ProtectedRoute Component={Integrations} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="maintenance"
|
|
||||||
element={<ProtectedRoute Component={MaintenanceWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/maintenance/create/:maintenanceWindowId?"
|
|
||||||
element={<CreateNewMaintenanceWindow />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="settings"
|
|
||||||
element={<ProtectedRoute Component={SettingsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="advanced-settings"
|
|
||||||
element={<ProtectedRoute Component={AdvancedSettingsWithAdminProp} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="account/profile"
|
|
||||||
element={
|
|
||||||
<ProtectedRoute
|
|
||||||
Component={Account}
|
|
||||||
open="profile"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="account/password"
|
|
||||||
element={
|
|
||||||
<ProtectedRoute
|
|
||||||
Component={Account}
|
|
||||||
open="password"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="account/team"
|
|
||||||
element={
|
|
||||||
<ProtectedRoute
|
|
||||||
Component={Account}
|
|
||||||
open="team"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Route>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path="/login"
|
|
||||||
element={<Login />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path="/register"
|
|
||||||
element={<AdminCheckedRegister />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path="/register/:token"
|
|
||||||
element={<Register />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
path="*"
|
|
||||||
element={<NotFound />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
path="/forgot-password"
|
|
||||||
element={<ForgotPassword />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/check-email"
|
|
||||||
element={<CheckEmail />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/set-new-password/:token"
|
|
||||||
element={<SetNewPassword />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/new-password-confirmed"
|
|
||||||
element={<NewPasswordConfirmed />}
|
|
||||||
/>
|
|
||||||
</Routes>
|
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
import { useSelector } from "react-redux";
|
|
||||||
|
|
||||||
const withAdminProp = (WrappedComponent) => {
|
|
||||||
const WithAdminProp = (props) => {
|
|
||||||
const { user } = useSelector((state) => state.auth);
|
|
||||||
const isAdmin =
|
|
||||||
(user?.role?.includes("admin") ?? false) ||
|
|
||||||
(user?.role?.includes("superadmin") ?? false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<WrappedComponent
|
|
||||||
{...props}
|
|
||||||
isAdmin={isAdmin}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrappedComponentName =
|
|
||||||
WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
||||||
WithAdminProp.displayName = `WithAdminProp(${wrappedComponentName})`;
|
|
||||||
|
|
||||||
return WithAdminProp;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withAdminProp;
|
|
||||||
@@ -3,21 +3,20 @@ import { useSelector } from "react-redux";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProtectedRoute is a higher-order component that wraps the `Route` component from `react-router-dom`
|
* ProtectedRoute is a wrapper component that ensures only authenticated users
|
||||||
* to create a protected route. It uses Redux to check if the user is authenticated. If the user is
|
* can access the wrapped content. It checks authentication status (e.g., from Redux or Context).
|
||||||
* authenticated, it renders the component passed to it; otherwise, it redirects the user to the login page.
|
* If the user is authenticated, it renders the children; otherwise, it redirects to the login page.
|
||||||
*
|
*
|
||||||
* @param {Object} props - The props passed to the ProtectedRoute component.
|
* @param {Object} props - The props passed to the ProtectedRoute component.
|
||||||
* @param {React.ComponentType} props.Component - The component to render if the user is authenticated.
|
* @param {React.ReactNode} props.children - The children to render if the user is authenticated.
|
||||||
* @param {Object} rest - The remaining props passed to the Route component.
|
* @returns {React.ReactElement} The children wrapped in a protected route or a redirect to the login page.
|
||||||
* @returns {React.ReactElement} A Route component that conditionally renders the passed Component or redirects to the login page.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ProtectedRoute = ({ Component, ...rest }) => {
|
const ProtectedRoute = ({ children }) => {
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
|
|
||||||
return authState.authToken ? (
|
return authState.authToken ? (
|
||||||
<Component {...rest} />
|
children
|
||||||
) : (
|
) : (
|
||||||
<Navigate
|
<Navigate
|
||||||
to="/login"
|
to="/login"
|
||||||
@@ -27,7 +26,7 @@ const ProtectedRoute = ({ Component, ...rest }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ProtectedRoute.propTypes = {
|
ProtectedRoute.propTypes = {
|
||||||
Component: PropTypes.elementType.isRequired,
|
children: PropTypes.elementType.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProtectedRoute;
|
export default ProtectedRoute;
|
||||||
@@ -14,10 +14,11 @@ import { useState, useEffect } from "react";
|
|||||||
import Select from "../../Components/Inputs/Select";
|
import Select from "../../Components/Inputs/Select";
|
||||||
import { advancedSettingsValidation } from "../../Validation/validation";
|
import { advancedSettingsValidation } from "../../Validation/validation";
|
||||||
import { buildErrors, hasValidationErrors } from "../../Validation/error";
|
import { buildErrors, hasValidationErrors } from "../../Validation/error";
|
||||||
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
const AdvancedSettings = ({ isAdmin }) => {
|
const AdvancedSettings = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
|||||||
@@ -8,13 +8,14 @@ import { useSelector } from "react-redux";
|
|||||||
import { networkService } from "../../main";
|
import { networkService } from "../../main";
|
||||||
import Breadcrumbs from "../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../Components/Breadcrumbs";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
const Maintenance = ({ isAdmin }) => {
|
const Maintenance = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
||||||
const [maintenanceWindowCount, setMaintenanceWindowCount] = useState(0);
|
const [maintenanceWindowCount, setMaintenanceWindowCount] = useState(0);
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
@@ -99,7 +100,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
"Stop sending alerts in maintenance windows",
|
"Stop sending alerts in maintenance windows",
|
||||||
]}
|
]}
|
||||||
link="/maintenance/create"
|
link="/maintenance/create"
|
||||||
isAdmin={true}
|
isAdmin={isAdmin}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ import Checkbox from "../../../Components/Inputs/Checkbox";
|
|||||||
import PieChart from "./Charts/PieChart";
|
import PieChart from "./Charts/PieChart";
|
||||||
import useUtils from "../../Uptime/utils";
|
import useUtils from "../../Uptime/utils";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
const PageSpeedDetails = ({ isAdmin }) => {
|
const PageSpeedDetails = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
const { statusColor, pagespeedStatusMsg, determineState } = useUtils();
|
||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const [audits, setAudits] = useState({});
|
const [audits, setAudits] = useState({});
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ import SkeletonLayout from "./skeleton";
|
|||||||
import Card from "./card";
|
import Card from "./card";
|
||||||
import { networkService } from "../../main";
|
import { networkService } from "../../main";
|
||||||
import { Heading } from "../../Components/Heading";
|
import { Heading } from "../../Components/Heading";
|
||||||
const PageSpeed = ({ isAdmin }) => {
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
|
const PageSpeed = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [monitors, setMonitors] = useState([]);
|
const [monitors, setMonitors] = useState([]);
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ import { networkService } from "../../main";
|
|||||||
import { settingsValidation } from "../../Validation/validation";
|
import { settingsValidation } from "../../Validation/validation";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import Dialog from "../../Components/Dialog";
|
import Dialog from "../../Components/Dialog";
|
||||||
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
const SECONDS_PER_DAY = 86400;
|
const SECONDS_PER_DAY = 86400;
|
||||||
|
|
||||||
const Settings = ({ isAdmin }) => {
|
const Settings = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
const { checkTTL } = user;
|
const { checkTTL } = user;
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
|
|||||||
@@ -32,14 +32,16 @@ import SkeletonLayout from "./skeleton";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import useUtils from "../utils";
|
import useUtils from "../utils";
|
||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details page component displaying monitor details and related information.
|
* Details page component displaying monitor details and related information.
|
||||||
* @component
|
* @component
|
||||||
*/
|
*/
|
||||||
const DetailsPage = ({ isAdmin }) => {
|
const DetailsPage = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { statusColor, statusStyles, statusMsg, determineState } = useUtils();
|
const { statusColor, statusStyles, statusMsg, determineState } = useUtils();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import StatusBox from "./StatusBox";
|
|||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import Greeting from "../../../Utils/greeting";
|
import Greeting from "../../../Utils/greeting";
|
||||||
import { CurrentMonitoring } from "./CurrentMonitoring";
|
import { CurrentMonitoring } from "./CurrentMonitoring";
|
||||||
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
|
|
||||||
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
|
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
|
||||||
|
|
||||||
const UptimeMonitors = ({ isAdmin }) => {
|
const UptimeMonitors = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
const uptimeMonitorsState = useSelector((state) => state.uptimeMonitors);
|
const uptimeMonitorsState = useSelector((state) => state.uptimeMonitors);
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const dispatch = useDispatch({});
|
const dispatch = useDispatch({});
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
import { Navigate, Route, Routes as LibRoutes } from "react-router";
|
||||||
|
import HomeLayout from "../Components/Layouts/HomeLayout";
|
||||||
|
import { Infrastructure } from "../Pages/Infrastructure";
|
||||||
|
import InfrastructureDetails from "../Pages/Infrastructure/Details";
|
||||||
|
import NotFound from "../Pages/NotFound";
|
||||||
|
import Login from "../Pages/Auth/Login";
|
||||||
|
import Register from "../Pages/Auth/Register/Register";
|
||||||
|
import Account from "../Pages/Account";
|
||||||
|
import Monitors from "../Pages/Uptime/Home";
|
||||||
|
import CreateMonitor from "../Pages/Uptime/CreateUptime";
|
||||||
|
import CreateInfrastructureMonitor from "../Pages/Infrastructure/CreateMonitor";
|
||||||
|
import Incidents from "../Pages/Incidents";
|
||||||
|
import Status from "../Pages/Status";
|
||||||
|
import Integrations from "../Pages/Integrations";
|
||||||
|
import Settings from "../Pages/Settings";
|
||||||
|
import ForgotPassword from "../Pages/Auth/ForgotPassword";
|
||||||
|
import CheckEmail from "../Pages/Auth/CheckEmail";
|
||||||
|
import SetNewPassword from "../Pages/Auth/SetNewPassword";
|
||||||
|
import NewPasswordConfirmed from "../Pages/Auth/NewPasswordConfirmed";
|
||||||
|
import ProtectedRoute from "../Components/ProtectedRoute";
|
||||||
|
import Details from "../Pages/Uptime/Details";
|
||||||
|
import AdvancedSettings from "../Pages/AdvancedSettings";
|
||||||
|
import Maintenance from "../Pages/Maintenance";
|
||||||
|
import Configure from "../Pages/Uptime/Configure";
|
||||||
|
import PageSpeed from "../Pages/PageSpeed";
|
||||||
|
import CreatePageSpeed from "../Pages/PageSpeed/CreatePageSpeed";
|
||||||
|
import CreateNewMaintenanceWindow from "../Pages/Maintenance/CreateMaintenance";
|
||||||
|
import PageSpeedDetails from "../Pages/PageSpeed/Details";
|
||||||
|
import PageSpeedConfigure from "../Pages/PageSpeed/Configure";
|
||||||
|
import withAdminCheck from "../Components/HOC/withAdminCheck";
|
||||||
|
|
||||||
|
const Routes = () => {
|
||||||
|
const AdminCheckedRegister = withAdminCheck(Register);
|
||||||
|
return (
|
||||||
|
<LibRoutes>
|
||||||
|
<Route
|
||||||
|
path="/"
|
||||||
|
element={
|
||||||
|
<ProtectedRoute>
|
||||||
|
<HomeLayout />
|
||||||
|
</ProtectedRoute>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Route
|
||||||
|
path="/"
|
||||||
|
element={<Navigate to="/uptime" />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/uptime"
|
||||||
|
element={<Monitors />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/uptime/create/:monitorId?"
|
||||||
|
element={<CreateMonitor />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/uptime/:monitorId/"
|
||||||
|
element={<Details />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/uptime/configure/:monitorId/"
|
||||||
|
element={<Configure />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed"
|
||||||
|
element={<PageSpeed />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/create"
|
||||||
|
element={<CreatePageSpeed />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/:monitorId"
|
||||||
|
element={<PageSpeedDetails />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="pagespeed/configure/:monitorId"
|
||||||
|
element={<PageSpeedConfigure />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="infrastructure"
|
||||||
|
element={<Infrastructure />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="infrastructure/create"
|
||||||
|
element={<CreateInfrastructureMonitor />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="infrastructure/:monitorId"
|
||||||
|
element={<InfrastructureDetails />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="incidents/:monitorId?"
|
||||||
|
element={<Incidents />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="status"
|
||||||
|
element={<Status />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="integrations"
|
||||||
|
element={<Integrations />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="maintenance"
|
||||||
|
element={<Maintenance />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/maintenance/create/:maintenanceWindowId?"
|
||||||
|
element={<CreateNewMaintenanceWindow />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="settings"
|
||||||
|
element={<Settings />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="advanced-settings"
|
||||||
|
element={<AdvancedSettings />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="account/profile"
|
||||||
|
element={<Account open={"profile"} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="account/password"
|
||||||
|
element={<Account open={"password"} />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="account/team"
|
||||||
|
element={<Account open={"team"} />}
|
||||||
|
/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="/login"
|
||||||
|
element={<Login />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="/register"
|
||||||
|
element={<AdminCheckedRegister />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
exact
|
||||||
|
path="/register/:token"
|
||||||
|
element={<Register />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="/forgot-password"
|
||||||
|
element={<ForgotPassword />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/check-email"
|
||||||
|
element={<CheckEmail />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/set-new-password/:token"
|
||||||
|
element={<SetNewPassword />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/new-password-confirmed"
|
||||||
|
element={<NewPasswordConfirmed />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route
|
||||||
|
path="*"
|
||||||
|
element={<NotFound />}
|
||||||
|
/>
|
||||||
|
</LibRoutes>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Routes };
|
||||||
Reference in new issue
Block a user