frontend tweaks, preview workspace

This commit is contained in:
2025-10-28 00:43:54 +01:00
parent 709d32050e
commit 1179f4fcd4
6 changed files with 266 additions and 209 deletions
+4 -52
View File
@@ -1,13 +1,9 @@
import React from 'react';
import { DownloadIcon } from '../ui/icons';
import { formatFileSize } from '../utils/format';
const PreviewWorkspace = ({
document,
previewEntry,
resolveApiPath,
onClose,
onRegenerateThumbnails,
}) => {
if (!document) {
return null;
@@ -15,9 +11,6 @@ const PreviewWorkspace = ({
const title = document.title || document.original_name || 'Document';
const mime = previewEntry?.contentType || document.content_type || 'application/pdf';
const downloadHref = document.current_version?.download_path
? resolveApiPath(document.current_version.download_path)
: null;
const sizeBytes = Number(document.current_version?.size_bytes) || 0;
const sizeLabel = sizeBytes > 0 ? formatFileSize(sizeBytes) : null;
const metadata =
@@ -25,48 +18,6 @@ const PreviewWorkspace = ({
return (
<section className="preview-workspace">
<header className="preview-workspace__header">
<div className="preview-workspace__meta">
<button
type="button"
className="secondary"
onClick={() => onClose(document.folder_id ?? 'root')}
>
Back
</button>
<div>
<h2>{title}</h2>
<span className="meta">
{document.content_type || mime}
{sizeLabel ? ` · ${sizeLabel}` : ''}
</span>
</div>
</div>
<div className="preview-workspace__actions">
<a
className="button-link with-icon"
href={downloadHref || '#'}
target="_blank"
rel="noopener noreferrer"
aria-disabled={!downloadHref}
onClick={(event) => {
if (!downloadHref) {
event.preventDefault();
}
}}
>
<DownloadIcon className="icon-inline" />
<span>Download</span>
</a>
<button
type="button"
className="secondary"
onClick={() => onRegenerateThumbnails(document.id)}
>
Re-run analysis
</button>
</div>
</header>
<div className="preview-workspace__body">
{!previewEntry?.url ? (
<div className="preview-workspace__message">Loading preview</div>
@@ -78,15 +29,16 @@ const PreviewWorkspace = ({
/>
)}
</div>
{metadata && (
{metadata ? (
<section className="preview-workspace__metadata">
<h3>Metadata</h3>
{sizeLabel ? <p><strong>Size:</strong> {sizeLabel}</p> : null}
<p><strong>Type:</strong> {mime}</p>
<pre>{JSON.stringify(metadata, null, 2)}</pre>
</section>
)}
) : null}
</section>
);
};
export default PreviewWorkspace;