github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/src/SideBar/Pipeline.elm (about)

     1  module SideBar.Pipeline exposing (pipeline)
     2  
     3  import Assets
     4  import Concourse
     5  import HoverState
     6  import Message.Message exposing (DomID(..), Message(..), PipelinesSection(..))
     7  import Routes
     8  import Set exposing (Set)
     9  import SideBar.Styles as Styles
    10  import SideBar.Views as Views
    11  
    12  
    13  type alias PipelineScoped a =
    14      { a
    15          | teamName : String
    16          , pipelineName : String
    17      }
    18  
    19  
    20  pipeline :
    21      { a
    22          | hovered : HoverState.HoverState
    23          , currentPipeline : Maybe (PipelineScoped b)
    24          , favoritedPipelines : Set Int
    25          , isFavoritesSection : Bool
    26      }
    27      -> Concourse.Pipeline
    28      -> Views.Pipeline
    29  pipeline params p =
    30      let
    31          isCurrent =
    32              case params.currentPipeline of
    33                  Just cp ->
    34                      cp.pipelineName == p.name && cp.teamName == p.teamName
    35  
    36                  Nothing ->
    37                      False
    38  
    39          pipelineId =
    40              { pipelineName = p.name, teamName = p.teamName }
    41  
    42          domID =
    43              SideBarPipeline
    44                  (if params.isFavoritesSection then
    45                      FavoritesSection
    46  
    47                   else
    48                      AllPipelinesSection
    49                  )
    50                  pipelineId
    51  
    52          isHovered =
    53              HoverState.isHovered domID params.hovered
    54  
    55          isFavorited =
    56              Set.member p.id params.favoritedPipelines
    57      in
    58      { icon =
    59          if p.archived then
    60              Assets.ArchivedPipelineIcon
    61  
    62          else if isHovered then
    63              Assets.PipelineIconWhite
    64  
    65          else if isCurrent then
    66              Assets.PipelineIconLightGrey
    67  
    68          else
    69              Assets.PipelineIconGrey
    70      , name =
    71          { pipelineColor =
    72              if isHovered then
    73                  Styles.White
    74  
    75              else if isCurrent then
    76                  Styles.LightGrey
    77  
    78              else
    79                  Styles.Grey
    80          , text = p.name
    81          , weight =
    82              if isCurrent || isHovered then
    83                  Styles.Bold
    84  
    85              else
    86                  Styles.Default
    87          }
    88      , background =
    89          if isCurrent then
    90              Styles.Dark
    91  
    92          else if isHovered then
    93              Styles.Light
    94  
    95          else
    96              Styles.Invisible
    97      , href =
    98          Routes.toString <|
    99              Routes.Pipeline { id = pipelineId, groups = [] }
   100      , domID = domID
   101      , starIcon =
   102          { filled = isFavorited
   103          , isBright = isHovered || isCurrent
   104          }
   105      , id = p.id
   106      }