{-# LANGUAGE MultiWayIf #-}
-- |

module Test.Sandwich.Formatters.TerminalUI.Draw.TopBox (
  topBox
  ) where

import Brick
import qualified Brick.Widgets.List as L
import Control.Monad.Logger
import qualified Data.List as L
import Data.Maybe
import Lens.Micro
import Test.Sandwich.Formatters.TerminalUI.AttrMap
import Test.Sandwich.Formatters.TerminalUI.Keys
import Test.Sandwich.Formatters.TerminalUI.Types
import Test.Sandwich.RunTree
import Test.Sandwich.Types.RunTree
import Test.Sandwich.Types.Spec


topBox :: AppState -> Widget n
topBox AppState
app = forall n. [Widget n] -> Widget n
hBox [forall {n}. Widget n -> Widget n
columnPadding forall {n}. Widget n
settingsColumn
                  , forall {n}. Widget n -> Widget n
columnPadding forall {n}. Widget n
actionsColumn
                  , forall {n}. Widget n -> Widget n
columnPadding forall {n}. Widget n
otherActionsColumn]
  where
    settingsColumn :: Widget n
settingsColumn = forall n. [Widget n] -> Widget n
keybindingBox [forall {n}. String -> String -> Widget n
keyIndicator (forall a. a -> [a] -> [a]
L.intersperse Char
'/' [Key -> Char
unKChar Key
nextKey, Key -> Char
unKChar Key
previousKey, Char
'↑', Char
'↓']) String
"Navigate"
                                   , forall {n}. AppState -> String -> String -> Widget n
keyIndicatorHasSelected AppState
app ([Key] -> String
showKeys [Key]
toggleKeys) String
"Open/close node"
                                   , forall {n}. AppState -> String -> String -> Widget n
keyIndicatorHasSelectedOpen AppState
app String
"Control-v/Meta-v" String
"Scroll node"
                                   , forall {n}. AppState -> String -> String -> Widget n
keyIndicatorHasSelected AppState
app (Key -> Char
unKChar Key
closeNodeKey forall a. a -> [a] -> [a]
: Char
'/' forall a. a -> [a] -> [a]
: [Key -> Char
unKChar Key
openNodeKey]) String
"Fold/unfold node"
                                   , forall {n}. String -> String -> Widget n
keyIndicator String
"Meta + [0-9]" String
"Unfold top # nodes"
                                   , forall {n}. String -> String -> Widget n
keyIndicator (Key -> Char
unKChar Key
nextFailureKey forall a. a -> [a] -> [a]
: Char
'/' forall a. a -> [a] -> [a]
: [Key -> Char
unKChar Key
previousFailureKey]) String
"Next/previous failure"
                                   ]

    actionsColumn :: Widget n
actionsColumn = forall n. [Widget n] -> Widget n
keybindingBox [forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
selectedTestRunning AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
cancelSelectedKey)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
someTestRunning AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
cancelAllKey)
                                         , forall n. String -> Widget n
str String
"] "
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Cancel "
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
selectedTestRunning AppState
app (forall n. String -> Widget n
str String
"selected")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
someTestRunning AppState
app (forall n. String -> Widget n
str String
"all")
                                         ]
                                  , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
selectedTestDone AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
runSelectedKey)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
noTestsRunning AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
runAllKey)
                                         , forall n. String -> Widget n
str String
"] "
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Run "
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
selectedTestDone AppState
app (forall n. String -> Widget n
str String
"selected")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
noTestsRunning AppState
app (forall n. String -> Widget n
str String
"all")
                                         ]
                                  , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
selectedTestDone AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
clearSelectedKey)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
allTestsDone AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
clearAllKey)
                                         , forall n. String -> Widget n
str String
"] "
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Clear "
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
selectedTestDone AppState
app (forall n. String -> Widget n
str String
"selected")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
allTestsDone AppState
app (forall n. String -> Widget n
str String
"all")
                                         ]
                                  , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
openSelectedFolderInFileExplorer)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate (forall a b. a -> b -> a
const Bool
True) AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
openTestRootKey)
                                         , forall n. String -> Widget n
str String
"] "
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Open "
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str String
"selected")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate (forall a b. a -> b -> a
const Bool
True) AppState
app (forall n. String -> Widget n
str String
"root")
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
" folder"
                                         ]
                                  , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
openTestInEditorKey)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
openLogsInEditorKey)
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
openFailureInEditorKey)
                                         , forall n. String -> Widget n
str String
"] "
                                         , forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Edit "
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str String
"test")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
someTestSelected AppState
app (forall n. String -> Widget n
str String
"logs")
                                         , forall n. String -> Widget n
str String
"/"
                                         , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate AppState -> Bool
selectedTestHasCallStack AppState
app (forall n. String -> Widget n
str String
"failure")
                                         ]
                                  ]

    otherActionsColumn :: Widget n
otherActionsColumn = forall n. [Widget n] -> Widget n
keybindingBox [forall {n}. String -> Widget n -> Widget n
keyIndicator' (Key -> String
showKey Key
cycleVisibilityThresholdKey) (forall {n}. AppState -> Widget n
visibilityThresholdWidget AppState
app)
                                       , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                              , forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
toggleShowRunTimesKey
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
toggleFileLocationsKey
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ Key -> String
showKey Key
toggleVisibilityThresholdsKey
                                              , forall n. String -> Widget n
str String
"] "
                                              , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate (forall s a. s -> Getting a s a -> a
^. Lens' AppState Bool
appShowRunTimes) AppState
app (forall n. String -> Widget n
str String
"Times")
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate (forall s a. s -> Getting a s a -> a
^. Lens' AppState Bool
appShowFileLocations) AppState
app (forall n. String -> Widget n
str String
"locations")
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall {t} {n}. (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate (forall s a. s -> Getting a s a -> a
^. Lens' AppState Bool
appShowVisibilityThresholds) AppState
app (forall n. String -> Widget n
str String
"thresholds")
                                         ]
                                       , forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"["
                                              , forall {n}. AppState -> LogLevel -> String -> Widget n
highlightIfLogLevel AppState
app LogLevel
LevelDebug [Key -> Char
unKChar Key
debugKey]
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall {n}. AppState -> LogLevel -> String -> Widget n
highlightIfLogLevel AppState
app LogLevel
LevelInfo [Key -> Char
unKChar Key
infoKey]
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall {n}. AppState -> LogLevel -> String -> Widget n
highlightIfLogLevel AppState
app LogLevel
LevelWarn [Key -> Char
unKChar Key
warnKey]
                                              , forall n. String -> Widget n
str String
"/"
                                              , forall {n}. AppState -> LogLevel -> String -> Widget n
highlightIfLogLevel AppState
app LogLevel
LevelError [Key -> Char
unKChar Key
errorKey]
                                              , forall n. String -> Widget n
str String
"] "
                                              , forall n. String -> Widget n
str String
"Log level"]

                                       , forall {n}. String -> String -> Widget n
keyIndicator String
"q" String
"Exit"]

visibilityThresholdWidget :: AppState -> Widget n
visibilityThresholdWidget AppState
app = forall n. [Widget n] -> Widget n
hBox forall a b. (a -> b) -> a -> b
$
  [forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
"Visibility threshold ("]
  forall a. Semigroup a => a -> a -> a
<> forall a. a -> [a] -> [a]
L.intersperse (forall n. String -> Widget n
str String
", ") [forall n. AttrName -> Widget n -> Widget n
withAttr (if Int
x forall a. Eq a => a -> a -> Bool
== AppState
app forall s a. s -> Getting a s a -> a
^. Lens' AppState Int
appVisibilityThreshold then AttrName
visibilityThresholdSelectedAttr else AttrName
visibilityThresholdNotSelectedAttr) forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
x | Int
x <- (AppState
app forall s a. s -> Getting a s a -> a
^. Lens' AppState [Int]
appVisibilityThresholdSteps)]
  forall a. Semigroup a => a -> a -> a
<> [(forall n. String -> Widget n
str String
")")]

columnPadding :: Widget n -> Widget n
columnPadding = forall n. Padding -> Widget n -> Widget n
padLeft (Int -> Padding
Pad Int
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. Padding -> Widget n -> Widget n
padRight (Int -> Padding
Pad Int
3) -- . padTop (Pad 1)

keybindingBox :: [Widget n] -> Widget n
keybindingBox = forall n. [Widget n] -> Widget n
vBox

highlightIfLogLevel :: AppState -> LogLevel -> String -> Widget n
highlightIfLogLevel AppState
app LogLevel
desiredLevel String
thing =
  if | AppState
app forall s a. s -> Getting a s a -> a
^. Lens' AppState (Maybe LogLevel)
appLogLevel forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just LogLevel
desiredLevel -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
visibilityThresholdSelectedAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
thing
     | Bool
otherwise -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
thing

highlightKeyIfPredicate :: (t -> Bool) -> t -> Widget n -> Widget n
highlightKeyIfPredicate t -> Bool
p t
app Widget n
x = case t -> Bool
p t
app of
  Bool
True -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyAttr Widget n
x
  Bool
False -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
disabledHotkeyAttr Widget n
x

highlightMessageIfPredicate :: (t -> Bool) -> t -> Widget n -> Widget n
highlightMessageIfPredicate t -> Bool
p t
app Widget n
x = case t -> Bool
p t
app of
  Bool
True -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr Widget n
x
  Bool
False -> forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
disabledHotkeyMessageAttr Widget n
x

keyIndicator :: String -> String -> Widget n
keyIndicator String
key String
msg = forall {n}. String -> Widget n -> Widget n
keyIndicator' String
key (forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
msg)

keyIndicator' :: String -> Widget n -> Widget n
keyIndicator' String
key Widget n
label = forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"[", forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
key, forall n. String -> Widget n
str String
"] ", Widget n
label]

keyIndicatorHasSelected :: AppState -> String -> String -> Widget n
keyIndicatorHasSelected AppState
app = forall {t} {n}. t -> (t -> Bool) -> String -> String -> Widget n
keyIndicatorContextual AppState
app AppState -> Bool
someTestSelected

keyIndicatorHasSelectedOpen :: AppState -> String -> String -> Widget n
keyIndicatorHasSelectedOpen AppState
app = forall {t} {n}. t -> (t -> Bool) -> String -> String -> Widget n
keyIndicatorContextual AppState
app AppState -> Bool
selectedTestToggled

keyIndicatorContextual :: t -> (t -> Bool) -> String -> String -> Widget n
keyIndicatorContextual t
app t -> Bool
p String
key String
msg = case t -> Bool
p t
app of
  Bool
True -> forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"[", forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
key, forall n. String -> Widget n
str String
"] ", forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
hotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
msg]
  Bool
False -> forall n. [Widget n] -> Widget n
hBox [forall n. String -> Widget n
str String
"[", forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
disabledHotkeyAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
key, forall n. String -> Widget n
str String
"] ", forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
disabledHotkeyMessageAttr forall a b. (a -> b) -> a -> b
$ forall n. String -> Widget n
str String
msg]


-- * Predicates

selectedTestRunning :: AppState -> Bool
selectedTestRunning AppState
s = case forall (t :: * -> *) e n.
(Splittable t, Traversable t, Semigroup (t e)) =>
GenericList n t e -> Maybe (Int, e)
L.listSelectedElement (AppState
s forall s a. s -> Getting a s a -> a
^. Lens' AppState (GenericList ClickableName Vector MainListElem)
appMainList) of
  Maybe (Int, MainListElem)
Nothing -> Bool
False
  Just (Int
_, MainListElem {Bool
Int
String
Maybe String
Seq LogEntry
RunNodeCommon
Status
ident :: MainListElem -> Int
node :: MainListElem -> RunNodeCommon
folderPath :: MainListElem -> Maybe String
visibilityLevel :: MainListElem -> Int
logs :: MainListElem -> Seq LogEntry
status :: MainListElem -> Status
open :: MainListElem -> Bool
toggled :: MainListElem -> Bool
depth :: MainListElem -> Int
label :: MainListElem -> String
ident :: Int
node :: RunNodeCommon
folderPath :: Maybe String
visibilityLevel :: Int
logs :: Seq LogEntry
status :: Status
open :: Bool
toggled :: Bool
depth :: Int
label :: String
..}) -> Status -> Bool
isRunning Status
status

selectedTestDone :: AppState -> Bool
selectedTestDone AppState
s = case forall (t :: * -> *) e n.
(Splittable t, Traversable t, Semigroup (t e)) =>
GenericList n t e -> Maybe (Int, e)
L.listSelectedElement (AppState
s forall s a. s -> Getting a s a -> a
^. Lens' AppState (GenericList ClickableName Vector MainListElem)
appMainList) of
  Maybe (Int, MainListElem)
Nothing -> Bool
False
  Just (Int
_, MainListElem {Bool
Int
String
Maybe String
Seq LogEntry
RunNodeCommon
Status
ident :: Int
node :: RunNodeCommon
folderPath :: Maybe String
visibilityLevel :: Int
logs :: Seq LogEntry
status :: Status
open :: Bool
toggled :: Bool
depth :: Int
label :: String
ident :: MainListElem -> Int
node :: MainListElem -> RunNodeCommon
folderPath :: MainListElem -> Maybe String
visibilityLevel :: MainListElem -> Int
logs :: MainListElem -> Seq LogEntry
status :: MainListElem -> Status
open :: MainListElem -> Bool
toggled :: MainListElem -> Bool
depth :: MainListElem -> Int
label :: MainListElem -> String
..}) -> Status -> Bool
isDone Status
status

selectedTestHasCallStack :: AppState -> Bool
selectedTestHasCallStack AppState
s = case forall (t :: * -> *) e n.
(Splittable t, Traversable t, Semigroup (t e)) =>
GenericList n t e -> Maybe (Int, e)
L.listSelectedElement (AppState
s forall s a. s -> Getting a s a -> a
^. Lens' AppState (GenericList ClickableName Vector MainListElem)
appMainList) of
  Maybe (Int, MainListElem)
Nothing -> Bool
False
  Just (Int
_, MainListElem {Bool
Int
String
Maybe String
Seq LogEntry
RunNodeCommon
Status
ident :: Int
node :: RunNodeCommon
folderPath :: Maybe String
visibilityLevel :: Int
logs :: Seq LogEntry
status :: Status
open :: Bool
toggled :: Bool
depth :: Int
label :: String
ident :: MainListElem -> Int
node :: MainListElem -> RunNodeCommon
folderPath :: MainListElem -> Maybe String
visibilityLevel :: MainListElem -> Int
logs :: MainListElem -> Seq LogEntry
status :: MainListElem -> Status
open :: MainListElem -> Bool
toggled :: MainListElem -> Bool
depth :: MainListElem -> Int
label :: MainListElem -> String
..}) -> case Status
status of
    (Done UTCTime
_ UTCTime
_ (Failure FailureReason
failureReason)) -> forall a. Maybe a -> Bool
isJust forall a b. (a -> b) -> a -> b
$ FailureReason -> Maybe CallStack
failureCallStack FailureReason
failureReason
    Status
_ -> Bool
False

selectedTestToggled :: AppState -> Bool
selectedTestToggled AppState
s = case forall (t :: * -> *) e n.
(Splittable t, Traversable t, Semigroup (t e)) =>
GenericList n t e -> Maybe (Int, e)
L.listSelectedElement (AppState
s forall s a. s -> Getting a s a -> a
^. Lens' AppState (GenericList ClickableName Vector MainListElem)
appMainList) of
  Maybe (Int, MainListElem)
Nothing -> Bool
False
  Just (Int
_, MainListElem {Bool
Int
String
Maybe String
Seq LogEntry
RunNodeCommon
Status
ident :: Int
node :: RunNodeCommon
folderPath :: Maybe String
visibilityLevel :: Int
logs :: Seq LogEntry
status :: Status
open :: Bool
toggled :: Bool
depth :: Int
label :: String
ident :: MainListElem -> Int
node :: MainListElem -> RunNodeCommon
folderPath :: MainListElem -> Maybe String
visibilityLevel :: MainListElem -> Int
logs :: MainListElem -> Seq LogEntry
status :: MainListElem -> Status
open :: MainListElem -> Bool
toggled :: MainListElem -> Bool
depth :: MainListElem -> Int
label :: MainListElem -> String
..}) -> Bool
toggled

noTestsRunning :: AppState -> Bool
noTestsRunning AppState
s = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Status -> Bool
isRunning forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon) (AppState
s forall s a. s -> Getting a s a -> a
^. Lens'
  AppState [RunNodeWithStatus BaseContext Status (Seq LogEntry) Bool]
appRunTree)

someTestRunning :: AppState -> Bool
someTestRunning AppState
s = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Status -> Bool
isRunning forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon) (AppState
s forall s a. s -> Getting a s a -> a
^. Lens'
  AppState [RunNodeWithStatus BaseContext Status (Seq LogEntry) Bool]
appRunTree)

allTestsDone :: AppState -> Bool
allTestsDone AppState
s = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Status -> Bool
isDone forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon) (AppState
s forall s a. s -> Getting a s a -> a
^. Lens'
  AppState [RunNodeWithStatus BaseContext Status (Seq LogEntry) Bool]
appRunTree)

someTestSelected :: AppState -> Bool
someTestSelected AppState
s = forall a. Maybe a -> Bool
isJust forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) e n.
(Splittable t, Traversable t, Semigroup (t e)) =>
GenericList n t e -> Maybe (Int, e)
L.listSelectedElement (AppState
s forall s a. s -> Getting a s a -> a
^. Lens' AppState (GenericList ClickableName Vector MainListElem)
appMainList)