// AK-P4a Interim-UI (AD-28) — File detail preview screen composed from ~/ui. // Presentational: renders the unwrapped FileDetailData; mutations stay server-driven // (
+ intent, exactly like the baseline route action). Modals are // real ~/ui Dialogs (David standard), not Card fakes. No useLoaderData / server imports. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherArchive, FeatherDownload, FeatherLink, FeatherRefreshCw, FeatherTrash2, FeatherX } from "@subframe/core"; import type { FileDetailData } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { Breadcrumbs } from "~/ui/components/Breadcrumbs"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { Dialog } from "~/ui/components/Dialog"; import { IconButton } from "~/ui/components/IconButton"; import { Select } from "~/ui/components/Select"; import { Tag_Label } from "~/ui/components/Tag_Label"; import { TextInput } from "~/ui/components/TextInput"; export type FileDetailPageProps = { data: FileDetailData; /** Allowed polymorphic entity types for the add-link form. */ entityTypes: readonly string[]; /** Href back to the files browser (breadcrumb). */ filesHref: string; }; function formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B`; const units = ["KB", "MB", "GB"]; let value = bytes / 1024; let unitIndex = 0; while (value >= 1024 && unitIndex < units.length - 1) { value /= 1024; unitIndex += 1; } return `${value.toFixed(1)} ${units[unitIndex]}`; } function MetaRow({ label, value }: { label: string; value: string }) { return (
{label} {value}
); } export function FileDetailPage({ data, entityTypes, filesHref }: FileDetailPageProps) { const { t, i18n } = useTranslation(); const [addLinkOpen, setAddLinkOpen] = useState(false); const [deleteOpen, setDeleteOpen] = useState(false); const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" }); return (
{t("files.nav.title")} {data.displayName} {/* Header + action bar */}
{data.displayName} {data.mimeType} · {dateFormatter.format(new Date(data.createdAtIso))}
{data.canWrite && data.canRegeneratePreview ? ( ) : null} {data.canWrite ? (
) : null} {data.canDelete ? ( ) : null}
{data.scanNoticeKey ? (
) : null} {/* Preview */}
{data.previewUrl ? (
{data.displayName}
) : data.previewFallbackKey ? ( ) : null}
{/* Metadata */} {t("files.detail.section.metadata")}
{data.notes ? (
{t("files.detail.section.notes")} {data.notes}
) : null}
{/* Tags */} {data.tags.length > 0 || data.canWrite ? (
{t("files.detail.section.tags")} {data.tags.length > 0 ? (
{data.tags.map((tag) => ( {tag} ))}
) : null} {data.canWrite ? (
) : null}
) : null} {/* Linked entities */}
{t("files.detail.section.links")} {data.canWrite ? ( ) : null}
{data.linkedEntities.length > 0 ? (
    {data.linkedEntities.map((link) => (
  • {link.entityType} {link.linkRole ? ` · ${link.linkRole}` : ""} {data.canWrite ? (
    } aria-label={t("files.detail.actions.unlink")} /> ) : null}
  • ))}
) : ( {t("files.detail.links.empty")} )}
{/* Add-link dialog (real ~/ui Dialog, size S) */}
{t("files.detail.addLink.title")}
{/* Delete confirmation dialog (real ~/ui Dialog, size XS) */}
{t("files.detail.delete.title")} {t("files.detail.delete.body")}
); }