From 284eedde20dfa45f0a8575176759180923ba03de Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Thu, 5 Jun 2025 23:30:31 -0700 Subject: [PATCH] refactor: simplify document type icon rendering by consolidating logic into a single function --- .../researcher/[chat_id]/page.tsx | 48 ++----------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/researcher/[chat_id]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/researcher/[chat_id]/page.tsx index 7ffb31dcd..a9ebd9ce0 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/researcher/[chat_id]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/researcher/[chat_id]/page.tsx @@ -16,15 +16,11 @@ import { SendHorizontal, FileText, Grid3x3, - File, - Globe, - Webhook, FolderOpen, Upload, ChevronDown, Filter } from 'lucide-react'; -import { IconBrandDiscord, IconBrandGithub, IconBrandNotion, IconBrandSlack, IconBrandYoutube, IconLayoutKanban } from "@tabler/icons-react"; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; @@ -118,30 +114,8 @@ const DocumentTypeFilter = ({ }; const getTypeIcon = (type: DocumentType | "ALL") => { - switch (type) { - case "ALL": - return ; - case "EXTENSION": - return ; - case "CRAWLED_URL": - return ; - case "FILE": - return ; - case "SLACK_CONNECTOR": - return ; - case "NOTION_CONNECTOR": - return ; - case "YOUTUBE_VIDEO": - return ; - case "GITHUB_CONNECTOR": - return ; - case "LINEAR_CONNECTOR": - return ; - case "DISCORD_CONNECTOR": - return ; - default: - return ; - } + if (type === "ALL") return ; + return getConnectorIcon(type); }; return ( @@ -1345,21 +1319,9 @@ const ChatPage = () => { onClick={() => handleDocumentToggle(document.id)} >
- {(() => { - const iconClassName = `${isSelected ? 'text-primary' : 'text-muted-foreground'} transition-colors`; - const iconSize = { className: iconClassName }; - - if (document.document_type === "EXTENSION") return ; - if (document.document_type === "CRAWLED_URL") return ; - if (document.document_type === "FILE") return ; - if (document.document_type === "SLACK_CONNECTOR") return ; - if (document.document_type === "NOTION_CONNECTOR") return ; - if (document.document_type === "YOUTUBE_VIDEO") return ; - if (document.document_type === "GITHUB_CONNECTOR") return ; - if (document.document_type === "LINEAR_CONNECTOR") return ; - if (document.document_type === "DISCORD_CONNECTOR") return ; - return ; - })()} +
+ {getConnectorIcon(document.document_type)} +