Files
kandev/apps/web/components/task/file-browser-header.tsx
T
Corey Fogg d4742089fc feat(web): add manual file upload and download to the Files panel (#3292)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
2026-09-03 08:07:13 +00:00

74 lines
2.0 KiB
TypeScript

"use client";
import type { Ref } from "react";
import { FileBrowserSearchHeader } from "./file-browser-search-header";
import { FileBrowserToolbar } from "./file-browser-parts";
import { useFileBrowserSearch } from "./file-browser-hooks";
export type FileBrowserHeaderProps = {
treeLoaded: boolean;
search: ReturnType<typeof useFileBrowserSearch>;
displayPath: string;
fullPath: string;
copied: boolean;
expandedPathsSize: number;
onCopyPath: (value: string) => void | Promise<void>;
onStartCreate?: () => void;
onOpenFolder: () => void;
onCollapseAll: () => void;
showCreateButton: boolean;
onUploadFiles?: (mode: "files" | "folder") => void;
onAddSources?: (opener: HTMLButtonElement) => void;
addSourcesButtonRef?: Ref<HTMLButtonElement>;
addSourcesDisabledReason?: string;
};
export function FileBrowserHeader({
treeLoaded,
search,
displayPath,
fullPath,
copied,
expandedPathsSize,
onCopyPath,
onStartCreate,
onOpenFolder,
onCollapseAll,
showCreateButton,
onUploadFiles,
onAddSources,
addSourcesButtonRef,
addSourcesDisabledReason,
}: FileBrowserHeaderProps) {
if (!treeLoaded) return null;
if (search.isSearchActive) {
return (
<FileBrowserSearchHeader
isSearching={search.isSearching}
localSearchQuery={search.localSearchQuery}
searchInputRef={search.searchInputRef}
onSearchChange={search.handleSearchChange}
onCloseSearch={search.handleCloseSearch}
/>
);
}
return (
<FileBrowserToolbar
displayPath={displayPath}
fullPath={fullPath}
copied={copied}
expandedPathsSize={expandedPathsSize}
onCopyPath={onCopyPath}
onStartCreate={onStartCreate}
onOpenFolder={onOpenFolder}
onStartSearch={() => search.setIsSearchActive(true)}
onCollapseAll={onCollapseAll}
showCreateButton={showCreateButton}
onUploadFiles={onUploadFiles}
onAddSources={onAddSources}
addSourcesButtonRef={addSourcesButtonRef}
addSourcesDisabledReason={addSourcesDisabledReason}
/>
);
}