feat: implement file deletion functionality and enhance deployment script

This commit is contained in:
Anders Böttcher
2026-05-13 12:35:58 +02:00
parent cf23467be6
commit 9dbbf814b4
10 changed files with 229 additions and 50 deletions
+8 -1
View File
@@ -1,7 +1,9 @@
import Link from "next/link";
import { getFile } from "@/lib/store";
import { notFound } from "next/navigation";
import { getSession } from "@/lib/session";
import CopyLinkButton from "./CopyLinkButton";
import DeleteFileButton from "./DeleteFileButton";
function formatBytes(n: number) {
if (n < 1024) return `${n} B`;
@@ -24,8 +26,9 @@ export default async function FileDetailPage({
params: Promise<{ token: string }>;
}) {
const { token } = await params;
const record = await getFile(token);
const [record, session] = await Promise.all([getFile(token), getSession()]);
if (!record) notFound();
const isAdmin = session?.role === "admin";
const isBackerup = record.type === "backerup";
const downloadUrl = `/api/files/${token}/download`;
@@ -138,6 +141,10 @@ export default async function FileDetailPage({
<CopyLinkButton token={token} />
{isAdmin && (
<DeleteFileButton token={token} name={title} />
)}
<Link
href="/browse"
className="flex w-full items-center justify-center gap-2 rounded-xl border border-white/8 bg-white/3 py-3 text-sm font-medium text-slate-400 hover:text-white hover:bg-white/6 transition-all"