-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test reports): add scaffolding and basic styling
- Loading branch information
1 parent
2557666
commit 8f34f21
Showing
8 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
{-- | ||
SPDX-License-Identifier: Apache-2.0 | ||
--} | ||
|
||
|
||
module Pages.Org_.Repo_.Build_.Reports exposing (..) | ||
|
||
import Auth | ||
import Effect exposing (Effect) | ||
import Html exposing (a, button, div, li, text, ul) | ||
import Html.Attributes exposing (class, download, href) | ||
import Layouts | ||
import Page exposing (Page) | ||
import RemoteData exposing (WebData) | ||
import Route exposing (Route) | ||
import Route.Path | ||
import Shared | ||
import Vela | ||
import View exposing (View) | ||
|
||
|
||
{-| page : takes user, shared model, route, and returns a build's reports page. | ||
-} | ||
page : Auth.User -> Shared.Model -> Route { org : String, repo : String, build : String } -> Page Model Msg | ||
page user shared route = | ||
Page.new | ||
{ init = init shared route | ||
, update = update shared route | ||
, subscriptions = subscriptions | ||
, view = view shared route | ||
} | ||
|> Page.withLayout (toLayout user route) | ||
|
||
|
||
|
||
-- LAYOUT | ||
|
||
|
||
{-| toLayout : takes user, route, model, and passes a build's pipeline page info to Layouts. | ||
-} | ||
toLayout : Auth.User -> Route { org : String, repo : String, build : String } -> Model -> Layouts.Layout Msg | ||
toLayout user route model = | ||
Layouts.Default_Build | ||
{ navButtons = [] | ||
, utilButtons = [] | ||
, helpCommands = | ||
[ { name = "View Build" | ||
, content = | ||
"vela view build --org " | ||
++ route.params.org | ||
++ " --repo " | ||
++ route.params.repo | ||
++ " --build " | ||
++ route.params.build | ||
, docs = Just "build/view" | ||
} | ||
, { name = "Approve Build" | ||
, content = | ||
"vela approve build --org " | ||
++ route.params.org | ||
++ " --repo " | ||
++ route.params.repo | ||
++ " --build " | ||
++ route.params.build | ||
, docs = Just "build/approve" | ||
} | ||
, { name = "Restart Build" | ||
, content = | ||
"vela restart build --org " | ||
++ route.params.org | ||
++ " --repo " | ||
++ route.params.repo | ||
++ " --build " | ||
++ route.params.build | ||
, docs = Just "build/restart" | ||
} | ||
, { name = "Cancel Build" | ||
, content = | ||
"vela cancel build --org " | ||
++ route.params.org | ||
++ " --repo " | ||
++ route.params.repo | ||
++ " --build " | ||
++ route.params.build | ||
, docs = Just "build/cancel" | ||
} | ||
] | ||
, crumbs = | ||
[ ( "Overview", Just Route.Path.Home_ ) | ||
, ( route.params.org, Just <| Route.Path.Org_ { org = route.params.org } ) | ||
, ( route.params.repo, Just <| Route.Path.Org__Repo_ { org = route.params.org, repo = route.params.repo } ) | ||
, ( "#" ++ route.params.build, Nothing ) | ||
] | ||
, org = route.params.org | ||
, repo = route.params.repo | ||
, build = route.params.build | ||
, toBuildPath = | ||
\build -> | ||
Route.Path.Org__Repo__Build__Reports | ||
{ org = route.params.org | ||
, repo = route.params.repo | ||
, build = build | ||
} | ||
} | ||
|
||
|
||
|
||
-- INIT | ||
|
||
|
||
type alias Model = | ||
{ build : WebData Vela.Build | ||
} | ||
|
||
|
||
init : Shared.Model -> Route { org : String, repo : String, build : String } -> () -> ( Model, Effect Msg ) | ||
init shared route () = | ||
( { build = RemoteData.Loading | ||
} | ||
, Effect.none | ||
) | ||
|
||
|
||
|
||
-- UPDATE | ||
|
||
|
||
type Msg | ||
= NoOp | ||
| DownloadTextArtifact { filename : String, content : String, map : String -> String } | ||
|
||
|
||
{-| update : takes current models, route, message, and returns an updated model and effect. | ||
-} | ||
update : Shared.Model -> Route { org : String, repo : String, build : String } -> Msg -> Model -> ( Model, Effect Msg ) | ||
update shared route msg model = | ||
case msg of | ||
NoOp -> | ||
( model | ||
, Effect.none | ||
) | ||
|
||
DownloadTextArtifact options -> | ||
( model | ||
, Effect.downloadFile options | ||
) | ||
|
||
|
||
subscriptions : Model -> Sub Msg | ||
subscriptions model = | ||
Sub.none | ||
|
||
|
||
|
||
-- VIEW | ||
|
||
|
||
view : Shared.Model -> Route { org : String, repo : String, build : String } -> Model -> View Msg | ||
view shared route model = | ||
let | ||
downloadLinks = | ||
a | ||
[ class "report-output" | ||
, href "" | ||
, download "" | ||
] | ||
[ text "an artifact" ] | ||
in | ||
{ title = "Reports" | ||
, body = | ||
[ div [ class "reports-container" ] | ||
[ div [] | ||
[ ul [ class "reports-buttons" ] | ||
[ li [] | ||
[ button | ||
[ class "reports-button" | ||
] | ||
[ text "artifacts" ] | ||
] | ||
, li [] | ||
[ button | ||
[ class "reports-button" | ||
] | ||
[ text "test results" ] | ||
] | ||
] | ||
] | ||
, downloadLinks | ||
] | ||
] | ||
} | ||
|
||
|
||
|
||
-- TODO: | ||
-- - default artifacts button to active | ||
-- - allow any other buttons to replace active button | ||
-- - each button will provide a different view |
Oops, something went wrong.