From f4d8a26972728891de8bde4eeb94c80f027ce2d2 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Mon, 11 Aug 2025 16:04:32 +0100 Subject: basic v0 ui working --- frontend/components/FileTable.tsx | 179 -------------------------------------- 1 file changed, 179 deletions(-) delete mode 100644 frontend/components/FileTable.tsx (limited to 'frontend/components/FileTable.tsx') diff --git a/frontend/components/FileTable.tsx b/frontend/components/FileTable.tsx deleted file mode 100644 index 97660f3..0000000 --- a/frontend/components/FileTable.tsx +++ /dev/null @@ -1,179 +0,0 @@ -'use client' - -import { useState } from 'react' -import { DriveLsEntry } from '@/lib/drive_types' -import { Drive_basename } from '@/lib/drive_shared' -import { formatSize } from '@/lib/utils' -import Link from 'next/link' - -interface FileTableEntry extends DriveLsEntry { - isParent?: boolean - parentPath?: string -} - -interface FileTableProps { - entries: DriveLsEntry[] - currentPath?: string - showParent?: boolean - parentPath?: string - onSelectedFilesChange?: (selectedFiles: string[]) => void -} - -export default function FileTable({ - entries, - currentPath = '', - showParent = false, - parentPath, - onSelectedFilesChange -}: FileTableProps) { - const [selectedFiles, setSelectedFiles] = useState>(new Set()) - - // Create entries with optional parent directory at top - const allEntries: FileTableEntry[] = [] - if (showParent && parentPath !== undefined) { - allEntries.push({ - path: '(parent)', - type: 'dir' as const, - lastmod: 0, - blob: null, - size: null, - author: '', - isParent: true, - parentPath - }) - } - - // Sort entries: directories first, then files, both alphabetically - const sortedEntries = entries.sort((a, b) => { - // First sort by type (directories before files) - if (a.type !== b.type) { - return a.type === 'dir' ? -1 : 1 - } - // Then sort alphabetically by path - return a.path.localeCompare(b.path) - }) - - allEntries.push(...sortedEntries) - - const handleFileSelection = (filePath: string, isSelected: boolean) => { - const newSelectedFiles = new Set(selectedFiles) - if (isSelected) { - newSelectedFiles.add(filePath) - } else { - newSelectedFiles.delete(filePath) - } - setSelectedFiles(newSelectedFiles) - onSelectedFilesChange?.(Array.from(newSelectedFiles)) - } - - const handleSelectAll = (isSelected: boolean) => { - if (isSelected) { - // Select all files (not directories or parent) - const fileEntries = allEntries.filter(entry => - entry.type === 'file' && !entry.isParent - ) - const newSelectedFiles = new Set(fileEntries.map(entry => entry.path)) - setSelectedFiles(newSelectedFiles) - onSelectedFilesChange?.(Array.from(newSelectedFiles)) - } else { - setSelectedFiles(new Set()) - onSelectedFilesChange?.([]) - } - } - - const selectableFiles = allEntries.filter(entry => - entry.type === 'file' && !entry.isParent - ) - const allFilesSelected = selectableFiles.length > 0 && - selectableFiles.every(entry => selectedFiles.has(entry.path)) - - return ( -
-
- - - - - - - - - - - - {allEntries.map((entry) => ( - - - - - - - - ))} - -
- handleSelectAll(e.target.checked)} - className="rounded border-gray-300 text-blue-600 focus:ring-blue-500" - disabled={selectableFiles.length === 0} - /> - - Name - - Size - - Author - - Modified -
- {entry.type === 'file' && !entry.isParent ? ( - handleFileSelection(entry.path, e.target.checked)} - className="rounded border-gray-300 text-blue-600 focus:ring-blue-500" - /> - ) : ( -
// Placeholder to maintain alignment - )} -
-
-
- {entry.type === 'dir' ? ( -
📁
- ) : ( -
📄
- )} -
- {entry.type === 'dir' ? ( - - {entry.isParent ? '(parent)' : Drive_basename(entry.path)} - - ) : ( - - {Drive_basename(entry.path)} - - )} -
-
- {formatSize(entry.size)} - - {entry.author} - - {entry.lastmod > 0 ? new Date(entry.lastmod * 1000).toLocaleString() : ''} -
-
-
- ) -} \ No newline at end of file -- cgit