-
+
);
}
diff --git a/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx b/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx
index 30cee0d..a93d5b4 100644
--- a/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx
+++ b/frontend/src/pages/WorkspaceDashboard/DocumentsList/index.tsx
@@ -11,7 +11,7 @@ import UploadDocumentModal from './UploadModal';
import UploadModalNoKey from './UploadModal/UploadModalNoKey';
import Document from '../../../models/document';
import useQuery from '../../../hooks/useQuery';
-import { APP_NAME, SEARCH_MODES } from '../../../utils/constants';
+import { APP_NAME, ISearchTypes, SEARCH_MODES } from '../../../utils/constants';
import { useParams } from 'react-router-dom';
import DocumentListPagination from '../../../components/DocumentPaginator';
import SearchView from './SearchView';
@@ -40,6 +40,8 @@ export default function DocumentsList({
const [documents, setDocuments] = useState([]);
const [totalDocuments, setTotalDocuments] = useState(0);
const [canUpload, setCanUpload] = useState(false);
+ const [searchBy, setSearchBy] = useState
('exactText');
+ const [searchResults, setSearchResults] = useState([]);
const [currentPage, setCurrentPage] = useState(
Number(query.get('docPage')) || 1
);
@@ -69,6 +71,11 @@ export default function DocumentsList({
document.getElementById(`document-row-${documentId}`)?.remove();
};
+ const handleSearchResults = (results: any[]) => {
+ setSearchResults(results);
+ setSearchMode(true);
+ };
+
useEffect(() => {
async function getDocs(orgSlug: string, wsSlug?: string) {
if (!orgSlug || !wsSlug) return false;
@@ -87,7 +94,7 @@ export default function DocumentsList({
if (loading) {
return (
-
+
@@ -102,17 +109,6 @@ export default function DocumentsList({
);
}
- if (searchMode)
- return (
- setSearchMode(false)}
- deleteDocument={deleteDocument}
- />
- );
-
return (
<>
-
+
Documents
@@ -132,343 +128,106 @@ export default function DocumentsList({
({workspace?.documentCount})
- {/*
*/}
- <>
-
- >
+
setSearchMode(false)}
+ deleteDocument={deleteDocument}
+ setSearchMode={setSearchMode}
+ handleSearchResults={handleSearchResults}
+ />
- {!!knownConnector ? (
-
- ) : (
-
- )}
- {documents.length > 0 ? (
-
-
-
-
- |
- Name
- |
-
- Date
- |
-
- Vectors
- |
-
- {' '}
- |
-
-
-
+
+
+
+
+ |
+ Name
+ |
+
+ Date
+ |
+
+ Vectors
+ |
+
+ {' '}
+ |
+
+
+ {!searchMode && documents?.length > 0 && (
+
{documents.map((document, index) => (
- <>
-
- |
-
- {truncate(document?.name, 35)}
- |
-
- {moment(document?.createdAt).format('lll')}
- |
- Cached |
-
-
-
-
-
- Details
-
-
-
-
- |
-
-
- >
+
))}
-
- {/* <>
- {documents.map((document) => {
- console.log(document);
- return (
-
-
-
-
-
-
- {truncate(document.name, 20)}
-
-
-
-
-
- {document.workspace.name || ''}
-
-
-
-
- {moment(document.createdAt).format('lll')}
-
-
-
-
- Cached
-
-
+ )}
+ {searchMode && searchResults?.length > 0 && (
+
+ {searchResults.map((document, index) => (
+
+ ))}
+
+ )}
+
-
-
-
- Details
-
-
-
-
-
-
- );
- })}
- > */}
-
- ) : (
- <>
-
-
-
-
You have no documents in any workspaces!
-
- Get started managing documents by adding them to workspaces
- via the UI or code.
-
-
+ {documents?.length === 0 && (
+
+
+
+ 0 Documents
+
+ Upload documents to your workspace
+
+
- {/*
*/}
- >
- )}
+ )}
+
{
+ return (
+ <>
+
+ |
+
+ {truncate(document?.name, 35)}
+ |
+ {moment(document?.createdAt).format('lll')} |
+ Cached |
+
+
+
+
+
+ Details
+
+
+
+
+ |
+
+
+ >
+ );
+};
+
export const CopyDocToModal = memo(
({
document,