From 7deddfbfd1a884a556e8aff69124ccbcd670c1df Mon Sep 17 00:00:00 2001 From: David May <49894298+wass3rw3rk@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:44:21 -0500 Subject: [PATCH] fix(dashboards): show appropriate messaging for deleted dashboards (#823) --- src/elm/Pages/Dashboards.elm | 42 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/elm/Pages/Dashboards.elm b/src/elm/Pages/Dashboards.elm index 66617ad0..74a17f58 100644 --- a/src/elm/Pages/Dashboards.elm +++ b/src/elm/Pages/Dashboards.elm @@ -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 @@ -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" ] )