Skip to content

Commit

Permalink
refactor: license headers, moved everything to components and utils, …
Browse files Browse the repository at this point in the history
…cleanup
  • Loading branch information
plyr4 committed Jan 16, 2024
1 parent 3c6f0a5 commit bdb2ab6
Show file tree
Hide file tree
Showing 73 changed files with 405 additions and 812 deletions.
5 changes: 5 additions & 0 deletions src/elm/Api/Operations.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Api.Operations exposing
( addDeployment
, addSchedule
Expand Down
5 changes: 5 additions & 0 deletions src/elm/Api/Operations_.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Api.Operations_ exposing (enableRepo, finishAuthentication, getCurrentUser, getToken, getUserSourceRepos, logout, updateCurrentUser)

import Api.Api exposing (Request, delete, get, patch, post, put, withAuth)
Expand Down
5 changes: 5 additions & 0 deletions src/elm/Auth.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Auth exposing (User, onPageLoad, viewLoadingPage)

import Auth.Action
Expand Down
5 changes: 5 additions & 0 deletions src/elm/Auth/Action.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Auth.Action exposing
( Action(..)
, loadPageWithUser, showLoadingPage
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Auth/Jwt.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Auth.Jwt exposing
import Json.Decode as Decode exposing (Decoder, bool, field, int, string)
import Json.Decode.Pipeline exposing (required)
import Time
import Util
import Util.Helpers as Util


type alias JwtAccessToken =
Expand Down
4 changes: 2 additions & 2 deletions src/elm/Alerts.elm → src/elm/Components/Alerts.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ SPDX-License-Identifier: Apache-2.0
--}


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

import FeatherIcons
import Html exposing (Html, a, button, div, h1, p, text)
import Html.Attributes exposing (attribute, class, href)
import Html.Events
import Toasty as Alerting
import Toasty.Defaults as Alerts
import Util
import Util.Helpers as Util
import Vela exposing (Copy)


Expand Down
5 changes: 1 addition & 4 deletions src/elm/Components/Crumbs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ module Components.Crumbs exposing (view)

import Html exposing (Html, a, li, ol, text)
import Html.Attributes exposing (attribute)
import Pages exposing (Page, toRoute)
import Route exposing (Route)
import Route.Path
import Routes
import Tuple exposing (first, second)
import Url exposing (percentDecode)
import Util exposing (pageToString)
import Util.Helpers as Util



Expand Down
6 changes: 3 additions & 3 deletions src/elm/Favorites.elm → src/elm/Components/Favorites.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ SPDX-License-Identifier: Apache-2.0
--}


module Favorites exposing (UpdateFavorites, UpdateType(..), addFavorite, isFavorited, starToggle, toFavorite, toggleFavorite)
module Components.Favorites exposing (UpdateFavorites, UpdateType(..), addFavorite, isFavorited, starToggle, toFavorite, toggleFavorite)

import Components.Svgs exposing (star)
import Html exposing (Html, button)
import Html.Attributes exposing (attribute, class)
import Html.Events exposing (onClick)
import List.Extra
import RemoteData exposing (RemoteData(..), WebData)
import SvgBuilder exposing (star)
import Util
import Util.Helpers as Util
import Vela exposing (CurrentUser, Org, Repo)


Expand Down
9 changes: 7 additions & 2 deletions src/elm/Components/Footer.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Components.Footer exposing (view)

import Alerts exposing (Alert)
import Components.Alerts as Alerts exposing (Alert)
import Html exposing (Html, div)
import Html.Attributes exposing (class)
import Toasty as Alerting exposing (Stack)
import Util
import Util.Helpers as Util


view :
Expand Down
15 changes: 10 additions & 5 deletions src/elm/Components/Header.elm
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
module Components.Header exposing (..)
{--
SPDX-License-Identifier: Apache-2.0
--}


module Components.Header exposing (view)

import Auth.Session exposing (Session(..))
import Components.Help
import Components.Svgs exposing (velaLogo)
import FeatherIcons
import Help.Commands
import Help.View
import Html exposing (Html, a, button, details, div, header, li, nav, summary, text, ul)
import Html.Attributes exposing (attribute, class, classList, href, id)
import Html.Events exposing (onClick)
import Routes
import SvgBuilder exposing (velaLogo)
import Util
import Util.Helpers as Util
import Vela exposing (Theme(..))


Expand Down Expand Up @@ -56,7 +61,7 @@ view { session, feedbackLink, docsLink, theme, setTheme, help, showId, showHideI
[ li [] [ viewThemeToggle theme setTheme ]
, li [] [ a [ href feedbackLink, attribute "aria-label" "go to feedback" ] [ text "feedback" ] ]
, li [] [ a [ href docsLink, attribute "aria-label" "go to docs" ] [ text "docs" ] ]
, Help.View.help help
, Components.Help.help help
]
]
]
Expand Down
6 changes: 3 additions & 3 deletions src/elm/Help/View.elm → src/elm/Components/Help.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ SPDX-License-Identifier: Apache-2.0
--}


module Help.View exposing (help)
module Components.Help exposing (help)

import Components.Svgs as SvgBuilder
import FeatherIcons
import Help.Commands
exposing
Expand All @@ -20,8 +21,7 @@ import Help.Commands
import Html exposing (Html, a, button, details, div, label, li, span, strong, summary, text)
import Html.Attributes exposing (attribute, class, for, href, id, size, value)
import Html.Events
import SvgBuilder
import Util
import Util.Helpers as Util
import Vela exposing (Copy)


Expand Down
147 changes: 2 additions & 145 deletions src/elm/Components/Nav.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0
module Components.Nav exposing (Msgs, Tab, view, viewTabs)

import Components.Crumbs
import Favorites exposing (UpdateFavorites, isFavorited, starToggle)
import Components.Favorites exposing (UpdateFavorites)
import Html
exposing
( Html
Expand All @@ -22,16 +22,14 @@ import Html.Attributes
( attribute
, class
, classList
, disabled
)
import Html.Events exposing (onClick)
import Pages exposing (Page)
import RemoteData exposing (RemoteData(..), WebData)
import Route exposing (Route)
import Route.Path
import Routes
import Shared
import Util
import Util.Helpers as Util
import Vela
exposing
( Build
Expand Down Expand Up @@ -75,147 +73,6 @@ view shared route buttons =
)


navButtonsLegacy : Shared.Model -> Msgs msg -> Page -> Html msg
navButtonsLegacy shared { fetchSourceRepos, toggleFavorite, approveBuild, restartBuild, cancelBuild } legacyPage =
case legacyPage of
Pages.Overview ->
-- migrated
a
[ class "button"
, class "-outline"
, Util.testAttribute "source-repos"
, Routes.href <| Routes.SourceRepositories
]
[ text "Source Repositories" ]

Pages.OrgRepositories _ _ _ ->
a
[ class "button"
, class "-outline"
, Util.testAttribute "source-repos"
, Routes.href <| Routes.SourceRepositories
]
[ text "Source Repositories" ]

Pages.SourceRepositories ->
-- migrated
button
[ classList
[ ( "button", True )
, ( "-outline", True )
]
, onClick fetchSourceRepos

-- , disabled (shared.sourceRepos == Loading)
, Util.testAttribute "refresh-source-repos"
]
[-- case shared.sourceRepos of
-- Loading ->
-- text "Loading…"
-- _ ->
-- text "Refresh List"
]

Pages.RepositoryBuilds org repo _ _ _ ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.RepositoryDeployments org repo _ _ ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.Schedules org repo _ _ ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.RepoSettings org repo ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.RepoSecrets _ org repo _ _ ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.Build org repo _ _ ->
div [ class "buttons" ]
[ approveBuildButton org repo shared.repo.build.build approveBuild
, cancelBuildButton org repo shared.repo.build.build cancelBuild
, restartBuildButton org repo shared.repo.build.build restartBuild
]

Pages.BuildServices org repo _ _ ->
div [ class "buttons" ]
[ approveBuildButton org repo shared.repo.build.build approveBuild
, cancelBuildButton org repo shared.repo.build.build cancelBuild
, restartBuildButton org repo shared.repo.build.build restartBuild
]

Pages.BuildPipeline org repo _ _ _ ->
div [ class "buttons" ]
[ approveBuildButton org repo shared.repo.build.build approveBuild
, cancelBuildButton org repo shared.repo.build.build cancelBuild
, restartBuildButton org repo shared.repo.build.build restartBuild
]

Pages.BuildGraph org repo _ ->
div [ class "buttons" ]
[ cancelBuildButton org repo shared.repo.build.build cancelBuild
, restartBuildButton org repo shared.repo.build.build restartBuild
]

Pages.Hooks org repo _ _ ->
starToggle org repo toggleFavorite <| isFavorited shared.user <| org ++ "/" ++ repo

Pages.OrgSecrets _ _ _ _ ->
text ""

Pages.SharedSecrets _ _ _ _ _ ->
text ""

Pages.AddOrgSecret _ _ ->
text ""

Pages.AddRepoSecret _ _ _ ->
text ""

Pages.AddDeployment _ _ ->
text ""

Pages.PromoteDeployment _ _ _ ->
text ""

Pages.AddSharedSecret _ _ _ ->
text ""

Pages.OrgSecret _ _ _ ->
text ""

Pages.RepoSecret _ _ _ _ ->
text ""

Pages.SharedSecret _ _ _ _ ->
text ""

Pages.RepositoryBuildsPulls _ _ _ _ ->
text ""

Pages.RepositoryBuildsTags _ _ _ _ ->
text ""

Pages.OrgBuilds _ _ _ _ ->
text ""

Pages.AddSchedule _ _ ->
text ""

Pages.Schedule _ _ _ ->
text ""

Pages.Settings ->
text ""

Pages.Login ->
text ""

Pages.NotFound ->
text ""


{-| viewTabs : takes list of tab records and renders them with spacers and horizontal filler
-}
viewTabs : List Tab -> String -> Html msg
Expand Down
5 changes: 2 additions & 3 deletions src/elm/Search.elm → src/elm/Components/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module Search exposing
module Components.Search exposing
( Search
, SimpleSearch
, filterRepo
Expand All @@ -24,13 +24,12 @@ import Html.Attributes
( attribute
, autofocus
, class
, disabled
, id
, placeholder
, value
)
import Html.Events exposing (onInput)
import Util
import Util.Helpers as Util
import Vela exposing (Org, RepoSearchFilters, SearchFilter)


Expand Down
4 changes: 2 additions & 2 deletions src/elm/SvgBuilder.elm → src/elm/Components/Svgs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SPDX-License-Identifier: Apache-2.0
--}


module SvgBuilder exposing
module Components.Svgs exposing
( buildStatusAnimation
, buildStatusToIcon
, buildVizLegendEdge
Expand Down Expand Up @@ -40,7 +40,7 @@ import Svg.Attributes
, y1
, y2
)
import Util exposing (ariaHidden)
import Util.Helpers as Util exposing (ariaHidden)
import Vela exposing (Status)


Expand Down
Loading

0 comments on commit bdb2ab6

Please sign in to comment.