[search] fix browse mode to show dashboards (#98842)

[search] fix browse mode to show dashboards
This commit is contained in:
Scott Lepper
2025-01-11 11:09:31 -05:00
committed by GitHub
parent ad1417b732
commit 01aeb56646
2 changed files with 5 additions and 6 deletions
+5
View File
@@ -192,6 +192,8 @@ func (s *SearchHandler) DoSortable(w http.ResponseWriter, r *http.Request) {
s.write(w, sortable)
}
const rootFolder = "general"
func (s *SearchHandler) DoSearch(w http.ResponseWriter, r *http.Request) {
ctx, span := s.tracer.Start(r.Context(), "dashboard.search")
defer span.End()
@@ -234,6 +236,9 @@ func (s *SearchHandler) DoSearch(w http.ResponseWriter, r *http.Request) {
// Add the folder constraint. Note this does not do recursive search
folder := queryParams.Get("folder")
if folder != "" {
if folder == rootFolder {
folder = "" // root folder is empty in the search index
}
searchRequest.Options.Fields = []*resource.Requirement{{
Key: "folder",
Operator: "=",
@@ -58,12 +58,6 @@ export class UnifiedSearcher implements GrafanaSearcher {
if (query.facet?.length) {
throw new Error('facets not supported!');
}
if (query.kind?.length === 1 && query.kind[0] === 'dashboard') {
// TODO: this is browse mode, so skip the search
return noDataResponse();
}
return this.doSearchQuery(query);
}