defensive checks

This commit is contained in:
Alex Holliday committed 2025-12-31 20:51:30 +00:00
1 parent 86cfc89545
commit 7f15811fdf
11 files changed
+57 -20

No files matched your search

+1 -1
View File
@@ -39,7 +39,7 @@ const DockerDetailsPage = () => {
const monitor = response?.data?.monitor;
const stats = response?.data?.stats;
const checks = (response?.data?.checks || []) as any;
const snapshot = monitor?.latestChecks?.[0].dockerContainers || [];
const snapshot = monitor?.latestChecks?.[0]?.dockerContainers ?? [];
const palette = getStatusPalette(monitor?.status || "initializing");
const streakDuration = stats?.currentStreakStartedAt
@@ -106,7 +106,9 @@ export const DockerMonitorsTable = ({
{t("common.table.headers.status")}
</Typography>
),
render: (row) => <StatusLabel status={row.status} />,
render: (row) => (
<StatusLabel status={(row.status as any) ?? ("initializing" as any)} />
),
},
{
id: "runningContainers",
@@ -116,7 +118,6 @@ export const DockerMonitorsTable = ({
</Typography>
),
render: (row) => {
console.log(row);
const containerCount = (
row.latestChecks?.[0]?.dockerContainers || []
).filter((c: any) => c?.running).length;
@@ -193,7 +193,9 @@ export const InfraMonitorsTable = ({
</Typography>
),
render: (row) => {
return <StatusLabel status={row.status} />;
return (
<StatusLabel status={(row.status as any) ?? ("initializing" as any)} />
);
},
},
{
@@ -204,7 +204,7 @@ export const PageSpeedMonitorTable = ({
return (
<Stack alignItems={"center"}>
<HistogramPageSpeed
checks={row.latestChecks}
checks={row.latestChecks ?? []}
status={row.status}
/>
</Stack>
@@ -20,7 +20,7 @@ const StatusPageConfigPage = () => {
);
const monitors = response?.data || [];
const initialData = statusPageResponse?.data;
const initialData = statusPageResponse?.data || {};
initialData.monitors =
initialData?.monitors?.map((monitor: IMonitor) => monitor?._id) || [];
@@ -16,7 +16,7 @@ const GLOBAL_REFRESH = config.GLOBAL_REFRESH;
const StatusPages = () => {
const theme = useTheme();
const { id } = useParams();
const { response } = useGet<ApiResponse<IStatusPageWithMonitors>>(
const { response, loading } = useGet<ApiResponse<IStatusPageWithMonitors>>(
`/status-pages/${id}`,
{},
{ refreshInterval: GLOBAL_REFRESH, keepPreviousData: true }
@@ -29,7 +29,7 @@ const StatusPages = () => {
}
return (
<BasePage alignItems={"center"}>
<BasePage alignItems={"center"} loading={loading}>
<Stack minWidth={"66vw"} spacing={theme.spacing(8)}>
<NameHeader statusPage={statusPage} />
<StatusHeader statusPage={statusPage} />
@@ -206,9 +206,9 @@ export const MonitorTable = ({
content: t("monitors.uptime.table.headers.responseTime"),
render: (row) => {
if (chartType === "histogram") {
return <HistogramResponseTime checks={row.latestChecks} />;
return <HistogramResponseTime checks={row.latestChecks ?? []} />;
} else {
return <HeatmapResponseTime checks={row.latestChecks} />;
return <HeatmapResponseTime checks={row.latestChecks ?? []} />;
}
},
},