- | {document.name} |
- {document.date} |
+
+ {document.name}
+ |
+
+ {document.date}
+ |
{document.location === 'remote'
? 'Pre-loaded'
diff --git a/frontend/src/components/Dropdown.tsx b/frontend/src/components/Dropdown.tsx
index 9822925a..cc570893 100644
--- a/frontend/src/components/Dropdown.tsx
+++ b/frontend/src/components/Dropdown.tsx
@@ -1,98 +1,64 @@
-import Trash from '../assets/trash.svg';
+import { useState } from 'react';
import Arrow2 from '../assets/dropdown-arrow.svg';
-import { Doc } from '../preferences/preferenceApi';
-import { useDispatch } from 'react-redux';
-
-type Props = {
- options: Doc[] | null;
- selectedDocs: Doc | null;
- setSelectedDocs: any;
- isDocsListOpen: boolean;
- setIsDocsListOpen: React.Dispatch>;
- handleDeleteClick: any;
-};
function Dropdown({
options,
- setSelectedDocs,
- selectedDocs,
- setIsDocsListOpen,
- isDocsListOpen,
- handleDeleteClick,
-}: Props) {
- const dispatch = useDispatch();
- const embeddingsName =
- import.meta.env.VITE_EMBEDDINGS_NAME ||
- 'huggingface_sentence-transformers/all-mpnet-base-v2';
+ selectedValue,
+ onSelect,
+ showDelete,
+ onDelete,
+}: {
+ options: string[] | { name: string; id: string; type: string }[];
+ selectedValue: string;
+ onSelect:
+ | ((value: string) => void)
+ | ((value: { name: string; id: string; type: string }) => void);
+ showDelete?: boolean;
+ onDelete?: (value: string) => void;
+}) {
+ const [isOpen, setIsOpen] = useState(false);
return (
-
+
- {isDocsListOpen && (
-
- {options ? (
- options.map((option: any, index: number) => {
- if (option.model !== embeddingsName) {
- return (
- {
- dispatch(setSelectedDocs(option));
- setIsDocsListOpen(false);
- }}
- >
- {
- setIsDocsListOpen(false);
- }}
- className="ml-4 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3"
- >
- {option.name}
-
- {option.location === 'local' && (
-  {
- event.stopPropagation();
- handleDeleteClick(index, option);
- }}
- />
- )}
-
- );
- }
- })
- ) : (
-
- No default documentation.
+ {isOpen && (
+
+ {options.map((option: any, index) => (
+
+ {
+ onSelect(option);
+ setIsOpen(false);
+ }}
+ className="ml-2 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3 dark:text-light-gray"
+ >
+ {typeof option === 'string' ? option : option.name}
+
+ {showDelete && onDelete && (
+
+ )}
- )}
+ ))}
)}
diff --git a/frontend/src/components/SourceDropdown.tsx b/frontend/src/components/SourceDropdown.tsx
new file mode 100644
index 00000000..4c69495f
--- /dev/null
+++ b/frontend/src/components/SourceDropdown.tsx
@@ -0,0 +1,102 @@
+import Trash from '../assets/trash.svg';
+import Arrow2 from '../assets/dropdown-arrow.svg';
+import { Doc } from '../preferences/preferenceApi';
+import { useDispatch } from 'react-redux';
+
+type Props = {
+ options: Doc[] | null;
+ selectedDocs: Doc | null;
+ setSelectedDocs: any;
+ isDocsListOpen: boolean;
+ setIsDocsListOpen: React.Dispatch >;
+ handleDeleteClick: any;
+};
+
+function SourceDropdown({
+ options,
+ setSelectedDocs,
+ selectedDocs,
+ setIsDocsListOpen,
+ isDocsListOpen,
+ handleDeleteClick,
+}: Props) {
+ const dispatch = useDispatch();
+ const embeddingsName =
+ import.meta.env.VITE_EMBEDDINGS_NAME ||
+ 'huggingface_sentence-transformers/all-mpnet-base-v2';
+ return (
+
+
+ {isDocsListOpen && (
+
+ {options ? (
+ options.map((option: any, index: number) => {
+ if (option.model !== embeddingsName) {
+ return (
+ {
+ dispatch(setSelectedDocs(option));
+ setIsDocsListOpen(false);
+ }}
+ >
+ {
+ setIsDocsListOpen(false);
+ }}
+ className="ml-4 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap py-3"
+ >
+ {option.name}
+
+ {option.location === 'local' && (
+  {
+ event.stopPropagation();
+ handleDeleteClick(index, option);
+ }}
+ />
+ )}
+
+ );
+ }
+ })
+ ) : (
+
+ No default documentation.
+
+ )}
+
+ )}
+
+ );
+}
+
+export default SourceDropdown;
|