Skip to content

Commit fd100f4

Browse files
committed
added failed assertion checks endpoint and minor update to incident text
1 parent 900c2b7 commit fd100f4

File tree

4 files changed

+82
-3
lines changed

4 files changed

+82
-3
lines changed

apps/dashboard/src/api/endpoints/monitors/checks.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ export async function getMonitorChecks(
5656
return response?.data;
5757
}
5858

59+
/*
60+
Get Failed Monitor Checks
61+
*/
62+
63+
export interface GetFailedMonitorChecksResponse {
64+
checks: Check[];
65+
}
66+
67+
export async function getFailedMonitorChecks(
68+
teamId: number,
69+
monitorId: number,
70+
assertionId: number,
71+
offset?: number,
72+
limit?: number,
73+
): Promise<GetFailedMonitorChecksResponse> {
74+
const response = await client.get(
75+
`/v1/teams/${teamId}/monitors/${monitorId}/checks/failed/${assertionId}`,
76+
{
77+
params: {
78+
offset,
79+
limit,
80+
},
81+
},
82+
);
83+
84+
return response?.data;
85+
}
86+
87+
5988
export interface GetMonitorsIncidentsResponse {
6089
monitors: MonitorsWithIncidents[];
6190
}

apps/dashboard/src/hooks/monitors.query.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,36 @@ export const useMonitorChecks = (monitorId?: number, offset = 0, limit = 5) => {
121121
);
122122
};
123123

124+
export const useFailedMonitorChecks = (monitorId: number, assertionId: number, offset = 0, limit = 5) => {
125+
const teamId = useAuthenticationStore((state) => state.currentTeamId);
126+
127+
return useQuery(
128+
[
129+
"teams",
130+
teamId,
131+
"monitors",
132+
monitorId,
133+
"checks",
134+
"assertion",
135+
assertionId,
136+
{
137+
offset,
138+
limit,
139+
},
140+
],
141+
() => {
142+
if (!teamId || !monitorId) {
143+
return Promise.resolve(null);
144+
}
145+
146+
return MonitorsAPI.getFailedMonitorChecks(teamId, monitorId, assertionId, offset, limit);
147+
},
148+
{
149+
keepPreviousData: true,
150+
},
151+
);
152+
};
153+
124154
export const useMonitorsIncidents = () => {
125155
const teamId = useAuthenticationStore((state) => state.currentTeamId);
126156

apps/dashboard/src/pages/Dashboard/Incidents/Detail/index.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { FunctionComponent } from "react";
22
import { useMonitorIncidents } from "../../../../hooks/incidents.query";
33
import { Helmet } from "react-helmet";
4-
import { Link, NavLink, useParams } from "react-router-dom";
4+
import { Link, useParams } from "react-router-dom";
55
import { useMonitor } from "../../../../hooks/monitors.query";
66
interface IncidentsWindowDetailViewProps {}
77
import Container from "../../../../components/Container";
8-
import { Button, Skeleton } from "@mui/material";
8+
import { Skeleton , Stack, Typography } from "@mui/material";
99
import Placeholder from "../../../../components/Placeholder";
1010
import IncidentsList from "../components/IncidentsList";
11+
import Conditional from "../../../../components/Conditional";
12+
import { stripProtocolAndPath } from "../../../../utilities/url";
13+
1114

1215
const IncidentsWindowDetailView: FunctionComponent<
1316
IncidentsWindowDetailViewProps
@@ -39,9 +42,26 @@ const IncidentsWindowDetailView: FunctionComponent<
3942
),
4043
]}
4144
>
45+
<Stack direction="row" spacing={2} alignItems={"center"}>
46+
<Stack>
47+
<Typography color="primary" fontSize={24}>
48+
{stripProtocolAndPath(data?.settings.url)}
49+
</Typography>
50+
<Typography color="secondary">
51+
52+
<Conditional value={!incidentsAreLoading && monitorIncidents != undefined && monitorIncidents?.incidents.length > 0}>
53+
{monitorIncidents?.incidents.length} active incidents monitor
54+
55+
</Conditional>
56+
57+
<Conditional value={monitorIncidents?.incidents.length == 0}>No Incidents!! :D</Conditional>
58+
</Typography>
59+
</Stack>
60+
</Stack>
4261
{incidentsAreLoading ? (
4362
<Placeholder />
4463
) : (
64+
4565
<IncidentsList incidents={monitorIncidents?.incidents} />
4666
)}
4767
</Container>

apps/dashboard/src/pages/Dashboard/Incidents/components/IncidentsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const IncidentsListItem: FunctionComponent<IncidentsListItemProps> = (
6565
>
6666
<Grid item>
6767
<Stack spacing={1}>
68-
<Typography variant="body2">ERROR: {incident.title} {incident.operator} {incident.target}</Typography>
68+
<Typography variant="body2">Assertion failed: {incident.title} {incident.operator} {incident.target}</Typography>
6969

7070
<Stack direction="row" spacing={1}>
7171
<Chip size="small" label="api" color="info" />

0 commit comments

Comments
 (0)