From e4cb26be43dd5e340af201a4c0ea9b45d9f26dcc Mon Sep 17 00:00:00 2001 From: Reece Date: Tue, 1 Sep 2026 22:54:13 +0100 Subject: [PATCH] refactor(files): Local in the tree sets the source filter It was a pseudo-tab with a view of its own: its own predicate for which files count, its own empty state, and a carve-out anywhere folders are involved - folder visibility, the New folder button, the heading. All of it to say "files with no server copy", which the source filter already says. Clicking it now sets that filter and nothing else, so it narrows whichever view you are in instead of taking you somewhere. The tab value goes with the machinery, and the strings only its empty state read. --- .../public/locales/en-US/translation.toml | 4 ---- .../core/components/filesPage/FileGrid.tsx | 15 +++--------- .../components/filesPage/FileManagerView.tsx | 23 +++++-------------- .../filesPage/FolderTreeSidebar.tsx | 19 +++++++++------ .../src/core/contexts/FilesPageContext.tsx | 8 +------ 5 files changed, 22 insertions(+), 47 deletions(-) diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml index 882fde45b8..a8585debd3 100644 --- a/frontend/editor/public/locales/en-US/translation.toml +++ b/frontend/editor/public/locales/en-US/translation.toml @@ -4419,10 +4419,6 @@ offlineHint = "Reconnect to load your cloud library." offlineTitle = "No cached cloud files" title = "No cloud files yet" -[filesPage.empty.local] -hint = "Files saved without uploading stay here. Drop a file to add one." -title = "No local-only files" - [filesPage.empty.noResults] hint = "No files in this folder match your filter. Try a different term or clear the filter." title = "No matching files" diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.tsx index 28eb6bbc0d..eb1bb5df3e 100644 --- a/frontend/editor/src/core/components/filesPage/FileGrid.tsx +++ b/frontend/editor/src/core/components/filesPage/FileGrid.tsx @@ -153,7 +153,7 @@ interface FileGridProps { sortMode?: FilesPageSortMode; onChangeSortMode?: (mode: FilesPageSortMode) => void; /** Drives the empty-state copy. */ - currentTab?: "all" | "local" | "cloud" | "recent" | "shared" | "sharedByMe"; + currentTab?: "all" | "cloud" | "recent" | "shared" | "sharedByMe"; /** A filter is applied; an empty result then means "no matches", not "no files". */ searchActive?: boolean; /** Cloud reachability; switches the cloud empty-state copy. */ @@ -384,7 +384,7 @@ function SkeletonGrid({ viewMode }: { viewMode: FilesPageViewMode }) { interface EmptyStateProps { /** Drives copy + iconography. */ - tab?: "all" | "local" | "cloud" | "recent" | "shared" | "sharedByMe"; + tab?: "all" | "cloud" | "recent" | "shared" | "sharedByMe"; /** When true the empty list is the result of a filter, not a bare folder. */ searchActive?: boolean; /** Switches the cloud empty-state copy. */ @@ -429,14 +429,6 @@ function EmptyState({ const { titleKey, titleFallback, hintKey, hintFallback } = (() => { switch (tab) { - case "local": - return { - titleKey: "filesPage.empty.local.title", - titleFallback: "No local-only files", - hintKey: "filesPage.empty.local.hint", - hintFallback: - "Files saved without uploading stay here. Drop a file to add one.", - }; case "cloud": return serverReachable ? { @@ -489,8 +481,7 @@ function EmptyState({ const readOnlyTab = tab === "recent" || tab === "shared" || tab === "sharedByMe"; const showUpload = Boolean(onUpload) && !readOnlyTab; - const showCreateFolder = - Boolean(onCreateFolder) && !readOnlyTab && tab !== "local"; + const showCreateFolder = Boolean(onCreateFolder) && !readOnlyTab; const showCtas = showUpload || showCreateFolder; return (
diff --git a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx index a8dce9a804..f7afd07dfb 100644 --- a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx +++ b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx @@ -290,7 +290,6 @@ export default function FileManagerView() { const visibleFolders = useMemo(() => { // Folders only appear in cloud-rooted tabs. if ( - currentTab === "local" || currentTab === "recent" || currentTab === "shared" || currentTab === "sharedByMe" @@ -321,12 +320,6 @@ export default function FileManagerView() { const filesInCurrentFolder = useMemo(() => { // Tab overrides folder navigation for Local/Recent/Shared. switch (currentTab) { - case "local": - // Both halves: a local file inside a browser folder belongs to that folder, - // not here as well. - return allFiles.filter( - (f) => f.remoteStorageId == null && (f.folderId ?? null) === null, - ); case "cloud": // Cloud bucket; search widens to subtree, else direct-folder match. return allFiles.filter((f) => { @@ -1101,7 +1094,6 @@ export default function FileManagerView() { const newFolderDisabledReason: string | null = useMemo(() => { // Only All/Cloud render folders, so creating one elsewhere would look inert. if ( - currentTab === "local" || currentTab === "recent" || currentTab === "shared" || currentTab === "sharedByMe" @@ -1143,8 +1135,7 @@ export default function FileManagerView() {
{/* Breadcrumb only for folder-rooted tabs. */} {(currentTab === "all" || currentTab === "cloud") && } - {(currentTab === "local" || - currentTab === "recent" || + {(currentTab === "recent" || currentTab === "shared" || currentTab === "sharedByMe") && (
- {currentTab === "local" - ? t("filesPage.tabName.local", "Local") - : currentTab === "recent" - ? t("filesPage.tabName.recent", "Recent") - : currentTab === "shared" - ? t("filesPage.tabName.shared", "Shared with me") - : t("filesPage.tabName.sharedByMe", "Shared by me")} + {currentTab === "recent" + ? t("filesPage.tabName.recent", "Recent") + : currentTab === "shared" + ? t("filesPage.tabName.shared", "Shared with me") + : t("filesPage.tabName.sharedByMe", "Shared by me")}
)} {(() => { diff --git a/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx index 918dbe9880..95e6d86d06 100644 --- a/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx +++ b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx @@ -72,7 +72,13 @@ export function FolderTreeSidebar({ }: FolderTreeSidebarProps) { const { t } = useTranslation(); const { tree, currentFolderId, setCurrentFolderId } = useFolders(); - const { currentTab, setCurrentTab, moveFolderTo } = useFilesPage(); + const { + currentTab, + setCurrentTab, + moveFolderTo, + originFilter, + setOriginFilter, + } = useFilesPage(); return (
setCurrentTab("local")} + isActive={originFilter === "local"} + onSelect={() => setOriginFilter("local")} /> {tree.map((node) => (