Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(ui): send secret reminders to any alert channel
Calvinc19ad0edcbbd
diff --git a/frontend/src/hooks/api/alerts/queries.ts b/frontend/src/hooks/api/alerts/queries.tsindex 663af0d037..7cb530d573 100644--- a/frontend/src/hooks/api/alerts/queries.ts+++ b/frontend/src/hooks/api/alerts/queries.ts@@ -9,7 +9,7 @@ export const alertKeys = {list: (filters: TListAlertsDTO) => [...alertKeys.all, "list", filters] as const};-const fetchAlerts = async (filters: TListAlertsDTO) => {+export const fetchAlerts = async (filters: TListAlertsDTO) => {const { data } = await apiRequest.get<{ alerts: TAlert[] }>("/api/v1/alerts", {params: filters});diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.tsindex c927843f01..7e84f126a5 100644--- a/frontend/src/hooks/api/alerts/types.ts+++ b/frontend/src/hooks/api/alerts/types.ts@@ -10,24 +10,6 @@ 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",@@ -37,7 +19,8 @@ export enum AlertChannelType {export enum AlertPrincipalType {User = "user",- Group = "group"+ Group = "group",+ ProjectMembers = "project-members"}export const MIN_ALERT_BEFORE_DAYS = 1;@@ -88,9 +71,7 @@ export type TAlert = {resourceType: string;resourceId: string | null;eventType: string;- condition:- | ({ alertBefore?: string; dailyReminder?: boolean } & Partial<TSecretReminderCondition>)- | null;+ condition: { alertBefore?: string; dailyReminder?: boolean } | null;enabled: boolean;orgId: string;projectId: string | null;diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsxindex ded5d7fe77..ff9326b9eb 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx@@ -94,6 +94,7 @@ import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionCoimport { 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";@@ -105,11 +106,10 @@ 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 { SecretReminders } from "./SecretReminders";+import { SecretReminderForm } from "./SecretReminderForm";import { SecretTagForm } from "./SecretTagForm";import { SecretVersionHistory } from "./SecretVersionHistory";@@ -125,6 +125,7 @@ type Props = {tags?: WsTag[];secretMetadata?: { key: string; value: string; isEncrypted?: boolean }[];skipMultilineEncoding?: boolean | null;+ reminder?: Reminder;environment: string;environmentName: string;secretValueHidden: boolean;@@ -207,6 +208,7 @@ export const SecretEditTableRow = ({secretMetadata,environmentName,skipMultilineEncoding,+ reminder,isSingleEnvView,isBatchMode,isPendingCreate,@@ -344,8 +346,6 @@ 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,16 +1079,14 @@ export const SecretEditTableRow = ({</TooltipContent></Tooltip>) : null}- {hasReminders && !isImportedSecret && (+ {reminder && !isImportedSecret && (<Tooltip><TooltipTrigger asChild><span className="flex size-5 items-center justify-center text-muted"><BellIcon className="size-3.5" /></span></TooltipTrigger>- <TooltipContent>- {reminders.length} reminder{reminders.length > 1 ? "s" : ""}- </TooltipContent>+ <TooltipContent>Has reminder</TooltipContent></Tooltip>)}{secretMetadata?.length && !isImportedSecret ? (@@ -1234,16 +1232,27 @@ export const SecretEditTableRow = ({/></PopoverContent></Popover>- {secretId && (- <SecretReminders- secretId={secretId}- secretKey={secretName}- environmentName={environmentName}- canEdit={canEditSecretValue}- isOpen={isReminderOpen}- onOpenChange={setIsReminderOpen}- />- )}+ <Sheet open={isReminderOpen} onOpenChange={setIsReminderOpen}>+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-lg">+ <SheetHeader className="border-b">+ <SheetTitle>{reminder ? "Edit Reminder" : "Add Reminder"}</SheetTitle>+ <SheetDescription>+ Notify the channels below when {secretName} in {environmentName} is due for+ rotation.+ </SheetDescription>+ </SheetHeader>+ {secretId && isReminderOpen && (+ <SecretReminderForm+ secretId={secretId}+ secretKey={secretName}+ secretPath={secretPath}+ environment={environment}+ reminder={reminder}+ onClose={() => setIsReminderOpen(false)}+ />+ )}+ </SheetContent>+ </Sheet><Popover open={isMetadataOpen} onOpenChange={setIsMetadataOpen}><PopoverAnchor asChild><span className="pointer-events-none absolute inset-0" />@@ -1291,12 +1300,7 @@ export const SecretEditTableRow = ({{!isImportedSecret &&!isCreatable &&!isPendingDelete &&- !!(- comment ||- (canReadTags && tags?.length) ||- hasReminders ||- secretMetadata?.length- ) && (+ !!(comment || (canReadTags && tags?.length) || reminder || secretMetadata?.length) && (<>{comment && (<Tooltip>@@ -1330,11 +1334,11 @@ export const SecretEditTableRow = ({<TooltipContent>View Tags</TooltipContent></Tooltip>) : null}- {hasReminders && (+ {reminder && (<Tooltip><TooltipTrigger asChild><IconButton- aria-label="View secret reminders"+ aria-label="View secret reminder"variant="ghost"size="xs"className="size-7 border-0"@@ -1343,7 +1347,7 @@ export const SecretEditTableRow = ({<BellIcon className="size-3.5" /></IconButton></TooltipTrigger>- <TooltipContent>View Reminders</TooltipContent>+ <TooltipContent>View Reminder</TooltipContent></Tooltip>)}{secretMetadata?.length ? (@@ -1461,7 +1465,7 @@ export const SecretEditTableRow = ({"px-2.5 py-1.5",(comment ||(canReadTags && tags?.length) ||- hasReminders ||+ reminder ||secretMetadata?.length) &&!isImportedSecret &&"[&>svg:first-child]:text-project"@@ -1503,8 +1507,8 @@ export const SecretEditTableRow = ({isDisabled={!secretId || isPendingCreate}onClick={() => setPendingAnnotation("reminder")}>- <BellIcon className={twMerge(hasReminders && "text-project")} />- {hasReminders ? "View Reminders" : "Add Reminder"}+ <BellIcon className={twMerge(reminder && "text-project")} />+ {reminder ? "View Reminder" : "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.tsxnew file mode 100644index 0000000000..1088d40ac6--- /dev/null+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminderForm.tsx@@ -0,0 +1,513 @@+import { useCallback, useEffect, useMemo } from "react";+import { Controller, FormProvider, 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,+ Input,+ Popover,+ PopoverContent,+ PopoverTrigger,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ SheetFooter,+ TextArea+} from "@app/components/v3";+import { useProject, useProjectPermission } from "@app/context";+import {+ ProjectPermissionSecretActions,+ ProjectPermissionSub+} from "@app/context/ProjectPermissionContext/types";+import {+ AlertChannelType,+ alertKeys,+ AlertPrincipalType,+ AlertResourceType,+ channelFormSchema,+ fetchAlerts,+ TChannelForm,+ toChannelForm,+ toChannelInput,+ useListAlerts,+ useUpdateAlert+} from "@app/hooks/api/alerts";+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";+import { ChannelsField } from "@app/views/Alerts";++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(),+ channels: z.array(channelFormSchema).min(1, "At least one channel is required"),+ 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 { mutateAsync: updateAlert, isPending: isUpdatingAlert } = useUpdateAlert();++ const alertFilters = {+ resourceType: AlertResourceType.SecretReminder,+ projectId,+ resourceId: secretId+ };+ const { data: alerts, isPending: isAlertLoading } = useListAlerts(alertFilters, {+ enabled: Boolean(reminder)+ });+ const alert = alerts?.[0];++ const isEditMode = Boolean(reminder);++ const canEditSecret = permission.can(+ ProjectPermissionSecretActions.Edit,+ subject(ProjectPermissionSub.Secrets, {+ environment,+ secretPath,+ secretName: secretKey,+ secretTags: ["*"]+ })+ );++ const everyoneEmailChannel = useMemo<TChannelForm>(+ () => ({+ channelType: AlertChannelType.Email,+ name: "Email",+ enabled: true,+ recipients: [+ { principalType: AlertPrincipalType.ProjectMembers, principalId: currentProject.id }+ ],+ webhookUrl: "",+ url: "",+ signingSecret: "",+ integrationKey: ""+ }),+ [currentProject.id]+ );++ const formMethods = 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,+ channels: [everyoneEmailChannel]+ },+ resolver: zodResolver(formSchema)+ });+ const {+ handleSubmit,+ control,+ setValue,+ watch,+ reset,+ formState: { isDirty }+ } = formMethods;++ const reminderType = watch("reminderType");+ const fromDate = watch("fromDate");++ useEffect(() => {+ if (alert) setValue("channels", alert.channels.map(toChannelForm), { shouldDirty: false });+ }, [alert, setValue]);++ const isPending = isCreating || isDeleting || isUpdatingAlert;++ 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.invalidateQueries({ queryKey: alertKeys.all });+ }, [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) => {+ // The reminder API saves the schedule and keeps the alert's email recipients in step with the users+ // it is given. The alert update that follows then sets every channel exactly as the form has them.+ const emailUserIds = data.channels+ .filter((channel) => channel.channelType === AlertChannelType.Email)+ .flatMap((channel) => channel.recipients)+ .filter((recipient) => recipient.principalType === AlertPrincipalType.User)+ .map((recipient) => recipient.principalId);++ await createReminder({+ repeatDays: data.repeatDays,+ message: data.message,+ recipients: [...new Set(emailUserIds)],+ secretId,+ nextReminderDate: data.nextReminderDate,+ fromDate: data.fromDate+ });++ const [savedAlert] = await queryClient.fetchQuery({+ queryKey: alertKeys.list(alertFilters),+ queryFn: () => fetchAlerts(alertFilters),+ staleTime: 0+ });+ if (savedAlert) {+ // Saving the schedule can replace email channels, so an id the form still holds may be gone.+ const savedChannelIds = new Set(savedAlert.channels.map((channel) => channel.id));+ await updateAlert({+ alertId: savedAlert.id,+ channels: data.channels.map((channel) =>+ toChannelInput(+ channel.id && !savedChannelIds.has(channel.id) ? { ...channel, id: undefined } : channel+ )+ )+ });+ }++ 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 (+ <FormProvider {...formMethods}>+ <form+ onSubmit={handleSubmit(onSubmit)}+ className="flex min-h-0 flex-1 flex-col overflow-y-auto"+ >+ <div className="flex flex-col gap-4 p-4">+ <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>++ {reminder && isAlertLoading ? (+ <p className="text-xs text-muted">Loading channels...</p>+ ) : (+ <ChannelsField+ projectId={projectId}+ resourceType={AlertResourceType.SecretReminder}+ resourceId={secretId}+ />+ )}++ {!canEditSecret && (+ <p className="mt-2 text-xs text-muted">+ You do not have permission to manage reminders on this secret.+ </p>+ )}+ </div>++ <SheetFooter className="sticky bottom-0 mt-auto flex-row border-t bg-popover">+ {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 || isUpdatingAlert}+ >+ {isEditMode ? "Update" : "Create"} Reminder+ </Button>+ )}+ </SheetFooter>+ </form>+ </FormProvider>+ );+};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.tsxdeleted file mode 100644index 6629d155cb..0000000000--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminderForm.tsx+++ /dev/null@@ -1,356 +0,0 @@-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.tsxdeleted file mode 100644index c8a7097f41..0000000000--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/SecretReminders.tsx+++ /dev/null@@ -1,306 +0,0 @@-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 "{removingReminder?.name}" 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.tsdeleted file mode 100644index 6aea0ba211..0000000000--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/index.ts+++ /dev/null@@ -1 +0,0 @@-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.tsdeleted file mode 100644index f71e021b7a..0000000000--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/secret-reminder-fns.ts+++ /dev/null@@ -1,43 +0,0 @@-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.tsdeleted file mode 100644index 8be84d47f3..0000000000--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretReminders/useSecretReminders.ts+++ /dev/null@@ -1,20 +0,0 @@-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.tsxindex f1d6dfc486..4c5e7832d4 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx@@ -413,6 +413,7 @@ export const SecretTableRow = ({tags={singleEnvSecret?.tags}secretMetadata={singleEnvSecret?.secretMetadata}skipMultilineEncoding={singleEnvSecret?.skipMultilineEncoding}+ reminder={singleEnvSecret?.reminder}revokedProjectFolderGrant={singleEnvSecret?.revokedProjectFolderGrant}onCopySecret={singleEnvSecret?.id@@ -755,6 +756,7 @@ export const SecretTableRow = ({tags={secret?.tags}secretMetadata={secret?.secretMetadata}skipMultilineEncoding={secret?.skipMultilineEncoding}+ reminder={secret?.reminder}revokedProjectFolderGrant={secret?.revokedProjectFolderGrant}onCopySecret={secret?.iddiff --git a/frontend/src/views/Alerts/ChannelRecipientsField.tsx b/frontend/src/views/Alerts/ChannelRecipientsField.tsxindex 7e78761e69..ece5bfb868 100644--- a/frontend/src/views/Alerts/ChannelRecipientsField.tsx+++ b/frontend/src/views/Alerts/ChannelRecipientsField.tsx@@ -15,9 +15,16 @@ type RecipientOption = {principalType: AlertPrincipalType;principalId: string;label: string;- groupLabel: "Users" | "Groups";+ groupLabel: "Project" | "Users" | "Groups";};+const projectMembersOption = (projectId: string): RecipientOption => ({+ principalType: AlertPrincipalType.ProjectMembers,+ principalId: projectId,+ label: "All Project Members",+ groupLabel: "Project"+});+const userLabel = (user: { firstName?: string; lastName?: string; username?: string }): string =>user.username || `${user.firstName ?? ""} ${user.lastName ?? ""}`.trim() || "Unknown user";@@ -41,7 +48,7 @@ const buildOptions = (const formatOptionLabel = (option: RecipientOption) => (<span className="flex items-center gap-2">- {option.principalType === AlertPrincipalType.Group ? (+ {option.principalType !== AlertPrincipalType.User ? (<UsersIcon className="size-3.5 text-muted" />) : (<UserIcon className="size-3.5 text-muted" />@@ -149,11 +156,12 @@ const ProjectRecipientSelect = ({);const groupOptions = groups.map((membership) => membership.group);+ const everyone = projectMembersOption(projectId);return (<RecipientSelect- options={buildOptions(eligibleUsers, groupOptions)}- labelledOptions={buildOptions(users, groupOptions)}+ options={[everyone, ...buildOptions(eligibleUsers, groupOptions)]}+ labelledOptions={[everyone, ...buildOptions(users, groupOptions)]}{...props}/>);