Skip to content

Commit 116e604

Browse files
mainawycliffemoshloop
authored andcommitted
fix: mark expired silences with a strikethrough
Fixes #2361
1 parent 268d34f commit 116e604

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/components/Notifications/SilenceNotificationsList.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import MRTDataTable from "@flanksource-ui/ui/MRTDataTable/MRTDataTable";
1414
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
1515
import { DotsVerticalIcon } from "@heroicons/react/solid";
1616
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
17+
import clsx from "clsx";
18+
import dayjs from "dayjs";
1719
import { MRT_ColumnDef } from "mantine-react-table";
1820
import { useState } from "react";
1921
import { BiRepeat } from "react-icons/bi";
@@ -120,13 +122,18 @@ const silenceNotificationListColumns: MRT_ColumnDef<NotificationSilenceItemApiRe
120122
const component = row.original.component;
121123
const recursive = row.original.recursive;
122124

125+
const isExpired = dayjs(row.original.until).isBefore(dayjs());
126+
123127
return (
124128
<div
125129
onClick={(e) => {
126130
e.stopPropagation();
127131
e.preventDefault();
128132
}}
129-
className="flex flex-row items-center"
133+
className={clsx(
134+
"flex flex-row items-center",
135+
isExpired && "line-through"
136+
)}
130137
>
131138
{check && (
132139
<CheckLink
@@ -157,19 +164,41 @@ const silenceNotificationListColumns: MRT_ColumnDef<NotificationSilenceItemApiRe
157164
Cell: ({ row }) => {
158165
const from = row.original.from;
159166
const until = row.original.until;
167+
const isExpired = dayjs(until).isBefore(dayjs());
160168

161-
return <Age from={from} to={until} />;
169+
return (
170+
<Age
171+
className={clsx(isExpired && "line-through")}
172+
from={from}
173+
to={until}
174+
/>
175+
);
162176
}
163177
},
164178
{
165179
header: "Source",
166180
accessorKey: "source",
167-
size: 100
181+
size: 100,
182+
Cell: ({ row }) => {
183+
const source = row.original.source;
184+
const isExpired = dayjs(row.original.until).isBefore(dayjs());
185+
return (
186+
<span className={clsx(isExpired && "line-through")}>{source}</span>
187+
);
188+
}
168189
},
169190
{
170191
header: "Reason",
171192
accessorKey: "description",
172-
size: 400
193+
size: 400,
194+
Cell: ({ row }) => {
195+
const isExpired = dayjs(row.original.until).isBefore(dayjs());
196+
return (
197+
<span className={clsx(isExpired && "line-through")}>
198+
{row.original.description}
199+
</span>
200+
);
201+
}
173202
},
174203
{
175204
header: "Created By",

0 commit comments

Comments
 (0)