Skip to content

Commit

Permalink
feat: add indefinitely option to duration picker
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Feb 10, 2025
1 parent c332f68 commit 17134f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/api/services/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const silenceNotification = async (
export const updateNotificationSilence = async (
data: Omit<NotificationSilenceItem, "created_at">
) => {
if (data.until === "indefinitely") {
data["until"] = null;
}

const res = await IncidentCommander.patch(
`/notification_silences?id=eq.${data.id}`,
data
Expand Down
4 changes: 2 additions & 2 deletions src/api/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type SilenceNotificationResponse = {
check_id?: string;
canary_id?: string;
from: string;
until: string;
until: string | null;
description?: string;
recursive?: boolean;
namespace?: string;
Expand Down Expand Up @@ -94,7 +94,7 @@ export type NotificationSilenceItem = {
filter?: string;
error?: string;
from: string;
until: string;
until: string | null;
recursive?: boolean;
config_id?: string;
check_id?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/ui/Dates/TimeRangePicker/TimeRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export function TimeRangePicker({
if (currentRange?.type === "absolute") {
return `${currentRange.from} - ${currentRange.to}`;
}

if (!currentRange?.display) {
return "Indefinitely";
}

return currentRange?.display;
}, [currentRange]);

Expand Down
5 changes: 5 additions & 0 deletions src/ui/Dates/TimeRangePicker/rangeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ export const rangeOptionsCategories: RangeOptionsCategory[] = [
name: "Relative time ranges",
type: "future",
options: [
{
type: "relative",
display: "Indefinitely",
range: "indefinitely"
},
{
type: "relative",
display: "5 minutes",
Expand Down

0 comments on commit 17134f4

Please sign in to comment.