diff --git a/Client/src/Pages/StatusPage/Status/Components/AdminLink/index.jsx b/Client/src/Pages/StatusPage/Status/Components/AdminLink/index.jsx
new file mode 100644
index 000000000..5f5941fe7
--- /dev/null
+++ b/Client/src/Pages/StatusPage/Status/Components/AdminLink/index.jsx
@@ -0,0 +1,34 @@
+// Components
+import { Box, Typography } from "@mui/material";
+
+// Utils
+import { useTheme } from "@mui/material/styles";
+import { useNavigate } from "react-router-dom";
+
+const AdminLink = () => {
+ const theme = useTheme();
+ const navigate = useNavigate();
+
+ return (
+
+
+ Administrator?
+
+ navigate("/login")}
+ >
+ Login here
+
+
+ );
+};
+
+export default AdminLink;
diff --git a/Client/src/Pages/StatusPage/Status/index.jsx b/Client/src/Pages/StatusPage/Status/index.jsx
index de2c6ccfa..4ea3aa4a8 100644
--- a/Client/src/Pages/StatusPage/Status/index.jsx
+++ b/Client/src/Pages/StatusPage/Status/index.jsx
@@ -2,8 +2,7 @@
import { Typography, Stack, Box } from "@mui/material";
import GenericFallback from "../../../Components/GenericFallback";
import Fallback from "../../../Components/Fallback";
-import CheckCircleIcon from "@mui/icons-material/CheckCircle";
-import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
+import AdminLink from "./Components/AdminLink";
import ControlsHeader from "./Components/ControlsHeader";
import SkeletonLayout from "./Components/Skeleton";
import StatusBar from "./Components/StatusBar";
@@ -19,7 +18,6 @@ import { useStatusPageDelete } from "./Hooks/useStatusPageDelete";
const PublicStatus = () => {
// Local state
- const [status, setStatus] = useState(undefined);
// Utils
const theme = useTheme();
@@ -28,13 +26,11 @@ const PublicStatus = () => {
useStatusPageFetch();
const [deleteStatusPage, isDeleting] = useStatusPageDelete(fetchStatusPage);
const location = useLocation();
- const navigate = useNavigate();
// Setup
const currentPath = location.pathname;
let sx = { paddingLeft: theme.spacing(20), paddingRight: theme.spacing(20) };
- let AdminLink = undefined;
-
+ let link = undefined;
// Public status page
if (currentPath === "/status/public") {
sx = {
@@ -42,70 +38,15 @@ const PublicStatus = () => {
paddingLeft: "20vw",
paddingRight: "20vw",
};
- AdminLink = (
-
-
- Administrator?
-
- navigate("/login")}
- >
- Login here
-
-
- );
+ link = ;
}
- // Effects
- useEffect(() => {
- if (typeof monitors === "undefined") return;
- const monitorsStatus = {
- icon: (
-
- ),
- };
- if (monitors.every((monitor) => monitor.status === true)) {
- monitorsStatus.msg = "All systems operational";
- monitorsStatus.color = theme.palette.success.lowContrast;
- monitorsStatus.icon = (
-
- );
- }
-
- if (monitors.every((monitor) => monitor.status === false)) {
- monitorsStatus.msg = "All systems down";
- monitorsStatus.color = theme.palette.error.lowContrast;
- }
-
- if (monitors.some((monitor) => monitor.status === false)) {
- monitorsStatus.msg = "Degraded performance";
- monitorsStatus.color = theme.palette.warning.lowContrast;
- }
-
- // Paused or unknown
- if (monitors.some((monitor) => typeof monitor.status === "undefined")) {
- monitorsStatus.msg = "Unknown status";
- monitorsStatus.color = theme.palette.warning.lowContrast;
- }
- setStatus(monitorsStatus);
- }, [monitors, theme]);
-
+ // Loading
if (isLoading) {
return ;
}
+ // Error fetching data
if (networkError === true) {
return (
@@ -121,7 +62,12 @@ const PublicStatus = () => {
);
}
- if (!isLoading && typeof status === "undefined" && currentPath === "/status/public") {
+ // Public status page fallback
+ if (
+ !isLoading &&
+ typeof statusPage === "undefined" &&
+ currentPath === "/status/public"
+ ) {
return (
@@ -138,21 +84,12 @@ const PublicStatus = () => {
);
}
- if (!isLoading && typeof statusPage === "undefined") {
- return (
-
- );
- }
-
- if (!isLoading && statusPage.isPublic === false) {
+ // Finished loading, but status page is not public
+ if (
+ !isLoading &&
+ currentPath === "/status/public" &&
+ statusPage.isPublished === false
+ ) {
return (
@@ -169,6 +106,21 @@ const PublicStatus = () => {
);
}
+ // Status page doesn't exist
+ if (!isLoading && typeof statusPage === "undefined") {
+ return (
+
+ );
+ }
+
return (
{
isDeleting={isDeleting}
/>
Service status
-
+
- {AdminLink}
+ {link}
);
};