import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { ActionForm, SubmitButton } from "@/components/forms"; import { PageHeader, Tag } from "@/components/status"; import { DateTime } from "@/components/time"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { api, unwrap } from "@/lib/api"; import { ConsoleNav, requireConsole } from "../../console-nav"; import { blockFile, unblockFile } from "../actions"; export const metadata: Metadata = { title: "Block" }; /** A file: whether it's blocked, the products using it, and blocking or unblocking it. */ export default async function BlockPage({ params }: { params: Promise<{ sha256: string }> }) { const { sha256 } = await params; if (!/^[0-9a-f]{64}$/.test(sha256)) notFound(); const { console: c } = await requireConsole(`/console/blocks/${sha256}`); if (!c.sections.includes("blocks")) notFound(); const { block, products } = unwrap(await api.blocks({ sha256 }).get()); const live = products.filter((p) => !p.removed); const removeCount = live.length === 1 ? "1 product" : `${live.length} products`; return ( <> {sha256}
{block ? "Blocked" : "Not Blocked"} {block ? ( <> By {block.by ?? "a former moderator"}, : {block.reason} ) : ( "Blocking it removes the products below, tells their catalogs to delete it, and refuses uploads with it." )} {block ? (
Unblock
) : (
{live.length ? `Block and remove ${removeCount}` : "Block"}
)}
Used By Products with a revision that has this file. {products.length === 0 ? (

No product uses it.

) : (
    {products.map((p) => (
  • {p.name} by {p.creatorUsername ?? "someone"} · {p.revisions.length === 1 ? "revision" : "revisions"} {p.revisions.join(", ")} {p.removed && removed}
  • ))}
)}
); }