Skip to content

Commit

Permalink
fix(dashboards): show appropriate messaging for deleted dashboards (#823
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wass3rw3rk authored Sep 24, 2024
1 parent 7ece904 commit 7deddfb
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions src/elm/Pages/Dashboards.elm
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,35 @@ viewDashboards dashboards =
|> Route.Path.href
in
div [ class "item", Util.testAttribute "dashboard-item" ]
[ span [ class "dashboard-item-title" ]
[ a [ dashboardLink ] [ text dashboard.dashboard.name ]
, code [] [ text dashboard.dashboard.id ]
(if String.contains "(not found)" dashboard.dashboard.name then
[ span [ class "dashboard-item-title" ]
[ text dashboard.dashboard.name
, code [] [ text dashboard.dashboard.id ]
]
, viewDashboardRepos dashboard
]
, div [ class "buttons" ]
[ a [ class "button", dashboardLink ] [ text "View" ]

else
[ span [ class "dashboard-item-title" ]
[ a [ dashboardLink ] [ text dashboard.dashboard.name ]
, code [] [ text dashboard.dashboard.id ]
]
, div [ class "buttons" ]
[ a [ class "button", dashboardLink ] [ text "View" ]
]
, viewDashboardRepos dashboard
]
, viewDashboardRepos dashboard.repos dashboard.dashboard.id
]
)
)


{-| viewDashboardRepos : renders a list of repos belonging to a dashboard.
-}
viewDashboardRepos : List Vela.DashboardRepoCard -> String -> Html Msg
viewDashboardRepos repos dashboardId =
viewDashboardRepos : Vela.Dashboard -> Html Msg
viewDashboardRepos dashboard =
div [ class "dashboard-repos", Util.testAttribute "dashboard-repos" ]
(if List.length repos > 0 then
repos
(if List.length dashboard.repos > 0 then
dashboard.repos
|> List.map
(\repo ->
let
Expand All @@ -282,10 +292,16 @@ viewDashboardRepos repos dashboardId =
]
)

else if String.contains "(not found)" dashboard.dashboard.name then
[ text <|
"⚠️ This dashboard has been deleted. You can remove it from your list: vela update user --drop-dashboards "
++ dashboard.dashboard.id
]

else
[ text <|
"⚠️ No repositories in this dashboard. Use the CLI to add some: vela update dashboard --id "
++ dashboardId
"ℹ️ No repositories in this dashboard. Use the CLI to add some: vela update dashboard --id "
++ dashboard.dashboard.id
++ " --add-repos org/repo"
]
)

0 comments on commit 7deddfb

Please sign in to comment.