Skip to content

Commit

Permalink
enhance: more consistent patterns generated by elm-land (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Apr 17, 2024
1 parent 0df904a commit 1534b6d
Show file tree
Hide file tree
Showing 14 changed files with 1,661 additions and 1,070 deletions.
4 changes: 2 additions & 2 deletions src/elm/Components/Logs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Html.Events exposing (onClick)
import Html.Lazy exposing (lazy6)
import RemoteData exposing (WebData)
import Shared
import Url
import Url exposing (Url)
import Utils.Ansi
import Utils.Focus as Focus
import Utils.Helpers as Util
Expand Down Expand Up @@ -308,7 +308,7 @@ viewLogLinks chunk =

{-| viewLogLink : takes a url and label and renders a link
-}
viewLogLink : Url.Url -> String -> Html msg
viewLogLink : Url -> String -> Html msg
viewLogLink link txt =
-- use toString in href to make the link safe
a [ Util.testAttribute "log-line-link", href <| Url.toString link ] [ text txt ]
Expand Down
1,921 changes: 1,071 additions & 850 deletions src/elm/Main.elm

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/elm/Main/Pages/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ SPDX-License-Identifier: Apache-2.0

module Main.Pages.Model exposing (Model(..))

import Pages.Account.Authenticate
import Pages.Account.Login
import Pages.Account.Logout
import Pages.Account.Settings
import Pages.Account.SourceRepos
import Pages.Dash.Secrets.Engine_.Org.Org_
Expand All @@ -29,16 +31,20 @@ import Pages.Org_.Repo_.Build_.Services
import Pages.Org_.Repo_.Deployments
import Pages.Org_.Repo_.Deployments.Add
import Pages.Org_.Repo_.Hooks
import Pages.Org_.Repo_.Pulls
import Pages.Org_.Repo_.Schedules
import Pages.Org_.Repo_.Schedules.Add
import Pages.Org_.Repo_.Schedules.Name_
import Pages.Org_.Repo_.Settings
import Pages.Org_.Repo_.Tags
import View exposing (View)


type Model
= Home_ Pages.Home_.Model
| Account_Authenticate Pages.Account.Authenticate.Model
| Account_Login Pages.Account.Login.Model
| Account_Logout Pages.Account.Logout.Model
| Account_Settings Pages.Account.Settings.Model
| Account_SourceRepos Pages.Account.SourceRepos.Model
| Dash_Secrets_Engine__Org_Org_ { engine : String, org : String } Pages.Dash.Secrets.Engine_.Org.Org_.Model
Expand All @@ -56,10 +62,12 @@ type Model
| Org__Repo__Deployments { org : String, repo : String } Pages.Org_.Repo_.Deployments.Model
| Org__Repo__Deployments_Add { org : String, repo : String } Pages.Org_.Repo_.Deployments.Add.Model
| Org__Repo__Hooks { org : String, repo : String } Pages.Org_.Repo_.Hooks.Model
| Org__Repo__Pulls { org : String, repo : String } Pages.Org_.Repo_.Pulls.Model
| Org__Repo__Schedules { org : String, repo : String } Pages.Org_.Repo_.Schedules.Model
| Org__Repo__Schedules_Add { org : String, repo : String } Pages.Org_.Repo_.Schedules.Add.Model
| Org__Repo__Schedules_Name_ { org : String, repo : String, name : String } Pages.Org_.Repo_.Schedules.Name_.Model
| Org__Repo__Settings { org : String, repo : String } Pages.Org_.Repo_.Settings.Model
| Org__Repo__Tags { org : String, repo : String } Pages.Org_.Repo_.Tags.Model
| Org__Repo__Build_ { org : String, repo : String, build : String } Pages.Org_.Repo_.Build_.Model
| Org__Repo__Build__Graph { org : String, repo : String, build : String } Pages.Org_.Repo_.Build_.Graph.Model
| Org__Repo__Build__Pipeline { org : String, repo : String, build : String } Pages.Org_.Repo_.Build_.Pipeline.Model
Expand Down
8 changes: 8 additions & 0 deletions src/elm/Main/Pages/Msg.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ SPDX-License-Identifier: Apache-2.0

module Main.Pages.Msg exposing (Msg(..))

import Pages.Account.Authenticate
import Pages.Account.Login
import Pages.Account.Logout
import Pages.Account.Settings
import Pages.Account.SourceRepos
import Pages.Dash.Secrets.Engine_.Org.Org_
Expand All @@ -29,15 +31,19 @@ import Pages.Org_.Repo_.Build_.Services
import Pages.Org_.Repo_.Deployments
import Pages.Org_.Repo_.Deployments.Add
import Pages.Org_.Repo_.Hooks
import Pages.Org_.Repo_.Pulls
import Pages.Org_.Repo_.Schedules
import Pages.Org_.Repo_.Schedules.Add
import Pages.Org_.Repo_.Schedules.Name_
import Pages.Org_.Repo_.Settings
import Pages.Org_.Repo_.Tags


type Msg
= Home_ Pages.Home_.Msg
| Account_Authenticate Pages.Account.Authenticate.Msg
| Account_Login Pages.Account.Login.Msg
| Account_Logout Pages.Account.Logout.Msg
| Account_Settings Pages.Account.Settings.Msg
| Account_SourceRepos Pages.Account.SourceRepos.Msg
| Dash_Secrets_Engine__Org_Org_ Pages.Dash.Secrets.Engine_.Org.Org_.Msg
Expand All @@ -55,10 +61,12 @@ type Msg
| Org__Repo__Deployments Pages.Org_.Repo_.Deployments.Msg
| Org__Repo__Deployments_Add Pages.Org_.Repo_.Deployments.Add.Msg
| Org__Repo__Hooks Pages.Org_.Repo_.Hooks.Msg
| Org__Repo__Pulls Pages.Org_.Repo_.Pulls.Msg
| Org__Repo__Schedules Pages.Org_.Repo_.Schedules.Msg
| Org__Repo__Schedules_Add Pages.Org_.Repo_.Schedules.Add.Msg
| Org__Repo__Schedules_Name_ Pages.Org_.Repo_.Schedules.Name_.Msg
| Org__Repo__Settings Pages.Org_.Repo_.Settings.Msg
| Org__Repo__Tags Pages.Org_.Repo_.Tags.Msg
| Org__Repo__Build_ Pages.Org_.Repo_.Build_.Msg
| Org__Repo__Build__Graph Pages.Org_.Repo_.Build_.Graph.Msg
| Org__Repo__Build__Pipeline Pages.Org_.Repo_.Build_.Pipeline.Msg
Expand Down
80 changes: 80 additions & 0 deletions src/elm/Pages/Account/Authenticate.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Pages.Account.Authenticate exposing (Model, Msg, page)

import Dict
import Effect exposing (Effect)
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)


page : Shared.Model -> Route () -> Page Model Msg
page shared route =
Page.new
{ init = init route
, update = update
, subscriptions = subscriptions
, view = view
}



-- INIT


type alias Model =
{}


init : Route () -> () -> ( Model, Effect Msg )
init route () =
let
code =
Dict.get "code" route.query

state =
Dict.get "state" route.query
in
( {}
, Effect.finishAuthentication { code = code, state = state }
)



-- UPDATE


type Msg
= NoOp


update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
NoOp ->
( model
, Effect.none
)



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none



-- VIEW


view : Model -> View Msg
view model =
View.none
73 changes: 73 additions & 0 deletions src/elm/Pages/Account/Logout.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Pages.Account.Logout exposing (Model, Msg, page)

import Dict
import Effect exposing (Effect)
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)


page : Shared.Model -> Route () -> Page Model Msg
page shared route =
Page.new
{ init = init route
, update = update
, subscriptions = subscriptions
, view = view
}



-- INIT


type alias Model =
{}


init : Route () -> () -> ( Model, Effect Msg )
init route () =
( {}
, Effect.logout { from = Dict.get "from" route.query }
)



-- UPDATE


type Msg
= NoOp


update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
NoOp ->
( model
, Effect.none
)



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none



-- VIEW


view : Model -> View Msg
view model =
View.none
78 changes: 78 additions & 0 deletions src/elm/Pages/Org_/Repo_/Pulls.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Pages.Org_.Repo_.Pulls exposing (Model, Msg, page)

import Dict
import Effect exposing (Effect)
import Page exposing (Page)
import Route exposing (Route)
import Route.Path
import Shared
import View exposing (View)


page : Shared.Model -> Route { org : String, repo : String } -> Page Model Msg
page shared route =
Page.new
{ init = init route
, update = update
, subscriptions = subscriptions
, view = view
}



-- INIT


type alias Model =
{}


init : Route { org : String, repo : String } -> () -> ( Model, Effect Msg )
init route () =
( {}
, Effect.replaceRoute <|
{ path = Route.Path.Org__Repo_ route.params
, query = Dict.fromList [ ( "event", "pull_request" ) ]
, hash = Nothing
}
)



-- UPDATE


type Msg
= NoOp


update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
NoOp ->
( model
, Effect.none
)



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none



-- VIEW


view : Model -> View Msg
view model =
View.none
Loading

0 comments on commit 1534b6d

Please sign in to comment.