Skip to content

Commit

Permalink
chore: general cleanup and consistency with comments etc
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Feb 5, 2024
1 parent 93da718 commit e82ec0b
Show file tree
Hide file tree
Showing 26 changed files with 188 additions and 114 deletions.
8 changes: 3 additions & 5 deletions src/elm/Api/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,11 @@ tryAll msg request_ =
|> Task.attempt msg


{-| tryString : way to request information from an endpoint with a string response
-- ENTRYPOINT

example usage:
Api.tryString UserResponse <| Api.getUser model authParams
{-| try : default way to request information from an endpoint
example usage:
Api.try UserResponse <| Api.getUser model authParams
-}
tryString : (Result (Http.Detailed.Error String) ( Http.Metadata, String ) -> msg) -> Request String -> Cmd msg
tryString msg request_ =
Expand Down
11 changes: 1 addition & 10 deletions src/elm/Components/Alerts.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module Components.Alerts exposing (Alert(..), errorConfig, successConfig, view, wrapAlertMessage)
module Components.Alerts exposing (Alert(..), errorConfig, successConfig, view)

import FeatherIcons
import Html exposing (Html, a, button, div, h1, p, text)
Expand Down Expand Up @@ -75,15 +75,6 @@ wrapAlert variantClass title message link copy =
]


wrapAlertMessage : String -> String
wrapAlertMessage message =
if not <| String.isEmpty message then
"`" ++ message ++ "` "

else
message


copyButton : String -> Maybe (String -> msg) -> Html msg
copyButton copyContent copy =
case copy of
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Components/Build.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module Components.Build exposing (..)
module Components.Build exposing (view, viewActionsMenu)

import Components.Svgs
import DateFormat.Relative
Expand Down
15 changes: 2 additions & 13 deletions src/elm/Components/Builds.elm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ viewHeader :
}
-> Html msg
viewHeader props =
div [ class "build-bar" ]
div [ class "builds-header" ]
[ viewFilter props.maybeEvent props.filterByEvent
, viewTimeToggle props.showFullTimestamps props.showHideFullTimestamps
]
Expand All @@ -164,17 +164,6 @@ viewFilter maybeEvent filterByEventMsg =

_ ->
Just event

eventEnum =
[ "all"
, "push"
, "pull_request"
, "tag"
, "deployment"
, "schedule"
, "comment"
, "delete"
]
in
div [ class "form-controls", class "build-filters", Util.testAttribute "build-filter" ] <|
div [] [ text "Filter by Event:" ]
Expand All @@ -198,7 +187,7 @@ viewFilter maybeEvent filterByEventMsg =
[ text <| String.replace "_" " " e ]
]
)
eventEnum
Vela.allowEventsFilterQueryKeys


viewTimeToggle : Bool -> msg -> Html msg
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Components/Crumbs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type alias Crumb =
-- VIEW


{-| crumbs : takes current page and returns Html breadcrumb that produce Msgs
{-| view : takes current path and returns Html breadcrumbs
-}
view : Route.Path.Path -> List Crumb -> Html msg
view path crumbs =
Expand Down
4 changes: 4 additions & 0 deletions src/elm/Components/Favorites.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import Utils.Helpers as Util
import Vela



-- VIEW


viewStarToggle :
{ msg : Vela.Org -> Maybe Vela.Repo -> msg
, user : WebData Vela.CurrentUser
Expand Down
2 changes: 0 additions & 2 deletions src/elm/Components/Form.elm
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ viewButton { msg, text_, classList_, disabled_ } =
[ text text_ ]


{-| viewAllowEvents : takes model and repo and renders the settings category for updating repo webhook events
-}
viewAllowEvents :
Shared.Model
->
Expand Down
8 changes: 8 additions & 0 deletions src/elm/Components/Header.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import Utils.Helpers as Util
import Utils.Theme as Theme



-- TYPES


type alias Props msg =
{ from : String
, theme : Theme.Theme
Expand All @@ -30,6 +34,10 @@ type alias Props msg =
}



-- VIEW


view : Shared.Model -> Props msg -> Html msg
view shared props =
let
Expand Down
9 changes: 8 additions & 1 deletion src/elm/Components/Help.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ SPDX-License-Identifier: Apache-2.0

module Components.Help exposing (Command, Props, view)

import Components.Build exposing (Props)
import Components.Svgs as SvgBuilder
import FeatherIcons
import Html exposing (Html, a, button, details, div, label, span, strong, summary, text)
Expand All @@ -15,6 +14,10 @@ import Shared
import Utils.Helpers as Util



-- TYPES


type alias Props msg =
{ show : Bool
, showHide : Maybe Bool -> msg
Expand All @@ -30,6 +33,10 @@ type alias Command =
}



-- VIEW


view : Shared.Model -> Props msg -> Html msg
view shared props =
details
Expand Down
12 changes: 8 additions & 4 deletions src/elm/Components/Logs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import Utils.Logs as Logs
import Vela



-- TYPES


type alias Msgs msg =
{ pushUrlHash : { hash : String } -> msg
, focusOn : { target : String } -> msg
Expand Down Expand Up @@ -45,6 +49,10 @@ type alias LogLine msg =
}



-- VIEW


view : Shared.Model -> Props msg -> Html msg
view shared props =
case props.log of
Expand All @@ -59,10 +67,6 @@ view shared props =
[ Util.smallLoaderWithText "loading..." ]



-- LOGS


{-| viewLogLines : takes number linefocus log and clickAction shiftDown and renders logs for a build resource
-}
viewLogLines : Props msg -> Vela.Log -> Html msg
Expand Down
8 changes: 8 additions & 0 deletions src/elm/Components/Nav.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ import Utils.Helpers as Util
import Vela



-- TYPES


type alias Props msg =
{ buttons : List (Html msg)
, crumbs : Html msg
}



-- VIEW


view : Shared.Model -> Route () -> Props msg -> Html msg
view shared route props =
nav [ class "navigation", attribute "aria-label" "Navigation" ]
Expand Down
10 changes: 8 additions & 2 deletions src/elm/Components/Pager.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import RemoteData exposing (WebData)
import Utils.Helpers as Util



-- TYPES


type alias Labels =
{ previousLabel : String
, nextLabel : String
Expand All @@ -35,8 +39,10 @@ prevNextLabels =
}


{-| view : renders pager controls
-}

-- VIEW


view : List WebLink -> Labels -> (Pagination.Page -> msg) -> Html msg
view links labels toMsg =
let
Expand Down
8 changes: 8 additions & 0 deletions src/elm/Components/RecentBuilds.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import Utils.Helpers as Util
import Vela



--TYPES


type alias Props =
{ builds : WebData (List Vela.Build)
, build : WebData Vela.Build
Expand All @@ -23,6 +27,10 @@ type alias Props =
}



-- VIEW


view : Shared.Model -> Props -> Html msg
view shared props =
case props.builds of
Expand Down
8 changes: 8 additions & 0 deletions src/elm/Components/Repo.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import Utils.Favorites as Favorites
import Utils.Helpers as Util



-- TYPES


type alias Props msg =
{ toggleFavoriteMsg : Favorites.UpdateFavorites msg
, org : String
Expand All @@ -23,6 +27,10 @@ type alias Props msg =
}



-- VIEW


view : Shared.Model -> Props msg -> Html msg
view shared { toggleFavoriteMsg, org, repo, favorites, filtered } =
let
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Components/ScheduleForm.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module Components.ScheduleForm exposing (..)
module Components.ScheduleForm exposing (viewCronHelp, viewEnabledInput, viewHelp, viewSubmitButton)

import Components.Form
import Html
Expand Down
34 changes: 23 additions & 11 deletions src/elm/Components/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module Components.Search exposing
( Search
, SimpleSearch
, filterRepo
, homeSearchBar
, repoSearchBarGlobal
, repoSearchBarLocal
, searchFilterGlobal
, searchFilterLocal
, shouldSearch
, toLowerContains
, viewHomeSearchBar
, viewRepoSearchBarGlobal
, viewRepoSearchBarLocal
)

import Dict exposing (Dict)
Expand All @@ -33,6 +33,10 @@ import Utils.Helpers as Util
import Vela



-- TYPES


{-| Search : takes org and repo and searches/filters based on user input
-}
type alias Search msg =
Expand All @@ -45,8 +49,12 @@ type alias SimpleSearch msg =
String -> msg


homeSearchBar : String -> SimpleSearch msg -> Html msg
homeSearchBar filter search =

-- VIEW


viewHomeSearchBar : String -> SimpleSearch msg -> Html msg
viewHomeSearchBar filter search =
div [ class "form-control", class "-with-icon", class "-is-expanded", Util.testAttribute "home-search-bar" ]
[ input
[ Util.testAttribute "home-search-input"
Expand All @@ -60,10 +68,10 @@ homeSearchBar filter search =
]


{-| repoSearchBarGlobal : renders a input bar for searching across all repos
{-| viewRepoSearchBarGlobal : renders a input bar for searching across all repos
-}
repoSearchBarGlobal : Dict Vela.Org String -> Search msg -> Html msg
repoSearchBarGlobal searchFilters search =
viewRepoSearchBarGlobal : Dict Vela.Org String -> Search msg -> Html msg
viewRepoSearchBarGlobal searchFilters search =
div [ class "form-control", class "-with-icon", class "-is-expanded", Util.testAttribute "global-search-bar" ]
[ input
[ Util.testAttribute "global-search-input"
Expand All @@ -77,10 +85,10 @@ repoSearchBarGlobal searchFilters search =
]


{-| repoSearchBarLocal : takes an org and placeholder text and renders a search bar for local repo filtering
{-| viewRepoSearchBarLocal : takes an org and placeholder text and renders a search bar for local repo filtering
-}
repoSearchBarLocal : Dict Vela.Org String -> Vela.Org -> Search msg -> Html msg
repoSearchBarLocal searchFilters org search =
viewRepoSearchBarLocal : Dict Vela.Org String -> Vela.Org -> Search msg -> Html msg
viewRepoSearchBarLocal searchFilters org search =
div [ class "form-control", class "-with-icon", class "-is-expanded", Util.testAttribute "local-search-bar" ]
[ input
[ Util.testAttribute <| "local-search-input-" ++ org
Expand All @@ -96,6 +104,10 @@ repoSearchBarLocal searchFilters org search =
]



-- HELPERS


{-| toLowerContains : takes user input and
-}
toLowerContains : String -> String -> Bool
Expand Down
Loading

0 comments on commit e82ec0b

Please sign in to comment.