diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index 8502cf36..8a8d645b 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -53,6 +53,7 @@ "default": "Default" }, "documents": { + "title": "This table contains all the documents that are available to you and those you have uploaded", "label": "Documents", "name": "Document Name", "date": "Vector Date", diff --git a/frontend/src/locale/es.json b/frontend/src/locale/es.json index c5b0fa17..41b8fd96 100644 --- a/frontend/src/locale/es.json +++ b/frontend/src/locale/es.json @@ -53,6 +53,7 @@ "default": "Predeterminado" }, "documents": { + "title": "Esta tabla contiene todos los documentos que están disponibles para ti y los que has subido", "label": "Documentos", "name": "Nombre del Documento", "date": "Fecha de Vector", diff --git a/frontend/src/locale/ru.json b/frontend/src/locale/ru.json index 69897452..cd9f2f44 100644 --- a/frontend/src/locale/ru.json +++ b/frontend/src/locale/ru.json @@ -53,6 +53,7 @@ "default": "По умолчанию" }, "documents": { + "title": "Эта таблица содержит все документы, которые доступны вам и те, которые вы загрузили", "label": "Документы", "name": "Название документа", "date": "Дата вектора", diff --git a/frontend/src/locale/zh-TW.json b/frontend/src/locale/zh-TW.json index 3699afde..eb7ab9ef 100644 --- a/frontend/src/locale/zh-TW.json +++ b/frontend/src/locale/zh-TW.json @@ -53,6 +53,7 @@ "default": "預設" }, "documents": { + "title": "此表格包含所有可供您使用的文件以及您上傳的文件", "label": "文件", "name": "文件名稱", "date": "向量日期", diff --git a/frontend/src/locale/zh.json b/frontend/src/locale/zh.json index 9936350d..b73a8c54 100644 --- a/frontend/src/locale/zh.json +++ b/frontend/src/locale/zh.json @@ -53,7 +53,8 @@ "default": "默认" }, "documents": { - "label": "文件", + "title": "此表格包含所有可供您使用的文档以及您上传的文档", + "label": "文档", "name": "文件名称", "date": "向量日期", "type": "类型", @@ -111,7 +112,7 @@ "searchPlaceholder": "搜索...", "addTool": "添加工具", "noToolsFound": "未找到工具", - "selectToolSetup": "选择要设置的工具" , + "selectToolSetup": "选择要设置的工具", "settingsIconAlt": "设置图标", "configureToolAria": "配置 {toolName}", "toggleToolAria": "切换 {toolName}" diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx index ee04d121..ee52b377 100644 --- a/frontend/src/settings/Documents.tsx +++ b/frontend/src/settings/Documents.tsx @@ -16,6 +16,7 @@ import { getDocs, getDocsWithPagination } from '../preferences/preferenceApi'; import { setSourceDocs } from '../preferences/preferenceSlice'; import { setPaginatedDocuments } from '../preferences/preferenceSlice'; import { truncate } from '../utils/stringUtils'; +import { formatDate } from '../utils/dateTimeUtils'; // Utility function to format numbers const formatTokens = (tokens: number): string => { @@ -85,6 +86,7 @@ const Documents: React.FC = ({ setSortField(newSortField); setSortOrder(newSortOrder); } + setLoading(true); getDocsWithPagination( newSortField, @@ -110,7 +112,6 @@ const Documents: React.FC = ({ userService .manageSync({ source_id: doc.id, sync_frequency }) .then(() => { - // First, fetch the updated source docs return getDocs(); }) .then((data) => { @@ -136,206 +137,186 @@ const Documents: React.FC = ({ useEffect(() => { if (modalState === 'INACTIVE') { - refreshDocs(sortField, currentPage, rowsPerPage); + refreshDocs(undefined, currentPage, rowsPerPage); } }, [modalState]); useEffect(() => { - // undefine to prevent reset the sort order refreshDocs(undefined, 1, rowsPerPage); }, [searchTerm]); return (
-
-
-
- - { - setSearchTerm(e.target.value); - setCurrentPage(1); - }} - /> -
- -
- {loading ? ( - - ) : ( -
-
-
- - - - - - - {/*} - - */} - - - - - {!currentDocuments?.length && ( - - - - )} - {Array.isArray(currentDocuments) && - currentDocuments.map((document, index) => ( - - - - - {/*} - - */} - - - ))} - -
- {t('settings.documents.name')} - -
- {t('settings.documents.date')} - refreshDocs('date')} - src={caretSort} - alt="sort" - /> -
-
-
- {t('settings.documents.tokenUsage')} - refreshDocs('tokens')} - src={caretSort} - alt="sort" - /> -
-
-
- {t('settings.documents.type')} -
-
- {t('settings.documents.actions')} -
- {t('settings.documents.noData')} -
- {truncate(document.name, 50)} - - {document.date} - - {document.tokens - ? formatTokens(+document.tokens) - : ''} - - {document.type === 'remote' - ? 'Pre-loaded' - : 'Private'} - -
- {document.type !== 'remote' && ( - {t('convTile.delete')} { - event.stopPropagation(); - handleDeleteDocument(index, document); - }} - /> - )} - {document.syncFrequency && ( -
- { - handleManageSync(document, value); - }} - defaultValue={document.syncFrequency} - icon={SyncIcon} - /> -
- )} -
-
-
-
-
- )} +
+

+ {t('settings.documents.title')} +

+
+
+
+ + { + setSearchTerm(e.target.value); + setCurrentPage(1); + }} + /> +
+
- {/* outside scrollable area */} - { - setCurrentPage(page); - refreshDocs(undefined, page, rowsPerPage); - }} - onRowsPerPageChange={(rows) => { - setRowsPerPage(rows); - setCurrentPage(1); - refreshDocs(undefined, 1, rows); - }} - /> - {/* Conditionally render the Upload modal based on modalState */} - {modalState === 'ACTIVE' && ( -
-
- {/* Your Upload component */} - setModalState('INACTIVE')} - /> -
+ {loading ? ( + + ) : ( +
+ + + + + + + + + + + {!currentDocuments?.length && ( + + + + )} + {Array.isArray(currentDocuments) && + currentDocuments.map((document, index) => ( + + + + + + + ))} + +
+ {t('settings.documents.name')} + +
+ {t('settings.documents.date')} + refreshDocs('date')} + src={caretSort} + alt="sort" + /> +
+
+
+ + {t('settings.documents.tokenUsage')} + + + {t('settings.documents.tokenUsage')} + + refreshDocs('tokens')} + src={caretSort} + alt="sort" + /> +
+
+ + {t('settings.documents.actions')} + +
+ {t('settings.documents.noData')} +
+
+ {truncate(document.name, 50)} +
+
+ {document.date ? formatDate(document.date) : ''} + + {document.tokens ? formatTokens(+document.tokens) : ''} + +
+ {/* For non-remote documents, adding empty space holder */} + {!document.syncFrequency && ( +
+ )} + {document.syncFrequency && ( + { + handleManageSync(document, value); + }} + defaultValue={document.syncFrequency} + icon={SyncIcon} + /> + )} + +
+
)}
+ { + setCurrentPage(page); + refreshDocs(undefined, page, rowsPerPage); + }} + onRowsPerPageChange={(rows) => { + setRowsPerPage(rows); + setCurrentPage(1); + refreshDocs(undefined, 1, rows); + }} + /> + {modalState === 'ACTIVE' && ( + setModalState('INACTIVE')} + /> + )}
); };