@@ -14,6 +14,7 @@ import qualified GHCup.Brick.App.ContextMenu as ContextMenu
1414import  GHCup.Brick.Widgets.BaseWidget 
1515import  GHCup.Brick.Widgets.BasicOverlay 
1616import  qualified  GHCup.Brick.Attributes  as  Attributes 
17+ import  qualified  GHCup.Brick.Widgets.ConfirmationPrompt  as  ConfirmationPrompt 
1718import  qualified  GHCup.Brick.Widgets.SectionList  as  SectionList 
1819
1920import  GHCup.List  ( ListResult (.. ) )
@@ -47,7 +48,7 @@ import Control.Monad.Reader
4748import  Data.Some 
4849import  Data.Vector  ( Vector  )
4950import  qualified  Graphics.Vty  as  Vty 
50- import  Optics  (Lens' , use , to , (^.) , (%) , (&) , (%~) , (.~) )
51+ import  Optics  (Lens' , lens ,  use , to , (^.) , (%) , (&) , (%~) , (.~) )
5152import  Optics.TH  (makeLenses )
5253import  Optics.State.Operators  ((.=) , (?=) , (%=) )
5354
@@ -255,7 +256,7 @@ keyHandlers :: KeyBindings
255256               ]
256257keyHandlers KeyBindings  {.. } = 
257258  [ (bQuit, const  " Quit" Brick. halt)
258-   , (bInstall, const  " Install" withIOAction' install' )
259+   , (bInstall, const  " Install" installAfterPreInstallPrompt )
259260  , (bUninstall, const  " Uninstall" 
260261  , (bSet, const  " Set" 
261262  , (bChangelog, const  " ChangeLog" 
@@ -278,6 +279,22 @@ keyHandlers KeyBindings {..} =
278279        suspendBrickAndRunAction _appState $  action (curr_ix, e)
279280    updateNavigation
280281
282+   installAfterPreInstallPrompt =  do 
283+     Navigation  {.. } <-  Brick. get
284+     case  SectionList. sectionListSelectedElement _sectionList of 
285+       Nothing       ->  pure  () 
286+       Just  (curr_ix, lr) ->  do 
287+         let  action =  (Just  CloseAllOverlays ) <$  suspendBrickAndRunAction _appState (install' (curr_ix, lr))
288+             v =  GHCTargetVersion  (lCross lr) (lVer lr)
289+         case  getPreInstallMessage _appState v (lTool lr) of 
290+           Nothing  ->  do 
291+             action
292+             updateNavigation
293+           Just  msg ->  do 
294+             let  prompt =  ConfirmationPrompt. create " Warning" 
295+             --  updateNavigation will happen after the prompt is closed
296+             overlay ?=  Some  (IsSubWidget  $  lens (const  prompt) (\ s _ ->  s))
297+ 
281298  openContextMenuforTool =  do 
282299    e <-  use (sectionList %  to SectionList. sectionListSelectedElement)
283300    case  e of 
0 commit comments