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 b01e7b8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 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
16 changes: 15 additions & 1 deletion src/components/Notifications/SilenceNotificationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const DeleteCell = ({
<ConfirmationPromptDialog
isOpen={isOpen}
onClose={() => setIsOpen(false)}
title="Delete Notification Silence"
title="Delete Silence"
description="Are you sure you want to delete this notification silence?"
onConfirm={() => deleteItem(id)}
/>
Expand Down 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
5 changes: 1 addition & 4 deletions src/ui/AlertDialog/ConfirmationPromptDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ export function ConfirmationPromptDialog({
{title}
</h3>
<div className="mt-2">
<p className="text-sm text-gray-500">
Are you sure you want to deactivate your account? All of your
data will be permanently removed. This action cannot be undone.
</p>
<p className="text-sm text-gray-500">{description}</p>
</div>
</div>
</div>
Expand Down

0 comments on commit b01e7b8

Please sign in to comment.