From 337ad751148623e13bb6b8bf30a967686c4c1f9d Mon Sep 17 00:00:00 2001 From: twwu Date: Fri, 22 Aug 2025 18:16:50 +0800 Subject: [PATCH] refactor: remove document download functionality and related translations --- .../components/datasets/documents/list.tsx | 32 ++----------------- web/i18n/en-US/dataset-documents.ts | 1 - web/service/knowledge/use-document.ts | 19 +---------- 3 files changed, 3 insertions(+), 49 deletions(-) diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index 83effd446c..ad533c97ff 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -7,7 +7,6 @@ import { pick, uniq } from 'lodash-es' import { RiArchive2Line, RiDeleteBinLine, - RiDownloadLine, RiEditLine, RiEqualizer2Line, RiLoopLeftLine, @@ -35,7 +34,6 @@ import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator import Indicator from '@/app/components/header/indicator' import { asyncRunSafe } from '@/utils' import { formatNumber } from '@/utils/format' -import { useDocumentDownload } from '@/service/knowledge/use-document' import NotionIcon from '@/app/components/base/notion-icon' import ProgressBar from '@/app/components/base/progress-bar' import { ChunkingMode, DataSourceType, DocumentActionType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets' @@ -189,7 +187,6 @@ export const OperationAction: FC<{ scene?: 'list' | 'detail' className?: string }> = ({ embeddingAvailable, datasetId, detail, onUpdate, scene = 'list', className = '' }) => { - const downloadDocument = useDocumentDownload() const { id, enabled = false, archived = false, data_source_type, display_status } = detail || {} const [showModal, setShowModal] = useState(false) const [deleting, setDeleting] = useState(false) @@ -298,31 +295,6 @@ export const OperationAction: FC<{ )} {embeddingAvailable && ( <> - - - = ({ const result = aValue.localeCompare(bValue) return sortOrder === 'asc' ? result : -result } - else { + else { const result = aValue - bValue return sortOrder === 'asc' ? result : -result } @@ -539,7 +511,7 @@ const DocumentList: FC = ({ if (sortField === field) { setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc') } - else { + else { setSortField(field) setSortOrder('desc') } diff --git a/web/i18n/en-US/dataset-documents.ts b/web/i18n/en-US/dataset-documents.ts index 292270f931..5fdf185350 100644 --- a/web/i18n/en-US/dataset-documents.ts +++ b/web/i18n/en-US/dataset-documents.ts @@ -32,7 +32,6 @@ const translation = { sync: 'Sync', pause: 'Pause', resume: 'Resume', - download: 'Download File', }, index: { enable: 'Enable', diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.ts index 3d6e322552..e53a5ebde7 100644 --- a/web/service/knowledge/use-document.ts +++ b/web/service/knowledge/use-document.ts @@ -8,9 +8,7 @@ import type { MetadataType, SortType } from '../datasets' import { pauseDocIndexing, resumeDocIndexing } from '../datasets' import type { DocumentDetailResponse, DocumentListResponse, UpdateDocumentBatchParams } from '@/models/datasets' import { DocumentActionType } from '@/models/datasets' -import type { CommonResponse, FileDownloadResponse } from '@/models/common' -// Download document with authentication (sends Authorization header) -import Toast from '@/app/components/base/toast' +import type { CommonResponse } from '@/models/common' const NAME_SPACE = 'knowledge/document' @@ -97,21 +95,6 @@ export const useSyncDocument = () => { }) } -// Download document with authentication (sends Authorization header) -export const useDocumentDownload = () => { - return useMutation({ - mutationFn: async ({ datasetId, documentId }: { datasetId: string; documentId: string }) => { - // The get helper automatically adds the Authorization header from localStorage - return get(`/datasets/${datasetId}/documents/${documentId}/upload-file`) - }, - onError: (error: any) => { - // Show a toast notification if download fails - const message = error?.message || 'Download failed.' - Toast.notify({ type: 'error', message }) - }, - }) -} - export const useSyncWebsite = () => { return useMutation({ mutationFn: ({ datasetId, documentId }: UpdateDocumentBatchParams) => {