import { useEffect, useState } from "react"; import { Helmet } from "react-helmet"; import { Controller, useForm } from "react-hook-form"; import { faArrowUpRightFromSquare, faBookOpen, faBugs } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { useNavigate, useSearch } from "@tanstack/react-router"; import { z } from "zod"; import { Button, Card, CardTitle, FormControl, Select, SelectItem } from "@app/components/v2"; import { SecretPathInput } from "@app/components/v2/SecretPathInput"; import { ROUTE_PATHS } from "@app/const/routes"; import { useWorkspace } from "@app/context"; // import { RadioGroup } from "@app/components/v2/RadioGroup"; import { useCreateIntegration } from "@app/hooks/api"; import { useGetIntegrationAuthApps, useGetIntegrationAuthById } from "@app/hooks/api/integrationAuth"; import { IntegrationSyncBehavior } from "@app/hooks/api/integrations/types"; import { IntegrationsListPageTabs } from "@app/types/integrations"; const initialSyncBehaviors = [ { label: "No Import - Overwrite all values in Heroku", value: IntegrationSyncBehavior.OVERWRITE_TARGET }, { label: "Import - Prefer values from Heroku", value: IntegrationSyncBehavior.PREFER_TARGET }, { label: "Import - Prefer values from Infisical", value: IntegrationSyncBehavior.PREFER_SOURCE } ]; const schema = z.object({ selectedSourceEnvironment: z.string(), secretPath: z.string(), targetApp: z.string(), initialSyncBehavior: z.nativeEnum(IntegrationSyncBehavior) }); type FormData = z.infer; export const HerokuConfigurePage = () => { const navigate = useNavigate(); const { currentWorkspace } = useWorkspace(); const { control, handleSubmit, setValue, watch } = useForm({ resolver: zodResolver(schema), defaultValues: { secretPath: "/", initialSyncBehavior: IntegrationSyncBehavior.PREFER_SOURCE, selectedSourceEnvironment: currentWorkspace.environments[0].slug } }); const selectedSourceEnvironment = watch("selectedSourceEnvironment"); const { mutateAsync } = useCreateIntegration(); // const { mutateAsync: mutateAsyncEnv } = useCreateWsEnvironment(); const integrationAuthId = useSearch({ from: ROUTE_PATHS.SecretManager.Integratons.HerokuConfigurePage.id, select: (el) => el.integrationAuthId }); const { data: integrationAuth } = useGetIntegrationAuthById((integrationAuthId as string) ?? ""); const { data: integrationAuthApps, isPending: isIntegrationAuthAppsLoading } = useGetIntegrationAuthApps({ integrationAuthId: (integrationAuthId as string) ?? "" }); const [isLoading, setIsLoading] = useState(false); useEffect(() => { if (integrationAuthApps) { if (integrationAuthApps.length > 0) { setValue("targetApp", integrationAuthApps[0].name); } else { setValue("targetApp", "none"); } } }, [integrationAuthApps]); const onFormSubmit = async ({ secretPath, targetApp, initialSyncBehavior }: FormData) => { try { if (!integrationAuth?.id) return; setIsLoading(true); await mutateAsync({ integrationAuthId: integrationAuth?.id, isActive: true, app: targetApp, sourceEnvironment: selectedSourceEnvironment, secretPath, metadata: { initialSyncBehavior } }); setIsLoading(false); navigate({ to: "/secret-manager/$projectId/integrations", params: { projectId: currentWorkspace.id }, search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations } }); } catch (err) { console.error(err); } }; return integrationAuth && selectedSourceEnvironment && integrationAuthApps ? (
Set Up Heroku Integration
Heroku logo
Heroku Integration
Docs
( )} /> ( )} /> { return ( ); }} /> ( )} />
{/* {integrationType === "App" && <>
{" "} Pro Tip
After creating an integration, your secrets will start syncing immediately. This might cause an unexpected override of current secrets in Heroku with secrets from Infisical.
} */}
) : (
Set Up Heroku Integration {isIntegrationAuthAppsLoading ? ( infisical loading indicator ) : (

Something went wrong. Please contact{" "} support@infisical.com {" "} if the issue persists.

)}
); };