feat: incident skeleton adjustement
This commit is contained in:
1 parent
a20db6df51
commit
4bf3ce6781
5 files changed
+109
-28
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import PlaceholderLight from "../../../../assets/Images/data_placeholder.svg?react";
|
||||||
|
import PlaceholderDark from "../../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Box, Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const Empty = ({ styles, mode }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<Box sx={{ ...styles }}>
|
||||||
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
pb={theme.spacing(20)}
|
||||||
|
>
|
||||||
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
|
</Box>
|
||||||
|
<Typography
|
||||||
|
textAlign="center"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
No incidents recorded yet.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Empty.propTypes = {
|
||||||
|
styles: PropTypes.object,
|
||||||
|
mode: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Empty };
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Skeleton /* , Stack */ } from "@mui/material";
|
||||||
|
const IncidentSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { IncidentSkeleton };
|
||||||
@@ -24,6 +24,8 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
||||||
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Empty } from "./Empty/Empty";
|
||||||
|
import { IncidentSkeleton } from "./Skeleton/Skeleton";
|
||||||
|
|
||||||
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
@@ -37,6 +39,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
page: 0,
|
page: 0,
|
||||||
rowsPerPage: 14,
|
rowsPerPage: 14,
|
||||||
});
|
});
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPaginationController((prevPaginationController) => ({
|
setPaginationController((prevPaginationController) => ({
|
||||||
@@ -51,6 +54,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
let res;
|
let res;
|
||||||
if (selectedMonitor === "0") {
|
if (selectedMonitor === "0") {
|
||||||
res = await networkService.getChecksByTeam({
|
res = await networkService.getChecksByTeam({
|
||||||
@@ -79,6 +83,8 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
setChecksCount(res.data.data.checksCount);
|
setChecksCount(res.data.data.checksCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchPage();
|
fetchPage();
|
||||||
@@ -129,23 +135,31 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
p: theme.spacing(30),
|
p: theme.spacing(30),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasChecks = checks?.length === 0;
|
||||||
|
const noIncidentsRecordedYet = hasChecks && selectedMonitor === "0";
|
||||||
|
const noIncidentsForThatMonitor = hasChecks && selectedMonitor !== "0";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{checks?.length === 0 && selectedMonitor === "0" ? (
|
{isLoading ? (
|
||||||
|
<IncidentSkeleton />
|
||||||
|
) : noIncidentsRecordedYet ? (
|
||||||
|
<Empty
|
||||||
|
mode={mode}
|
||||||
|
styles={sharedStyles}
|
||||||
|
/>
|
||||||
|
) : noIncidentsForThatMonitor ? (
|
||||||
<Box sx={{ ...sharedStyles }}>
|
<Box sx={{ ...sharedStyles }}>
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
pb={theme.spacing(20)}
|
||||||
|
>
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
<Typography
|
||||||
No incidents recorded yet.
|
textAlign="center"
|
||||||
</Typography>
|
color={theme.palette.text.secondary}
|
||||||
</Box>
|
>
|
||||||
) : checks?.length === 0 ? (
|
|
||||||
<Box sx={{ ...sharedStyles }}>
|
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
|
||||||
</Box>
|
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
|
||||||
The monitor you have selected has no recorded incidents yet.
|
The monitor you have selected has no recorded incidents yet.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -182,9 +196,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{formattedDate}</TableCell>
|
<TableCell>{formattedDate}</TableCell>
|
||||||
<TableCell>
|
<TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
|
||||||
{check.statusCode ? check.statusCode : "N/A"}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{check.message}</TableCell>
|
<TableCell>{check.message}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,14 +17,15 @@ const Incidents = () => {
|
|||||||
|
|
||||||
const [monitors, setMonitors] = useState({});
|
const [monitors, setMonitors] = useState({});
|
||||||
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
||||||
const [loading, setLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
// TODO do something with these filters
|
// TODO do something with these filters
|
||||||
const [filter, setFilter] = useState("all");
|
const [filter, setFilter] = useState("all");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
setLoading(true);
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
authToken: authState.authToken,
|
authToken: authState.authToken,
|
||||||
teamId: authState.user.teamId,
|
teamId: authState.user.teamId,
|
||||||
@@ -48,25 +49,38 @@ const Incidents = () => {
|
|||||||
setMonitors(monitorLookup);
|
setMonitors(monitorLookup);
|
||||||
monitorId !== undefined && setSelectedMonitor(monitorId);
|
monitorId !== undefined && setSelectedMonitor(monitorId);
|
||||||
}
|
}
|
||||||
setLoading(false);
|
} catch (error) {
|
||||||
|
console.info(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authState]);
|
}, [authState]);
|
||||||
|
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {}, [monitors]);
|
||||||
|
|
||||||
const handleSelect = (event) => {
|
const handleSelect = (event) => {
|
||||||
setSelectedMonitor(event.target.value);
|
setSelectedMonitor(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isActuallyLoading = isLoading && Object.keys(monitors)?.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="incidents" pt={theme.spacing(6)} gap={theme.spacing(12)}>
|
<Stack
|
||||||
{loading ? (
|
className="incidents"
|
||||||
|
pt={theme.spacing(6)}
|
||||||
|
gap={theme.spacing(12)}
|
||||||
|
>
|
||||||
|
{isActuallyLoading ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={theme.spacing(6)}
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
display="inline-block"
|
display="inline-block"
|
||||||
component="h1"
|
component="h1"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [sort, setSort] = useState({});
|
const [sort, setSort] = useState({});
|
||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
const handleActionMenuDelete = () => {
|
const handleActionMenuDelete = () => {
|
||||||
setUpdateTrigger((prev) => !prev);
|
setUpdateTrigger((prev) => !prev);
|
||||||
@@ -28,22 +29,25 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMaintenanceWindows = async () => {
|
const fetchMaintenanceWindows = async () => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
const response = await networkService.getMaintenanceWindowsByTeamId({
|
const response = await networkService.getMaintenanceWindowsByTeamId({
|
||||||
authToken: authToken,
|
authToken: authToken,
|
||||||
page: page,
|
page: page,
|
||||||
rowsPerPage: rowsPerPage,
|
rowsPerPage: rowsPerPage,
|
||||||
});
|
});
|
||||||
const { maintenanceWindows, maintenanceWindowCount } =
|
const { maintenanceWindows, maintenanceWindowCount } = response.data.data;
|
||||||
response.data.data;
|
|
||||||
setMaintenanceWindows(maintenanceWindows);
|
setMaintenanceWindows(maintenanceWindows);
|
||||||
setMaintenanceWindowCount(maintenanceWindowCount);
|
setMaintenanceWindowCount(maintenanceWindowCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMaintenanceWindows();
|
fetchMaintenanceWindows();
|
||||||
}, [authToken, page, rowsPerPage, updateTrigger]);
|
}, [authToken, page, rowsPerPage, updateTrigger]);
|
||||||
|
|
||||||
|
const isActuallyLoading = isLoading && maintenanceWindows?.length === 0;
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="maintenance"
|
className="maintenance"
|
||||||
@@ -67,9 +71,7 @@ const Maintenance = ({ isAdmin }) => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
mt={theme.spacing(5)}
|
mt={theme.spacing(5)}
|
||||||
>
|
>
|
||||||
<Breadcrumbs
|
<Breadcrumbs list={[{ name: "maintenance", path: "/maintenance" }]} />
|
||||||
list={[{ name: "maintenance", path: "/maintenance" }]}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
Reference in new issue
Block a user