MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / handleDeleteFile

Function handleDeleteFile

packages/ui/src/views/files/index.jsx:57–101  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

55 }
56
57 const handleDeleteFile = async (file) => {
58 const confirmPayload = {
59 title: `Delete`,
60 description: `Delete ${file.name}? This process cannot be undone.`,
61 confirmButtonName: 'Delete',
62 cancelButtonName: 'Cancel'
63 }
64 const isConfirmed = await confirm(confirmPayload)
65
66 if (isConfirmed) {
67 try {
68 const deleteResponse = await filesApi.deleteFile(file.path)
69 if (deleteResponse?.data) {
70 enqueueSnackbar({
71 message: 'File deleted',
72 options: {
73 key: new Date().getTime() + Math.random(),
74 variant: 'success',
75 action: (key) => (
76 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
77 <IconX />
78 </Button>
79 )
80 }
81 })
82 }
83 await getAllFilesApi.request()
84 } catch (error) {
85 setError(error)
86 enqueueSnackbar({
87 message: typeof error.response.data === 'object' ? error.response.data.message : error.response.data,
88 options: {
89 key: new Date().getTime() + Math.random(),
90 variant: 'error',
91 persist: true,
92 action: (key) => (
93 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
94 <IconX />
95 </Button>
96 )
97 }
98 })
99 }
100 }
101 }
102
103 useEffect(() => {
104 getAllFilesApi.request()

Callers

nothing calls this directly

Calls 4

enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
confirmFunction · 0.85
getTimeMethod · 0.45

Tested by

no test coverage detected