@@ -21,7 +21,7 @@ interface BatchHistoryItem {
21
21
status : string ;
22
22
}
23
23
const HistoryPanel : React . FC < HistoryPanelProps > = ( { isOpen, onClose } ) => {
24
- const headers = { }
24
+ const headers = { }
25
25
const [ batchHistory , setBatchHistory ] = useState < BatchHistoryItem [ ] > ( [ ] ) ;
26
26
const [ loading , setLoading ] = useState ( false ) ;
27
27
const [ error , setError ] = useState < string | null > ( null ) ;
@@ -41,7 +41,7 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
41
41
navigate ( `/batch-process/${ batch . batch_id } ` ) ;
42
42
}
43
43
} ) ;
44
- } ;
44
+ } ;
45
45
46
46
useEffect ( ( ) => {
47
47
if ( isOpen && ! hasFetched . current ) {
@@ -124,21 +124,20 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
124
124
const deleteBatchFromHistory = ( batchId : string ) => {
125
125
// Get the current URL path
126
126
const currentPath = window . location . pathname ;
127
-
127
+
128
128
// Check if the current URL contains the batch ID being deleted
129
- const isCurrentBatch = currentPath . includes ( `/batch-view/${ batchId } ` ) ||
130
- currentPath . includes ( `/batch-process/${ batchId } ` ) ;
131
-
129
+ const isCurrentBatch = currentPath . includes ( `/batch-view/${ batchId } ` ) ||
130
+ currentPath . includes ( `/batch-process/${ batchId } ` ) ;
131
+
132
132
const headers = {
133
- "Content-Type" : "application/json" ,
134
- "user_id" : "<authenticated_user_id>"
133
+ "Content-Type" : "application/json"
135
134
} ;
136
-
135
+
137
136
try {
138
137
dispatch ( deleteBatch ( { batchId, headers } ) ) . unwrap ( ) ;
139
138
const updatedBatchHistory = batchHistory . filter ( batch => batch . batch_id !== batchId ) ;
140
139
setBatchHistory ( updatedBatchHistory ) ;
141
-
140
+
142
141
// If the deleted batch is the current one, navigate to home page
143
142
if ( isCurrentBatch ) {
144
143
onClose ( ) ; // Close the panel first
@@ -154,16 +153,16 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
154
153
const deleteAllBatchesFromHistory = async ( ) => {
155
154
// Get the current URL path
156
155
const currentPath = window . location . pathname ;
157
-
156
+
158
157
// Check if the current URL contains "/batch-view/" or "/batch-process/"
159
- const isViewingBatch = currentPath . includes ( "/batch-view/" ) ||
160
- currentPath . includes ( "/batch-process/" ) ;
161
-
158
+ const isViewingBatch = currentPath . includes ( "/batch-view/" ) ||
159
+ currentPath . includes ( "/batch-process/" ) ;
160
+
162
161
try {
163
- const headers = { "Content-Type" : "application/json" , user_id : "<authenticated_user_id>" } ;
162
+ const headers = { "Content-Type" : "application/json" } ;
164
163
await dispatch ( deleteAllBatches ( { headers } ) ) . unwrap ( ) ;
165
164
setBatchHistory ( [ ] ) ;
166
-
165
+
167
166
// If the user is currently viewing any batch, navigate to home page
168
167
if ( isViewingBatch ) {
169
168
onClose ( ) ; // Close the panel first
@@ -268,7 +267,7 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
268
267
return dateFormatter . format ( date ) ;
269
268
} ) ( ) } ({ batch . file_count } { batch . file_count === 1 ? "file" : "files" } )
270
269
</ span >
271
- { hoveredBatchId === batch . batch_id ? (
270
+ { hoveredBatchId === batch . batch_id && batch . status === "completed" ? (
272
271
< Tooltip content = "Delete Batch" relationship = "label" >
273
272
< button className = "delete-button"
274
273
onClick = { ( ) => {
0 commit comments