Skip to content

Commit 4cfd22c

Browse files
committed
fix delete button not showing in document view in rag
1 parent 9b46563 commit 4cfd22c

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/renderer/components/Experiment/Rag/Documents.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { FaRegFileAlt } from 'react-icons/fa';
4949

5050
import { FaRegFilePdf } from 'react-icons/fa6';
5151
import { LuFileJson } from 'react-icons/lu';
52-
import { Alert, Stack } from '@mui/joy';
52+
import { Alert, CircularProgress, Stack } from '@mui/joy';
5353
import TinyButton from 'renderer/components/Shared/TinyButton';
5454

5555
function descendingComparator<T>(a: T, b: T, orderBy: keyof T) {
@@ -96,7 +96,7 @@ function stableSort<T>(
9696
return stabilizedThis?.map((el) => el[0]);
9797
}
9898

99-
function RowMenu({ experimentInfo, filename, mutate }) {
99+
function RowMenu({ experimentInfo, filename, mutate, row }) {
100100
return (
101101
<Dropdown>
102102
<MenuButton
@@ -106,8 +106,8 @@ function RowMenu({ experimentInfo, filename, mutate }) {
106106
<MoreHorizRoundedIcon size="16px" />
107107
</MenuButton>
108108
<Menu size="sm" sx={{ minWidth: 140 }}>
109-
<MenuItem>Edit</MenuItem>
110-
<MenuItem disabled>Rename</MenuItem>
109+
<MenuItem disabled>Size: {formatBytes(row?.size)}</MenuItem>
110+
{/* <MenuItem disabled>Rename</MenuItem> */}
111111
<Divider />
112112
<MenuItem
113113
color="danger"
@@ -142,6 +142,8 @@ export default function Documents({ experimentInfo }) {
142142

143143
const [previewFile, setPreviewFile] = React.useState<string | null>(null);
144144

145+
const [loading, setLoading] = React.useState(false);
146+
145147
const {
146148
data: rows,
147149
isLoading,
@@ -155,14 +157,15 @@ export default function Documents({ experimentInfo }) {
155157
})
156158
.then((response) => {
157159
if (response.ok) {
158-
mutate();
159160
return response.json();
160161
} else {
161162
throw new Error('File upload failed');
162163
}
163164
})
164165
.then((data) => {
165166
console.log('Server response:', data);
167+
setLoading(false);
168+
mutate();
166169
})
167170
.catch((error) => {
168171
console.error('Error uploading file:', error);
@@ -218,7 +221,10 @@ export default function Documents({ experimentInfo }) {
218221
justifyContent: 'space-between',
219222
}}
220223
>
221-
<FormLabel>Documents:</FormLabel>
224+
<FormLabel>
225+
{loading && <CircularProgress size="sm" />}
226+
Documents:
227+
</FormLabel>
222228
<IconButton
223229
color="primary"
224230
variant="plain"
@@ -234,6 +240,7 @@ export default function Documents({ experimentInfo }) {
234240
for (const file of files) {
235241
formData.append('files', file);
236242
}
243+
setLoading(true);
237244
await uploadFiles(formData);
238245
};
239246
input.click();
@@ -311,6 +318,7 @@ export default function Documents({ experimentInfo }) {
311318
for (const file of acceptedFiles) {
312319
formData.append('files', file);
313320
}
321+
setLoading(true);
314322
await uploadFiles(formData);
315323
}}
316324
onDragEnter={() => {
@@ -422,10 +430,10 @@ export default function Documents({ experimentInfo }) {
422430
</th>
423431
{/* <th style={{ padding: '12px 6px' }}>Date</th> */}
424432
{/* <th style={{ padding: '12px 6px' }}>Type</th>{' '} */}
425-
<th style={{ height: '10px' }}>
433+
{/* <th style={{ height: '10px' }}>
426434
<Typography color="neutral">Size</Typography>
427-
</th>
428-
<th style={{ height: '10px', width: '20px' }}> </th>
435+
</th> */}
436+
<th style={{ height: '10px', width: '70px' }}> </th>
429437
</tr>
430438
</thead>
431439
<tbody>
@@ -491,13 +499,13 @@ export default function Documents({ experimentInfo }) {
491499
{row?.type}
492500
</Chip>
493501
</td> */}
494-
<td>
502+
{/* <td>
495503
{row?.size && (
496504
<Typography level="body-xs" color="neutral">
497505
{formatBytes(row?.size)}
498506
</Typography>
499507
)}
500-
</td>
508+
</td> */}
501509
<td>
502510
<Box
503511
sx={{
@@ -520,6 +528,7 @@ export default function Documents({ experimentInfo }) {
520528
experimentInfo={experimentInfo}
521529
filename={row?.name}
522530
mutate={mutate}
531+
row={row}
523532
/>
524533
</Box>
525534
</td>

0 commit comments

Comments
 (0)