final release

This commit is contained in:
x032205
2025-05-14 01:16:42 -04:00
parent bae62421ae
commit 63f0f8e299
22 changed files with 93 additions and 153 deletions
@@ -10,8 +10,7 @@ import {
ModalClose,
ModalContent,
Select,
SelectItem,
Switch
SelectItem
} from "@app/components/v2";
import { SECRET_SYNC_IMPORT_BEHAVIOR_MAP, SECRET_SYNC_MAP } from "@app/helpers/secretSyncs";
import {
@@ -32,20 +31,13 @@ type ContentProps = {
};
const FormSchema = z.object({
importBehavior: z.nativeEnum(SecretSyncImportBehavior),
filterForSchema: z.boolean(),
stripSchema: z.boolean()
importBehavior: z.nativeEnum(SecretSyncImportBehavior)
});
type TFormData = z.infer<typeof FormSchema>;
const Content = ({ secretSync, onComplete }: ContentProps) => {
const {
id: syncId,
destination,
projectId,
syncOptions: { keySchema }
} = secretSync;
const { id: syncId, destination, projectId } = secretSync;
const destinationName = SECRET_SYNC_MAP[destination].name;
const {
@@ -53,28 +45,18 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
control,
formState: { isSubmitting, isDirty }
} = useForm<TFormData>({
resolver: zodResolver(FormSchema),
defaultValues: {
filterForSchema: false,
stripSchema: false
}
resolver: zodResolver(FormSchema)
});
const triggerImportSecrets = useTriggerSecretSyncImportSecrets();
const handleTriggerImportSecrets = async ({
importBehavior,
filterForSchema,
stripSchema
}: TFormData) => {
const handleTriggerImportSecrets = async ({ importBehavior }: TFormData) => {
try {
await triggerImportSecrets.mutateAsync({
syncId,
destination,
importBehavior,
projectId,
filterForSchema,
stripSchema
projectId
});
createNotification({
@@ -151,64 +133,6 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
</FormControl>
)}
/>
{keySchema && (
<>
<Controller
control={control}
name="filterForSchema"
defaultValue
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl
tooltipClassName="max-w-md"
tooltipText={
<div className="flex flex-col gap-2">
<p>
If enabled, Infisical will only import destination secrets that match your key
schema:
</p>
<code className="text-mineshaft-300">{keySchema}</code>
</div>
}
label="Filter Keys for Schema"
isError={Boolean(error)}
errorText={error?.message}
>
<Switch
id="filter-for-schema"
thumbClassName="bg-mineshaft-800"
isChecked={value}
onCheckedChange={onChange}
>
Only import destination secrets that match schema
</Switch>
</FormControl>
)}
/>
<Controller
control={control}
name="stripSchema"
defaultValue
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl
tooltipClassName="max-w-md"
tooltipText="If enabled, Infisical will strip secret keys according to your schema. Keys that do not match the schema will not be affected."
label="Strip Schema"
isError={Boolean(error)}
errorText={error?.message}
>
<Switch
id="strip-schema"
thumbClassName="bg-mineshaft-800"
isChecked={value}
onCheckedChange={onChange}
>
Strip schema from imported secret keys
</Switch>
</FormControl>
)}
/>
</>
)}
<div className="mt-8 flex w-full items-center justify-between gap-2">
<ModalClose asChild>
<Button colorSchema="secondary" variant="plain">
@@ -86,12 +86,10 @@ export const useTriggerSecretSyncImportSecrets = () => {
mutationFn: async ({
syncId,
destination,
importBehavior,
filterForSchema,
stripSchema
importBehavior
}: TTriggerSecretSyncImportSecretsDTO) => {
const { data } = await apiRequest.post(
`/api/v1/secret-syncs/${destination}/${syncId}/import-secrets?importBehavior=${importBehavior}&filterForSchema=${filterForSchema}&stripSchema=${stripSchema}`
`/api/v1/secret-syncs/${destination}/${syncId}/import-secrets?importBehavior=${importBehavior}`
);
return data;
@@ -82,8 +82,6 @@ export type TTriggerSecretSyncImportSecretsDTO = {
syncId: string;
importBehavior: SecretSyncImportBehavior;
projectId: string;
filterForSchema: boolean;
stripSchema: boolean;
};
export type TTriggerSecretSyncRemoveSecretsDTO = {