Skip to content

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

improvement: require confirmation to navigate back to provider step

Scott Wilsona6771514de15
diff --git a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
index e6d292d59a..a5d0d411b7 100644
--- a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
+++ b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
@@ -153,6 +153,7 @@ export const CreateSecretSyncForm = ({
const formTabs = getFormTabs(destination, destinationName);
const [showConfirmation, setShowConfirmation] = useState(false);
+ const [confirmBackToProvidersOpen, setConfirmBackToProvidersOpen] = useState(false);
// scoot: right now we only do this when creating a connection so we know index 1
const [selectedTabIndex, setSelectedTabIndex] = useState(initialFormData ? 1 : 0);
@@ -175,6 +176,8 @@ export const CreateSecretSyncForm = ({
reValidateMode: "onChange"
});
+ const { handleSubmit, trigger, control, watch, formState } = formMethods;
+
const onSubmit = async ({ environment, connection, ...formData }: TSecretSyncForm) => {
try {
const secretSync = await createSecretSync.mutateAsync({
@@ -196,6 +199,10 @@ export const CreateSecretSyncForm = ({
const handlePrev = () => {
if (selectedTabIndex === 0) {
+ if (formState.isDirty) {
+ setConfirmBackToProvidersOpen(true);
+ return;
+ }
onCancel();
return;
}
@@ -203,8 +210,6 @@ export const CreateSecretSyncForm = ({
setSelectedTabIndex((prev) => prev - 1);
};
- const { handleSubmit, trigger, control, watch, formState } = formMethods;
-
const { hasDuplicate } = useDuplicateDestinationCheck({
destination,
projectId: currentProject?.id || "",
@@ -235,6 +240,10 @@ export const CreateSecretSyncForm = ({
// Provider step (index 0) jumps directly back to the provider selection screen,
// regardless of which form tab the user is currently on.
if (stepperIndex === 0) {
+ if (formState.isDirty) {
+ setConfirmBackToProvidersOpen(true);
+ return;
+ }
onCancel();
return;
}
@@ -397,6 +406,28 @@ export const CreateSecretSyncForm = ({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
+ <AlertDialog
+ open={confirmBackToProvidersOpen}
+ onOpenChange={setConfirmBackToProvidersOpen}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogMedia>
+ <AlertTriangleIcon />
+ </AlertDialogMedia>
+ <AlertDialogTitle>Discard Sync Setup?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Your progress configuring this sync will be lost.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Keep Editing</AlertDialogCancel>
+ <AlertDialogAction variant="danger" onClick={onCancel}>
+ Discard
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</FormProvider>
);
};