From d8b26b0a31db7ab0cccc7c48f5db11c2883e831d Mon Sep 17 00:00:00 2001 From: Karl Persson <23356117+kalleep@users.noreply.github.com> Date: Fri, 14 Feb 2025 10:39:57 +0100 Subject: [PATCH] Search: Search dashboards without a parent (#100615) * Search dashboards without a parent --- pkg/services/dashboards/service/dashboard_service.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index eea8dd574ad..d1f78e34cb4 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -1690,6 +1690,16 @@ func (dr *DashboardServiceImpl) searchDashboardsThroughK8sRaw(ctx context.Contex } if len(query.FolderUIDs) > 0 { + // Grafana frontend issues a call to search for dashboards in "general" folder. General folder doesn't exists and + // should return all dashboards without a parent folder. + // We do something similar in the old sql search query https://github.com/grafana/grafana/blob/a58564a35efe8c05a21d8190b283af5bc0979d2a/pkg/services/sqlstore/searchstore/filters.go#L103 + for i := range query.FolderUIDs { + if query.FolderUIDs[i] == folder.GeneralFolderUID { + query.FolderUIDs[i] = "" + break + } + } + req := []*resource.Requirement{{ Key: resource.SEARCH_FIELD_FOLDER, Operator: string(selection.In),