@@ -2,14 +2,16 @@ import { useQuery } from '@tanstack/react-query'
2
2
import { useParams , Link as RouterLink , useNavigate } from 'react-router-dom'
3
3
import apiClient from '../../util/apiClient'
4
4
import type { RagFileAttributes } from '../../../shared/types'
5
- import { Button , Container , Link , Typography } from '@mui/material'
5
+ import { Box , Button , Container , Link , Typography } from '@mui/material'
6
6
import { RagFileInfo } from './RagFileDetails'
7
7
import type { RagIndexAttributes } from '../../../server/db/models/ragIndex'
8
8
import { Chunk } from './Chunk'
9
- import { useDeleteRagFileMutation } from './api'
9
+ import { useDeleteRagFileMutation , useDeleteRagFileTextMutation } from './api'
10
10
import { useTranslation } from 'react-i18next'
11
11
import Markdown from 'react-markdown'
12
12
import { enqueueSnackbar } from 'notistack'
13
+ import { OutlineButtonBlack } from '../ChatV2/general/Buttons'
14
+ import { Autorenew } from '@mui/icons-material'
13
15
14
16
type RagFile = RagFileAttributes & {
15
17
fileContent : string
@@ -32,6 +34,7 @@ export const RagFile: React.FC = () => {
32
34
} ,
33
35
} )
34
36
const deleteMutation = useDeleteRagFileMutation ( )
37
+ const deleteTextMutation = useDeleteRagFileTextMutation ( )
35
38
const navigate = useNavigate ( )
36
39
37
40
if ( isError ) {
@@ -51,24 +54,42 @@ export const RagFile: React.FC = () => {
51
54
< Typography variant = "h3" >
52
55
{ ragFile . ragIndex . metadata ?. name } / { ragFile . filename }
53
56
</ Typography >
54
- < Button
55
- variant = "text"
56
- color = "error"
57
- sx = { { my : 2 } }
58
- onClick = { async ( ) => {
59
- if ( window . confirm ( 'Are you sure you want to delete this file?' ) ) {
60
- await deleteMutation . mutateAsync ( {
61
- indexId : ragFile . ragIndex . id ,
62
- fileId : ragFile . id ,
63
- } )
64
- enqueueSnackbar ( t ( 'rag:fileDeleted' ) , { variant : 'success' } )
57
+ < Box sx = { { my : 2 , display : 'flex' , gap : 2 } } >
58
+ { ragFile . fileType === 'application/pdf' && (
59
+ < OutlineButtonBlack
60
+ startIcon = { < Autorenew /> }
61
+ onClick = { async ( ) => {
62
+ await deleteTextMutation . mutateAsync ( {
63
+ indexId : ragFile . ragIndex . id ,
64
+ fileId : ragFile . id ,
65
+ } )
66
+ enqueueSnackbar ( t ( 'rag:fileTextDeleted' ) , { variant : 'success' } )
65
67
66
- navigate ( `/rag/${ ragFile . ragIndex . id } ` )
67
- }
68
- } }
69
- >
70
- { t ( 'rag:deleteFile' ) }
71
- </ Button >
68
+ navigate ( `/rag/${ ragFile . ragIndex . id } ` )
69
+ } }
70
+ sx = { { my : 2 } }
71
+ >
72
+ { t ( 'rag:deleteFileText' ) }
73
+ </ OutlineButtonBlack >
74
+ ) }
75
+ < Button
76
+ variant = "text"
77
+ color = "error"
78
+ onClick = { async ( ) => {
79
+ if ( window . confirm ( 'Are you sure you want to delete this file?' ) ) {
80
+ await deleteMutation . mutateAsync ( {
81
+ indexId : ragFile . ragIndex . id ,
82
+ fileId : ragFile . id ,
83
+ } )
84
+ enqueueSnackbar ( t ( 'rag:fileDeleted' ) , { variant : 'success' } )
85
+
86
+ navigate ( `/rag/${ ragFile . ragIndex . id } ` )
87
+ }
88
+ } }
89
+ >
90
+ { t ( 'rag:deleteFile' ) }
91
+ </ Button >
92
+ </ Box >
72
93
< RagFileInfo file = { ragFile } />
73
94
< Typography variant = "h4" > { t ( 'rag:content' ) } </ Typography >
74
95
{ ragFile . fileContent . length === 0 ? (
0 commit comments