import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input } from "@app/components/v2"; import { useProject, useProjectPermission } from "@app/context"; import { useUpdateProject } from "@app/hooks/api"; import { ProjectMembershipRole } from "@app/hooks/api/roles/types"; const formSchema = z.object({ pitVersionLimit: z.coerce.number().min(1).max(100) }); type TForm = z.infer; export const PointInTimeVersionLimitSection = () => { const { mutateAsync: updateProject } = useUpdateProject(); const { currentProject, projectId } = useProject(); const { membership } = useProjectPermission(); const { control, formState: { isSubmitting, isDirty }, handleSubmit } = useForm({ resolver: zodResolver(formSchema), values: { pitVersionLimit: currentProject?.pitVersionLimit || 10 } }); if (!currentProject) return null; const handleVersionLimitSubmit = async ({ pitVersionLimit }: TForm) => { try { await updateProject({ pitVersionLimit, projectId }); createNotification({ text: "Successfully updated version limit", type: "success" }); } catch { createNotification({ text: "Failed updating project's version limit", type: "error" }); } }; const isAdmin = membership.roles.includes(ProjectMembershipRole.Admin); return (

Version Retention

This defines the maximum number of recent secret versions to keep per folder. Excess versions will be removed at midnight (UTC) each day.

( )} />
); };