From ae4eb96d483ab4ef12a9adf541eed2f32e93944b Mon Sep 17 00:00:00 2001 From: sabaimran Date: Mon, 11 Nov 2024 09:34:04 -0800 Subject: [PATCH] Consolidate file name to icon mapping --- src/interface/web/app/common/iconUtils.tsx | 18 ++- .../chatInputArea/chatInputArea.tsx | 4 +- .../components/chatMessage/chatMessage.tsx | 4 +- .../web/app/components/logo/fileLogo.tsx | 108 ------------------ 4 files changed, 11 insertions(+), 123 deletions(-) diff --git a/src/interface/web/app/common/iconUtils.tsx b/src/interface/web/app/common/iconUtils.tsx index 4fad417e..f266cac5 100644 --- a/src/interface/web/app/common/iconUtils.tsx +++ b/src/interface/web/app/common/iconUtils.tsx @@ -50,8 +50,10 @@ import { Broadcast, KeyReturn, FilePdf, + FileMd, + MicrosoftWordLogo, } from "@phosphor-icons/react"; -import { Markdown, OrgMode, Pdf, Word } from "@/app/components/logo/fileLogo"; +import { OrgMode } from "@/app/components/logo/fileLogo"; interface IconMap { [key: string]: (color: string, width: string, height: string) => JSX.Element | null; @@ -217,13 +219,6 @@ export function getIconForSlashCommand(command: string, customClassName: string return ; } -export function getIconFromFileType(fileType: string) { - if (fileType == "pdf") { - return ; - } - return ; -} - function getIconFromIconName( iconName: string, color: string = "gray", @@ -246,11 +241,12 @@ function getIconFromFilename( return ; case "markdown": case "md": - return ; + return ; case "pdf": - return ; + return ; case "doc": - return ; + case "docx": + return ; case "jpg": case "jpeg": case "png": diff --git a/src/interface/web/app/components/chatInputArea/chatInputArea.tsx b/src/interface/web/app/components/chatInputArea/chatInputArea.tsx index 49157f56..3ee0e258 100644 --- a/src/interface/web/app/components/chatInputArea/chatInputArea.tsx +++ b/src/interface/web/app/components/chatInputArea/chatInputArea.tsx @@ -41,7 +41,7 @@ import { convertColorToTextClass, convertToBGClass } from "@/app/common/colorUti import LoginPrompt from "../loginPrompt/loginPrompt"; import { InlineLoading } from "../loading/loading"; -import { getIconForSlashCommand, getIconFromFileType } from "@/app/common/iconUtils"; +import { getIconForSlashCommand, getIconFromFilename } from "@/app/common/iconUtils"; import { packageFilesForUpload } from "@/app/common/chatFunctions"; import { convertBytesToText } from "@/app/common/utils"; import { @@ -549,7 +549,7 @@ export const ChatInputArea = forwardRef((pr {file.name} - {getIconFromFileType(file.file_type)} + {getIconFromFilename(file.file_type)} {convertBytesToText(file.size)} diff --git a/src/interface/web/app/components/chatMessage/chatMessage.tsx b/src/interface/web/app/components/chatMessage/chatMessage.tsx index 9deaf955..bfe9e9e4 100644 --- a/src/interface/web/app/components/chatMessage/chatMessage.tsx +++ b/src/interface/web/app/components/chatMessage/chatMessage.tsx @@ -51,7 +51,7 @@ import { import { DialogTitle } from "@radix-ui/react-dialog"; import { convertBytesToText } from "@/app/common/utils"; import { ScrollArea } from "@/components/ui/scroll-area"; -import { getIconFromFileType } from "@/app/common/iconUtils"; +import { getIconFromFilename } from "@/app/common/iconUtils"; const md = new markdownIt({ html: true, @@ -714,7 +714,7 @@ const ChatMessage = forwardRef((props, ref) =>
- {getIconFromFileType(file.file_type)} + {getIconFromFilename(file.file_type)} {file.name} {file.size && ( diff --git a/src/interface/web/app/components/logo/fileLogo.tsx b/src/interface/web/app/components/logo/fileLogo.tsx index 56bef3f7..e6e8217f 100644 --- a/src/interface/web/app/components/logo/fileLogo.tsx +++ b/src/interface/web/app/components/logo/fileLogo.tsx @@ -81,111 +81,3 @@ export function OrgMode({ className }: { className?: string }) { ); } - -export function Markdown({ className }: { className?: string }) { - const classes = className ?? "w-6 h-6 text-muted-foreground inline-flex mr-1"; - return ( - - - - - ); -} - -export function Pdf({ className }: { className?: string }) { - const classes = className ?? "w-6 h-6 text-muted-foreground inline-flex mr-1"; - return ( - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export function Word({ className }: { className?: string }) { - const classes = className ?? "w-6 h-6 text-muted-foreground inline-flex mr-1"; - return ( - - - - - - - - ); -}