@@ -271,6 +271,11 @@ interface ProgressEvent {
271271 total : number ;
272272}
273273
274+ interface ConfirmationPrompt {
275+ message : string ;
276+ resolve : ( confirmed : boolean ) => void ;
277+ }
278+
274279function App ( ) {
275280 const [ tab , setTab ] = useState < Tab > ( "analysis" ) ;
276281 const [ config , setConfig ] = useState < AnalysisConfig > ( DEFAULT_CONFIG ) ;
@@ -288,6 +293,7 @@ function App() {
288293 const [ appVersion , setAppVersion ] = useState ( "v1.1.3" ) ;
289294 const [ batchProgress , setBatchProgress ] = useState < { current : number ; total : number } | null > ( null ) ;
290295 const [ runProgress , setRunProgress ] = useState < ProgressEvent | null > ( null ) ;
296+ const [ confirmationPrompt , setConfirmationPrompt ] = useState < ConfirmationPrompt | null > ( null ) ;
291297
292298 const configRef = useRef ( config ) ;
293299 useEffect ( ( ) => { configRef . current = config ; } , [ config ] ) ;
@@ -611,6 +617,19 @@ function App() {
611617 }
612618 } , [ ] ) ;
613619
620+ const askForConfirmation = useCallback ( ( message : string ) => {
621+ return new Promise < boolean > ( ( resolve ) => {
622+ setConfirmationPrompt ( { message, resolve } ) ;
623+ } ) ;
624+ } , [ ] ) ;
625+
626+ const resolveConfirmation = useCallback ( ( confirmed : boolean ) => {
627+ setConfirmationPrompt ( ( prompt ) => {
628+ prompt ?. resolve ( confirmed ) ;
629+ return null ;
630+ } ) ;
631+ } , [ ] ) ;
632+
614633 const confirmOutputWrites = useCallback ( async ( toRun : SampleEntry [ ] ) => {
615634 if ( toRun . length === 0 ) return true ;
616635
@@ -655,11 +674,11 @@ function App() {
655674 ) ;
656675 }
657676
658- return window . confirm ( `${ sections . join ( "\n\n" ) } \n\nContinue?` ) ;
677+ return askForConfirmation ( `${ sections . join ( "\n\n" ) } \n\nContinue?` ) ;
659678 } catch {
660679 return true ;
661680 }
662- } , [ ] ) ;
681+ } , [ askForConfirmation ] ) ;
663682
664683 const handleRunAll = useCallback ( ( ) => {
665684 const toRun = samples . filter ( ( s ) => s . status === "pending" || s . status === "error" ) ;
@@ -1181,6 +1200,36 @@ function App() {
11811200 ) }
11821201 </ main >
11831202
1203+ { confirmationPrompt && (
1204+ < div className = "confirm-dialog-backdrop" role = "presentation" >
1205+ < div
1206+ className = "confirm-dialog"
1207+ role = "dialog"
1208+ aria-modal = "true"
1209+ aria-labelledby = "confirm-dialog-title"
1210+ >
1211+ < h3 id = "confirm-dialog-title" > Confirm output overwrite</ h3 >
1212+ < p className = "confirm-dialog-text" > { confirmationPrompt . message } </ p >
1213+ < div className = "confirm-dialog-actions" >
1214+ < button
1215+ type = "button"
1216+ className = "confirm-dialog-btn confirm-dialog-btn--secondary"
1217+ onClick = { ( ) => resolveConfirmation ( false ) }
1218+ >
1219+ Cancel
1220+ </ button >
1221+ < button
1222+ type = "button"
1223+ className = "confirm-dialog-btn confirm-dialog-btn--primary"
1224+ onClick = { ( ) => resolveConfirmation ( true ) }
1225+ >
1226+ Continue
1227+ </ button >
1228+ </ div >
1229+ </ div >
1230+ </ div >
1231+ ) }
1232+
11841233 { /* Global drop overlay */ }
11851234 { dragActive && (
11861235 < div className = "drop-overlay" >
0 commit comments