diff --git a/frontend/src/components/SnapshotFilesPanel.jsx b/frontend/src/components/SnapshotFilesPanel.jsx new file mode 100644 index 0000000..660b5eb --- /dev/null +++ b/frontend/src/components/SnapshotFilesPanel.jsx @@ -0,0 +1,74 @@ +import { File, Folder } from 'lucide-react'; + +export function SnapshotFilesPanel({ files, loading, onClose, snapshot }) { + if (!snapshot) return null; + + return ( +
+
+
+

Snapshot Contents

+

{snapshot.id.slice(0, 8)}

+
+ +
+
+ + + + + + + + + + + {files.map((entry) => ( + + + + + + + ))} + {!files.length ? ( + + + + ) : null} + +
PathTypeSizeModified
+ + {entry.type === 'dir' ? : } + {entry.path} + + {entry.type}{entry.type === 'dir' ? '-' : formatBytes(entry.size)}{formatTime(entry.mtime)}
+ {loading ? 'Loading snapshot contents...' : 'No files found.'} +
+
+
+ ); +} + +function formatBytes(value) { + if (!value) return '0 B'; + const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']; + let size = Number(value); + let unitIndex = 0; + while (size >= 1024 && unitIndex < units.length - 1) { + size /= 1024; + unitIndex += 1; + } + return `${size.toFixed(unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`; +} + +function formatTime(value) { + if (!value) return '-'; + return new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'medium' }).format(new Date(value)); +}