mirror of
https://gitlab.w-hs.de/an14051/backerup-website.git
synced 2026-07-27 17:35:29 +00:00
feat: implement file deletion functionality and enhance deployment script
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user