From 5cc1104c4a01e5658ac46169d111db002ca813c2 Mon Sep 17 00:00:00 2001 From: wass3rw3rk <49894298+wass3rw3rk@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:59:20 -0500 Subject: [PATCH 1/2] fix(dashboards): show appropriate messaging for deleted dashboards see https://github.com/go-vela/server/pull/1193 --- src/elm/Pages/Dashboards.elm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/elm/Pages/Dashboards.elm b/src/elm/Pages/Dashboards.elm index 66617ad0..3f324558 100644 --- a/src/elm/Pages/Dashboards.elm +++ b/src/elm/Pages/Dashboards.elm @@ -252,18 +252,18 @@ viewDashboards dashboards = , div [ class "buttons" ] [ a [ class "button", dashboardLink ] [ text "View" ] ] - , viewDashboardRepos dashboard.repos dashboard.dashboard.id + , viewDashboardRepos dashboard ] ) {-| 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 +282,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" ] ) From 791fd8e3918f2af71d9f615c9cee0613c63e1008 Mon Sep 17 00:00:00 2001 From: wass3rw3rk <49894298+wass3rw3rk@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:21:17 -0500 Subject: [PATCH 2/2] dont render link/button if there's no dashboard --- src/elm/Pages/Dashboards.elm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/elm/Pages/Dashboards.elm b/src/elm/Pages/Dashboards.elm index 3f324558..74a17f58 100644 --- a/src/elm/Pages/Dashboards.elm +++ b/src/elm/Pages/Dashboards.elm @@ -245,15 +245,25 @@ 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 - ] + ) )