Skip to content

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

feat(secret-sync): add the include-subfolders toggle to the sync form

Calvine02c60afcf4f
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
index df939a07f5..8669804adb 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
@@ -96,7 +96,7 @@ export const SecretSyncReviewFields = () => {
connection,
environment,
secretPath,
- syncOptions: { disableSecretDeletion, initialSyncBehavior, keySchema },
+ syncOptions: { disableSecretDeletion, initialSyncBehavior, keySchema, recursive },
destination,
isAutoSyncEnabled
} = watch();
@@ -357,6 +357,14 @@ export const SecretSyncReviewFields = () => {
)}
</Detail>
{AdditionalSyncOptionsFieldsComponent}
+ <Detail>
+ <DetailLabel>Include Subfolders</DetailLabel>
+ <DetailValue>
+ <Badge variant={recursive ? "success" : "neutral"}>
+ {recursive ? "Enabled" : "Disabled"}
+ </Badge>
+ </DetailValue>
+ </Detail>
<Detail>
<DetailLabel>Secret Deletion Protection</DetailLabel>
<DetailValue>
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
index 3fdc1593e4..05c21cc167 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
@@ -5,30 +5,39 @@ import { subject } from "@casl/ability";
import {
Field,
FieldContent,
+ FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FilterableSelect,
- SecretPathInput
+ Label,
+ SecretPathInput,
+ Switch
} from "@app/components/v3";
import { useProject, useProjectPermission } from "@app/context";
import {
ProjectPermissionSecretSyncActions,
ProjectPermissionSub
} from "@app/context/ProjectPermissionContext/types";
-import { SecretSync } from "@app/hooks/api/secretSyncs";
+import { SecretSync, SecretSyncInitialSyncBehavior } from "@app/hooks/api/secretSyncs";
import { AzureEntraIdScimSyncSourceFields } from "./AzureEntraIdScimSyncSourceFields";
import { TSecretSyncForm } from "./schemas";
const DefaultSecretSyncSourceFields = () => {
- const { control, watch, setError, clearErrors } = useFormContext<TSecretSyncForm>();
+ const { control, watch, setValue, setError, clearErrors } = useFormContext<TSecretSyncForm>();
const { permission } = useProjectPermission();
const { currentProject } = useProject();
const selectedEnvironment = watch("environment");
const selectedSecretPath = watch("secretPath");
+ const initialSyncBehavior = watch("syncOptions.initialSyncBehavior");
+ const recursive = watch("syncOptions.recursive");
+
+ const importsFromDestination =
+ initialSyncBehavior === SecretSyncInitialSyncBehavior.ImportPrioritizeSource ||
+ initialSyncBehavior === SecretSyncInitialSyncBehavior.ImportPrioritizeDestination;
useEffect(() => {
if (!selectedEnvironment) {
@@ -53,6 +62,12 @@ const DefaultSecretSyncSourceFields = () => {
}
}, [selectedEnvironment, selectedSecretPath]);
+ useEffect(() => {
+ if (importsFromDestination && recursive) {
+ setValue("syncOptions.recursive", false);
+ }
+ }, [importsFromDestination, recursive, setValue]);
+
return (
<FieldGroup>
<Controller
@@ -96,6 +111,32 @@ const DefaultSecretSyncSourceFields = () => {
</Field>
)}
/>
+ <Controller
+ control={control}
+ name="syncOptions.recursive"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field>
+ <Field orientation="horizontal">
+ <FieldContent>
+ <Label htmlFor="recursive">Include subfolders</Label>
+ <FieldDescription>
+ {importsFromDestination
+ ? "Not available when the initial sync imports secrets from the destination. There is no single folder to import them back into."
+ : "Also sync secrets from every folder beneath this path. Secret names must be unique across those folders."}
+ </FieldDescription>
+ </FieldContent>
+ <Switch
+ id="recursive"
+ variant="project"
+ checked={Boolean(value) && !importsFromDestination}
+ disabled={importsFromDestination}
+ onCheckedChange={onChange}
+ />
+ </Field>
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
</FieldGroup>
);
};
diff --git a/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
index 962649c1bb..a09a96d892 100644
--- a/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
+++ b/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
@@ -9,6 +9,7 @@ export const BaseSecretSyncSchema = <T extends AnyZodObject | undefined = undefi
const baseSyncOptionsSchema = z.object({
initialSyncBehavior: z.nativeEnum(SecretSyncInitialSyncBehavior),
disableSecretDeletion: z.boolean().optional().default(false),
+ recursive: z.boolean().optional(),
keySchema: z
.string()
.optional()
diff --git a/frontend/src/hooks/api/secretSyncs/types/root-sync.ts b/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
index 38c9efdf2b..25ccb2727a 100644
--- a/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
+++ b/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
@@ -5,6 +5,7 @@ export type RootSyncOptions = {
initialSyncBehavior: SecretSyncInitialSyncBehavior;
disableSecretDeletion?: boolean;
keySchema?: string;
+ recursive?: boolean;
};
export type TRootSecretSync = {