diff --git a/frontend/src/components/SourcesPopup.tsx b/frontend/src/components/SourcesPopup.tsx index 3625f0a4..4f838a4e 100644 --- a/frontend/src/components/SourcesPopup.tsx +++ b/frontend/src/components/SourcesPopup.tsx @@ -1,9 +1,11 @@ -import React, { useRef, useEffect } from 'react'; +import React, { useRef, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; import { Doc } from '../models/misc'; import SourceIcon from '../assets/source.svg'; import CheckIcon from '../assets/checkmark.svg'; +import RedirectIcon from '../assets/redirect.svg'; +import Input from './Input'; import { selectSourceDocs, selectSelectedDocs, @@ -29,6 +31,8 @@ export default function SourcesPopup({ const dispatch = useDispatch(); const { t } = useTranslation(); const popupRef = useRef(null); + const [searchTerm, setSearchTerm] = useState(''); + const embeddingsName = import.meta.env.VITE_EMBEDDINGS_NAME || 'huggingface_sentence-transformers/all-mpnet-base-v2'; @@ -36,6 +40,10 @@ export default function SourcesPopup({ const options = useSelector(selectSourceDocs); const selectedDocs = useSelector(selectSelectedDocs); + const filteredOptions = options?.filter(option => + option.name.toLowerCase().includes(searchTerm.toLowerCase()) + ); + const getPopupPosition = () => { if (!anchorRef.current) return {}; @@ -89,20 +97,32 @@ export default function SourcesPopup({ className="bg-lotion dark:bg-charleston-green-2 rounded-xl shadow-md w-full max-w-md flex flex-col z-50 absolute" >
-

+

{t('conversation.sources.text')}

+ + setSearchTerm(e.target.value)} + placeholder={t('settings.documents.searchPlaceholder')} + borderVariant="thin" + className="mb-4" + labelBgClassName="bg-lotion dark:bg-charleston-green-2" + />
-
+
{options ? ( <> - {options.map((option: any, index: number) => { + {filteredOptions?.map((option: any, index: number) => { if (option.model === embeddingsName) { return (
{ dispatch(setSelectedDocs(option)); handlePostDocumentSelect(option); @@ -112,7 +132,8 @@ export default function SourcesPopup({ Source {option.name} @@ -121,7 +142,7 @@ export default function SourcesPopup({ Selected )}
@@ -130,10 +151,10 @@ export default function SourcesPopup({ return null; })}
- Source + Source {t('none')} @@ -143,16 +164,27 @@ export default function SourcesPopup({
) : ( -
+
{t('noSourcesAvailable')}
)}
+
+ + Go to Documents + Redirect + +
+
diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index 49fc10de..237cbe0e 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -118,7 +118,8 @@ "selectToolSetup": "Select a tool to set up", "settingsIconAlt": "Settings icon", "configureToolAria": "Configure {toolName}", - "toggleToolAria": "Toggle {toolName}" + "toggleToolAria": "Toggle {toolName}", + "manageTools": "Go to Tools" } }, "modals": {