Skip to content

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

feat(ui): prototype secret reminders on the shared alert channels

Calvin3c36162ae63b
diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.ts
index 182344fcab..c927843f01 100644
--- a/frontend/src/hooks/api/alerts/types.ts
+++ b/frontend/src/hooks/api/alerts/types.ts
@@ -1,7 +1,8 @@
import { z } from "zod";
export enum AlertResourceType {
- IdentityAuthentication = "identity.authentication"
+ IdentityAuthentication = "identity.authentication",
+ SecretReminder = "secret.reminder"
}
export enum AlertEventType {
@@ -9,6 +10,24 @@ export enum AlertEventType {
IdentityAuthMethodChanged = "identity.authentication.auth-method-changed"
}
+// Kept apart from AlertEventType, which the identity alert form offers in full.
+export enum SecretReminderEventType {
+ Due = "secret.reminder.due"
+}
+
+export enum SecretReminderRecurrence {
+ OneTime = "one-time",
+ Recurring = "recurring"
+}
+
+export type TSecretReminderCondition = {
+ recurrence: SecretReminderRecurrence;
+ // ISO date. The one-off date, or the first occurrence of a recurring reminder.
+ startDate: string;
+ repeatDays?: number | null;
+ note?: string | null;
+};
+
export enum AlertChannelType {
Email = "email",
Slack = "slack",
@@ -25,7 +44,8 @@ export const MIN_ALERT_BEFORE_DAYS = 1;
export const MAX_ALERT_BEFORE_DAYS = 90;
export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {
- [AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication"
+ [AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication",
+ [AlertResourceType.SecretReminder]: "Secret Reminder"
};
export const ALERT_EVENT_TYPE_LABELS: Record<AlertEventType, string> = {
@@ -68,7 +88,9 @@ export type TAlert = {
resourceType: string;
resourceId: string | null;
eventType: string;
- condition: { alertBefore?: string; dailyReminder?: boolean } | null;
+ condition:
+ | ({ alertBefore?: string; dailyReminder?: boolean } & Partial<TSecretReminderCondition>)
+ | null;
enabled: boolean;
orgId: string;
projectId: string | null;
@@ -193,6 +215,9 @@ export const channelFormSchema = z
export type TChannelForm = z.infer<typeof channelFormSchema>;
+// The part of an alert form the shared channel fields read and write.
+export type TChannelsForm = { channels: TChannelForm[] };
+
const alertFormBaseSchema = z.object({
name: z.string().min(1, "Name is required").max(255),
description: z.string().max(1000).optional(),
diff --git a/frontend/src/hooks/api/alerts/utils.ts b/frontend/src/hooks/api/alerts/utils.ts
index 9821494905..0260257d0c 100644
--- a/frontend/src/hooks/api/alerts/utils.ts
+++ b/frontend/src/hooks/api/alerts/utils.ts
@@ -1,4 +1,19 @@
-import { AlertChannelType, TAlertChannelInput, TChannelForm } from "./types";
+import { AlertChannelType, TAlert, TAlertChannelInput, TChannelForm } from "./types";
+
+export const toChannelForm = (channel: TAlert["channels"][number]): TChannelForm => ({
+ id: channel.id,
+ channelType: channel.channelType,
+ name: channel.name,
+ enabled: channel.enabled,
+ recipients: channel.recipients,
+ webhookUrl: "",
+ url: (channel.config.url as string) ?? "",
+ signingSecret: "",
+ integrationKey: "",
+ hasWebhookUrl: Boolean(channel.config.hasWebhookUrl),
+ hasSigningSecret: Boolean(channel.config.hasSigningSecret),
+ hasIntegrationKey: Boolean(channel.config.hasIntegrationKey)
+});
export const toChannelInput = (channel: TChannelForm): TAlertChannelInput => {
const base: TAlertChannelInput = {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx
index 7146843b15..ded5d7fe77 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx
@@ -94,7 +94,6 @@ import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionCo
import { usePopUp, useTimedReset, useToggle } from "@app/hooks";
import { useUpdateSecretV3 } from "@app/hooks/api";
import { useGetSecretValue } from "@app/hooks/api/dashboard/queries";
-import { Reminder } from "@app/hooks/api/reminders/types";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { ProjectEnv, SecretType, SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";
import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
@@ -106,10 +105,11 @@ import {
TABLE_ROW_ACTION_BAR_FORCE_VISIBLE_CLASS_NAME,
TABLE_ROW_ACTION_BAR_VISIBILITY_CLASS_NAME
} from "../tableRowActionStyles";
+import { useSecretReminders } from "./SecretReminders/useSecretReminders";
import { SecretAccessInsights } from "./SecretAccessInsights";
import { SecretCommentForm } from "./SecretCommentForm";
import { SecretMetadataForm } from "./SecretMetadataForm";
-import { SecretReminderForm } from "./SecretReminderForm";
+import { SecretReminders } from "./SecretReminders";
import { SecretTagForm } from "./SecretTagForm";
import { SecretVersionHistory } from "./SecretVersionHistory";
@@ -125,7 +125,6 @@ type Props = {
tags?: WsTag[];
secretMetadata?: { key: string; value: string; isEncrypted?: boolean }[];
skipMultilineEncoding?: boolean | null;
- reminder?: Reminder;
environment: string;
environmentName: string;
secretValueHidden: boolean;
@@ -208,7 +207,6 @@ export const SecretEditTableRow = ({
secretMetadata,
environmentName,
skipMultilineEncoding,
- reminder,
isSingleEnvView,
isBatchMode,
isPendingCreate,
@@ -346,6 +344,8 @@ export const SecretEditTableRow = ({
const [isTagOpen, setIsTagOpen] = useState(false);
const [isMetadataOpen, setIsMetadataOpen] = useState(false);
const [isReminderOpen, setIsReminderOpen] = useState(false);
+ const { data: reminders = [] } = useSecretReminders(secretId);
+ const hasReminders = reminders.length > 0;
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const [pendingAnnotation, setPendingAnnotation] = useState<
"comment" | "tags" | "reminder" | "metadata" | null
@@ -1079,14 +1079,16 @@ export const SecretEditTableRow = ({
</TooltipContent>
</Tooltip>
) : null}
- {reminder && !isImportedSecret && (
+ {hasReminders && !isImportedSecret && (
<Tooltip>
<TooltipTrigger asChild>
<span className="flex size-5 items-center justify-center text-muted">
<BellIcon className="size-3.5" />
</span>
</TooltipTrigger>
- <TooltipContent>Has reminder</TooltipContent>
+ <TooltipContent>
+ {reminders.length} reminder{reminders.length > 1 ? "s" : ""}
+ </TooltipContent>
</Tooltip>
)}
{secretMetadata?.length && !isImportedSecret ? (
@@ -1232,27 +1234,16 @@ export const SecretEditTableRow = ({
/>
</PopoverContent>
</Popover>
- <Popover open={isReminderOpen} onOpenChange={setIsReminderOpen}>
- <PopoverAnchor asChild>
- <span className="pointer-events-none absolute inset-0" />
- </PopoverAnchor>
- <PopoverContent
- onCloseAutoFocus={(e) => e.preventDefault()}
- className="w-[420px]"
- side="left"
- >
- {secretId && (
- <SecretReminderForm
- secretId={secretId}
- secretKey={secretName}
- secretPath={secretPath}
- environment={environment}
- reminder={reminder}
- onClose={() => setIsReminderOpen(false)}
- />
- )}
- </PopoverContent>
- </Popover>
+ {secretId && (
+ <SecretReminders
+ secretId={secretId}
+ secretKey={secretName}
+ environmentName={environmentName}
+ canEdit={canEditSecretValue}
+ isOpen={isReminderOpen}
+ onOpenChange={setIsReminderOpen}
+ />
+ )}
<Popover open={isMetadataOpen} onOpenChange={setIsMetadataOpen}>
<PopoverAnchor asChild>
<span className="pointer-events-none absolute inset-0" />
@@ -1300,7 +1291,12 @@ export const SecretEditTableRow = ({
{!isImportedSecret &&
!isCreatable &&
!isPendingDelete &&
- !!(comment || (canReadTags && tags?.length) || reminder || secretMetadata?.length) && (
+ !!(
+ comment ||
+ (canReadTags && tags?.length) ||
+ hasReminders ||
+ secretMetadata?.length
+ ) && (
<>
{comment && (
<Tooltip>
@@ -1334,11 +1330,11 @@ export const SecretEditTableRow = ({
<TooltipContent>View Tags</TooltipContent>
</Tooltip>
) : null}
- {reminder && (
+ {hasReminders && (
<Tooltip>
<TooltipTrigger asChild>
<IconButton
- aria-label="View secret reminder"
+ aria-label="View secret reminders"
variant="ghost"
size="xs"
className="size-7 border-0"
@@ -1347,7 +1343,7 @@ export const SecretEditTableRow = ({
<BellIcon className="size-3.5" />
</IconButton>
</TooltipTrigger>
- <TooltipContent>View Reminder</TooltipContent>
+ <TooltipContent>View Reminders</TooltipContent>
</Tooltip>
)}
{secretMetadata?.length ? (
@@ -1465,7 +1461,7 @@ export const SecretEditTableRow = ({
"px-2.5 py-1.5",
(comment ||
(canReadTags && tags?.length) ||
- reminder ||
+ hasReminders ||
secretMetadata?.length) &&
!isImportedSecret &&
"[&>svg:first-child]:text-project"
@@ -1507,8 +1503,8 @@ export const SecretEditTableRow = ({
isDisabled={!secretId || isPendingCreate}
onClick={() => setPendingAnnotation("reminder")}
>
- <BellIcon className={twMerge(reminder && "text-project")} />
- {reminder ? "View Reminder" : "Add Reminder"}
+ <BellIcon className={twMerge(hasReminders && "text-project")} />
+ {hasReminders ? "View Reminders" : "Add Reminder"}
</DropdownMenuItem>
</TooltipTrigger>
<TooltipContent side="left">Create Secret to Add Reminder</TooltipContent>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminderForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminderForm.tsx
deleted file mode 100644
index e5ca69e6d7..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminderForm.tsx
+++ /dev/null
@@ -1,478 +0,0 @@
-import { useCallback, useEffect, useMemo } from "react";
-import { Controller, useForm } from "react-hook-form";
-import { subject } from "@casl/ability";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useQueryClient } from "@tanstack/react-query";
-import { format } from "date-fns";
-import { CalendarIcon, TrashIcon } from "lucide-react";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import {
- Button,
- Calendar,
- Field,
- FieldContent,
- FieldDescription,
- FieldError,
- FieldLabel,
- FilterableSelect,
- Input,
- Popover,
- PopoverContent,
- PopoverTrigger,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- TextArea
-} from "@app/components/v3";
-import { useProject, useProjectPermission } from "@app/context";
-import {
- ProjectPermissionSecretActions,
- ProjectPermissionSub
-} from "@app/context/ProjectPermissionContext/types";
-import { useGetWorkspaceUsers } from "@app/hooks/api";
-import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
-import { useCreateReminder, useDeleteReminder } from "@app/hooks/api/reminders";
-import { reminderKeys } from "@app/hooks/api/reminders/queries";
-import { Reminder } from "@app/hooks/api/reminders/types";
-import { secretKeys } from "@app/hooks/api/secrets/queries";
-
-const MIN_REPEAT_DAYS = 1;
-const MAX_REPEAT_DAYS = 365;
-const DEFAULT_REPEAT_DAYS = 30;
-const ONE_DAY_IN_MILLIS = 86400000;
-
-enum ReminderType {
- Recurring = "Recurring",
- OneTime = "One Time"
-}
-
-const formSchema = z
- .object({
- reminderType: z.enum(["Recurring", "One Time"]),
- message: z.string().optional().nullable(),
- recipients: z.array(z.object({ label: z.string(), value: z.string().uuid() })).optional(),
- repeatDays: z
- .number()
- .min(MIN_REPEAT_DAYS, { message: `Must be at least ${MIN_REPEAT_DAYS} day` })
- .max(MAX_REPEAT_DAYS, { message: `Must be less than ${MAX_REPEAT_DAYS} days` })
- .nullable()
- .optional(),
- nextReminderDate: z.coerce.date().nullable().optional(),
- fromDate: z.coerce.date().nullable().optional()
- })
- .superRefine((data, ctx) => {
- if (data.reminderType === "One Time") {
- if (!data.nextReminderDate) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Reminder date is required",
- path: ["nextReminderDate"]
- });
- } else if (data.nextReminderDate <= new Date()) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Reminder date must be in the future",
- path: ["nextReminderDate"]
- });
- }
- }
-
- if (data.reminderType === "Recurring") {
- if (!data.fromDate) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Start date is required",
- path: ["fromDate"]
- });
- } else if (data.fromDate <= new Date()) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Start date must be in the future",
- path: ["fromDate"]
- });
- }
- }
- });
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-type Props = {
- secretId: string;
- secretKey: string;
- environment: string;
- secretPath: string;
-
- reminder?: Reminder;
- onClose?: () => void;
-};
-
-export const SecretReminderForm = ({
- secretId,
- secretKey,
- environment,
- secretPath,
- reminder,
- onClose
-}: Props) => {
- const queryClient = useQueryClient();
- const { projectId, currentProject } = useProject();
- const { permission } = useProjectPermission();
-
- const { mutateAsync: createReminder, isPending: isCreating } = useCreateReminder(secretId);
- const { mutateAsync: deleteReminder, isPending: isDeleting } = useDeleteReminder(secretId);
- const { data: members = [] } = useGetWorkspaceUsers(currentProject?.id);
-
- const isEditMode = Boolean(reminder);
-
- const canEditSecret = permission.can(
- ProjectPermissionSecretActions.Edit,
- subject(ProjectPermissionSub.Secrets, {
- environment,
- secretPath,
- secretName: secretKey,
- secretTags: ["*"]
- })
- );
-
- const memberOptions = useMemo(
- () =>
- members.map((member) => ({
- label: member.user.username || member.user.email,
- value: member.user.id
- })),
- [members]
- );
-
- const {
- handleSubmit,
- control,
- setValue,
- watch,
- reset,
- formState: { isDirty }
- } = useForm<TFormSchema>({
- defaultValues: {
- reminderType: reminder?.repeatDays ? ReminderType.Recurring : ReminderType.OneTime,
- repeatDays: reminder?.repeatDays || null,
- message: reminder?.message || "",
- nextReminderDate: reminder?.nextReminderDate || null,
- fromDate: reminder?.fromDate || null,
- recipients: []
- },
- resolver: zodResolver(formSchema)
- });
-
- const reminderType = watch("reminderType");
- const fromDate = watch("fromDate");
-
- useEffect(() => {
- if (!reminder || !memberOptions.length) return;
-
- if (reminder.recipients?.length) {
- const selectedRecipients = memberOptions.filter((option) =>
- reminder.recipients!.includes(option.value)
- );
- setValue("recipients", selectedRecipients, { shouldDirty: false });
- }
- }, [reminder, memberOptions, setValue]);
-
- const isPending = isCreating || isDeleting;
-
- const invalidateQueries = useCallback(() => {
- queryClient.invalidateQueries({
- queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
- });
- queryClient.invalidateQueries({
- queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
- });
- queryClient.invalidateQueries({
- queryKey: reminderKeys.getReminder(secretId)
- });
- }, [queryClient, projectId, secretPath, environment, secretId]);
-
- const handleReminderTypeChange = useCallback(
- (newType: string) => {
- if (newType === ReminderType.Recurring) {
- setValue("repeatDays", DEFAULT_REPEAT_DAYS);
- setValue("nextReminderDate", null);
- setValue("fromDate", null);
- } else if (newType === ReminderType.OneTime) {
- const tomorrow = new Date();
- tomorrow.setDate(tomorrow.getDate() + 1);
- setValue("nextReminderDate", tomorrow);
- setValue("repeatDays", null);
- }
- },
- [setValue]
- );
-
- const onSubmit = async (data: TFormSchema) => {
- await createReminder({
- repeatDays: data.repeatDays,
- message: data.message,
- recipients: data.recipients?.map((r) => r.value) || [],
- secretId,
- nextReminderDate: data.nextReminderDate,
- fromDate: data.fromDate
- });
-
- invalidateQueries();
-
- createNotification({
- type: "success",
- text: `Successfully ${isEditMode ? "updated" : "created"} secret reminder`
- });
-
- reset();
- onClose?.();
- };
-
- const handleDeleteReminder = async () => {
- await deleteReminder({ reminderId: reminder?.id || "", secretId });
- invalidateQueries();
- reset();
- onClose?.();
-
- createNotification({
- type: "success",
- text: "Successfully deleted reminder"
- });
- };
-
- return (
- <form onSubmit={handleSubmit(onSubmit)} className="space-y-3">
- <div>
- <p className="text-sm font-medium">{isEditMode ? "Update" : "Create"} Reminder</p>
- <p className="mt-1 text-xs text-accent">
- Set up a reminder for when this secret should be rotated.
- </p>
- </div>
-
- <Field>
- <FieldLabel className="text-xs">Recurrence</FieldLabel>
- <FieldContent>
- <Controller
- name="reminderType"
- control={control}
- render={({ field: { value, onChange } }) => (
- <Select
- value={value}
- onValueChange={(val) => {
- onChange(val);
- handleReminderTypeChange(val);
- }}
- disabled={!canEditSecret}
- >
- <SelectTrigger className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent position="popper">
- {Object.values(ReminderType).map((type) => (
- <SelectItem value={type} key={type}>
- {type}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- )}
- />
- </FieldContent>
- </Field>
-
- {reminderType === ReminderType.Recurring ? (
- <div className="flex items-start gap-3">
- <Field className="flex-1">
- <FieldLabel className="text-xs">Interval (days)</FieldLabel>
- <FieldContent>
- <Controller
- control={control}
- name="repeatDays"
- render={({ field, fieldState: { error } }) => (
- <>
- <Input
- type="number"
- placeholder={DEFAULT_REPEAT_DAYS.toString()}
- value={field.value || ""}
- onChange={(e) => {
- const val = parseInt(e.target.value, 10);
- setValue("repeatDays", Number.isNaN(val) ? null : val);
- }}
- min={MIN_REPEAT_DAYS}
- max={MAX_REPEAT_DAYS}
- disabled={!canEditSecret}
- />
- {error ? (
- <FieldError errors={[error]} />
- ) : (
- <FieldDescription className={field.value ? "opacity-100" : "opacity-0"}>
- Every {field.value && field.value > 1 ? `${field.value} days` : "day"}
- {fromDate ? ` from ${format(fromDate, "MM/dd/yy")}` : ""}
- </FieldDescription>
- )}
- </>
- )}
- />
- </FieldContent>
- </Field>
- <Field className="flex-1">
- <FieldLabel className="text-xs">Start Date</FieldLabel>
- <FieldContent>
- <Controller
- control={control}
- name="fromDate"
- render={({ field, fieldState: { error } }) => (
- <>
- <Popover>
- <PopoverTrigger asChild>
- <Button
- variant="outline"
- data-empty={!field.value}
- className="data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"
- isDisabled={!canEditSecret}
- >
- <CalendarIcon className="mr-2 size-4" />
- {field.value ? format(field.value, "P") : <span>Pick a date</span>}
- </Button>
- </PopoverTrigger>
- <PopoverContent align="end" className="w-auto p-0">
- <Calendar
- mode="single"
- selected={field.value || undefined}
- onSelect={field.onChange}
- disabled={{ before: new Date(Date.now() + ONE_DAY_IN_MILLIS) }}
- />
- </PopoverContent>
- </Popover>
- <FieldError errors={[error]} />
- </>
- )}
- />
- </FieldContent>
- </Field>
- </div>
- ) : (
- <Field>
- <FieldLabel className="text-xs">Reminder Date</FieldLabel>
- <FieldContent>
- <Controller
- control={control}
- name="nextReminderDate"
- render={({ field, fieldState: { error } }) => (
- <>
- <Popover>
- <PopoverTrigger asChild>
- <Button
- variant="outline"
- data-empty={!field.value}
- className="data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"
- isDisabled={!canEditSecret}
- >
- <CalendarIcon className="mr-2 size-4" />
- {field.value ? format(field.value, "P") : <span>Pick a date</span>}
- </Button>
- </PopoverTrigger>
- <PopoverContent align="start" className="w-auto p-0">
- <Calendar
- mode="single"
- selected={field.value || undefined}
- onSelect={field.onChange}
- disabled={{ before: new Date(Date.now() + ONE_DAY_IN_MILLIS) }}
- />
- </PopoverContent>
- </Popover>
- <FieldError errors={[error]} />
- </>
- )}
- />
- </FieldContent>
- </Field>
- )}
-
- <Field>
- <FieldLabel className="text-xs">Note</FieldLabel>
- <FieldContent>
- <Controller
- name="message"
- control={control}
- render={({ field }) => (
- <TextArea
- {...field}
- value={field.value ?? ""}
- placeholder="Remember to rotate this secret every month."
- className="max-h-32 min-h-16 resize-none"
- disabled={!canEditSecret}
- />
- )}
- />
- </FieldContent>
- </Field>
-
- <Field>
- <FieldLabel className="text-xs">Recipients</FieldLabel>
- <FieldContent>
- <Controller
- control={control}
- name="recipients"
- render={({ field }) => (
- <FilterableSelect
- menuPlacement="top"
- className="w-full"
- placeholder="Select recipients..."
- isMulti
- name="recipients"
- options={memberOptions}
- value={field.value}
- onChange={field.onChange}
- isDisabled={!canEditSecret}
- />
- )}
- />
- <FieldDescription>
- If none selected, all project members will be notified.
- </FieldDescription>
- </FieldContent>
- </Field>
-
- {!canEditSecret && (
- <p className="mt-2 text-xs text-muted">
- You do not have permission to manage reminders on this secret.
- </p>
- )}
-
- <div className="flex justify-end gap-2">
- {isEditMode && canEditSecret && (
- <Button
- variant="danger"
- size="xs"
- type="button"
- onClick={handleDeleteReminder}
- isDisabled={isPending}
- isPending={isDeleting}
- >
- <TrashIcon />
- Delete
- </Button>
- )}
- <div className="flex-1" />
- <Button variant="ghost" size="xs" type="button" onClick={onClose}>
- Close
- </Button>
- {canEditSecret && (
- <Button
- variant="project"
- size="xs"
- type="submit"
- isDisabled={!isDirty || isPending}
- isPending={isCreating}
- >
- {isEditMode ? "Update" : "Create"} Reminder
- </Button>
- )}
- </div>
- </form>
- );
-};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminderForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminderForm.tsx
new file mode 100644
index 0000000000..6629d155cb
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminderForm.tsx
@@ -0,0 +1,356 @@
+import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { format } from "date-fns";
+import { CalendarIcon } from "lucide-react";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ Calendar,
+ Field,
+ FieldContent,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ Input,
+ Label,
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ SheetFooter,
+ TextArea,
+ Toggle
+} from "@app/components/v3";
+import { useProject, useUser } from "@app/context";
+import {
+ AlertChannelType,
+ AlertPrincipalType,
+ AlertResourceType,
+ channelFormSchema,
+ SecretReminderEventType,
+ SecretReminderRecurrence,
+ TAlert,
+ toChannelForm,
+ toChannelInput,
+ TSecretReminderCondition,
+ useCreateAlert,
+ useUpdateAlert
+} from "@app/hooks/api/alerts";
+import { ChannelsField } from "@app/views/Alerts";
+
+import { getReminderCondition } from "./secret-reminder-fns";
+
+const MIN_REPEAT_DAYS = 1;
+const MAX_REPEAT_DAYS = 365;
+const DEFAULT_REPEAT_DAYS = 30;
+const DEFAULT_REMINDER_NAME = "Rotation reminder";
+
+const RECURRENCE_LABELS: Record<SecretReminderRecurrence, string> = {
+ [SecretReminderRecurrence.Recurring]: "Recurring",
+ [SecretReminderRecurrence.OneTime]: "One Time"
+};
+
+const tomorrow = () => {
+ const date = new Date();
+ date.setHours(0, 0, 0, 0);
+ date.setDate(date.getDate() + 1);
+ return date;
+};
+
+const formSchema = z
+ .object({
+ name: z.string().trim().min(1, "Name is required").max(255),
+ recurrence: z.nativeEnum(SecretReminderRecurrence),
+ repeatDays: z.number().or(z.nan()).nullable(),
+ startDate: z.date({ required_error: "Pick a date" }),
+ note: z.string().max(1000).optional(),
+ enabled: z.boolean(),
+ channels: z.array(channelFormSchema).min(1, "At least one channel is required")
+ })
+ .superRefine((form, ctx) => {
+ if (form.recurrence !== SecretReminderRecurrence.Recurring) return;
+ const days = form.repeatDays;
+ if (days === null || Number.isNaN(days)) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["repeatDays"],
+ message: "Enter a number"
+ });
+ } else if (!Number.isInteger(days) || days < MIN_REPEAT_DAYS || days > MAX_REPEAT_DAYS) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["repeatDays"],
+ message: `Must be a whole number from ${MIN_REPEAT_DAYS} to ${MAX_REPEAT_DAYS}`
+ });
+ }
+ });
+
+type TFormSchema = z.infer<typeof formSchema>;
+
+type Props = {
+ secretId: string;
+ reminder?: TAlert;
+ onComplete: () => void;
+ onCancel: () => void;
+};
+
+export const SecretReminderForm = ({ secretId, reminder, onComplete, onCancel }: Props) => {
+ const { projectId } = useProject();
+ const { user } = useUser();
+ const createAlert = useCreateAlert();
+ const updateAlert = useUpdateAlert();
+ const isEditing = Boolean(reminder);
+ const condition = reminder ? getReminderCondition(reminder) : null;
+
+ const formMethods = useForm<TFormSchema>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ name: reminder?.name ?? DEFAULT_REMINDER_NAME,
+ recurrence: condition?.recurrence ?? SecretReminderRecurrence.Recurring,
+ repeatDays: condition?.repeatDays ?? DEFAULT_REPEAT_DAYS,
+ startDate: condition ? new Date(condition.startDate) : tomorrow(),
+ note: condition?.note ?? "",
+ enabled: reminder?.enabled ?? true,
+ // New reminders start with the creator on email, which is the closest match to how reminders
+ // were delivered before channels existed.
+ channels: reminder
+ ? reminder.channels.map(toChannelForm)
+ : [
+ {
+ channelType: AlertChannelType.Email,
+ name: "Email",
+ enabled: true,
+ recipients: [{ principalType: AlertPrincipalType.User, principalId: user.id }],
+ webhookUrl: "",
+ url: "",
+ signingSecret: "",
+ integrationKey: ""
+ }
+ ]
+ }
+ });
+
+ const {
+ control,
+ register,
+ handleSubmit,
+ formState: { errors, isSubmitting }
+ } = formMethods;
+
+ const recurrence = useWatch({ control, name: "recurrence" });
+ const repeatDays = useWatch({ control, name: "repeatDays" });
+ const startDate = useWatch({ control, name: "startDate" });
+ const isRecurring = recurrence === SecretReminderRecurrence.Recurring;
+
+ const onSubmit = async (data: TFormSchema) => {
+ const reminderCondition: TSecretReminderCondition = {
+ recurrence: data.recurrence,
+ startDate: format(data.startDate, "yyyy-MM-dd"),
+ repeatDays: isRecurring ? data.repeatDays : null,
+ note: data.note || null
+ };
+ const channels = data.channels.map(toChannelInput);
+
+ try {
+ if (reminder) {
+ await updateAlert.mutateAsync({
+ alertId: reminder.id,
+ name: data.name,
+ enabled: data.enabled,
+ condition: reminderCondition,
+ channels
+ });
+ createNotification({ text: `Reminder "${data.name}" updated`, type: "success" });
+ } else {
+ await createAlert.mutateAsync({
+ name: data.name,
+ resourceType: AlertResourceType.SecretReminder,
+ resourceId: secretId,
+ eventType: SecretReminderEventType.Due,
+ condition: reminderCondition,
+ enabled: data.enabled,
+ projectId,
+ channels
+ });
+ createNotification({ text: `Reminder "${data.name}" created`, type: "success" });
+ }
+ onComplete();
+ } catch {
+ // MutationCache reports request errors globally; keep the form open for another attempt.
+ }
+ };
+
+ return (
+ <FormProvider {...formMethods}>
+ <form
+ onSubmit={handleSubmit(onSubmit)}
+ noValidate
+ className="flex min-h-0 flex-1 flex-col overflow-y-auto"
+ >
+ <div className="flex flex-col gap-5 p-4">
+ <Field>
+ <FieldLabel htmlFor="reminder-name">Name</FieldLabel>
+ <FieldContent>
+ <Input
+ id="reminder-name"
+ autoFocus
+ placeholder={DEFAULT_REMINDER_NAME}
+ isError={Boolean(errors.name)}
+ autoComplete="off"
+ {...register("name")}
+ />
+ <FieldError errors={[errors.name]} />
+ </FieldContent>
+ </Field>
+
+ <div className="flex flex-col gap-3">
+ <Label>Schedule</Label>
+ <Controller
+ control={control}
+ name="recurrence"
+ render={({ field }) => (
+ <Select value={field.value} onValueChange={field.onChange}>
+ <SelectTrigger className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {Object.values(SecretReminderRecurrence).map((value) => (
+ <SelectItem key={value} value={value}>
+ {RECURRENCE_LABELS[value]}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
+ />
+ <div className="flex items-start gap-3">
+ {isRecurring && (
+ <Field className="flex-1">
+ <FieldLabel htmlFor="reminder-repeat-days" className="text-xs">
+ Interval (days)
+ </FieldLabel>
+ <FieldContent>
+ <Input
+ id="reminder-repeat-days"
+ type="number"
+ min={MIN_REPEAT_DAYS}
+ max={MAX_REPEAT_DAYS}
+ isError={Boolean(errors.repeatDays)}
+ {...register("repeatDays", { valueAsNumber: true })}
+ />
+ <FieldError errors={[errors.repeatDays]} />
+ </FieldContent>
+ </Field>
+ )}
+ <Controller
+ control={control}
+ name="startDate"
+ render={({ field, fieldState: { error } }) => (
+ <Field className="flex-1">
+ <FieldLabel className="text-xs">
+ {isRecurring ? "Starting On" : "Date"}
+ </FieldLabel>
+ <FieldContent>
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ type="button"
+ variant="outline"
+ className="w-full justify-start text-left font-normal"
+ >
+ <CalendarIcon className="size-4" />
+ {field.value ? format(field.value, "PP") : "Pick a date"}
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-auto p-0">
+ <Calendar
+ mode="single"
+ selected={field.value}
+ onSelect={(date) => date && field.onChange(date)}
+ disabled={{ before: tomorrow() }}
+ />
+ </PopoverContent>
+ </Popover>
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+ </div>
+ {startDate && (
+ <FieldDescription>
+ {isRecurring && repeatDays && !Number.isNaN(repeatDays)
+ ? `Sends every ${repeatDays === 1 ? "day" : `${repeatDays} days`}, starting ${format(startDate, "PP")}.`
+ : `Sends once on ${format(startDate, "PP")}.`}
+ </FieldDescription>
+ )}
+ </div>
+
+ <Field>
+ <FieldLabel htmlFor="reminder-note">
+ Note <span className="text-muted">(optional)</span>
+ </FieldLabel>
+ <FieldContent>
+ <TextArea
+ id="reminder-note"
+ rows={3}
+ placeholder="Rotate this key and update the payments service."
+ isError={Boolean(errors.note)}
+ {...register("note")}
+ />
+ <FieldDescription>
+ Included in every notification this reminder sends.
+ </FieldDescription>
+ <FieldError errors={[errors.note]} />
+ </FieldContent>
+ </Field>
+
+ <Controller
+ control={control}
+ name="enabled"
+ render={({ field }) => (
+ <Label
+ htmlFor="reminder-enabled"
+ className="cursor-pointer justify-between rounded-md border border-border px-3 py-2.5 font-normal"
+ >
+ Enabled
+ <Toggle
+ id="reminder-enabled"
+ variant="project"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ </Label>
+ )}
+ />
+
+ <ChannelsField
+ projectId={projectId}
+ resourceType={AlertResourceType.SecretReminder}
+ resourceId={secretId}
+ />
+ </div>
+
+ <SheetFooter className="sticky bottom-0 border-t bg-popover">
+ <Button
+ type="submit"
+ variant="project"
+ isPending={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ {isEditing ? "Update Reminder" : "Create Reminder"}
+ </Button>
+ <Button type="button" variant="outline" onClick={onCancel} isDisabled={isSubmitting}>
+ Cancel
+ </Button>
+ </SheetFooter>
+ </form>
+ </FormProvider>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminders.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminders.tsx
new file mode 100644
index 0000000000..c8a7097f41
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminders.tsx
@@ -0,0 +1,306 @@
+import { useState } from "react";
+import { BellIcon, EllipsisIcon, PencilIcon, PlusIcon, TrashIcon } from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ Badge,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ IconButton,
+ Popover,
+ PopoverAnchor,
+ PopoverContent,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetHeader,
+ SheetTitle,
+ Toggle
+} from "@app/components/v3";
+import { cn } from "@app/components/v3/utils";
+import {
+ ALERT_CHANNEL_TYPE_LABELS,
+ AlertChannelType,
+ TAlert,
+ useDeleteAlert,
+ useUpdateAlert
+} from "@app/hooks/api/alerts";
+import { getChannelIcon } from "@app/views/Alerts/channelIcons";
+
+import { formatReminderSchedule, getReminderCondition } from "./secret-reminder-fns";
+import { SecretReminderForm } from "./SecretReminderForm";
+import { useSecretReminders } from "./useSecretReminders";
+
+type Props = {
+ secretId: string;
+ secretKey: string;
+ environmentName: string;
+ canEdit: boolean;
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+};
+
+const getEnabledChannelTypes = (alert: TAlert): AlertChannelType[] =>
+ Object.values(AlertChannelType).filter((type) =>
+ alert.channels.some((channel) => channel.channelType === type && channel.enabled)
+ );
+
+const ReminderRow = ({
+ reminder,
+ canEdit,
+ onEdit,
+ onRemove
+}: {
+ reminder: TAlert;
+ canEdit: boolean;
+ onEdit: () => void;
+ onRemove: () => void;
+}) => {
+ const updateAlert = useUpdateAlert();
+ const condition = getReminderCondition(reminder);
+ const channelTypes = getEnabledChannelTypes(reminder);
+
+ const handleToggleEnabled = async (enabled: boolean) => {
+ try {
+ await updateAlert.mutateAsync({ alertId: reminder.id, enabled });
+ createNotification({
+ text: `Reminder "${reminder.name}" ${enabled ? "enabled" : "disabled"}`,
+ type: "success"
+ });
+ } catch {
+ // MutationCache reports request errors globally.
+ }
+ };
+
+ return (
+ <div className="flex items-center justify-between gap-3 px-4 py-3">
+ <div className={cn("flex min-w-0 flex-col gap-0.5", !reminder.enabled && "opacity-60")}>
+ <span className="truncate text-sm text-foreground">{reminder.name}</span>
+ <div className="flex min-w-0 items-center gap-2 text-xs text-muted">
+ {condition && <span className="truncate">{formatReminderSchedule(condition)}</span>}
+ {channelTypes.length > 0 && (
+ <>
+ <span aria-hidden>·</span>
+ <div className="flex shrink-0 items-center gap-1">
+ {channelTypes.map((type) => {
+ const ChannelIcon = getChannelIcon(type);
+ return (
+ <ChannelIcon
+ key={type}
+ role="img"
+ aria-label={ALERT_CHANNEL_TYPE_LABELS[type]}
+ className="size-3.5"
+ />
+ );
+ })}
+ </div>
+ </>
+ )}
+ </div>
+ {condition?.note && (
+ <span className="line-clamp-1 text-xs text-accent">{condition.note}</span>
+ )}
+ </div>
+ {canEdit ? (
+ <div className="flex shrink-0 items-center gap-2">
+ <Toggle
+ aria-label={`${reminder.enabled ? "Disable" : "Enable"} ${reminder.name}`}
+ variant="project"
+ checked={reminder.enabled}
+ disabled={updateAlert.isPending}
+ onCheckedChange={handleToggleEnabled}
+ />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost-muted"
+ size="xs"
+ aria-label={`Options for ${reminder.name}`}
+ >
+ <EllipsisIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={onEdit}>
+ <PencilIcon />
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuItem variant="danger" onClick={onRemove}>
+ <TrashIcon />
+ Remove
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ ) : (
+ <Badge variant={reminder.enabled ? "success" : "neutral"}>
+ {reminder.enabled ? "Active" : "Disabled"}
+ </Badge>
+ )}
+ </div>
+ );
+};
+
+export const SecretReminders = ({
+ secretId,
+ secretKey,
+ environmentName,
+ canEdit,
+ isOpen,
+ onOpenChange
+}: Props) => {
+ const { data: reminders = [] } = useSecretReminders(secretId);
+ const deleteAlert = useDeleteAlert();
+
+ const [isSheetOpen, setIsSheetOpen] = useState(false);
+ const [editingReminder, setEditingReminder] = useState<TAlert>();
+ const [removingReminder, setRemovingReminder] = useState<TAlert>();
+
+ const enabledCount = reminders.filter((reminder) => reminder.enabled).length;
+
+ const openForm = (reminder?: TAlert) => {
+ setEditingReminder(reminder);
+ onOpenChange(false);
+ setIsSheetOpen(true);
+ };
+
+ const handleRemove = async () => {
+ if (!removingReminder) return;
+ try {
+ await deleteAlert.mutateAsync({ alertId: removingReminder.id });
+ createNotification({ text: `Reminder "${removingReminder.name}" removed`, type: "success" });
+ setRemovingReminder(undefined);
+ } catch {
+ // MutationCache reports request errors globally; keep the dialog open.
+ }
+ };
+
+ return (
+ <>
+ <Popover open={isOpen} onOpenChange={onOpenChange}>
+ <PopoverAnchor asChild>
+ <span className="pointer-events-none absolute inset-0" />
+ </PopoverAnchor>
+ <PopoverContent
+ onCloseAutoFocus={(e) => e.preventDefault()}
+ className="w-[420px] p-0"
+ side="left"
+ >
+ <div className="flex items-center justify-between gap-2 border-b border-border px-4 py-3">
+ <div className="flex min-w-0 flex-col">
+ <span className="text-sm font-semibold text-foreground">Reminders</span>
+ <span className="truncate text-xs text-accent">
+ {secretKey} in {environmentName}
+ </span>
+ </div>
+ {reminders.length > 0 && (
+ <span className="shrink-0 text-xs text-muted">
+ {enabledCount} of {reminders.length} enabled
+ </span>
+ )}
+ </div>
+
+ {reminders.length ? (
+ <div className="max-h-80 divide-y divide-border overflow-y-auto">
+ {reminders.map((reminder) => (
+ <ReminderRow
+ key={reminder.id}
+ reminder={reminder}
+ canEdit={canEdit}
+ onEdit={() => openForm(reminder)}
+ onRemove={() => {
+ onOpenChange(false);
+ setRemovingReminder(reminder);
+ }}
+ />
+ ))}
+ </div>
+ ) : (
+ <div className="flex flex-col items-center gap-1 px-4 py-6 text-center">
+ <BellIcon className="mb-1 size-5 text-muted" />
+ <span className="text-sm text-foreground">No reminders yet</span>
+ <span className="text-xs text-accent">
+ Add a reminder to get notified when this secret is due for rotation.
+ </span>
+ </div>
+ )}
+
+ <div className="flex items-center justify-between gap-2 border-t border-border px-4 py-3">
+ {canEdit ? (
+ <Button variant="project" size="xs" onClick={() => openForm()}>
+ <PlusIcon />
+ Add Reminder
+ </Button>
+ ) : (
+ <span className="text-xs text-muted">
+ You do not have permission to manage reminders on this secret.
+ </span>
+ )}
+ <Button variant="ghost" size="xs" onClick={() => onOpenChange(false)}>
+ Close
+ </Button>
+ </div>
+ </PopoverContent>
+ </Popover>
+
+ <Sheet open={isSheetOpen} onOpenChange={setIsSheetOpen}>
+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">
+ <SheetHeader className="border-b">
+ <SheetTitle>{editingReminder ? "Edit Reminder" : "Add Reminder"}</SheetTitle>
+ <SheetDescription>
+ Notify your channels on a schedule for {secretKey} in {environmentName}.
+ </SheetDescription>
+ </SheetHeader>
+ {isSheetOpen && (
+ <SecretReminderForm
+ key={editingReminder?.id ?? "new"}
+ secretId={secretId}
+ reminder={editingReminder}
+ onComplete={() => setIsSheetOpen(false)}
+ onCancel={() => setIsSheetOpen(false)}
+ />
+ )}
+ </SheetContent>
+ </Sheet>
+
+ <AlertDialog
+ open={Boolean(removingReminder)}
+ onOpenChange={(open) => !open && setRemovingReminder(undefined)}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Remove Reminder?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Remove &quot;{removingReminder?.name}&quot; from {secretKey}. Its channels stop
+ receiving notifications, and this cannot be undone.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel isDisabled={deleteAlert.isPending}>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ variant="danger"
+ isPending={deleteAlert.isPending}
+ onClick={(event) => {
+ event.preventDefault();
+ handleRemove();
+ }}
+ >
+ Remove Reminder
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/index.ts b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/index.ts
new file mode 100644
index 0000000000..6aea0ba211
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/index.ts
@@ -0,0 +1 @@
+export { SecretReminders } from "./SecretReminders";
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/secret-reminder-fns.ts b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/secret-reminder-fns.ts
new file mode 100644
index 0000000000..f71e021b7a
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/secret-reminder-fns.ts
@@ -0,0 +1,43 @@
+import { addDays, differenceInCalendarDays, format, startOfDay } from "date-fns";
+
+import { SecretReminderRecurrence, TAlert, TSecretReminderCondition } from "@app/hooks/api/alerts";
+
+export const getReminderCondition = (alert: TAlert): TSecretReminderCondition | null => {
+ const condition = alert.condition ?? {};
+ if (!condition.recurrence || !condition.startDate) return null;
+ return {
+ recurrence: condition.recurrence,
+ startDate: condition.startDate,
+ repeatDays: condition.repeatDays ?? null,
+ note: condition.note ?? null
+ };
+};
+
+// Null once a one-off reminder's date has passed.
+export const getNextReminderDate = (
+ condition: TSecretReminderCondition,
+ asOf: Date = new Date()
+): Date | null => {
+ const start = startOfDay(new Date(condition.startDate));
+ const today = startOfDay(asOf);
+
+ if (condition.recurrence === SecretReminderRecurrence.OneTime || !condition.repeatDays) {
+ return start >= today ? start : null;
+ }
+
+ if (start >= today) return start;
+ const elapsedPeriods = Math.ceil(differenceInCalendarDays(today, start) / condition.repeatDays);
+ return addDays(start, elapsedPeriods * condition.repeatDays);
+};
+
+export const formatReminderSchedule = (condition: TSecretReminderCondition): string => {
+ const next = getNextReminderDate(condition);
+
+ if (condition.recurrence === SecretReminderRecurrence.OneTime || !condition.repeatDays) {
+ const date = format(new Date(condition.startDate), "MMM d, yyyy");
+ return next ? `Once on ${date}` : `Sent on ${date}`;
+ }
+
+ const interval = condition.repeatDays === 1 ? "day" : `${condition.repeatDays} days`;
+ return next ? `Every ${interval}, next ${format(next, "MMM d, yyyy")}` : `Every ${interval}`;
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/useSecretReminders.ts b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/useSecretReminders.ts
new file mode 100644
index 0000000000..8be84d47f3
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/useSecretReminders.ts
@@ -0,0 +1,20 @@
+import { useCallback } from "react";
+
+import { useProject } from "@app/context";
+import { AlertResourceType, TAlert, useListAlerts } from "@app/hooks/api/alerts";
+
+// Every row reads the same project-wide list, so React Query sends one request per project rather
+// than one per secret.
+export const useSecretReminders = (secretId?: string) => {
+ const { projectId } = useProject();
+
+ const select = useCallback(
+ (alerts: TAlert[]) => alerts.filter((alert) => alert.resourceId === secretId),
+ [secretId]
+ );
+
+ return useListAlerts(
+ { resourceType: AlertResourceType.SecretReminder, projectId },
+ { enabled: Boolean(secretId), select }
+ );
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
index 4c5e7832d4..f1d6dfc486 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
@@ -413,7 +413,6 @@ export const SecretTableRow = ({
tags={singleEnvSecret?.tags}
secretMetadata={singleEnvSecret?.secretMetadata}
skipMultilineEncoding={singleEnvSecret?.skipMultilineEncoding}
- reminder={singleEnvSecret?.reminder}
revokedProjectFolderGrant={singleEnvSecret?.revokedProjectFolderGrant}
onCopySecret={
singleEnvSecret?.id
@@ -756,7 +755,6 @@ export const SecretTableRow = ({
tags={secret?.tags}
secretMetadata={secret?.secretMetadata}
skipMultilineEncoding={secret?.skipMultilineEncoding}
- reminder={secret?.reminder}
revokedProjectFolderGrant={secret?.revokedProjectFolderGrant}
onCopySecret={
secret?.id
diff --git a/frontend/src/views/Alerts/AlertForm.tsx b/frontend/src/views/Alerts/AlertForm.tsx
index 541f935d3c..b27386e787 100644
--- a/frontend/src/views/Alerts/AlertForm.tsx
+++ b/frontend/src/views/Alerts/AlertForm.tsx
@@ -35,8 +35,8 @@ import {
parseAlertBeforeDays,
TAlert,
TAlertForm,
- TChannelForm,
toAlertBefore,
+ toChannelForm,
toChannelInput,
useCreateAlert,
useUpdateAlert
@@ -64,21 +64,6 @@ const AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: Record<AlertEventType, string> = {
};
const DEFAULT_EVENT_TYPE = AlertEventType.IdentityAuthenticationExpiry;
-const toChannelForm = (channel: TAlert["channels"][number]): TChannelForm => ({
- id: channel.id,
- channelType: channel.channelType,
- name: channel.name,
- enabled: channel.enabled,
- recipients: channel.recipients,
- webhookUrl: "",
- url: (channel.config.url as string) ?? "",
- signingSecret: "",
- integrationKey: "",
- hasWebhookUrl: Boolean(channel.config.hasWebhookUrl),
- hasSigningSecret: Boolean(channel.config.hasSigningSecret),
- hasIntegrationKey: Boolean(channel.config.hasIntegrationKey)
-});
-
const buildFormDefaults = (
alert: TAlert | undefined,
defaultEventType: AlertEventType,
diff --git a/frontend/src/views/Alerts/ChannelCard.tsx b/frontend/src/views/Alerts/ChannelCard.tsx
index 51fd317d02..1dde359df8 100644
--- a/frontend/src/views/Alerts/ChannelCard.tsx
+++ b/frontend/src/views/Alerts/ChannelCard.tsx
@@ -22,7 +22,7 @@ import { useScopeVariant } from "@app/hooks";
import {
ALERT_CHANNEL_TYPE_LABELS,
AlertChannelType,
- TAlertForm,
+ TChannelsForm,
toChannelInput,
useTestAlertChannel
} from "@app/hooks/api/alerts";
@@ -91,7 +91,7 @@ export const ChannelCard = ({
getValues,
trigger,
formState: { errors }
- } = useFormContext<TAlertForm>();
+ } = useFormContext<TChannelsForm>();
const testChannel = useTestAlertChannel();
const channel = useWatch({ control, name: `channels.${index}` });
diff --git a/frontend/src/views/Alerts/ChannelsField.tsx b/frontend/src/views/Alerts/ChannelsField.tsx
index a022e39cb2..6f8abd0795 100644
--- a/frontend/src/views/Alerts/ChannelsField.tsx
+++ b/frontend/src/views/Alerts/ChannelsField.tsx
@@ -13,8 +13,8 @@ import {
ALERT_CHANNEL_TYPE_LABELS,
AlertChannelType,
AlertPrincipalType,
- TAlertForm,
- TChannelForm
+ TChannelForm,
+ TChannelsForm
} from "@app/hooks/api/alerts";
import { ChannelCard } from "./ChannelCard";
@@ -42,7 +42,7 @@ export const ChannelsField = ({ projectId, resourceType, resourceId }: Props) =>
control,
getValues,
formState: { errors }
- } = useFormContext<TAlertForm>();
+ } = useFormContext<TChannelsForm>();
const { fields, append, remove } = useFieldArray({ control, name: "channels" });
const rootError = errors.channels?.message || errors.channels?.root?.message;
diff --git a/frontend/src/views/Alerts/index.ts b/frontend/src/views/Alerts/index.ts
index 68fe73c77e..9c96cc2c66 100644
--- a/frontend/src/views/Alerts/index.ts
+++ b/frontend/src/views/Alerts/index.ts
@@ -1,2 +1,3 @@
export { AddAlertModal } from "./AddAlertModal";
export { AlertAction } from "./AlertAction";
+export { ChannelsField } from "./ChannelsField";