"use client"; import { useState } from "react"; import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog"; import { cancelPublishRunAction, buildAndDeployTargetAction } from "../lib/publishActions"; type Props = { // The site whose Publish tab this is. Always a real site now — the control // lives at /sites//publish, so there is no "all sites" state to disable. siteId: string; siteTitle: string; // The site's Cloudflare Pages project, or null if it has none (can't deploy). cloudflareProject: string | null; }; // One-click build-then-deploy for this site: the index update when it is // stale, the build (forced), then its production deploy — publish stages on // the publish queue, followed in one log (publishActions.ts). The deploy waits // ON DISK for this run's build: a failed or cancelled build ends it refused. export function BuildDeployButton({ siteId, siteTitle, cloudflareProject, }: Props) { const ready = Boolean(cloudflareProject); const [skipArchives, setSkipArchives] = useState(false); let notice: React.ReactNode; if (!cloudflareProject) { notice = (

{siteTitle} has no Cloudflare Pages project configured — set one on the site's page to deploy.

); } else { notice = (

Builds then deploys {siteTitle} ( {siteId} → {cloudflareProject}).

); } return ( buildAndDeployTargetAction(siteId, { where: "production", skipArchives })} cancelAction={cancelPublishRunAction} buttonLabel="Build & deploy" runningLabel="Building & deploying…" label="Build and deploy" disabled={!ready} extraControls={
{notice} {ready && ( )}
} /> ); }