import { useNavigate } from "@tanstack/react-router"; import { deleteFailedRepo } from "~/fns/repos"; import { useAction } from "~/hooks/use-action"; import { usePollWhile } from "~/hooks/use-poll-while"; import { Button } from "~/ui/Button"; import { ErrorBanner } from "~/ui/Callout"; import { formatDuration } from "~/lib/format"; import type { RepoSummary } from "~/lib/types"; import { Callout } from "~/ui/Callout"; import { Heading } from "~/ui/Heading"; import { ProgressTrack } from "~/ui/ProgressTrack"; import { Panel } from "~/ui/Panel"; const POLL_INTERVAL_MS = 4000; type Props = { owner: string; name: string; status: RepoSummary["status"]; error: string | null; createdAt: number; canAdmin: boolean; }; /** * Artifacts reports no byte-level progress for imports or forks, so this shows an indeterminate bar * with elapsed time and refreshes until the provisioning Workflow marks the repo ready or failed. */ export function RepoProvisioning({ owner, name, status, error, createdAt, canAdmin }: Props) { const pending = status === "importing" || status === "forking"; const now = usePollWhile(pending, POLL_INTERVAL_MS); const navigate = useNavigate(); const remove = useAction(deleteFailedRepo, { invalidate: false }); if (!pending) { return (

This repository could not be set up

{error ? `Artifacts reported: ${error}.` : "Artifacts did not finish copying the repository."}

{canAdmin && ( )}
); } const verb = status === "importing" ? "Importing" : "Forking"; return (
{verb} {owner}/{name}… {formatDuration(createdAt, now)}

Cloudflare Artifacts is copying objects. You can leave this page — the{" "} {status === "importing" ? "import" : "fork"} keeps running and the repository opens here once it's ready.

); }