Skip to content

Commit

Permalink
enh(dashboards): mvp for dashboards view
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMerrick committed Sep 13, 2024
1 parent 7d63d00 commit 3b38032
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 15 deletions.
7 changes: 7 additions & 0 deletions src/elm/Layouts/Default/Org.elm
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ view props shared route { toContentMsg, model, content } =
{ buttons =
props.navButtons
++ [ a
[ class "button"
, class "-outline"
, Util.testAttribute "dashboards-button"
, Route.Path.href Route.Path.Dashboards
]
[ text "Dashboards" ]
, a
[ class "button"
, class "-outline"
, Util.testAttribute "source-repos"
Expand Down
83 changes: 69 additions & 14 deletions src/elm/Pages/Dashboards.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import Auth
import Components.Crumbs
import Components.Nav
import Effect exposing (Effect)
import Html exposing (code, h1, h2, main_, p, text)
import Html exposing (Html, a, code, div, h1, h2, li, main_, p, text, ul)
import Html.Attributes exposing (class)
import Layouts
import Page exposing (Page)
import RemoteData
import Route exposing (Route)
import Route.Path
import Shared
import Time
import Utils.Helpers as Util
import Utils.Interval as Interval
import View exposing (View)


Expand Down Expand Up @@ -82,7 +85,7 @@ type alias Model =
init : Shared.Model -> Route () -> () -> ( Model, Effect Msg )
init shared route () =
( {}
, Effect.none
, Effect.getCurrentUserShared {}
)


Expand All @@ -94,6 +97,8 @@ init shared route () =
-}
type Msg
= NoOp
-- REFRESH
| Tick { time : Time.Posix, interval : Interval.Interval }


{-| update : takes current model, message, and returns an updated model and effect.
Expand All @@ -106,6 +111,12 @@ update shared route msg model =
, Effect.none
)

-- REFRESH
Tick options ->
( model
, Effect.none
)



-- SUBSCRIPTIONS
Expand All @@ -115,7 +126,7 @@ update shared route msg model =
-}
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
Interval.tickEveryFiveSeconds Tick



Expand All @@ -140,17 +151,61 @@ view shared route model =
{ buttons = []
, crumbs = Components.Crumbs.view route.path crumbs
}
, main_ [ class "content-wrap", Util.testAttribute "dashboards" ]
[ h1 [] [ text "Welcome to dashboards!" ]
, h2 [] [ text "✨ Want to create a new dashboard?" ]
, p [] [ text "Use the Vela CLI to add a new dashboard:" ]
, code [ class "shell" ] [ text "vela add dashboard --help" ]
, h2 [] [ text "🚀 Already have a dashboard?" ]
, p [] [ text "Check your available dashboards with:" ]
, code [ class "shell" ] [ text "vela get dashboards" ]
, p [] [ text "Take note of your dashboard ID you are interested in and and add it to the current URL to view it." ]
, h2 [] [ text "💬 Got Feedback?" ]
, p [] [ text "Follow the link in the top right to let us know your thoughts and ideas." ]
, main_ [ class "content-wrap" ]
[ div [ Util.testAttribute "dashboards" ] <|
case shared.user of
RemoteData.Success u ->
if List.length u.dashboards > 0 then
[ div []
[ h1 [] [ text "BETA something" ]
, h2 [] [ text "Dashboards" ]
, p [] [ text "UI Dashboard functionality is very minimal in this Vela version." ]
, ul []
[ li []
[ text "Manage dashboards with the CLI or API"
]
, li []
[ text "Dashboard names do not display on this page yet"
]
, li []
[ text "You'll only see dashboards you created"
]
, li []
[ text "You won't see dashboards that were shared with you, or you were added to as an admin; so you might want to save those links!"
]
]
, h2 [] [ text "💬 Got Feedback?" ]
, p [] [ text "Follow the feedback link in the top right to let us know your thoughts and ideas. We really need your feedback on the whole dashboard experience to prioritize what we'll focus on for the next version." ]
, viewDashboards u.dashboards
]
]

else
[ div [ class "dashboards" ]
[ h1 [] [ text "Welcome to dashboards!" ]
, h2 [] [ text "✨ Want to create a new dashboard?" ]
, p [] [ text "Use the Vela CLI to add a new dashboard:" ]
, code [ class "shell" ] [ text "vela add dashboard --help" ]
, h2 [] [ text "🚀 Already have a dashboard?" ]
, p [] [ text "Check your available dashboards with:" ]
, code [ class "shell" ] [ text "vela get dashboards" ]
, p [] [ text "Take note of your dashboard ID you are interested in and and add it to the current URL to view it." ]
, h2 [] [ text "💬 Got Feedback?" ]
, p [] [ text "Follow the link in the top right to let us know your thoughts and ideas." ]
]
]

_ ->
[ div [] [ text "no dashboards" ]
]
]
]
}


{-| viewDashboards : renders a list of dashboard id links.
-}
viewDashboards : List String -> Html Msg
viewDashboards dashboards =
div []
(List.map (\dashboard -> div [] [ a [ Route.Path.href <| Route.Path.Dashboards_Dashboard_ { dashboard = dashboard } ] [ text dashboard ] ]) dashboards)
7 changes: 7 additions & 0 deletions src/elm/Pages/Home_.elm
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ view shared route model =
route
{ buttons =
[ a
[ class "button"
, class "-outline"
, Util.testAttribute "dashboards-button"
, Route.Path.href Route.Path.Dashboards
]
[ text "Dashboards" ]
, a
[ class "button"
, class "-outline"
, Util.testAttribute "source-repos"
Expand Down
4 changes: 3 additions & 1 deletion src/elm/Vela.elm
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ type alias User =
{ id : Int
, name : String
, favorites : List String
, dashboards : List String
, active : Bool
, admin : Bool
}
Expand All @@ -270,13 +271,14 @@ decodeUser =
|> required "id" int
|> required "name" string
|> optional "favorites" (Json.Decode.list string) []
|> optional "dashboards" (Json.Decode.list string) []
|> required "active" bool
|> optional "admin" bool False


emptyUser : User
emptyUser =
{ id = -1, name = "", favorites = [], active = False, admin = False }
{ id = -1, name = "", favorites = [], dashboards = [], active = False, admin = False }


type alias UpdateUserPayload =
Expand Down

0 comments on commit 3b38032

Please sign in to comment.