import { useState } from "react"; import { Clipboard } from "lucide-react"; import { shortRefName } from "@/shared/git/ref-display"; import { Card } from "@/client/components/ui/card"; import { formatSampleBytes, shortValue } from "./format"; import type { AdminState } from "./types"; export type RepoOverviewCardProps = { storageSize: string; packCount: number; supersededPackCount: number; compactionStatus: string; state: AdminState; head?: { target?: string; unborn?: boolean }; branchCount: number; tagCount: number; }; export function RepoOverviewCard({ storageSize, packCount, supersededPackCount, compactionStatus, state, head, branchCount, tagCount, }: RepoOverviewCardProps) { const [copiedDoId, setCopiedDoId] = useState(false); const activePackCount = Array.isArray(state.activePacks) ? state.activePacks.length : packCount; async function copyDoId(doId: string) { try { await navigator.clipboard.writeText(doId); setCopiedDoId(true); window.setTimeout(() => setCopiedDoId(false), 1200); } catch (error) { window.alert(`Failed to copy DO ID: ${String(error)}`); } } return (

Repository Overview

R2 Packs Storage
{storageSize || "0 bytes"}
Active Packs
{activePackCount} {supersededPackCount > 0 ? ( ({supersededPackCount} superseded) ) : null}
{state?.meta?.doId ? (
Durable Object ID
{shortValue(String(state.meta.doId), 12)} {copiedDoId ? "copied" : "___copy"}
) : null} {state.looseR2SampleBytes ? (
R2 Loose (sample)
{formatSampleBytes(state.looseR2SampleBytes)} ({state.looseR2SampleCount || 0} objs{state.looseR2Truncated ? ", truncated" : ""})
) : null} {state.dbSizeBytes ? (
Durable Object Storage
{formatSampleBytes(state.dbSizeBytes)}
) : null}
Receive Lease
{state.receiveLease ? "Active" : "Idle"}
Compaction
{compactionStatus}
Catalog Version
{typeof state.packCatalogVersion === "number" ? state.packCatalogVersion : "n/a"}
HEAD
{head?.target ? shortRefName(String(head.target)) : head?.unborn ? "unborn" : "unknown"}
Branches/Tags
{branchCount}/{tagCount}
); }