@@ -8,7 +8,6 @@ module Page.Popup.NewDeployment (newDeploymentPopup) where
8import Control.Lens
8import Control.Lens
9import Control.Monad
9import Control.Monad
10import Data.Functor
10import Data.Functor
11−import Data.Generics.Sum
12import Data.Monoid
11import Data.Monoid
13import qualified Data.Text as T
12import qualified Data.Text as T
14import Reflex.Dom as R
13import Reflex.Dom as R
@@ -30,31 +29,35 @@ newDeploymentPopup ::
30 Event t () ->
29 Event t () ->
31 -- | \"Close\" event.
30 -- | \"Close\" event.
32 Event t () ->
31 Event t () ->
33− m ()
32+ m (Event t Deployment)
34−newDeploymentPopup showEv hideEv = void $
33+newDeploymentPopup showEv hideEv =
34+ catchReturns $ \enterEv ->
35− sidebar showEv hideEv $
35+ sidebar showEv hideEv $
36− const $ mdo
36+ const $ mdo
37− divClass "popup__body" $ mdo
37+ divClass "popup__body" $ mdo
38− (closeEv', saveEv) <- newDeploymentPopupHeader enabledDyn sentDyn
38+ (closeEv', (enterEv <>) -> saveEv) <- newDeploymentPopupHeader enabledDyn sentDyn
39− deploymentMDyn <- newDeploymentPopupBody respEv
39+ deploymentMDyn <- newDeploymentPopupBody (snd <$> respEv)
40− respEv <-
40+ respEv <-
41− holdDyn (pure never) >=> networkView >=> switchHold never $
41+ holdDyn (pure never) >=> networkView >=> switchHold never $
42− tagMaybe (current deploymentMDyn) saveEv <&> \dep -> do
42+ tagMaybe (current deploymentMDyn) saveEv <&> \dep -> do
43− pb <- getPostBuild
43+ pb <- getPostBuild
44− createEndpoint
45+ <$> createEndpoint
45− (pure $ Right dep)
46+ (pure $ Right dep)
47− sentDyn <-
48+ sentDyn <-
48− holdDyn False $
49+ holdDyn False $
50− [ True <$ saveEv
51+ [ True <$ saveEv
51− , False <$ respEv
52+ , False <$ respEv
53− let successEv =
54+ let successEv =
54− fmapMaybe (preview (_Ctor @"Success") <=< commandResponse) respEv
55+ respEv `fforMaybe` \case
56+ (dep, commandResponse -> Just Success {}) -> Just dep
55− closeEv = leftmost [closeEv', successEv]
58+ closeEv = leftmost [closeEv', successEv $> ()]
56− enabledDyn = zipDynWith (&&) (not <$> sentDyn) (isJust <$> deploymentMDyn)
59+ enabledDyn = zipDynWith (&&) (not <$> sentDyn) (isJust <$> deploymentMDyn)
57− pure (never, closeEv)
60+ pure (successEv, closeEv)
59-- | The header of sidebar contains control buttons: \"Save\" and \"Close\".
62-- | The header of sidebar contains control buttons: \"Save\" and \"Close\".
60newDeploymentPopupHeader ::
63newDeploymentPopupHeader ::