Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mark expired silences with a strikethrough #2368

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions src/components/Notifications/SilenceNotificationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import MRTDataTable from "@flanksource-ui/ui/MRTDataTable/MRTDataTable";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
import { DotsVerticalIcon } from "@heroicons/react/solid";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import clsx from "clsx";
import dayjs from "dayjs";
import { MRT_ColumnDef } from "mantine-react-table";
import { useState } from "react";
import { BiRepeat } from "react-icons/bi";
Expand Down Expand Up @@ -120,13 +122,18 @@ const silenceNotificationListColumns: MRT_ColumnDef<NotificationSilenceItemApiRe
const component = row.original.component;
const recursive = row.original.recursive;

const isExpired = dayjs(row.original.until).isBefore(dayjs());

return (
<div
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
}}
className="flex flex-row items-center"
className={clsx(
"flex flex-row items-center",
isExpired && "line-through"
)}
>
{check && (
<CheckLink
Expand Down Expand Up @@ -157,19 +164,41 @@ const silenceNotificationListColumns: MRT_ColumnDef<NotificationSilenceItemApiRe
Cell: ({ row }) => {
const from = row.original.from;
const until = row.original.until;
const isExpired = dayjs(until).isBefore(dayjs());

return <Age from={from} to={until} />;
return (
<Age
className={clsx(isExpired && "line-through")}
from={from}
to={until}
/>
);
}
},
{
header: "Source",
accessorKey: "source",
size: 100
size: 100,
Cell: ({ row }) => {
const source = row.original.source;
const isExpired = dayjs(row.original.until).isBefore(dayjs());
return (
<span className={clsx(isExpired && "line-through")}>{source}</span>
);
}
},
{
header: "Reason",
accessorKey: "description",
size: 400
size: 400,
Cell: ({ row }) => {
const isExpired = dayjs(row.original.until).isBefore(dayjs());
return (
<span className={clsx(isExpired && "line-through")}>
{row.original.description}
</span>
);
}
},
{
header: "Created By",
Expand Down
Loading