remove: document download file permission (#24459)

This commit is contained in:
quicksand
2025-08-25 15:11:48 +08:00
committed by GitHub
parent 424fdf4b52
commit a06681913d
5 changed files with 1 additions and 111 deletions

View File

@@ -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,32 +295,6 @@ export const OperationAction: FC<{
)}
{embeddingAvailable && (
<>
<Tooltip
popupContent={t('datasetDocuments.list.action.download')}
popupClassName='text-text-secondary system-xs-medium'
needsDelay={false}
>
<button
className={cn('mr-2 cursor-pointer rounded-lg',
!isListScene
? 'shadow-shadow-3 border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg p-2 shadow-xs backdrop-blur-[5px] hover:border-components-button-secondary-border-hover hover:bg-components-button-secondary-bg-hover'
: 'p-0.5 hover:bg-state-base-hover')}
onClick={() => {
downloadDocument.mutateAsync({
datasetId,
documentId: detail.id,
}).then((response) => {
if (response.download_url)
window.location.href = response.download_url
}).catch((error) => {
console.error(error)
notify({ type: 'error', message: t('common.actionMsg.downloadFailed') })
})
}}
>
<RiDownloadLine className='h-4 w-4 text-components-button-secondary-text' />
</button>
</Tooltip>
<Tooltip
popupContent={t('datasetDocuments.list.action.settings')}
popupClassName='text-text-secondary system-xs-medium'

View File

@@ -32,7 +32,6 @@ const translation = {
sync: 'Sync',
pause: 'Pause',
resume: 'Resume',
download: 'Download File',
},
index: {
enable: 'Enable',

View File

@@ -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<FileDownloadResponse>(`/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) => {