Skip to content

Commit

Permalink
feat: add notification silence filter
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Nov 8, 2024
1 parent a2de537 commit 156cfde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type NotificationRules = {

export type SilenceNotificationResponse = {
id: string;
filter?: string;
component_id?: string;
config_id?: string;
check_id?: string;
Expand Down Expand Up @@ -85,6 +86,7 @@ export type NotificationSilenceItem = {
id: string;
namespace: string;
description?: string;
filter?: string;
from: string;
until: string;
recursive?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function NotificationSilenceForm({
if (data.id) {
return updateNotificationSilence({
id: data.id,
filter: data.filter,
updated_at: "now()",
source: data.source,
canary_id: data.canary_id,
Expand Down Expand Up @@ -126,6 +127,11 @@ export default function NotificationSilenceForm({
label="Silence Duration"
/>
<FormikTextArea name="description" label="Reason" />
<FormikTextArea
name="filter"
label="Filter"
hint="CEL expression for the silence to match against"
/>
</div>
<div className={`${footerClassName}`}>
{data?.id && (
Expand Down
14 changes: 14 additions & 0 deletions src/components/Notifications/SilenceNotificationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ const silenceNotificationListColumns: MRT_ColumnDef<NotificationSilenceItemApiRe
);
}
},

{
header: "Filter",
accessorKey: "filter",
size: 100,
Cell: ({ row }) => {
const isExpired = dayjs(row.original.until).isBefore(dayjs());
return (
<span className={clsx(isExpired && "line-through")}>
{row.original.filter}
</span>
);
}
},
{
header: "Reason",
accessorKey: "description",
Expand Down

0 comments on commit 156cfde

Please sign in to comment.