diff --git a/Client/src/Components/Fallback/index.jsx b/Client/src/Components/Fallback/index.jsx index 55e22cd68..d68237bf0 100644 --- a/Client/src/Components/Fallback/index.jsx +++ b/Client/src/Components/Fallback/index.jsx @@ -20,7 +20,7 @@ import "./index.css"; * @returns {JSX.Element} The rendered fallback UI. */ -const Fallback = ({ title, checks, link = "/", isAdmin }) => { +const Fallback = ({ title, checks, link = "/", isAdmin, ovalStart }) => { const theme = useTheme(); const navigate = useNavigate(); const mode = useSelector((state) => state.ui.mode); @@ -48,7 +48,7 @@ const Fallback = ({ title, checks, link = "/", isAdmin }) => { { marginY={theme.spacing(4)} color={theme.palette.text.tertiary} > - A {title} is used to: + {ovalStart ? "An" : "A"} {title} is used to: {checks.map((check, index) => ( navigate("/infrastructure/create"); @@ -99,6 +102,7 @@ function Infrastructure() { const fetchMonitors = async () => { try { + setIsLoading(true); const response = await networkService.getMonitorsByTeamId({ authToken, teamId: user.teamId, @@ -116,6 +120,8 @@ function Infrastructure() { }); } catch (error) { console.error(error); + } finally { + setIsLoading(false); } }; @@ -165,168 +171,200 @@ function Infrastructure() { }; }); + let isActuallyLoading = isLoading && monitorState.monitors?.length === 0; return ( - [class*="fallback__"])': { + position: "relative", + border: 1, + borderColor: theme.palette.border.light, + borderRadius: theme.shape.borderRadius, + borderStyle: "dashed", + backgroundColor: theme.palette.background.main, + overflow: "hidden", + }, + }} > - - - {/* + {isActuallyLoading ? ( + + ) : monitorState.monitors?.length !== 0 ? ( + + + + {/* This will be removed from here, but keeping the commented code to remind me to add a max width to the greeting component */} - - - - - Infrastructure monitors - {/* TODO Correct the class current-monitors-counter, there are some unnecessary things there */} - + Create infrastructure monitor + + + - {totalMonitors} - - - - - - - {columns.map((column, index) => ( - - {column.label} - - ))} - - - - {monitorsAsRows.map((row) => { - return ( - openDetails(row.id)} - sx={{ - cursor: "pointer", - "&:hover": { - backgroundColor: theme.palette.background.accent, - }, - }} - > - {/* TODO iterate over column and get column id, applying row[column.id] */} - - - - - - - - - - {row.processor} - - - - - - - - - - - - - {/* Get ActionsMenu from Monitor Table and create a component */} - + Infrastructure monitors + {/* TODO Correct the class current-monitors-counter, there are some unnecessary things there */} + + {totalMonitors} + + + +
+ + + {columns.map((column, index) => ( + + {column.label} + + ))} + + + + {monitorsAsRows.map((row) => { + return ( + openDetails(row.id)} + sx={{ + cursor: "pointer", + "&:hover": { + backgroundColor: theme.palette.background.accent, }, }} > - - {/* + + + + + + + + + {row.processor} + + + + + + + + + + + + + {/* Get ActionsMenu from Monitor Table and create a component */} + + + {/* */} - - - - ); - })} - -
-
- + + + ); + })} + + + + +
+
+ ) : ( + -
-
+ )} + ); } diff --git a/Client/src/Pages/Infrastructure/skeleton.jsx b/Client/src/Pages/Infrastructure/skeleton.jsx new file mode 100644 index 000000000..b6d29dc38 --- /dev/null +++ b/Client/src/Pages/Infrastructure/skeleton.jsx @@ -0,0 +1,73 @@ +import { Box, Skeleton, Stack } from "@mui/material"; +import { useTheme } from "@emotion/react"; + +/** + * Renders a skeleton layout. + * + * @returns {JSX.Element} + */ +const SkeletonLayout = () => { + const theme = useTheme(); + + return ( + + + + + + + + + + + + + + + + ); +}; + +export default SkeletonLayout;