From c37e368d982a4ae387ae8827355940f94f625482 Mon Sep 17 00:00:00 2001 From: Dustin Healy Date: Sat, 6 Sep 2025 16:14:35 -0700 Subject: [PATCH] chore: remove unused component and translation strings --- .../Prompts/Files/PromptFileUpload.tsx | 192 ------------------ client/src/components/Prompts/Files/index.ts | 1 - client/src/locales/en/translation.json | 2 - 3 files changed, 195 deletions(-) delete mode 100644 client/src/components/Prompts/Files/PromptFileUpload.tsx diff --git a/client/src/components/Prompts/Files/PromptFileUpload.tsx b/client/src/components/Prompts/Files/PromptFileUpload.tsx deleted file mode 100644 index 75f7ecb64f..0000000000 --- a/client/src/components/Prompts/Files/PromptFileUpload.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import React, { useRef, useState, useMemo } from 'react'; -import { Upload, Folder } from 'lucide-react'; -import { - Button, - TooltipAnchor, - AttachmentIcon, - DropdownPopup, - FileUpload, -} from '@librechat/client'; -import { EToolResources } from 'librechat-data-provider'; -import type { ExtendedFile } from '~/common'; -import { usePromptFileHandling } from '~/hooks/Prompts'; -import PromptFileRow from './PromptFileRow'; -import * as Ariakit from '@ariakit/react'; -import { useLocalize } from '~/hooks'; -import { cn } from '~/utils'; - -interface PromptFileUploadProps { - files: ExtendedFile[]; - onFilesChange: (files: ExtendedFile[]) => void; - onToolResourcesChange?: (toolResources: any) => void; - disabled?: boolean; - className?: string; - variant?: 'button' | 'icon'; - showFileList?: boolean; -} - -const PromptFileUpload: React.FC = ({ - files, - onFilesChange, - onToolResourcesChange, - disabled = false, - className = '', - variant = 'button', - showFileList = true, -}) => { - const localize = useLocalize(); - const fileInputRef = useRef(null); - const [isPopoverActive, setIsPopoverActive] = useState(false); - const [toolResource, setToolResource] = useState(EToolResources.file_search); - - const { handleFileChange, promptFiles, getToolResources, areFilesReady, fileStats } = - usePromptFileHandling({ - fileSetter: onFilesChange, - initialFiles: files, - }); - - // Update parent component when files change - React.useEffect(() => { - if (onToolResourcesChange && areFilesReady) { - const toolResources = getToolResources(); - onToolResourcesChange(toolResources); - } - }, [promptFiles, areFilesReady, getToolResources, onToolResourcesChange]); - - const handleUploadClick = (isImage?: boolean) => { - if (isImage) { - setToolResource(EToolResources.image_edit); - } else { - setToolResource(EToolResources.file_search); - } - if (fileInputRef.current) { - fileInputRef.current.click(); - } - }; - - const handleRemoveFile = (fileId: string) => { - const updatedFiles = promptFiles.filter( - (file) => file.temp_file_id !== fileId && file.file_id !== fileId, - ); - onFilesChange(updatedFiles); - }; - - const dropdownItems = useMemo(() => { - return [ - { - label: localize('com_ui_upload_file_search'), - onClick: () => handleUploadClick(false), - icon: , - }, - { - label: localize('com_ui_upload_ocr_text'), - onClick: () => handleUploadClick(true), - icon: , - }, - ]; - }, [localize]); - - const getButtonText = () => { - if (fileStats.uploading > 0) { - return `${localize('com_ui_uploading')} (${fileStats.uploading})`; - } - if (fileStats.total > 0) { - return `${fileStats.total} ${localize('com_ui_files_attached')}`; - } - return localize('com_ui_attach_files'); - }; - - const menuTrigger = ( - -
- -
- - } - id="prompt-attach-file-menu-button" - description={localize('com_sidepanel_attach_files')} - disabled={disabled} - /> - ); - - if (variant === 'icon') { - return ( - <> - { - handleFileChange(e, toolResource); - }} - > - - - - {showFileList && ( - - )} - - ); - } - - return ( -
- { - handleFileChange(e, toolResource); - }} - > - 0 && 'opacity-70')} - > - {fileStats.uploading > 0 ? ( - - ) : ( - - )} - {getButtonText()} - - } - items={dropdownItems} - iconClassName="mr-0" - /> - - - {showFileList && promptFiles.length > 0 && ( - - )} -
- ); -}; - -export default PromptFileUpload; diff --git a/client/src/components/Prompts/Files/index.ts b/client/src/components/Prompts/Files/index.ts index 700ca1c3f1..f43b1026b5 100644 --- a/client/src/components/Prompts/Files/index.ts +++ b/client/src/components/Prompts/Files/index.ts @@ -1,2 +1 @@ -export { default as PromptFileUpload } from './PromptFileUpload'; export { default as PromptFileRow } from './PromptFileRow'; diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index 8fc3da461e..e00d2dca5b 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -898,7 +898,6 @@ "com_ui_file_token_limit": "File Token Limit", "com_ui_file_token_limit_desc": "Set maximum token limit for file processing to control costs and resource usage", "com_ui_files": "Files", - "com_ui_files_attached": "files attached", "com_ui_files_info": "Attach files to enhance your prompt with additional context", "com_ui_filter_prompts": "Filter Prompts", "com_ui_filter_prompts_name": "Filter prompts by name", @@ -1235,7 +1234,6 @@ "com_ui_upload_ocr_text": "Upload as Text", "com_ui_upload_success": "Successfully uploaded file", "com_ui_upload_type": "Select Upload Type", - "com_ui_uploading": "Uploading", "com_ui_remove_file": "Remove file", "com_ui_usage": "Usage", "com_ui_use_2fa_code": "Use 2FA Code Instead",