import { Controller, useFormContext } from "react-hook-form"; import { faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format, setHours, setMinutes } from "date-fns"; import { FilterableSelect, FormControl, Input, Switch } from "@app/components/v2"; import { getRotateAtLocal, IS_ROTATION_DUAL_CREDENTIALS, SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2"; import { ProjectEnv } from "@app/hooks/api/projects/types"; import { TSecretRotationV2Form } from "./schemas"; import { SecretRotationV2ConnectionField } from "./SecretRotationV2ConnectionField"; type Props = { isUpdate: boolean; environments?: ProjectEnv[]; }; export const SecretRotationV2ConfigurationFields = ({ isUpdate, environments }: Props) => { const { control, watch } = useFormContext(); const [type, isAutoRotationEnabled] = watch(["type", "isAutoRotationEnabled"]); return ( <>

Configure the connection rotation strategy for this Secret Rotation.

{!isUpdate && environments && ( ( option?.name} getOptionValue={(option) => option?.id} /> )} /> )} ( )} control={control} name="rotationInterval" /> { return ( { const time = e.target.value; if (time) { const [hours, minutes] = time.split(":").map((str) => parseInt(str, 10)); const newSelectedDate = setHours(setMinutes(new Date(), minutes), hours); onChange({ hours: newSelectedDate.getUTCHours(), minutes: newSelectedDate.getUTCMinutes() }); } }} className="bg-mineshaft-700 text-white scheme-dark" /> ); }} control={control} name="rotateAtUtc" /> { return (

Auto-Rotation {value ? "Enabled" : "Disabled"}

); }} /> {!IS_ROTATION_DUAL_CREDENTIALS[type] && isAutoRotationEnabled && (
Due to{" "} {SECRET_ROTATION_MAP[type].name} Rotations rotating a single credential set, auto-rotation may result in service interruptions. If you need to ensure service continuity, we recommend disabling this option.
Read more .
)} ); };