diff --git a/frontend/src/pages/Dashboard/DocumentsList/index.tsx b/frontend/src/pages/Dashboard/DocumentsList/index.tsx index 69e9fe0..234797c 100644 --- a/frontend/src/pages/Dashboard/DocumentsList/index.tsx +++ b/frontend/src/pages/Dashboard/DocumentsList/index.tsx @@ -11,6 +11,8 @@ import UploadDocumentModal from './UploadModal'; import UploadModalNoKey from './UploadModal/UploadModalNoKey'; import DocumentListPagination from '../../../components/DocumentPaginator'; import useQuery from '../../../hooks/useQuery'; +import Document from '../../../models/document'; +import { File, Trash } from '@phosphor-icons/react'; export default function DocumentsList({ organization, @@ -41,6 +43,18 @@ export default function DocumentsList({ setCurrentPage(setTo); } + const deleteDocument = async (documentId: number) => { + if ( + !confirm( + 'Are you sure you want to delete this document? This will remove the document from your vector database and remove it from the cache. This process cannot be undone.' + ) + ) + return false; + const success = await Document.delete(documentId); + if (!success) return false; + document.getElementById(`document-row-${documentId}`)?.remove(); + }; + useEffect(() => { async function getDocs(slug?: string) { if (!slug) return false; @@ -59,30 +73,17 @@ export default function DocumentsList({ if (loading) { return ( -
-
-
-

- Documents {totalDocuments! > 0 ? `(${totalDocuments})` : ''} -

-
-
-
-
-
-
+
); } return ( <> -
+ {/*
-
-

- Documents {totalDocuments! > 0 ? `(${totalDocuments})` : ''} -

-
{workspaces.length > 0 ? ( <> {!!knownConnector ? ( @@ -128,16 +129,41 @@ export default function DocumentsList({ Workspace
- Created + Date
- Status + Vectors
+ + {documents?.length === 0 && ( +
+
+
+ 0 Documents +
+
+ Upload documents to your workspace +
+ +
+
+ )} <> {documents.map((document) => { return ( @@ -216,17 +242,212 @@ export default function DocumentsList({
)} + */} +
+
+ + + + + + + + + + + + {documents?.length > 0 && ( + + {documents.map((document, index) => ( + + ))} + + )} +
+ Name + + Workspace + + Date + + Vectors + + {' '} +
+ + {workspaces?.length === 0 && ( +
+
+
+ Create a workspace to get started +
+
+ Workspaces are used to organize your documents +
+ +
+
+ )} + + {documents?.length === 0 && workspaces?.length > 0 && ( +
+
+
+ 0 Documents +
+
+ Upload documents to your workspace +
+ +
+
+ )} +
+ +
+ +
+ {canUpload ? ( + + ) : ( + + )}
- - {canUpload ? ( - - ) : ( - - )} ); } + +const Fragment = ({ + document, + index, + deleteDocument, + organization, +}: { + document: any; + index: number; + deleteDocument: any; + organization: any; +}) => { + return ( + <> + + + +

{truncate(document?.name, 35)}

+ + + + + {truncate(document.workspace.name, 20) || ''} + + + + {moment(document?.createdAt).format('lll')} + Cached + + + Details + + + +
+
+ +
+
+ + + + ); +}; diff --git a/frontend/src/pages/Dashboard/WorkspacesList/index.tsx b/frontend/src/pages/Dashboard/WorkspacesList/index.tsx index 7ba65a9..a35bc64 100644 --- a/frontend/src/pages/Dashboard/WorkspacesList/index.tsx +++ b/frontend/src/pages/Dashboard/WorkspacesList/index.tsx @@ -20,7 +20,7 @@ export default function WorkspacesList({ totalWorkspaces?: number; }) { return ( -
+

diff --git a/frontend/src/pages/Dashboard/index.tsx b/frontend/src/pages/Dashboard/index.tsx index 2b7a087..e1090d7 100644 --- a/frontend/src/pages/Dashboard/index.tsx +++ b/frontend/src/pages/Dashboard/index.tsx @@ -135,8 +135,8 @@ export default function Dashboard() {

)} -
-
+
+
void; }) => { const [loading, setLoading] = useState(false); - const [type, setType] = useState(connector.type); + const [type, setType] = useState(connector?.type); const [error, setError] = useState(null); const [success, setSuccess] = useState(false); - const settings = JSON.parse(connector.settings); + const settings = JSON.parse(connector?.settings); const handleSubmit = async (e: any) => { e.preventDefault();