Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add daily remainder option

Thiago Araujo da Silva7efe73267dc9
diff --git a/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts b/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
index 90f66332ab..30b49c36ac 100644
--- a/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
+++ b/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
@@ -26,9 +26,12 @@ export const IDENTITY_CREDENTIAL_EXPIRY_EVENT = "identity.credential.expiry";
const alertBeforeRegex = new RE2("^\\d+[dwmy]$");
const IdentityCredentialConditionSchema = z.object({
- alertBefore: z.string().refine((v) => alertBeforeRegex.test(v), "Must be in format like '30d', '1w', '3m', '1y'")
+ alertBefore: z.string().refine((v) => alertBeforeRegex.test(v), "Must be in format like '30d', '1w', '3m', '1y'"),
+ dailyReminder: z.boolean().optional()
});
+const DAILY_REPEAT_DEDUP_WINDOW_HOURS = 20;
+
type TIdentityCredentialTarget = { credentialType: "ua-client-secret" } & TExpiringUaClientSecret;
const UNIT_TO_INTERVAL_WORD: Record<string, string> = { d: "days", w: "weeks", m: "months", y: "years" };
@@ -228,6 +231,7 @@ export const identityCredentialAlarmProviderFactory = ({
dedupWindowHours: (condition) => {
const parsed = IdentityCredentialConditionSchema.safeParse(condition);
if (!parsed.success) return DEFAULT_DEDUP_WINDOW_HOURS;
+ if (parsed.data.dailyReminder) return DAILY_REPEAT_DEDUP_WINDOW_HOURS;
return Math.max(DEFAULT_DEDUP_WINDOW_HOURS, parseAlertBefore(parsed.data.alertBefore).days * 24);
},
assertPermission,
diff --git a/frontend/src/hooks/api/alarms/types.ts b/frontend/src/hooks/api/alarms/types.ts
index 1288d7e43d..592fdf8058 100644
--- a/frontend/src/hooks/api/alarms/types.ts
+++ b/frontend/src/hooks/api/alarms/types.ts
@@ -76,7 +76,7 @@ export type TAlarm = {
resourceType: string;
resourceId: string | null;
eventType: string;
- condition: { alertBefore?: string } | null;
+ condition: { alertBefore?: string; dailyReminder?: boolean } | null;
filters: unknown | null;
enabled: boolean;
orgId: string;
@@ -134,6 +134,7 @@ export const alarmFormSchema = z.object({
.min(1, "Must be at least 1")
.max(3650, "Too large"),
alertBeforeUnit: z.nativeEnum(AlarmTimeUnit),
+ dailyReminder: z.boolean().default(false),
enabled: z.boolean().default(true),
channelIds: z.array(z.string()).min(1, "At least one channel is required")
});
diff --git a/frontend/src/views/AlarmsPage/components/AlarmForm.tsx b/frontend/src/views/AlarmsPage/components/AlarmForm.tsx
index c8ed148b33..2f0f5a6868 100644
--- a/frontend/src/views/AlarmsPage/components/AlarmForm.tsx
+++ b/frontend/src/views/AlarmsPage/components/AlarmForm.tsx
@@ -1,7 +1,7 @@
import { ReactNode } from "react";
import { Controller, FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { KeyRoundIcon, LockIcon } from "lucide-react";
+import { CircleHelpIcon, KeyRoundIcon, LockIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
@@ -23,7 +23,10 @@ import {
SheetFooter,
SubOrgIcon,
Switch,
- TextArea
+ TextArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
} from "@app/components/v3";
import { useScopeVariant } from "@app/hooks";
import {
@@ -86,6 +89,7 @@ const buildFormDefaults = (alarm?: TAlarm): TAlarmForm => {
eventType: AlarmEventType.IdentityCredentialExpiry,
alertBeforeValue: 7,
alertBeforeUnit: AlarmTimeUnit.Days,
+ dailyReminder: false,
enabled: true,
channelIds: []
};
@@ -100,6 +104,7 @@ const buildFormDefaults = (alarm?: TAlarm): TAlarmForm => {
eventType: (alarm.eventType as AlarmEventType) ?? AlarmEventType.IdentityCredentialExpiry,
alertBeforeValue: value,
alertBeforeUnit: unit,
+ dailyReminder: alarm.condition?.dailyReminder ?? false,
enabled: alarm.enabled,
channelIds: alarm.channels.map((channel) => channel.id)
};
@@ -142,6 +147,7 @@ export const AlarmForm = ({ projectId, scopeName, alarm, onComplete, onCancel }:
const onSubmit = async (data: TAlarmForm) => {
const alertBefore = `${data.alertBeforeValue}${data.alertBeforeUnit}`;
+ const condition = { alertBefore, dailyReminder: data.dailyReminder };
try {
if (isEditing && alarm) {
const channelsDirty = Boolean(dirtyFields.channelIds);
@@ -151,7 +157,7 @@ export const AlarmForm = ({ projectId, scopeName, alarm, onComplete, onCancel }:
name: data.name,
description: data.description || null,
enabled: data.enabled,
- condition: { alertBefore },
+ condition,
...(channelsDirty ? { channelIds: data.channelIds } : {})
});
createNotification({ text: "Successfully updated alarm", type: "success" });
@@ -162,7 +168,7 @@ export const AlarmForm = ({ projectId, scopeName, alarm, onComplete, onCancel }:
resourceType: data.resourceType,
resourceId: null,
eventType: data.eventType,
- condition: { alertBefore },
+ condition,
filters: null,
enabled: data.enabled,
projectId: projectId ?? null,
@@ -325,6 +331,32 @@ export const AlarmForm = ({ projectId, scopeName, alarm, onComplete, onCancel }:
<FieldError errors={[errors.alertBeforeValue, errors.alertBeforeUnit]} />
</div>
</div>
+
+ <Controller
+ control={control}
+ name="dailyReminder"
+ render={({ field }) => (
+ <div className="flex items-center gap-2">
+ <FieldLabel htmlFor="alarm-repeat-daily" className="cursor-pointer">
+ Daily Reminder
+ </FieldLabel>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <CircleHelpIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent>
+ Send a reminder every day from the alert threshold until the event happens
+ </TooltipContent>
+ </Tooltip>
+ <Switch
+ id="alarm-repeat-daily"
+ variant={scopeVariant}
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </div>
+ )}
+ />
</section>
<section className="flex flex-col gap-4">