From 53a1dd20fd567001d9f270aed0edea427b43b08c Mon Sep 17 00:00:00 2001 From: davidvader Date: Wed, 24 Jan 2024 13:40:32 -0600 Subject: [PATCH] refactor: clean up imports and RemoteData --- src/elm/Auth.elm | 1 - src/elm/Components/Build.elm | 7 +- src/elm/Components/Builds.elm | 21 +----- src/elm/Components/Favorites.elm | 6 +- src/elm/Components/Nav.elm | 2 +- src/elm/Components/RecentBuilds.elm | 2 +- src/elm/Components/Secrets.elm | 2 - src/elm/Components/Tabs.elm | 3 +- src/elm/Layouts/Default.elm | 2 +- src/elm/Layouts/Default/Build.elm | 2 +- src/elm/Layouts/Default/Repo.elm | 2 - src/elm/Main.elm | 3 - src/elm/Pages/Account/Login.elm | 6 -- src/elm/Pages/Account/SourceRepos.elm | 16 ++--- src/elm/Pages/Home.elm | 15 +--- src/elm/Pages/NotFound_.elm | 2 - src/elm/Pages/Org_/Builds.elm | 3 +- src/elm/Pages/Org_/Repo_.elm | 1 - src/elm/Pages/Org_/Repo_/Audit.elm | 3 +- src/elm/Pages/Org_/Repo_/Build_.elm | 2 +- src/elm/Pages/Org_/Repo_/Build_/Graph.elm | 2 +- src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm | 11 ++- src/elm/Pages/Org_/Repo_/Build_/Services.elm | 2 +- src/elm/Pages/Org_/Repo_/Deployments.elm | 2 +- src/elm/Pages/Org_/Repo_/Deployments/Add.elm | 2 +- src/elm/Pages/Org_/Repo_/Schedules.elm | 6 +- src/elm/Pages/Org_/Repo_/Secrets.elm | 2 +- src/elm/Pages/Org_/Repo_/Secrets/Add.elm | 1 - src/elm/Pages/Org_/Repo_/Secrets/Edit_.elm | 2 +- src/elm/Pages/Org_/Repo_/Settings.elm | 14 ++-- src/elm/Pages/Org_/Secrets.elm | 2 +- src/elm/Pages/Org_/Secrets/Add.elm | 1 - src/elm/Pages/Org_/Secrets/Edit_.elm | 2 +- src/elm/Pages/PageTemplate.elm | 1 - src/elm/Shared.elm | 6 +- src/elm/Shared/Model.elm | 2 +- src/elm/Utils/Ansi.elm | 5 ++ src/elm/Utils/Errors.elm | 4 +- src/elm/Utils/Favicons.elm | 5 ++ src/elm/Utils/HelpCommands.elm | 72 -------------------- src/elm/Utils/Helpers.elm | 4 +- src/elm/Utils/Theme.elm | 5 ++ src/elm/Vela.elm | 51 +------------- src/elm/Visualization/DOT.elm | 5 ++ 44 files changed, 75 insertions(+), 235 deletions(-) diff --git a/src/elm/Auth.elm b/src/elm/Auth.elm index 6cc5ccfad..958edbdb3 100644 --- a/src/elm/Auth.elm +++ b/src/elm/Auth.elm @@ -10,7 +10,6 @@ import Auth.Session exposing (Session(..)) import Dict import Route exposing (Route) import Route.Path -import Route.Query import Shared import View exposing (View) diff --git a/src/elm/Components/Build.elm b/src/elm/Components/Build.elm index d2f3c8129..358fa6f06 100644 --- a/src/elm/Components/Build.elm +++ b/src/elm/Components/Build.elm @@ -1,13 +1,10 @@ module Components.Build exposing (..) -import Ansi -import Ansi.Log import Components.Svgs import DateFormat.Relative import FeatherIcons -import Html exposing (Html, a, details, div, input, label, li, span, strong, summary, text, ul) -import Html.Attributes exposing (attribute, checked, class, classList, for, href, id, name, style, title, type_) -import Html.Events exposing (onClick) +import Html exposing (Html, a, details, div, label, li, span, strong, summary, text, ul) +import Html.Attributes exposing (attribute, class, classList, href, id, title) import List.Extra import RemoteData exposing (WebData) import Route.Path diff --git a/src/elm/Components/Builds.elm b/src/elm/Components/Builds.elm index a37f51947..ddd4894b4 100644 --- a/src/elm/Components/Builds.elm +++ b/src/elm/Components/Builds.elm @@ -1,17 +1,12 @@ module Components.Builds exposing (view, viewHeader) -import Ansi -import Ansi.Log import Components.Build -import DateFormat.Relative exposing (relativeTime) -import FeatherIcons import Html exposing ( Html , a , br , code - , details , div , em , h1 @@ -20,38 +15,24 @@ import Html , li , ol , p - , span - , strong - , summary - , table - , td , text - , tr - , ul ) import Html.Attributes exposing ( attribute , checked , class - , classList , for , href , id , name - , style - , title , type_ ) import Html.Events exposing (onClick) -import List.Extra import RemoteData exposing (WebData) -import Route.Path import Shared import String -import Time -import Utils.Errors as Errors -import Utils.Helpers as Util exposing (getNameFromRef) +import Utils.Helpers as Util import Vela diff --git a/src/elm/Components/Favorites.elm b/src/elm/Components/Favorites.elm index a70900b29..e6a1d6909 100644 --- a/src/elm/Components/Favorites.elm +++ b/src/elm/Components/Favorites.elm @@ -10,7 +10,7 @@ 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 RemoteData exposing (WebData) import Utils.Helpers as Util import Vela @@ -79,7 +79,7 @@ isFavorited user favorite = toggleFavorite : WebData Vela.CurrentUser -> String -> ( List String, Bool ) toggleFavorite user favorite = case user of - Success u -> + RemoteData.Success u -> let favorited = List.member favorite u.favorites @@ -102,7 +102,7 @@ toggleFavorite user favorite = addFavorite : WebData Vela.CurrentUser -> String -> ( List String, Bool ) addFavorite user favorite = case user of - Success u -> + RemoteData.Success u -> let favorites = List.Extra.unique <| favorite :: u.favorites diff --git a/src/elm/Components/Nav.elm b/src/elm/Components/Nav.elm index 55f82fb57..279cec32f 100644 --- a/src/elm/Components/Nav.elm +++ b/src/elm/Components/Nav.elm @@ -21,7 +21,7 @@ import Html.Attributes , classList ) import Html.Events exposing (onClick) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import Utils.Helpers as Util diff --git a/src/elm/Components/RecentBuilds.elm b/src/elm/Components/RecentBuilds.elm index 1db547cd0..b38f63a0f 100644 --- a/src/elm/Components/RecentBuilds.elm +++ b/src/elm/Components/RecentBuilds.elm @@ -2,7 +2,7 @@ module Components.RecentBuilds exposing (..) import Components.Svgs import Html exposing (Html, a, div, em, li, p, span, text, ul) -import Html.Attributes exposing (attribute, class, href) +import Html.Attributes exposing (attribute, class) import RemoteData exposing (WebData) import Route.Path import Shared diff --git a/src/elm/Components/Secrets.elm b/src/elm/Components/Secrets.elm index 70183cb35..5ced3e853 100644 --- a/src/elm/Components/Secrets.elm +++ b/src/elm/Components/Secrets.elm @@ -6,11 +6,9 @@ import Html exposing (Html, a, button, div, span, td, text, tr) import Html.Attributes exposing (attribute, class, scope) import Html.Events exposing (onClick) import Http -import Maybe.Extra import RemoteData exposing (WebData) import Route.Path import Shared -import Url import Utils.Helpers as Util import Vela diff --git a/src/elm/Components/Tabs.elm b/src/elm/Components/Tabs.elm index 9837cdde1..93faff750 100644 --- a/src/elm/Components/Tabs.elm +++ b/src/elm/Components/Tabs.elm @@ -3,11 +3,10 @@ module Components.Tabs exposing (Tab, view, viewBuildTabs, viewOrgTabs, viewRepo import Api.Pagination as Pagination import Html exposing (Html, a, div, span, text) import Html.Attributes exposing (class, classList) -import RemoteData exposing (WebData) +import RemoteData import Route.Path import Shared import Utils.Helpers as Util -import Vela {-| Tab : record to represent information used by page navigation tab diff --git a/src/elm/Layouts/Default.elm b/src/elm/Layouts/Default.elm index 6fdd05922..382c42f2f 100644 --- a/src/elm/Layouts/Default.elm +++ b/src/elm/Layouts/Default.elm @@ -5,7 +5,7 @@ SPDX-License-Identifier: Apache-2.0 module Layouts.Default exposing (Model, Msg, Props, layout, map) -import Components.Alerts as Alerts exposing (Alert) +import Components.Alerts exposing (Alert) import Components.Footer import Components.Header import Components.Nav diff --git a/src/elm/Layouts/Default/Build.elm b/src/elm/Layouts/Default/Build.elm index 73a2bf98e..e83adabde 100644 --- a/src/elm/Layouts/Default/Build.elm +++ b/src/elm/Layouts/Default/Build.elm @@ -9,7 +9,7 @@ import Components.Build import Components.RecentBuilds import Components.Tabs import Effect exposing (Effect) -import Html exposing (..) +import Html exposing (Html) import Http import Http.Detailed import Layout exposing (Layout) diff --git a/src/elm/Layouts/Default/Repo.elm b/src/elm/Layouts/Default/Repo.elm index c0f029ac8..1c3f940c5 100644 --- a/src/elm/Layouts/Default/Repo.elm +++ b/src/elm/Layouts/Default/Repo.elm @@ -10,10 +10,8 @@ import Effect exposing (Effect) import Html exposing (..) import Layout exposing (Layout) import Layouts.Default -import RemoteData exposing (WebData) import Route exposing (Route) import Shared -import Vela import View exposing (View) diff --git a/src/elm/Main.elm b/src/elm/Main.elm index c8a860168..9a786964b 100644 --- a/src/elm/Main.elm +++ b/src/elm/Main.elm @@ -1,9 +1,6 @@ {-- SPDX-License-Identifier: Apache-2.0 --} ---todo: known issues: --- favicon fails to load sometimes on fresh visit --- not found redirects are weird, refreshing 404 goes to the home page? module Main exposing (main) diff --git a/src/elm/Pages/Account/Login.elm b/src/elm/Pages/Account/Login.elm index b373b1dbc..66bf0d05f 100644 --- a/src/elm/Pages/Account/Login.elm +++ b/src/elm/Pages/Account/Login.elm @@ -16,7 +16,6 @@ import Html , div , h1 , p - , span , text ) import Html.Attributes @@ -27,7 +26,6 @@ import Html.Attributes import Html.Events exposing (onClick) import Layouts import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) import Route exposing (Route) import Shared import Utils.Helpers as Util @@ -90,8 +88,6 @@ update shared msg model = ) SignInRequested -> - -- Login on server needs to accept redirect URL and pass it along to as part of 'state' encoded as base64 - -- so we can parse it when the source provider redirects back to the API ( model , (Browser.Navigation.load <| Api.Endpoint.toUrl shared.velaAPI Api.Endpoint.Login) |> Effect.sendCmd ) @@ -110,8 +106,6 @@ subscriptions model = -- VIEW -{-| view : takes current user, user input and action params and renders home page with favorited repos --} view : Shared.Model -> Model -> View Msg view shared model = let diff --git a/src/elm/Pages/Account/SourceRepos.elm b/src/elm/Pages/Account/SourceRepos.elm index b47217328..c22c97823 100644 --- a/src/elm/Pages/Account/SourceRepos.elm +++ b/src/elm/Pages/Account/SourceRepos.elm @@ -46,7 +46,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import Utils.Errors as Errors @@ -80,11 +80,11 @@ toLayout user shared model = , ( "-outline", True ) ] , onClick (GetUserSourceRepos True) - , disabled (model.sourceRepos == Loading) + , disabled (model.sourceRepos == RemoteData.Loading) , Util.testAttribute "refresh-source-repos" ] [ case model.sourceRepos of - Loading -> + RemoteData.Loading -> text "Loading…" _ -> @@ -108,7 +108,7 @@ type alias Model = init : () -> ( Model, Effect Msg ) init () = ( { searchFilters = Dict.empty - , sourceRepos = NotAsked + , sourceRepos = RemoteData.NotAsked } , Effect.batch [ Effect.getCurrentUser {} @@ -143,8 +143,8 @@ update shared msg model = GetUserSourceRepos isReload -> ( { model | sourceRepos = - if isReload || model.sourceRepos == NotAsked then - Loading + if isReload || model.sourceRepos == RemoteData.NotAsked then + RemoteData.Loading else model.sourceRepos @@ -186,7 +186,7 @@ update shared msg model = EnableRepo repo -> ( { model - | sourceRepos = Vela.enableUpdate repo Loading model.sourceRepos + | sourceRepos = Vela.enableUpdate repo RemoteData.Loading model.sourceRepos -- todo: need this moved to the repo settings page -- , repo = updateRepoEnabling Vela.Enabling rm @@ -253,8 +253,6 @@ subscriptions model = -- VIEW -{-| view : takes current user with repos fetched from source control --} view : Shared.Model -> Model -> View Msg view shared model = let diff --git a/src/elm/Pages/Home.elm b/src/elm/Pages/Home.elm index 71848cd71..a5aa12b6b 100644 --- a/src/elm/Pages/Home.elm +++ b/src/elm/Pages/Home.elm @@ -36,7 +36,7 @@ import Layouts import List import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..)) +import RemoteData import Route exposing (Route) import Route.Path import Shared @@ -135,15 +135,13 @@ subscriptions model = -- VIEW -{-| view : takes current user, user input and action params and renders home page with favorited repos --} view : Shared.Model -> Model -> View Msg view shared model = { title = "Home" , body = [ div [ Util.testAttribute "overview" ] <| case shared.user of - Success u -> + RemoteData.Success u -> if List.length u.favorites > 0 then [ homeSearchBar model.favoritesFilter SearchFavorites , viewFavorites u.favorites model.favoritesFilter @@ -162,17 +160,10 @@ view shared model = ] ] - Loading -> - [ h1 [] [ Util.largeLoader ] ] - - NotAsked -> + _ -> [ homeSearchBar model.favoritesFilter SearchFavorites , viewFavorites [] model.favoritesFilter ] - - -- [ text "not asked" ] - Failure _ -> - [ text "failed" ] ] } diff --git a/src/elm/Pages/NotFound_.elm b/src/elm/Pages/NotFound_.elm index 0ebab1a3e..c57416cdf 100644 --- a/src/elm/Pages/NotFound_.elm +++ b/src/elm/Pages/NotFound_.elm @@ -82,8 +82,6 @@ subscriptions model = -- VIEW -{-| view : takes current user, user input and action params and renders home page with favorited repos --} view : Shared.Model -> Model -> View Msg view shared model = { title = "Not Found" diff --git a/src/elm/Pages/Org_/Builds.elm b/src/elm/Pages/Org_/Builds.elm index 4c12f5a4c..e3a092b13 100644 --- a/src/elm/Pages/Org_/Builds.elm +++ b/src/elm/Pages/Org_/Builds.elm @@ -12,7 +12,6 @@ import Components.Builds import Components.Pager import Dict import Effect exposing (Effect) -import Html exposing (text) import Http import Http.Detailed import Layouts @@ -20,7 +19,7 @@ import LinkHeader exposing (WebLink) import List import Maybe.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import Utils.Errors as Errors diff --git a/src/elm/Pages/Org_/Repo_.elm b/src/elm/Pages/Org_/Repo_.elm index 6e2630a78..e66cbbfcc 100644 --- a/src/elm/Pages/Org_/Repo_.elm +++ b/src/elm/Pages/Org_/Repo_.elm @@ -19,7 +19,6 @@ import LinkHeader exposing (WebLink) import List import Maybe.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..)) import Route exposing (Route) import Shared import Utils.Helpers as Util diff --git a/src/elm/Pages/Org_/Repo_/Audit.elm b/src/elm/Pages/Org_/Repo_/Audit.elm index 7d6580bc7..09553be5f 100644 --- a/src/elm/Pages/Org_/Repo_/Audit.elm +++ b/src/elm/Pages/Org_/Repo_/Audit.elm @@ -39,12 +39,11 @@ import Layouts import LinkHeader exposing (WebLink) import List import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import Time import Utils.Ansi -import Utils.Errors as Errors import Utils.Helpers as Util import Vela import View exposing (View) diff --git a/src/elm/Pages/Org_/Repo_/Build_.elm b/src/elm/Pages/Org_/Repo_/Build_.elm index 29618ee8c..1522bb59d 100644 --- a/src/elm/Pages/Org_/Repo_/Build_.elm +++ b/src/elm/Pages/Org_/Repo_/Build_.elm @@ -20,7 +20,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Repo_/Build_/Graph.elm b/src/elm/Pages/Org_/Repo_/Build_/Graph.elm index e9b218b07..73ba0e482 100644 --- a/src/elm/Pages/Org_/Repo_/Build_/Graph.elm +++ b/src/elm/Pages/Org_/Repo_/Build_/Graph.elm @@ -20,7 +20,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm b/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm index 3540f8139..6358b0379 100644 --- a/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm +++ b/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm @@ -8,21 +8,18 @@ module Pages.Org_.Repo_.Build_.Pipeline exposing (..) import Ansi.Log import Array import Auth -import Components.Svgs -import Debug exposing (log) import Dict exposing (Dict) -import Effect exposing (Effect, getPipelineConfig) +import Effect exposing (Effect) import FeatherIcons -import Html exposing (Html, a, button, code, details, div, small, span, strong, summary, td, text, tr) +import Html exposing (Html, a, button, code, div, small, span, strong, td, text, tr) import Html.Attributes exposing (attribute, class, id) import Html.Events exposing (onClick) import Http import Http.Detailed import Layouts -import List.Extra import Maybe.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared @@ -397,7 +394,7 @@ view shared route model = , let toggle = case model.build of - Success build -> + RemoteData.Success build -> div [ class "action", class "expand-pipeline", Util.testAttribute "pipeline-expand" ] [ viewExpandToggleButton model , if model.expanding then diff --git a/src/elm/Pages/Org_/Repo_/Build_/Services.elm b/src/elm/Pages/Org_/Repo_/Build_/Services.elm index c0f9115dc..753b32b4e 100644 --- a/src/elm/Pages/Org_/Repo_/Build_/Services.elm +++ b/src/elm/Pages/Org_/Repo_/Build_/Services.elm @@ -20,7 +20,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Repo_/Deployments.elm b/src/elm/Pages/Org_/Repo_/Deployments.elm index 770211eae..88bb666de 100644 --- a/src/elm/Pages/Org_/Repo_/Deployments.elm +++ b/src/elm/Pages/Org_/Repo_/Deployments.elm @@ -38,7 +38,7 @@ import LinkHeader exposing (WebLink) import List import Maybe.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Repo_/Deployments/Add.elm b/src/elm/Pages/Org_/Repo_/Deployments/Add.elm index 3bffc3783..426fcf342 100644 --- a/src/elm/Pages/Org_/Repo_/Deployments/Add.elm +++ b/src/elm/Pages/Org_/Repo_/Deployments/Add.elm @@ -17,7 +17,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import String.Extra diff --git a/src/elm/Pages/Org_/Repo_/Schedules.elm b/src/elm/Pages/Org_/Repo_/Schedules.elm index 0e2d2dd44..0038268f3 100644 --- a/src/elm/Pages/Org_/Repo_/Schedules.elm +++ b/src/elm/Pages/Org_/Repo_/Schedules.elm @@ -19,7 +19,7 @@ import Http.Detailed import Layouts import LinkHeader exposing (WebLink) import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import Svg.Attributes @@ -188,12 +188,12 @@ viewRepoSchedules shared model org repo = ( noRowsView, rows ) = if schedulesAllowed then case model.schedules of - Success s -> + RemoteData.Success s -> ( text "No schedules found for this repo" , schedulesToRows shared.zone org repo s ) - Failure error -> + RemoteData.Failure error -> ( span [ Util.testAttribute "repo-schedule-error" ] [ text <| case error of diff --git a/src/elm/Pages/Org_/Repo_/Secrets.elm b/src/elm/Pages/Org_/Repo_/Secrets.elm index 267428d86..a90eb85e7 100644 --- a/src/elm/Pages/Org_/Repo_/Secrets.elm +++ b/src/elm/Pages/Org_/Repo_/Secrets.elm @@ -19,7 +19,7 @@ import Http.Detailed import Layouts import LinkHeader exposing (WebLink) import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Repo_/Secrets/Add.elm b/src/elm/Pages/Org_/Repo_/Secrets/Add.elm index 98575d22e..f5915e0c4 100644 --- a/src/elm/Pages/Org_/Repo_/Secrets/Add.elm +++ b/src/elm/Pages/Org_/Repo_/Secrets/Add.elm @@ -16,7 +16,6 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..)) import Route exposing (Route) import Shared import String.Extra diff --git a/src/elm/Pages/Org_/Repo_/Secrets/Edit_.elm b/src/elm/Pages/Org_/Repo_/Secrets/Edit_.elm index 31638a1a6..a94ceb3f8 100644 --- a/src/elm/Pages/Org_/Repo_/Secrets/Edit_.elm +++ b/src/elm/Pages/Org_/Repo_/Secrets/Edit_.elm @@ -16,7 +16,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import String.Extra diff --git a/src/elm/Pages/Org_/Repo_/Settings.elm b/src/elm/Pages/Org_/Repo_/Settings.elm index 0df6dd216..199c61f9a 100644 --- a/src/elm/Pages/Org_/Repo_/Settings.elm +++ b/src/elm/Pages/Org_/Repo_/Settings.elm @@ -7,22 +7,18 @@ module Pages.Org_.Repo_.Settings exposing (Model, Msg, page, view) import Auth import Components.Form -import Dict import Effect exposing (Effect) import FeatherIcons -import Html exposing (Html, a, br, button, code, div, em, h2, h3, img, input, label, p, section, small, span, strong, text, textarea) -import Html.Attributes exposing (alt, attribute, checked, class, classList, disabled, for, href, id, readonly, rows, src, type_, value, wrap) -import Html.Events exposing (onCheck, onClick, onInput) +import Html exposing (Html, a, br, button, div, em, h2, h3, img, input, label, p, section, small, span, strong, text, textarea) +import Html.Attributes exposing (alt, attribute, class, classList, disabled, for, href, id, readonly, rows, src, type_, value, wrap) +import Html.Events exposing (onClick, onInput) import Http import Http.Detailed import Layouts -import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared -import String.Extra -import Url import Utils.Helpers as Util import Vela import View exposing (View) @@ -232,7 +228,7 @@ view shared route model = { title = "Settings" , body = [ case model.repo of - Success repo -> + RemoteData.Success repo -> div [ class "repo-settings", Util.testAttribute "repo-settings" ] [ viewEvents repo , viewAccess repo AccessUpdate diff --git a/src/elm/Pages/Org_/Secrets.elm b/src/elm/Pages/Org_/Secrets.elm index b0bc78673..a31fb46c8 100644 --- a/src/elm/Pages/Org_/Secrets.elm +++ b/src/elm/Pages/Org_/Secrets.elm @@ -19,7 +19,7 @@ import Http.Detailed import Layouts import LinkHeader exposing (WebLink) import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Route.Path import Shared diff --git a/src/elm/Pages/Org_/Secrets/Add.elm b/src/elm/Pages/Org_/Secrets/Add.elm index bf20b4241..8bc708fa9 100644 --- a/src/elm/Pages/Org_/Secrets/Add.elm +++ b/src/elm/Pages/Org_/Secrets/Add.elm @@ -16,7 +16,6 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..)) import Route exposing (Route) import Shared import String.Extra diff --git a/src/elm/Pages/Org_/Secrets/Edit_.elm b/src/elm/Pages/Org_/Secrets/Edit_.elm index cb1fd25c1..86204b3a3 100644 --- a/src/elm/Pages/Org_/Secrets/Edit_.elm +++ b/src/elm/Pages/Org_/Secrets/Edit_.elm @@ -16,7 +16,7 @@ import Http.Detailed import Layouts import List.Extra import Page exposing (Page) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Route exposing (Route) import Shared import String.Extra diff --git a/src/elm/Pages/PageTemplate.elm b/src/elm/Pages/PageTemplate.elm index f7c7a460a..9f2389b4a 100644 --- a/src/elm/Pages/PageTemplate.elm +++ b/src/elm/Pages/PageTemplate.elm @@ -13,7 +13,6 @@ import Html ) import Layouts import Page exposing (Page) -import RemoteData exposing (RemoteData(..)) import Route exposing (Route) import Shared import View exposing (View) diff --git a/src/elm/Shared.elm b/src/elm/Shared.elm index b8fc00346..c75aad1a8 100644 --- a/src/elm/Shared.elm +++ b/src/elm/Shared.elm @@ -22,7 +22,7 @@ import Interop import Json.Decode import Json.Decode.Pipeline exposing (required) import Json.Encode -import RemoteData exposing (RemoteData(..)) +import RemoteData import Route exposing (Route) import Route.Path import Route.Query @@ -132,7 +132,7 @@ init flagsResult route = , session = Auth.Session.Unauthenticated -- USER - , user = NotAsked + , user = RemoteData.NotAsked -- TIME , zone = Time.utc @@ -370,7 +370,7 @@ update route msg model = -- USER Shared.Msg.GetCurrentUser -> - ( { model | user = Loading } + ( { model | user = RemoteData.Loading } , Api.try Shared.Msg.CurrentUserResponse (Api.Operations.getCurrentUser model.velaAPI model.session) diff --git a/src/elm/Shared/Model.elm b/src/elm/Shared/Model.elm index dc91972ce..d1f42bf56 100644 --- a/src/elm/Shared/Model.elm +++ b/src/elm/Shared/Model.elm @@ -8,7 +8,7 @@ module Shared.Model exposing (Model) import Auth.Session exposing (Session(..)) import Browser.Events exposing (Visibility(..)) import Components.Alerts exposing (Alert) -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Time exposing (Posix, Zone) import Toasty exposing (Stack) import Utils.Favicons as Favicons diff --git a/src/elm/Utils/Ansi.elm b/src/elm/Utils/Ansi.elm index 165a04da4..6e577033a 100644 --- a/src/elm/Utils/Ansi.elm +++ b/src/elm/Utils/Ansi.elm @@ -1,3 +1,8 @@ +{-- +SPDX-License-Identifier: Apache-2.0 +--} + + module Utils.Ansi exposing (..) import Ansi diff --git a/src/elm/Utils/Errors.elm b/src/elm/Utils/Errors.elm index dfaac302f..9bd0a2523 100644 --- a/src/elm/Utils/Errors.elm +++ b/src/elm/Utils/Errors.elm @@ -8,7 +8,7 @@ module Utils.Errors exposing (Error, addError, addErrorString, detailedErrorToSt import Http import Http.Detailed import Json.Decode as Decode -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import Task exposing (perform, succeed) @@ -108,7 +108,7 @@ wrapErrorContent content = -} toFailure : Http.Detailed.Error String -> WebData a toFailure error = - Failure <| detailedErrorToError error + RemoteData.Failure <| detailedErrorToError error {-| addError : takes a detailed http error and produces a Cmd Msg that invokes an action in the Errors module diff --git a/src/elm/Utils/Favicons.elm b/src/elm/Utils/Favicons.elm index ace40d0c3..118d70ece 100644 --- a/src/elm/Utils/Favicons.elm +++ b/src/elm/Utils/Favicons.elm @@ -1,3 +1,8 @@ +{-- +SPDX-License-Identifier: Apache-2.0 +--} + + module Utils.Favicons exposing (..) import Interop diff --git a/src/elm/Utils/HelpCommands.elm b/src/elm/Utils/HelpCommands.elm index adb4684bf..4e4446edc 100644 --- a/src/elm/Utils/HelpCommands.elm +++ b/src/elm/Utils/HelpCommands.elm @@ -20,8 +20,6 @@ import String.Extra import Vela -{-| Model : wrapper for help args, meant to slim down the input required to render contextual help for each page --} type alias Model msg = { user : Arg , sourceRepos : Arg @@ -36,14 +34,10 @@ type alias Model msg = , toggle : Maybe Bool -> msg , copy : String -> msg , noOp : msg - - -- , page : Page , velaDocsURL : String } -{-| Arg : type alias for extracting remotedata information --} type alias Arg = { loading : Bool , success : Bool @@ -65,72 +59,6 @@ commands path = [] - --- case page of --- Pages.Overview -> --- [ listFavorites ] --- Pages.SourceRepositories -> --- [] --- Pages.OrgRepositories _ _ _ -> --- [] --- Pages.Hooks org repo _ _ -> --- [ validate, listHooks org repo, viewHook org repo ] --- Pages.OrgBuilds _ _ _ _ -> --- [] --- Pages.RepositoryBuilds org repo _ _ _ -> --- [ listBuilds org repo ] --- Pages.RepositoryBuildsPulls org repo _ _ -> --- [ listBuilds org repo ] --- Pages.RepositoryBuildsTags org repo _ _ -> --- [ listBuilds org repo ] --- Pages.RepositoryDeployments org repo _ _ -> --- [ listDeployments org repo ] --- Pages.Build org repo buildNumber _ -> --- [ viewBuild org repo buildNumber, approveBuild org repo buildNumber, restartBuild org repo buildNumber, cancelBuild org repo buildNumber, listSteps org repo buildNumber, viewStep org repo buildNumber ] --- Pages.BuildServices org repo buildNumber _ -> --- [ viewBuild org repo buildNumber, approveBuild org repo buildNumber, restartBuild org repo buildNumber, cancelBuild org repo buildNumber, listServices org repo buildNumber, viewService org repo buildNumber ] --- Pages.BuildPipeline org repo buildNumber _ _ -> --- [ viewBuild org repo buildNumber, approveBuild org repo buildNumber, restartBuild org repo buildNumber ] --- Pages.BuildGraph org repo buildNumber -> --- [ viewBuild org repo buildNumber, restartBuild org repo buildNumber ] --- Pages.RepoSettings org repo -> --- [ viewRepo org repo, repairRepo org repo, chownRepo org repo ] --- Pages.OrgSecrets secretEngine org _ _ -> --- [ listSecrets secretEngine Vela.OrgSecret org Nothing ] --- Pages.RepoSecrets secretEngine org repo _ _ -> --- [ listSecrets secretEngine Vela.RepoSecret org <| Just repo ] --- Pages.SharedSecrets secretEngine org key _ _ -> --- [ listSecrets secretEngine Vela.SharedSecret org <| Just key ] --- Pages.AddOrgSecret secretEngine org -> --- [ addSecret secretEngine Vela.OrgSecret org Nothing ] --- Pages.AddRepoSecret secretEngine org repo -> --- [ addSecret secretEngine Vela.RepoSecret org <| Just repo ] --- Pages.AddDeployment org repo -> --- [ addDeployment org repo ] --- Pages.PromoteDeployment org repo _ -> --- [ addDeployment org repo ] --- Pages.AddSharedSecret secretEngine org team -> --- [ addSecret secretEngine Vela.SharedSecret org <| Just team ] --- Pages.OrgSecret secretEngine org name -> --- [ viewSecret secretEngine Vela.OrgSecret org Nothing name, updateSecret secretEngine Vela.OrgSecret org Nothing name ] --- Pages.RepoSecret secretEngine org repo name -> --- [ viewSecret secretEngine Vela.RepoSecret org (Just repo) name, updateSecret secretEngine Vela.RepoSecret org (Just repo) name ] --- Pages.SharedSecret secretEngine org team name -> --- [ viewSecret secretEngine Vela.SharedSecret org (Just team) name, updateSecret secretEngine Vela.SharedSecret org (Just team) name ] --- Pages.Settings -> --- [] --- Pages.Login -> --- [ authenticate ] --- Pages.NotFound -> --- [] --- Pages.AddSchedule org repo -> --- [ addSchedule org repo ] --- Pages.Schedule org repo name -> --- [ viewSchedule org repo name, updateSchedule org repo name ] --- Pages.Schedules org repo _ _ -> --- [ listSchedules org repo ] - - {-| listFavorites : returns cli command for listing favorites not yet supported diff --git a/src/elm/Utils/Helpers.elm b/src/elm/Utils/Helpers.elm index 912f54bd6..9f4ecd85e 100644 --- a/src/elm/Utils/Helpers.elm +++ b/src/elm/Utils/Helpers.elm @@ -61,7 +61,7 @@ import Html.Attributes exposing (attribute, class) import Html.Events exposing (custom) import Json.Decode import List.Extra -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) import String.Extra import Task exposing (perform, succeed) import Time exposing (Posix, Zone, posixToMillis, toHour, toMinute, utc) @@ -501,7 +501,7 @@ successful = List.filterMap (\item -> case item of - Success item_ -> + RemoteData.Success item_ -> Just item_ _ -> diff --git a/src/elm/Utils/Theme.elm b/src/elm/Utils/Theme.elm index 48af22a46..e5ea584fd 100644 --- a/src/elm/Utils/Theme.elm +++ b/src/elm/Utils/Theme.elm @@ -1,3 +1,8 @@ +{-- +SPDX-License-Identifier: Apache-2.0 +--} + + module Utils.Theme exposing (..) import Json.Decode diff --git a/src/elm/Vela.elm b/src/elm/Vela.elm index 3adca3d5c..faf831b45 100644 --- a/src/elm/Vela.elm +++ b/src/elm/Vela.elm @@ -82,7 +82,6 @@ module Vela exposing , defaultEnableRepositoryPayload , defaultSecret , defaultStep - , enableRepoDict , enableRepoList , enableUpdate , encodeBuildGraphRenderData @@ -107,7 +106,7 @@ import Json.Decode exposing (Decoder, andThen, bool, int, string, succeed) import Json.Decode.Extra exposing (dict2) import Json.Decode.Pipeline exposing (hardcoded, optional, required) import Json.Encode -import RemoteData exposing (RemoteData(..), WebData) +import RemoteData exposing (WebData) @@ -271,7 +270,7 @@ decodeRepository = |> optional "allow_comment" bool False |> optional "allow_events" (Json.Decode.maybe decodeAllowEvents) Nothing -- "enabled" - |> optional "active" enabledDecoder NotAsked + |> optional "active" enabledDecoder RemoteData.NotAsked -- "enabling" |> optional "active" enablingDecoder NotAsked_ |> optional "pipeline_type" string "" @@ -295,33 +294,25 @@ type alias Enabled = WebData Bool -{-| enabledDecoder : decodes string field "status" to the union type Enabled --} enabledDecoder : Decoder Enabled enabledDecoder = bool |> andThen toEnabled -{-| toEnabled : helper to decode string to Enabled --} toEnabled : Bool -> Decoder Enabled toEnabled active = if active then succeed <| RemoteData.succeed True else - succeed NotAsked + succeed RemoteData.NotAsked -{-| enablingDecoder : decodes string field "status" to the union type Enabling --} enablingDecoder : Decoder Enabling enablingDecoder = bool |> andThen toEnabling -{-| toEnabling : helper to decode string to Enabling --} toEnabling : Bool -> Decoder Enabling toEnabling active = if active then @@ -478,8 +469,6 @@ encodeCommentActions comment = ] -{-| SourceRepositories : type alias for repositories available for creation --} type alias SourceRepositories = Dict String (List Repository) @@ -514,8 +503,6 @@ decodeSourceRepositories = Json.Decode.dict (Json.Decode.list decodeRepository) -{-| enableUpdate : takes repo, enabled status and source repos and sets enabled status of the specified repo --} enableUpdate : Repository -> Enabled -> WebData SourceRepositories -> WebData SourceRepositories enableUpdate repo status sourceRepos = case sourceRepos of @@ -531,15 +518,11 @@ enableUpdate repo status sourceRepos = sourceRepos -{-| enableRepoDict : update the dictionary containing org source repo lists --} enableRepoDict : Repository -> Enabled -> Dict String (List Repository) -> List Repository -> Dict String (List Repository) enableRepoDict repo status repos orgRepos = Dict.update repo.org (\_ -> Just <| enableRepoList repo status orgRepos) repos -{-| enableRepoList : list map for updating single repo status by repo name --} enableRepoList : Repository -> Enabled -> List Repository -> List Repository enableRepoList repo status orgRepos = List.map @@ -1048,22 +1031,16 @@ decodeGraphInteraction = |> optional "nodeID" string "-1" -{-| decodeBuilds : decodes json from vela into list of builds --} decodeBuilds : Decoder (List Build) decodeBuilds = Json.Decode.list decodeBuild -{-| buildStatusDecoder : decodes string field "status" to the union type BuildStatus --} buildStatusDecoder : Decoder Status buildStatusDecoder = string |> andThen toStatus -{-| Status : type enum to represent the possible statuses a vela object can be in --} type Status = Pending | Running @@ -1075,8 +1052,6 @@ type Status | PendingApproval -{-| toStatus : helper to decode string to Status --} toStatus : String -> Decoder Status toStatus status = case status of @@ -1108,8 +1083,6 @@ toStatus status = succeed Error -{-| stringToStatus : helper to convert string to Status --} stringToStatus : String -> Status stringToStatus status = case status of @@ -1138,8 +1111,6 @@ stringToStatus status = Error -{-| statusToString : helper to convert Status to string --} statusToString : Status -> String statusToString status = case status of @@ -1168,8 +1139,6 @@ statusToString status = "error" -{-| isComplete : helper to determine if status is 'complete' --} isComplete : Status -> Bool isComplete status = case status of @@ -1356,8 +1325,6 @@ decodeLog = -- HOOKS -{-| Hook : record type for vela repo hooks --} type alias Hook = { id : Int , repo_id : Int @@ -1391,8 +1358,6 @@ decodeHook = |> optional "link" string "" -{-| decodeHooks : decodes json from vela into list of hooks --} decodeHooks : Decoder (List Hook) decodeHooks = Json.Decode.list decodeHook @@ -1512,15 +1477,11 @@ defaultSecret secretType = Secret -1 "" "" "" "" "" secretType [] [ "push" ] True -{-| secretTypeDecoder : decodes string field "type" to the union type SecretType --} secretTypeDecoder : Decoder SecretType secretTypeDecoder = string |> andThen toSecretTypeDecoder -{-| toSecretTypeDecoder : helper to decode string to SecretType --} toSecretTypeDecoder : String -> Decoder SecretType toSecretTypeDecoder type_ = case type_ of @@ -1537,8 +1498,6 @@ toSecretTypeDecoder type_ = Json.Decode.fail "unrecognized secret type" -{-| secretTypeToString : helper to convert SecretType to string --} secretTypeToString : SecretType -> String secretTypeToString type_ = case type_ of @@ -1552,8 +1511,6 @@ secretTypeToString type_ = "repo" -{-| secretsErrorLabel : helper to convert SecretType to string for printing GET secrets resource errors --} secretsErrorLabel : SecretType -> Org -> Maybe Key -> String secretsErrorLabel type_ org key = case type_ of @@ -1567,8 +1524,6 @@ secretsErrorLabel type_ org key = "shared secrets for " ++ org ++ "/" ++ Maybe.withDefault "" key -{-| maybeSecretTypeToMaybeString : helper to convert Maybe SecretType to Maybe string --} maybeSecretTypeToMaybeString : Maybe SecretType -> Maybe String maybeSecretTypeToMaybeString type_ = case type_ of diff --git a/src/elm/Visualization/DOT.elm b/src/elm/Visualization/DOT.elm index ff2a78b62..b7e34e961 100644 --- a/src/elm/Visualization/DOT.elm +++ b/src/elm/Visualization/DOT.elm @@ -1,3 +1,8 @@ +{-- +SPDX-License-Identifier: Apache-2.0 +--} + + module Visualization.DOT exposing ( Attribute(..) , AttributeValue(..)