"use client"; import { FolderOpen, Loader2, Upload } from "@/components/icons/platform-icons"; import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, } from "@/components/ui/empty"; import { FileGrid, FileList, LoadMoreBanner, } from "@/modules/files/components/content/file-manager-entry-views"; import { OpenFileDialog } from "@/modules/files/components/content/file-manager-open-file-dialog"; import type { FileEntry } from "@/modules/files/components/file-manager-presenters"; import type { FileReadResponse } from "@/lib/shared/contracts/files"; import type { DragEventHandler, MouseEvent, SetStateAction } from "react"; type FileManagerFileAreaProps = { canSaveOpenFile: boolean; directoryErrorMessage: string; directoryIsError: boolean; directoryIsLoading: boolean; editorNotice: string | null; fileContentErrorMessage: string; fileContentIsError: boolean; fileContentIsLoading: boolean; globalSearchIsFetching: boolean; hasMoreSearchResults: boolean; hasUnsavedChanges: boolean; isDragOver: boolean; isGlobalSearchActive: boolean; isStarredView: boolean; isTrashView: boolean; openFile: { entry: FileEntry } | null; openFileAssetUrl: string; openFileBadgeLabel: string; openFileContent: string; openFileKey: string | null; openFileLanguage: string; openFileViewer: FileReadResponse | null; showSaveOpenFile: boolean; pendingEntryPath: string | null; searchQuery: string; selectedFiles: Set; sortedEntries: FileEntry[]; totalEntriesCount: number; viewMode: "grid" | "list"; onBackgroundContextMenu: (event: MouseEvent) => void; onChangeOpenFileDraft: (value: SetStateAction) => void; onCloseOpenFile: () => void; onDragLeave: DragEventHandler; onDragOver: DragEventHandler; onDrop: DragEventHandler; onEntryClick: (event: MouseEvent, entry: FileEntry) => void; onEntryContextMenu: (event: MouseEvent, entry: FileEntry) => void; onLoadMoreSearch: () => void; onOpenEntry: (entry: FileEntry) => void; onSaveOpenFile: () => void; }; export function FileManagerFileArea({ canSaveOpenFile, directoryErrorMessage, directoryIsError, directoryIsLoading, editorNotice, fileContentErrorMessage, fileContentIsError, fileContentIsLoading, globalSearchIsFetching, hasMoreSearchResults, hasUnsavedChanges, isDragOver, isGlobalSearchActive, isStarredView, isTrashView, onBackgroundContextMenu, onChangeOpenFileDraft, onCloseOpenFile, onDragLeave, onDragOver, onDrop, onEntryClick, onEntryContextMenu, onLoadMoreSearch, onOpenEntry, onSaveOpenFile, openFile, openFileAssetUrl, openFileBadgeLabel, openFileContent, openFileKey, openFileLanguage, openFileViewer, showSaveOpenFile, pendingEntryPath, searchQuery, selectedFiles, sortedEntries, totalEntriesCount, viewMode, }: FileManagerFileAreaProps) { return (
{isDragOver && !isTrashView && !isStarredView ? (
Drop files to upload
) : null} {renderBrowserState({ directoryErrorMessage, directoryIsError, directoryIsLoading, globalSearchIsFetching, hasMoreSearchResults, isGlobalSearchActive, isTrashView, onEntryClick, onEntryContextMenu, onLoadMoreSearch, onOpenEntry, pendingEntryPath, searchQuery, selectedFiles, sortedEntries, totalEntriesCount, viewMode, })} {openFile ? ( ) : null}
); } function renderBrowserState({ directoryErrorMessage, directoryIsError, directoryIsLoading, globalSearchIsFetching, hasMoreSearchResults, isGlobalSearchActive, isTrashView, onEntryClick, onEntryContextMenu, onLoadMoreSearch, onOpenEntry, pendingEntryPath, searchQuery, selectedFiles, sortedEntries, totalEntriesCount, viewMode, }: Omit< FileManagerFileAreaProps, | "canSaveOpenFile" | "editorNotice" | "fileContentErrorMessage" | "fileContentIsError" | "fileContentIsLoading" | "hasUnsavedChanges" | "isDragOver" | "isStarredView" | "openFile" | "openFileAssetUrl" | "openFileBadgeLabel" | "openFileContent" | "openFileKey" | "openFileLanguage" | "openFileViewer" | "showSaveOpenFile" | "onBackgroundContextMenu" | "onChangeOpenFileDraft" | "onCloseOpenFile" | "onDragLeave" | "onDragOver" | "onDrop" | "onSaveOpenFile" >) { if (directoryIsLoading) { return ( Loading files... ); } if (directoryIsError) { return ( {directoryErrorMessage} ); } if (sortedEntries.length === 0) { return ( {isGlobalSearchActive && globalSearchIsFetching ? ( ) : ( )} {isGlobalSearchActive ? globalSearchIsFetching ? "Searching..." : "No results found" : searchQuery ? "No matching files found" : "This folder is empty"} ); } const browser = viewMode === "grid" ? ( ) : ( ); return ( <> {browser} {hasMoreSearchResults ? ( ) : null} ); }