import { Switch } from "~/components/primitives/Switch"; import { Label } from "~/components/primitives/Label"; import { Hint } from "~/components/primitives/Hint"; import { TextLink } from "~/components/primitives/TextLink"; import { SimpleTooltip } from "~/components/primitives/Tooltip"; import { EnvironmentIcon, environmentFullTitle, environmentTextClassName, } from "~/components/environments/EnvironmentLabel"; import { envSlugToType, type EnvSlug } from "~/v3/vercel/vercelProjectIntegrationSchema"; type BuildSettingsFieldsProps = { availableEnvSlugs: EnvSlug[]; pullEnvVarsBeforeBuild: EnvSlug[]; onPullEnvVarsChange: (slugs: EnvSlug[]) => void; discoverEnvVars: EnvSlug[]; onDiscoverEnvVarsChange: (slugs: EnvSlug[]) => void; atomicBuilds: EnvSlug[]; onAtomicBuildsChange: (slugs: EnvSlug[]) => void; envVarsConfigLink?: string; /** Slugs that should be forced off and disabled, with tooltip reason. */ disabledEnvSlugs?: Partial>; autoPromote?: boolean; onAutoPromoteChange?: (value: boolean) => void; /** The currently pinned TRIGGER_VERSION on Vercel production, if any. Shown under the * Atomic deployments toggle so the user knows what version is set on Vercel right now. */ currentTriggerVersion?: string | null; /** True when the Vercel lookup for TRIGGER_VERSION failed. We show this so the user knows * the pin status is unknown — distinct from "not set". */ currentTriggerVersionFetchFailed?: boolean; /** Hide the section-level master toggles for "Pull env vars" and "Discover new env vars". */ hideSectionToggles?: boolean; }; export function BuildSettingsFields({ availableEnvSlugs, pullEnvVarsBeforeBuild, onPullEnvVarsChange, discoverEnvVars, onDiscoverEnvVarsChange, atomicBuilds, onAtomicBuildsChange, envVarsConfigLink, disabledEnvSlugs, autoPromote, onAutoPromoteChange, currentTriggerVersion, currentTriggerVersionFetchFailed, hideSectionToggles, }: BuildSettingsFieldsProps) { const isSlugDisabled = (slug: EnvSlug) => !!disabledEnvSlugs?.[slug]; const enabledSlugs = availableEnvSlugs.filter((s) => !isSlugDisabled(s)); return ( <> {/* Pull env vars before build */}
{!hideSectionToggles && availableEnvSlugs.length > 1 && ( 0 && enabledSlugs.every((s) => pullEnvVarsBeforeBuild.includes(s)) } onCheckedChange={(checked) => { onPullEnvVarsChange(checked ? [...enabledSlugs] : []); }} /> )}
Select which environments should pull environment variables from Vercel before each build.{" "} {envVarsConfigLink && ( <> Configure which variables to pull. )}
{availableEnvSlugs.map((slug) => { const envType = envSlugToType(slug); const disabled = isSlugDisabled(slug); const disabledReason = disabledEnvSlugs?.[slug]; const row = (
{environmentFullTitle({ type: envType })}
{ onPullEnvVarsChange( checked ? [...pullEnvVarsBeforeBuild, slug] : pullEnvVarsBeforeBuild.filter((s) => s !== slug) ); }} />
); if (disabled && disabledReason) { return ; } return row; })}
{/* Discover new env vars */}
{!hideSectionToggles && availableEnvSlugs.length > 1 && ( 0 && enabledSlugs.every( (s) => discoverEnvVars.includes(s) || !pullEnvVarsBeforeBuild.includes(s) ) && enabledSlugs.some((s) => discoverEnvVars.includes(s)) } disabled={!enabledSlugs.some((s) => pullEnvVarsBeforeBuild.includes(s))} onCheckedChange={(checked) => { onDiscoverEnvVarsChange( checked ? enabledSlugs.filter((s) => pullEnvVarsBeforeBuild.includes(s)) : [] ); }} /> )}
Select which environments should automatically discover and create new environment variables from Vercel during builds.
{availableEnvSlugs.map((slug) => { const envType = envSlugToType(slug); const disabled = isSlugDisabled(slug); const disabledReason = disabledEnvSlugs?.[slug]; const isPullDisabled = !pullEnvVarsBeforeBuild.includes(slug); const row = (
{environmentFullTitle({ type: envType })}
{ onDiscoverEnvVarsChange( checked ? [...discoverEnvVars, slug] : discoverEnvVars.filter((s) => s !== slug) ); }} />
); if (disabled && disabledReason) { return ; } return row; })}
{/* Atomic deployments */}
{ onAtomicBuildsChange(checked ? ["prod"] : []); }} />
When enabled, production deployments wait for Vercel deployment to complete before promoting the Trigger.dev deployment. This will disable the "Auto-assign Custom Production Domains" option in your Vercel project settings to perform staged deployments.{" "} Learn more . {currentTriggerVersion && ( Currently pinned to{" "} {currentTriggerVersion} in Vercel production. )} {!currentTriggerVersion && currentTriggerVersionFetchFailed && ( Couldn't read TRIGGER_VERSION from Vercel — check the Vercel dashboard to confirm the production pin. )}
{/* Auto promotion — only visible when atomic deployments are on */} {atomicBuilds.includes("prod") && onAutoPromoteChange !== undefined && (
When enabled, the integration automatically promotes the Vercel deployment after the Trigger.dev build completes. Turn off to manually promote from your Vercel dashboard — Trigger.dev will then promote automatically once you do.
)} ); }