@@ -16,6 +16,7 @@ import JobsList from './JobsList';
1616import  NewTaskModal  from  './NewTaskModal' ; 
1717import  EditTaskModal  from  './EditTaskModal' ; 
1818import  ViewOutputModalStreaming  from  './ViewOutputModalStreaming' ; 
19+ import  {  useNotification  }  from  'renderer/components/Shared/NotificationSystem' ; 
1920
2021const  duration  =  require ( 'dayjs/plugin/duration' ) ; 
2122
@@ -34,6 +35,7 @@ export default function Tasks() {
3435  const  [ viewEvalImagesFromJob ,  setViewEvalImagesFromJob ]  =  useState ( - 1 ) ; 
3536  const  [ viewOutputFromSweepJob ,  setViewOutputFromSweepJob ]  =  useState ( false ) ; 
3637  const  {  experimentInfo }  =  useExperimentInfo ( ) ; 
38+   const  {  addNotification }  =  useNotification ( ) ; 
3739
3840  const  handleOpen  =  ( )  =>  setModalOpen ( true ) ; 
3941  const  handleClose  =  ( )  =>  setModalOpen ( false ) ; 
@@ -97,19 +99,24 @@ export default function Tasks() {
9799      ) ; 
98100
99101      if  ( response . ok )  { 
100-         // eslint-disable-next-line no-alert 
101-         alert ( 'Task deleted successfully!' ) ; 
102+         addNotification ( { 
103+           type : 'success' , 
104+           message : 'Task deleted successfully!' , 
105+         } ) ; 
102106        // Refresh the data to remove the deleted task 
103107        await  tasksMutate ( ) ; 
104108      }  else  { 
105-         // eslint-disable-next-line no-alert 
106-         alert ( 'Failed to delete task. Please try again.' ) ; 
109+         addNotification ( { 
110+           type : 'danger' , 
111+           message : 'Failed to delete task. Please try again.' , 
112+         } ) ; 
107113      } 
108114    }  catch  ( error )  { 
109-       // eslint-disable-next-line no-console 
110115      console . error ( 'Error deleting task:' ,  error ) ; 
111-       // eslint-disable-next-line no-alert 
112-       alert ( 'Failed to delete task. Please try again.' ) ; 
116+       addNotification ( { 
117+         type : 'danger' , 
118+         message : 'Failed to delete task. Please try again.' , 
119+       } ) ; 
113120    } 
114121  } ; 
115122
@@ -130,26 +137,30 @@ export default function Tasks() {
130137      ) ; 
131138
132139      if  ( response . ok )  { 
133-         // eslint-disable-next-line no-alert 
134-         alert ( 'Job deleted successfully!' ) ; 
140+         addNotification ( { 
141+           type : 'success' , 
142+           message : 'Job deleted successfully!' , 
143+         } ) ; 
135144        // Refresh the data to remove the deleted job 
136145        await  jobsMutate ( ) ; 
137146      }  else  { 
138-         // eslint-disable-next-line no-alert 
139-         alert ( 'Failed to delete job. Please try again.' ) ; 
147+         addNotification ( { 
148+           type : 'danger' , 
149+           message : 'Failed to delete job. Please try again.' , 
150+         } ) ; 
140151      } 
141152    }  catch  ( error )  { 
142-       // eslint-disable-next-line no-console 
143153      console . error ( 'Error deleting job:' ,  error ) ; 
144-       // eslint-disable-next-line no-alert 
145-       alert ( 'Failed to delete job. Please try again.' ) ; 
154+       addNotification ( { 
155+         type : 'danger' , 
156+         message : 'Failed to delete job. Please try again.' , 
157+       } ) ; 
146158    } 
147159  } ; 
148160
149161  const  handleSubmit  =  async  ( data : any )  =>  { 
150162    if  ( ! experimentInfo ?. id )  { 
151-       // eslint-disable-next-line no-alert 
152-       alert ( 'No experiment selected' ) ; 
163+       addNotification ( {  type : 'warning' ,  message : 'No experiment selected'  } ) ; 
153164      return ; 
154165    } 
155166
@@ -191,18 +202,23 @@ export default function Tasks() {
191202      if  ( response . ok )  { 
192203        setModalOpen ( false ) ; 
193204        await  tasksMutate ( ) ; 
194-         // eslint-disable-next-line no-alert 
195-         alert ( 'Task created. Use Queue to launch remotely.' ) ; 
205+         addNotification ( { 
206+           type : 'success' , 
207+           message : 'Task created. Use Queue to launch remotely.' , 
208+         } ) ; 
196209      }  else  { 
197210        const  txt  =  await  response . text ( ) ; 
198-         // eslint-disable-next-line no-alert 
199-         alert ( `Failed to create task: ${ txt }  ) ; 
211+         addNotification ( { 
212+           type : 'danger' , 
213+           message : `Failed to create task: ${ txt }  , 
214+         } ) ; 
200215      } 
201216    }  catch  ( error )  { 
202-       // eslint-disable-next-line no-console 
203217      console . error ( 'Error creating task:' ,  error ) ; 
204-       // eslint-disable-next-line no-alert 
205-       alert ( 'Failed to create task. Please try again.' ) ; 
218+       addNotification ( { 
219+         type : 'danger' , 
220+         message : 'Failed to create task. Please try again.' , 
221+       } ) ; 
206222    }  finally  { 
207223      setIsSubmitting ( false ) ; 
208224    } 
@@ -229,26 +245,32 @@ export default function Tasks() {
229245        formData . append ( 'accelerators' ,  String ( cfg . accelerators ) ) ; 
230246      if  ( cfg . num_nodes )  formData . append ( 'num_nodes' ,  String ( cfg . num_nodes ) ) ; 
231247      if  ( cfg . setup )  formData . append ( 'setup' ,  String ( cfg . setup ) ) ; 
232-       if  ( cfg . uploaded_dir_path )  formData . append ( 'uploaded_dir_path' ,  String ( cfg . uploaded_dir_path ) ) ; 
248+       if  ( cfg . uploaded_dir_path ) 
249+         formData . append ( 'uploaded_dir_path' ,  String ( cfg . uploaded_dir_path ) ) ; 
233250
234251      const  resp  =  await  chatAPI . authenticatedFetch ( 
235252        chatAPI . Endpoints . Jobs . LaunchRemote ( experimentInfo . id ) , 
236253        {  method : 'POST' ,  body : formData  } , 
237254      ) ; 
238255      const  result  =  await  resp . json ( ) ; 
239256      if  ( result . status  ===  'success' )  { 
240-         // eslint-disable-next-line no-alert 
241-         alert ( 'Task queued for remote launch.' ) ; 
257+         addNotification ( { 
258+           type : 'success' , 
259+           message : 'Task queued for remote launch.' , 
260+         } ) ; 
242261        await  Promise . all ( [ jobsMutate ( ) ,  tasksMutate ( ) ] ) ; 
243262      }  else  { 
244-         // eslint-disable-next-line no-alert 
245-         alert ( `Remote launch failed: ${ result . message }  ) ; 
263+         addNotification ( { 
264+           type : 'danger' , 
265+           message : `Remote launch failed: ${ result . message }  , 
266+         } ) ; 
246267      } 
247268    }  catch  ( e )  { 
248-       // eslint-disable-next-line no-console 
249269      console . error ( e ) ; 
250-       // eslint-disable-next-line no-alert 
251-       alert ( 'Failed to queue remote task.' ) ; 
270+       addNotification ( { 
271+         type : 'danger' , 
272+         message : 'Failed to queue remote task.' , 
273+       } ) ; 
252274    } 
253275  } ; 
254276
0 commit comments