import Link from "next/link"; import { getFile } from "@/lib/store"; import { notFound } from "next/navigation"; import CopyLinkButton from "./CopyLinkButton"; function formatBytes(n: number) { if (n < 1024) return `${n} B`; if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`; return `${(n / 1024 / 1024).toFixed(2)} MB`; } function MetaRow({ label, value }: { label: string; value: React.ReactNode }) { return (
{label} {value}
); } export default async function FileDetailPage({ params, }: { params: Promise<{ token: string }>; }) { const { token } = await params; const record = await getFile(token); if (!record) notFound(); const isBackerup = record.type === "backerup"; const downloadUrl = `/api/files/${token}/download`; const title = record.displayName ?? record.containerName ?? record.originalName; return (
{/* Back */} Back to browse {/* Header card */}
{/* Badges */}
{isBackerup ? ( .backerup archive ) : ( .json config )} {record.group && ( {record.group} )} {record.originalName}
{/* Title */}

{title}

{/* Image */} {record.image && (

{record.image}

)} {/* Description */} {record.description && (

{record.description}

)}
{/* Metadata */}
{record.group && } {record.containerName && } {record.image && }
{/* Docker restore snippet for configs */} {!isBackerup && record.image && (
quick restore
            # Pull the image used by this config{"\n"}
            $ 
            docker pull {record.image}{"\n\n"}
            # Download & import this config into Backerup to restore{"\n"}
            $ 
            curl -O {`{{BACKERUP_URL}}`}/api/files/{token}/download
          
)} {/* Actions */}
Download {record.originalName} Browse more configs
{/* Warning for .backerup */} {isBackerup && (

Note: This is a full .backerup archive. It may contain volume data in addition to the container config. Import it into Backerup to restore or clone the container.

)}
); }