(chore:chunks) i18n

This commit is contained in:
ManishMadan2882
2025-07-23 20:47:36 +05:30
parent 4d6ea401b5
commit ad2f0f8950
8 changed files with 125 additions and 22 deletions

View File

@@ -10,6 +10,7 @@ import NoFilesDarkIcon from '../assets/no-files-dark.svg';
import OutlineSource from '../assets/outline-source.svg';
import Spinner from '../components/Spinner';
import ChunkModal from '../modals/ChunkModal';
import ConfirmationModal from '../modals/ConfirmationModal';
import { ActiveState } from '../models/misc';
import { ChunkType } from '../settings/types';
import EditIcon from '../assets/edit.svg';
@@ -104,6 +105,8 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
const [editingTitle, setEditingTitle] = useState('');
const [editingText, setEditingText] = useState('');
const [isAddingChunk, setIsAddingChunk] = useState(false);
const [deleteModalState, setDeleteModalState] = useState<ActiveState>('INACTIVE');
const [chunkToDelete, setChunkToDelete] = useState<ChunkType | null>(null);
@@ -200,6 +203,24 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
}
};
const confirmDeleteChunk = (chunk: ChunkType) => {
setChunkToDelete(chunk);
setDeleteModalState('ACTIVE');
};
const handleConfirmedDelete = () => {
if (chunkToDelete) {
handleDeleteChunk(chunkToDelete);
setDeleteModalState('INACTIVE');
setChunkToDelete(null);
}
};
const handleCancelDelete = () => {
setDeleteModalState('INACTIVE');
setChunkToDelete(null);
};
useEffect(() => {
fetchChunks();
}, [page, perPage, path]);
@@ -251,8 +272,7 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
<button
className="rounded-full border border-solid border-red-500 px-3 py-1 text-sm text-nowrap text-red-500 hover:bg-red-500 hover:text-white"
onClick={() => {
handleDeleteChunk(editingChunk);
setEditingChunk(null);
confirmDeleteChunk(editingChunk);
}}
>
{t('modals.chunk.delete')}
@@ -281,7 +301,7 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
onClick={() => setIsAddingChunk(false)}
className="dark:text-light-gray cursor-pointer rounded-full px-3 py-1 text-sm font-medium hover:bg-gray-100 dark:bg-transparent dark:hover:bg-[#767183]/50"
>
{t('modals.chunk.close')}
{t('modals.chunk.cancel')}
</button>
<button
onClick={() => {
@@ -366,10 +386,10 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
<div className="w-full">
<div className="flex w-full items-center justify-between border-b border-[#D1D9E0] bg-[#F6F8FA] dark:bg-[#27282D] dark:border-[#6A6A6A] px-4 py-3">
<div className="text-[#59636E] text-sm dark:text-[#E0E0E0]">
{chunk.metadata.token_count ? chunk.metadata.token_count.toLocaleString() : '-'} tokens
{chunk.metadata.token_count ? chunk.metadata.token_count.toLocaleString() : '-'} {t('settings.documents.tokensUnit')}
</div>
<button
aria-label={'edit'}
aria-label={t('settings.documents.editAlt')}
onClick={() => {
setEditingChunk(chunk);
setEditingTitle(chunk.metadata?.title || '');
@@ -408,7 +428,7 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
<div className="relative flex flex-col rounded-[5.86px] border border-[#D1D9E0] dark:border-[#6A6A6A] overflow-hidden w-full">
<div className="flex w-full items-center justify-between border-b border-[#D1D9E0] bg-[#F6F8FA] dark:bg-[#27282D] dark:border-[#6A6A6A] px-4 py-3">
<div className="text-[#59636E] text-sm dark:text-[#E0E0E0]">
{editingChunk.metadata.token_count ? editingChunk.metadata.token_count.toLocaleString() : '-'} tokens
{editingChunk.metadata.token_count ? editingChunk.metadata.token_count.toLocaleString() : '-'} {t('settings.documents.tokensUnit')}
</div>
</div>
<div className="p-4 overflow-hidden">
@@ -436,6 +456,17 @@ const DocumentChunks: React.FC<DocumentChunksProps> = ({
)}
</div>
</div>
{/* Delete Confirmation Modal */}
<ConfirmationModal
message={t('modals.chunk.deleteConfirmation')}
modalState={deleteModalState}
setModalState={setDeleteModalState}
handleSubmit={handleConfirmedDelete}
handleCancel={handleCancelDelete}
submitLabel={t('modals.chunk.delete')}
variant="danger"
/>
</div>
);
};

View File

@@ -283,7 +283,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
<div className="flex items-center">
<img
src={FolderIcon}
alt="Parent folder"
alt={t('settings.documents.parentFolderAlt')}
className="mr-2 h-4 w-4"
/>
<span className="text-sm dark:text-[#E0E0E0]">..</span>
@@ -312,7 +312,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
>
<td className="px-4 py-2">
<div className="flex items-center">
<img src={FolderIcon} alt="Folder" className="mr-2 h-4 w-4" />
<img src={FolderIcon} alt={t('settings.documents.folderAlt')} className="mr-2 h-4 w-4" />
<span className="text-sm dark:text-[#E0E0E0]">{name}</span>
</div>
</td>
@@ -333,7 +333,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
>
<img
src={ThreeDots}
alt="Menu"
alt={t('settings.documents.menuAlt')}
className="opacity-60 hover:opacity-100"
/>
</button>
@@ -364,7 +364,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
>
<td className="px-4 py-2">
<div className="flex items-center">
<img src={FileIcon} alt="File" className="mr-2 h-4 w-4" />
<img src={FileIcon} alt={t('settings.documents.fileAlt')} className="mr-2 h-4 w-4" />
<span className="text-sm dark:text-[#E0E0E0]">{name}</span>
</div>
</td>
@@ -383,7 +383,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
>
<img
src={ThreeDots}
alt="Menu"
alt={t('settings.documents.menuAlt')}
className="opacity-60 hover:opacity-100"
/>
</button>
@@ -490,7 +490,7 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
>
<img
src={result.isFile ? FileIcon : FolderIcon}
alt={result.isFile ? "File" : "Folder"}
alt={result.isFile ? t('settings.documents.fileAlt') : t('settings.documents.folderAlt')}
className="flex-shrink-0 w-4 h-4 mr-2"
/>
<span className="text-sm dark:text-[#E0E0E0]">
@@ -537,16 +537,16 @@ const FileTreeComponent: React.FC<FileTreeComponentProps> = ({
<thead className="bg-gray-100 dark:bg-[#27282D]">
<tr className="border-b border-[#D1D9E0] dark:border-[#6A6A6A]">
<th className="w-3/5 px-4 py-3 text-left text-sm font-medium text-gray-700 dark:text-[#59636E]">
Name
{t('settings.documents.fileName')}
</th>
<th className="w-1/5 px-4 py-3 text-left text-sm font-medium text-gray-700 dark:text-[#59636E]">
Tokens
{t('settings.documents.tokens')}
</th>
<th className="w-1/5 px-4 py-3 text-left text-sm font-medium text-gray-700 dark:text-[#59636E]">
Size
{t('settings.documents.size')}
</th>
<th className="w-[60px] px-4 py-3 text-left text-sm font-medium text-gray-700 dark:text-[#59636E]">
<span className="sr-only">Actions</span>
<span className="sr-only">{t('settings.documents.actions')}</span>
</th>
</tr>
</thead>

View File

@@ -79,7 +79,18 @@
"noChunks": "No chunks found",
"noChunksAlt": "No chunks found",
"goToDocuments": "Go to Documents",
"uploadNew": "Upload new"
"uploadNew": "Upload new",
"searchFiles": "Search files...",
"noResults": "No results found",
"fileName": "Name",
"tokens": "Tokens",
"size": "Size",
"fileAlt": "File",
"folderAlt": "Folder",
"parentFolderAlt": "Parent folder",
"menuAlt": "Menu",
"tokensUnit": "tokens",
"editAlt": "Edit"
},
"apiKeys": {
"label": "Chatbots",
@@ -257,6 +268,7 @@
"promptText": "Prompt Text",
"update": "Update",
"close": "Close",
"cancel": "Cancel",
"delete": "Delete",
"deleteConfirmation": "Are you sure you want to delete this chunk?"
}

View File

@@ -79,7 +79,18 @@
"noChunks": "No se encontraron fragmentos",
"noChunksAlt": "No se encontraron fragmentos",
"goToDocuments": "Ir a Documentos",
"uploadNew": "Subir nuevo"
"uploadNew": "Subir nuevo",
"searchFiles": "Buscar archivos...",
"noResults": "No se encontraron resultados",
"fileName": "Nombre",
"tokens": "Tokens",
"size": "Tamaño",
"fileAlt": "Archivo",
"folderAlt": "Carpeta",
"parentFolderAlt": "Carpeta padre",
"menuAlt": "Menú",
"tokensUnit": "tokens",
"editAlt": "Editar"
},
"apiKeys": {
"label": "Chatbots",
@@ -257,6 +268,7 @@
"promptText": "Texto del prompt",
"update": "Actualizar",
"close": "Cerrar",
"cancel": "Cancelar",
"delete": "Eliminar",
"deleteConfirmation": "¿Estás seguro de que deseas eliminar este fragmento?"
}

View File

@@ -79,7 +79,18 @@
"noChunks": "チャンクが見つかりません",
"noChunksAlt": "チャンクが見つかりません",
"goToDocuments": "ドキュメントへ移動",
"uploadNew": "新規アップロード"
"uploadNew": "新規アップロード",
"searchFiles": "ファイルを検索...",
"noResults": "結果が見つかりません",
"fileName": "名前",
"tokens": "トークン",
"size": "サイズ",
"fileAlt": "ファイル",
"folderAlt": "フォルダ",
"parentFolderAlt": "親フォルダ",
"menuAlt": "メニュー",
"tokensUnit": "トークン",
"editAlt": "編集"
},
"apiKeys": {
"label": "チャットボット",
@@ -257,6 +268,7 @@
"promptText": "プロンプトテキスト",
"update": "更新",
"close": "閉じる",
"cancel": "キャンセル",
"delete": "削除",
"deleteConfirmation": "このチャンクを削除してもよろしいですか?"
}

View File

@@ -79,7 +79,18 @@
"noChunks": "Фрагменты не найдены",
"noChunksAlt": "Фрагменты не найдены",
"goToDocuments": "Перейти к документам",
"uploadNew": "Загрузить новый"
"uploadNew": "Загрузить новый",
"searchFiles": "Поиск файлов...",
"noResults": "Результаты не найдены",
"fileName": "Имя",
"tokens": "Токены",
"size": "Размер",
"fileAlt": "Файл",
"folderAlt": "Папка",
"parentFolderAlt": "Родительская папка",
"menuAlt": "Меню",
"tokensUnit": "токенов",
"editAlt": "Редактировать"
},
"apiKeys": {
"label": "API ключи",
@@ -257,6 +268,7 @@
"promptText": "Текст подсказки",
"update": "Обновить",
"close": "Закрыть",
"cancel": "Отмена",
"delete": "Удалить",
"deleteConfirmation": "Вы уверены, что хотите удалить этот фрагмент?"
}

View File

@@ -79,7 +79,18 @@
"noChunks": "未找到文本塊",
"noChunksAlt": "未找到文本塊",
"goToDocuments": "前往文件",
"uploadNew": "上傳新文件"
"uploadNew": "上傳新文件",
"searchFiles": "搜尋檔案...",
"noResults": "未找到結果",
"fileName": "名稱",
"tokens": "Token",
"size": "大小",
"fileAlt": "檔案",
"folderAlt": "資料夾",
"parentFolderAlt": "上層資料夾",
"menuAlt": "選單",
"tokensUnit": "Token",
"editAlt": "編輯"
},
"apiKeys": {
"label": "聊天機器人",
@@ -257,6 +268,7 @@
"promptText": "提示文字",
"update": "更新",
"close": "關閉",
"cancel": "取消",
"delete": "刪除",
"deleteConfirmation": "您確定要刪除此區塊嗎?"
}

View File

@@ -79,7 +79,18 @@
"noChunks": "未找到文本块",
"noChunksAlt": "未找到文本块",
"goToDocuments": "前往文档",
"uploadNew": "上传新文档"
"uploadNew": "上传新文档",
"searchFiles": "搜索文件...",
"noResults": "未找到结果",
"fileName": "名称",
"tokens": "令牌",
"size": "大小",
"fileAlt": "文件",
"folderAlt": "文件夹",
"parentFolderAlt": "父文件夹",
"menuAlt": "菜单",
"tokensUnit": "令牌",
"editAlt": "编辑"
},
"apiKeys": {
"label": "聊天机器人",
@@ -257,6 +268,7 @@
"promptText": "提示文本",
"update": "更新",
"close": "关闭",
"cancel": "取消",
"delete": "删除",
"deleteConfirmation": "您确定要删除此块吗?"
}