import { deployPages, removePagesPreview, rollbackPages } from "~/fns/pages"; import { useAction } from "~/hooks/use-action"; import { Badge } from "~/ui/Badge"; import { EmptyState } from "~/ui/EmptyState"; import { formatBytes } from "~/lib/format"; import { Panel } from "~/ui/Panel"; import { RelativeTime } from "~/ui/RelativeTime"; import { Button } from "~/ui/Button"; import { ErrorBanner } from "~/ui/Callout"; import type { PagesData } from "./PagesSettings"; import { ExternalLink } from "~/ui/TextLink"; type RepoParams = { owner: string; repo: string }; type Deployment = PagesData["deployments"][number]; const STATUS_TONES = { queued: "neutral", building: "warning", active: "success", failed: "danger", superseded: "neutral", } as const; function DeploymentRow({ deployment, activeId, onRollback, onRemovePreview, }: { deployment: Deployment; activeId: string | null; onRollback: (id: string) => void; onRemovePreview: (prNumber: number) => void; }) { const live = deployment.status === "active"; const prNumber = deployment.prNumber; return (
  • {deployment.status} {deployment.environment === "preview" ? `Preview #${deployment.prNumber}` : "Production"} {deployment.ref}@{deployment.sha.slice(0, 7)} {deployment.source === "artifact" ? "artifact" : "branch"} {deployment.fileCount > 0 && ( {deployment.fileCount} files, {formatBytes(deployment.totalBytes)} )} {deployment.error && {deployment.error}} {live && deployment.url && ( Visit )} {deployment.environment === "production" && deployment.status === "superseded" && deployment.id !== activeId && ( )} {deployment.environment === "preview" && live && prNumber !== null && ( )}
  • ); } export function PagesDeployments({ data, params }: { data: PagesData; params: RepoParams }) { const deploy = useAction(deployPages); const rollback = useAction(rollbackPages); const remove = useAction(removePagesPreview); if (!data.site) return null; return ( deploy.run({ data: params })}> Deploy now } >
    {data.deployments.length === 0 ? ( Push to the configured branch or deploy now. ) : ( )}
    ); }