diff --git a/Client/src/Pages/Monitors/Home/MonitorTable/Skeleton/index.jsx b/Client/src/Pages/Monitors/Home/MonitorTable/Skeleton/index.jsx
index 186b89725..e30e0a255 100644
--- a/Client/src/Pages/Monitors/Home/MonitorTable/Skeleton/index.jsx
+++ b/Client/src/Pages/Monitors/Home/MonitorTable/Skeleton/index.jsx
@@ -1,10 +1,10 @@
-import { Skeleton, TableBody, TableCell, TableRow } from "@mui/material";
+import { Skeleton, TableCell, TableRow } from "@mui/material";
const ROWS_NUMBER = 7;
const ROWS_ARRAY = Array.from({ length: ROWS_NUMBER }, (_, i) => i);
const TableBodySkeleton = () => {
return (
-
+ <>
{ROWS_ARRAY.map((row) => (
@@ -24,7 +24,7 @@ const TableBodySkeleton = () => {
))}
-
+ >
);
};
diff --git a/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx b/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
index 4e8f5100b..b5e36f634 100644
--- a/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
+++ b/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
@@ -12,6 +12,7 @@ import {
Stack,
Typography,
Button,
+ CircularProgress,
} from "@mui/material";
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
@@ -108,7 +109,7 @@ TablePaginationActions.propTypes = {
onPageChange: PropTypes.func.isRequired,
};
-const MonitorTable = ({ isAdmin, filter, setLoading }) => {
+const MonitorTable = ({ isAdmin, filter, setLoading, isSearching }) => {
const theme = useTheme();
const navigate = useNavigate();
const dispatch = useDispatch();
@@ -221,7 +222,37 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
};
return (
- <>
+
+ {isSearching && (
+ <>
+
+
+
+
+ >
+ )}
@@ -271,9 +302,10 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
Actions
- {monitors.length > 0 ? (
-
- {monitors.map((monitor) => {
+
+ {/* TODO add empty state. Check if is searching, and empty => skeleton. Is empty, not searching => skeleton */}
+ {monitors.length > 0 ? (
+ monitors.map((monitor) => {
let uptimePercentage = "";
let percentageColor = theme.palette.percentage.uptimeExcellent;
@@ -343,11 +375,11 @@ const MonitorTable = ({ isAdmin, filter, setLoading }) => {
);
- })}
-
- ) : (
-
- )}
+ })
+ ) : (
+
+ )}
+
{
}}
/>
- >
+
);
};
@@ -428,6 +460,7 @@ MonitorTable.propTypes = {
isAdmin: PropTypes.bool,
filter: PropTypes.string,
setLoading: PropTypes.func,
+ isSearching: PropTypes.bool,
};
const MemoizedMonitorTable = memo(MonitorTable);
diff --git a/Client/src/Pages/Monitors/Home/index.jsx b/Client/src/Pages/Monitors/Home/index.jsx
index e52556bb9..c2413f6cc 100644
--- a/Client/src/Pages/Monitors/Home/index.jsx
+++ b/Client/src/Pages/Monitors/Home/index.jsx
@@ -4,7 +4,7 @@ import { useSelector, useDispatch } from "react-redux";
import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { useNavigate } from "react-router-dom";
import { useTheme } from "@emotion/react";
-import { Box, Button, CircularProgress, Stack, Typography } from "@mui/material";
+import { Box, Button, Stack, Typography } from "@mui/material";
import PropTypes from "prop-types";
import SkeletonLayout from "./skeleton";
import Fallback from "./fallback";
@@ -36,17 +36,15 @@ const Monitors = ({ isAdmin }) => {
dispatch(getUptimeMonitorsByTeamId(authState.authToken));
}, [authState.authToken, dispatch]);
- //Why are we tying loading to monitors length?
- const loading =
- monitorState?.isLoading; /* && monitorState?.monitorsSummary?.monitors?.length === 0 */
+ const loading = monitorState?.isLoading;
- const hasMonitors = monitorState?.monitorsSummary?.monitors?.length !== 0;
- const noMonitors = monitorState?.monitorsSummary?.monitors?.length === 0;
+ const totalMonitors = monitorState?.monitorsSummary?.monitorCounts?.total;
+ const isTotalMonitorsUndefined = totalMonitors === undefined;
+ const hasMonitors = !isTotalMonitorsUndefined && totalMonitors !== 0;
+ const noMonitors = isTotalMonitorsUndefined || totalMonitors === 0;
const canAddMonitor = isAdmin && hasMonitors;
const needsAdmin = !isAdmin && noMonitors;
- /* console.log({ loading });
- console.log({ monitorState }); */
return (
{
borderColor={theme.palette.border.light}
backgroundColor={theme.palette.background.accent}
>
- {/* TODO maybe we dont need the conditional here, since we already check for monitors before */}
- {monitorState?.monitorsSummary?.monitorCounts?.total || 0}
+ {totalMonitors}
{
ml="auto"
>
-
- {isSearching && (
- <>
-
-
-
-
- >
- )}
-
-
+
>
)}