import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; import { faTriangleExclamation, faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { useQueryClient } from "@tanstack/react-query"; import { z } from "zod"; import { createNotification } from "@app/components/notifications"; import { Button, Checkbox, Modal, ModalContent, Spinner } from "@app/components/v2"; import { useProject, useProjectPermission } from "@app/context"; import { usePopUp } from "@app/hooks"; import { projectKeys, useGetWorkspaceById, useMigrateProjectToV3 } from "@app/hooks/api"; import { ProjectVersion } from "@app/hooks/api/projects/types"; import { ProjectMembershipRole } from "@app/hooks/api/roles/types"; enum ProjectUpgradeStatus { InProgress = "IN_PROGRESS", // Completed -> Will be null if completed. So a completed status is not needed Failed = "FAILED" } const formSchema = z.object({ isCLIChecked: z.literal(true), isOperatorChecked: z.literal(true), shouldCloseOpenApprovals: z.literal(true) }); export const SecretV2MigrationSection = () => { const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["migrationInfo"] as const); const { currentProject } = useProject(); const queryClient = useQueryClient(); const { data: workspaceDetails, refetch } = useGetWorkspaceById( // if v3 no need to fetch currentProject?.version === ProjectVersion.V3 ? "" : currentProject?.id || "", { refetchInterval: currentProject?.upgradeStatus === ProjectUpgradeStatus.InProgress ? 2000 : false } ); const { hasProjectRole } = useProjectPermission(); const migrateProjectToV3 = useMigrateProjectToV3(); const { handleSubmit, control, reset } = useForm({ resolver: zodResolver(formSchema) }); useEffect(() => { if (!popUp.migrationInfo.isOpen) { reset(); } }, [popUp.migrationInfo.isOpen]); const isProjectUpgraded = workspaceDetails?.version === ProjectVersion.V3; useEffect(() => { if (isProjectUpgraded && migrateProjectToV3.data) { createNotification({ type: "success", text: "Project upgrade completed successfully" }); migrateProjectToV3.reset(); queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() }); } }, [isProjectUpgraded, Boolean(migrateProjectToV3.data)]); if (isProjectUpgraded || currentProject?.version === ProjectVersion.V3) return null; const isUpgrading = workspaceDetails?.upgradeStatus === ProjectUpgradeStatus.InProgress; const didProjectUpgradeFailed = workspaceDetails?.upgradeStatus === ProjectUpgradeStatus.Failed; const handleMigrationSecretV2 = async () => { try { handlePopUpToggle("migrationInfo"); await migrateProjectToV3.mutateAsync({ projectId: currentProject?.id || "" }); refetch(); createNotification({ text: "Project upgrade started", type: "success" }); } catch { createNotification({ text: "Failed to upgrade project", type: "error" }); } }; const isAdmin = hasProjectRole(ProjectMembershipRole.Admin); return (
Upgrade secrets engine version
Your existing workflows to fetch secrets will continue to work. However, viewing secrets on the UI requires you to upgrade your project's secrets engine version.
Upgrading is free and enables the use of Infisical's new secrets engine, which is 10x faster and allows you to encrypt secrets with your own KMS provider.
The upgrade takes only 1-2 minutes and will not cause any downtime.
{didProjectUpgradeFailed && (