From b911a36bcf454174bc70fb173d6a1a10733d3971 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Tue, 7 Jul 2026 21:58:47 +0530 Subject: [PATCH] feat(sidebar): enhance document filtering with Drawer component - Integrated Drawer component in EmbeddedDocumentsMenu for mobile-friendly document type filtering. - Updated UI to improve accessibility and user experience with new button interactions and layout adjustments. - Refactored document type display logic to streamline filtering options and enhance visual clarity. --- .../layout/ui/sidebar/DocumentsSidebar.tsx | 140 ++++++++++++------ .../components/layout/ui/sidebar/Sidebar.tsx | 9 +- 2 files changed, 105 insertions(+), 44 deletions(-) diff --git a/surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx index a5b67ae7d..5d4efac81 100644 --- a/surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx @@ -3,6 +3,7 @@ import { useQuery } from "@rocicorp/zero/react"; import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { + Check, FolderInput, FolderPlus, FolderSync, @@ -50,6 +51,7 @@ import { AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; +import { Drawer, DrawerContent, DrawerHandle, DrawerTitle } from "@/components/ui/drawer"; import { DropdownMenu, DropdownMenuCheckboxItem, @@ -69,6 +71,7 @@ import { EnumConnectorName } from "@/contracts/enums/connector"; import { getConnectorIcon } from "@/contracts/enums/connectorIcons"; import type { SearchSourceConnector } from "@/contracts/types/connector.types"; import type { DocumentTypeEnum } from "@/contracts/types/document.types"; +import { useIsMobile } from "@/hooks/use-mobile"; import { useElectronAPI, usePlatform } from "@/hooks/use-platform"; import { documentsApiService } from "@/lib/apis/documents-api.service"; import { foldersApiService } from "@/lib/apis/folders-api.service"; @@ -127,60 +130,111 @@ export function EmbeddedDocumentsMenu({ onToggleType: (type: DocumentTypeEnum, checked: boolean) => void; onCreateFolder: () => void; }) { + const isMobile = useIsMobile(); + const [filterDrawerOpen, setFilterDrawerOpen] = useState(false); const documentTypes = useMemo( () => Object.keys(typeCounts).sort() as DocumentTypeEnum[], [typeCounts] ); return ( - - - + + + + + New folder + + {isMobile ? ( + setFilterDrawerOpen(true)}> + + Filter by type + + ) : ( + + + + Filter by type + + + {documentTypes.length > 0 ? ( + documentTypes.map((type) => ( + onToggleType(type, checked === true)} + onSelect={(event) => event.preventDefault()} + > + {getDocumentTypeIcon(type, "h-4 w-4")} + {getDocumentTypeLabel(type)} + + {typeCounts[type] ?? 0} + + + )) + ) : ( + No document types + )} + + + )} + + + + + - - {activeTypes.length > 0 ? ( - - ) : null} - - - - - - New folder - - - - + + Filter by type - - + +
{documentTypes.length > 0 ? ( - documentTypes.map((type) => ( - onToggleType(type, checked === true)} - onSelect={(event) => event.preventDefault()} - > - {getDocumentTypeIcon(type, "h-4 w-4")} - {getDocumentTypeLabel(type)} - - {typeCounts[type] ?? 0} - - - )) + documentTypes.map((type, index) => { + const isActive = activeTypes.includes(type); + return ( +
+ {index > 0 &&
} + +
+ ); + }) ) : ( - No document types +

No document types

)} - - - - +
+ + + ); } diff --git a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx index 28264a77f..edd978283 100644 --- a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx @@ -5,6 +5,7 @@ import Link from "next/link"; import { useParams } from "next/navigation"; import { useTranslations } from "next-intl"; import { type ReactNode, useMemo, useState } from "react"; +import { ConnectAgentDialog } from "@/components/mcp/connect-agent-dialog"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Progress } from "@/components/ui/progress"; @@ -322,10 +323,16 @@ export function Sidebar({ /> )} + {!isCollapsed && ( +
+ +
+ )} + 0} + hasNavSectionAbove={footerNavItems.length > 0 || !isCollapsed} onNavigate={onNavigate} />