Skip to content

Commit

Permalink
fix: cleaning up code, making linksView more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Claire.Nicholas authored and Claire.Nicholas committed Jan 11, 2024
1 parent 4129187 commit 0c8b0b2
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/elm/Pages/Deployments/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ redeployLink org repo deployment =
[ text "Redeploy"
]


{-| pullBuildLinks : takes deployment and creates a list of links to every build in the builds field
-}
pullBuildLinks : Deployment -> List String
Expand All @@ -285,26 +284,23 @@ pullBuildLinks deployment =
[]

Just builds ->
List.map (String.dropRight 1) (List.map (String.dropLeft 1) (List.map Debug.toString (List.map .link builds)))
(List.map .link builds)


{-| linksView : takes list of links and creates an HTML msg that displays as a list of links
-}
linksView : List String -> Html msg
linksView links =
links
|> List.map (\link -> a [ href link ] [ text (String.append "#" (getHead (List.head (List.reverse (String.split "/" link))))) ])
|> List.map (\link -> a
[ href link ]
[ text (link
|> String.split "/"
|> List.reverse
|> List.head
|> Maybe.withDefault ""
|> String.append "#" )
]
)
|> List.intersperse (text ", ")
|> div []


{-| getHead : takes Maybe String and returns either Nothing or the value to help with the linksView function
-}
getHead : Maybe String -> String
getHead link =
case link of
Nothing ->
""

Just val ->
val

0 comments on commit 0c8b0b2

Please sign in to comment.