Merge pull request #3625 from Infisical/ENG-2795

fix secret rollback not tainting form
This commit is contained in:
x032205
2025-05-19 16:17:26 -04:00
committed by GitHub
@@ -95,7 +95,6 @@ export const SecretDetailSidebar = ({
handleSecretShare handleSecretShare
}: Props) => { }: Props) => {
const { const {
register,
control, control,
watch, watch,
handleSubmit, handleSubmit,
@@ -104,7 +103,8 @@ export const SecretDetailSidebar = ({
formState: { isDirty, isSubmitting } formState: { isDirty, isSubmitting }
} = useForm<TFormSchema>({ } = useForm<TFormSchema>({
resolver: zodResolver(formSchema), resolver: zodResolver(formSchema),
values: secret values: secret,
disabled: !secret
}); });
const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp([ const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp([
@@ -713,14 +713,25 @@ export const SecretDetailSidebar = ({
</FormControl> </FormControl>
</div> </div>
</div> </div>
<FormControl label="Comments & Notes"> <Controller
control={control}
name="comment"
render={({ field, fieldState: { error } }) => (
<FormControl
label="Comments & Notes"
isError={Boolean(error?.message)}
errorText={error?.message}
className="mb-0"
>
<TextArea <TextArea
className="border border-mineshaft-600 bg-bunker-800 text-sm" className="border border-mineshaft-600 bg-bunker-800 text-sm"
{...register("comment")}
readOnly={isReadOnly} readOnly={isReadOnly}
rows={5} rows={5}
{...field}
/> />
</FormControl> </FormControl>
)}
/>
<FormControl> <FormControl>
{secretReminderRepeatDays && secretReminderRepeatDays > 0 ? ( {secretReminderRepeatDays && secretReminderRepeatDays > 0 ? (
<div className="flex items-center justify-between px-2"> <div className="flex items-center justify-between px-2">
@@ -921,7 +932,9 @@ export const SecretDetailSidebar = ({
variant="outline_bg" variant="outline_bg"
size="sm" size="sm"
className="h-8 w-8 rounded-md" className="h-8 w-8 rounded-md"
onClick={() => setValue("value", secretValue)} onClick={() =>
setValue("value", secretValue, { shouldDirty: true })
}
> >
<FontAwesomeIcon icon={faArrowRotateRight} /> <FontAwesomeIcon icon={faArrowRotateRight} />
</IconButton> </IconButton>