Skip to content

Commit 665d26c

Browse files
mainawycliffemoshloop
authored andcommitted
fix: show error on notifications_summary when it's there
Fixes #2306
1 parent 3dc3389 commit 665d26c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/api/types/notifications.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type NotificationRules = {
3838
sent?: number;
3939
most_common_error?: string;
4040
repeat_interval?: string;
41+
error?: string;
4142
};
4243

4344
export type SilenceNotificationResponse = {

src/components/Notifications/Rules/notificationsRulesTableColumns.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { NotificationRules } from "@flanksource-ui/api/types/notifications";
22
import { Badge } from "@flanksource-ui/ui/Badge/Badge";
3+
import { Modal } from "@flanksource-ui/ui/Modal";
34
import MRTAvatarCell from "@flanksource-ui/ui/MRTDataTable/Cells/MRTAvataCell";
45
import { MRTDateCell } from "@flanksource-ui/ui/MRTDataTable/Cells/MRTDateCells";
56
import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps";
67
import { formatDuration } from "@flanksource-ui/utils/date";
78
import { atom, useAtom } from "jotai";
89
import { MRT_ColumnDef } from "mantine-react-table";
910
import { useState } from "react";
11+
import { FaExclamationTriangle } from "react-icons/fa";
1012
import { Tooltip } from "react-tooltip";
1113
import JobHistoryStatusColumn from "../../JobsHistory/JobHistoryStatusColumn";
1214
import { JobsHistoryDetails } from "../../JobsHistory/JobsHistoryDetails";
@@ -181,8 +183,40 @@ export const notificationsRulesTableColumns: MRT_ColumnDef<NotificationRules>[]
181183
accessorKey: "title",
182184
Cell: ({ row, column }) => {
183185
const value = row.getValue<string>(column.id);
186+
const error = row.original.error;
187+
188+
const [showError, setShowError] = useState(false);
189+
184190
return (
185-
<div className="w-full overflow-hidden text-ellipsis">{value}</div>
191+
<div className="w-full overflow-hidden text-ellipsis">
192+
{error && (
193+
<>
194+
<span
195+
data-tooltip-id={`error-tooltip-${row.original.id}`}
196+
data-tooltip-content={error}
197+
onClick={(e) => {
198+
e.stopPropagation();
199+
e.preventDefault();
200+
setShowError(!showError);
201+
}}
202+
>
203+
<FaExclamationTriangle className="mr-1 inline h-4 w-4 text-red-500" />
204+
</span>
205+
<Tooltip id={`error-tooltip-${row.original.id}`} />
206+
207+
<Modal
208+
open={showError}
209+
onClose={() => setShowError(false)}
210+
title={` ${value} Error Details`}
211+
>
212+
<div className="flex flex-col p-4">
213+
<pre className="whitespace-pre-wrap text-sm">{error}</pre>
214+
</div>
215+
</Modal>
216+
</>
217+
)}
218+
{value}
219+
</div>
186220
);
187221
}
188222
},

0 commit comments

Comments
 (0)