diff --git a/frontend/src/pages/Dashboard/DocumentsList/index.tsx b/frontend/src/pages/Dashboard/DocumentsList/index.tsx index 5d180e3..69e9fe0 100644 --- a/frontend/src/pages/Dashboard/DocumentsList/index.tsx +++ b/frontend/src/pages/Dashboard/DocumentsList/index.tsx @@ -59,7 +59,7 @@ export default function DocumentsList({ if (loading) { return ( -
+

diff --git a/frontend/src/pages/DocumentView/FragmentList/index.tsx b/frontend/src/pages/DocumentView/FragmentList/index.tsx index 1d6a509..6017f08 100644 --- a/frontend/src/pages/DocumentView/FragmentList/index.tsx +++ b/frontend/src/pages/DocumentView/FragmentList/index.tsx @@ -107,7 +107,7 @@ export default function FragmentList({

) : ( - + + {searchResults.map((document, index) => ( + + ))} + + )} +
void; + searchMode: boolean; + setSearchMode: (searchMode: boolean) => void; + handleSearchResults: (results: any) => void; }) { const formEl = useRef(null); const [searching, setSearching] = useState(false); @@ -36,6 +43,7 @@ export default function SearchView({ }; const handleSearch = async (e: SyntheticEvent) => { e.preventDefault(); + setSearchMode(true); const formData = new FormData(e.target as any); const query = formData.get('query') as string; @@ -48,215 +56,109 @@ export default function SearchView({ ); setDocuments(matches); setSearching(false); + + handleSearchResults(matches); }; return ( -
-
-
-
- +
+ +
+ - - ); - })} - +
-
- + +
+
    + {Object.keys(SEARCH_MODES).map((_key, i) => { + const method = _key as ISearchTypes; + return ( +
  • + +
  • + ); + })} +
+
+
+ + {false ? ( +
+
+
+ ) : searchMode ? ( + + ) : ( -
- + )}
- -
- {searching ? ( -
-
-
- -

- Running {SEARCH_MODES[searchBy].display} for{' '} - "{searchTerm}" -

-
-
+
- ) : ( - <> - {documents.length > 0 ? ( -
-
-
-
- Document Name -
-
- Workspace -
-
- Created -
-
- Status -
-
- -
-
-
- <> - {documents.map((document) => { - return ( -
-
-
-
- - - {truncate(document.name, 20)} - -
-
-
- - {workspace.name || ''} - -
-
- - {moment(document.createdAt).format('lll')} - -
-
- - Cached - -
- -
- - - Details - - -
-
- -
- ); - })} - -
- ) : ( - <> -
-
-
- {!!searchTerm ? ( -

- No results on {SEARCH_MODES[searchBy].display} for{' '} - "{searchTerm}" -

- ) : ( -

- Type in a query to search for a document -

- )} -
-
-
- - )} - - )} +
); } 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})
- {/* */} - <> -
-
-
console.log('search')} - className="w-full" - > -
- -
-
    - {Object.keys(SEARCH_MODES).map((_key, i) => { - const method = _key as ISearchTypes; - return ( -
  • - -
  • - ); - })} -
-
-
- - {false ? ( -
-
-
- ) : searchMode ? ( - - ) : ( - - )} -
- -
- -
-
- + setSearchMode(false)} + deleteDocument={deleteDocument} + setSearchMode={setSearchMode} + handleSearchResults={handleSearchResults} + />
- {!!knownConnector ? ( - - ) : ( - - )}
- {documents.length > 0 ? ( -
- - - - - - - - - - +
+
- Name - - Date - - Vectors - - {' '} -
+ + + + + + + + + {!searchMode && documents?.length > 0 && ( + {documents.map((document, index) => ( - <> - - - - - - - - + ))} -
+ Name + + Date + + Vectors + + {' '} +
- -

{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 && ( +

-
- - - 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,