@@ -7,7 +7,7 @@ import Data.Coerce
77import Data.Generics.Product (field)
88import Data.List as L (null)
99import Data.Map as M (Map, fromList, partition, toList, filter)
10−import Data.Text as T (Text, toCaseFold, isPrefixOf)
10+import Data.Text as T (Text, toCaseFold, isPrefixOf, pack)
1111import Obelisk.Route.Frontend
1212import Reflex.Dom
1313import Servant.Reflex
@@ -183,12 +183,8 @@ activeDeploymentWidget clickedEv dname dDyn' = do
183183 <> "target" =: "_blank") $ text url
184184 el "td" $
185185 text $ coerce $ deployment ^. field @"tag"
186− el "td" $ do
187− divClass "listing" $
188− forM_ (deployment ^. field @"envs") $ \(var, val) ->
189− divClass "listing__item bar" $ do
190− el "b" $ text $ var <> ": "
191− text val
186+ el "td" $
187+ overridesWidget $ deployment ^. field @"envs"
192188 el "td" $
193189 text $ formatPosixToDate createdAt
194190 el "td" $
@@ -268,12 +264,8 @@ archivedDeploymentWidget clickedEv dDyn' = do
268264 el "td" $ text "..."
269265 el "td" $
270266 text $ coerce $ deployment ^. field @"tag"
271− el "td" $ do
272− divClass "listing" $
273− forM_ (deployment ^. field @"envs") $ \(var, val) ->
274− divClass "listing__item bar" $ do
275− el "b" $ text $ var <> ": "
276− text val
267+ el "td" $
268+ overridesWidget $ deployment ^. field @"envs"
277269 el "td" $
278270 text $ formatPosixToDate createdAt
279271 el "td" $
@@ -292,6 +284,38 @@ archivedDeploymentWidget clickedEv dDyn' = do
292284 pure never
293285 dropdownWidget' clickedEv btn body
294286
287+overridesWidget :: MonadWidget t m => EnvPairs -> m ()
288+overridesWidget envs = divClass "listing" $ do
289+ let
290+ visible = take 3 envs
291+ envLength = length envs
292+ listing visible
293+ when (envLength > 3) $ mdo
294+ let hidden = drop 3 envs
295+ showDyn <- toggle False toggleEv
296+ dyn_ $ showDyn <&> \case
297+ True -> listing hidden
298+ False -> blank
299+ let
300+ btnClassDyn = ifThenElseDyn showDyn
301+ "listing__item expander bar expander--open"
302+ "listing__item expander bar"
303+ btnTextDyn = ifThenElseDyn showDyn "Hide"
304+ $ "Show all (" <> (pack . show $ envLength) <> ")"
305+ toggleEv <- buttonDynClass btnClassDyn btnTextDyn
306+ blank
307+ where
308+ listing envs' = do
309+ forM_ envs' $ \(var, val) ->
310+ divClass "listing__item bar" $ do
311+ el "b" $ text $ var <> ": "
312+ text val
313+
314+ifThenElseDyn :: Reflex t => Dynamic t Bool -> b -> b -> Dynamic t b
315+ifThenElseDyn bDyn t f = bDyn <&> \case
316+ True -> t
317+ False -> f
318+
295319tableWrapper :: MonadWidget t m => m a -> m a
296320tableWrapper ma =
297321 divClass "table table--stagings table--clickable" $