From 0f40e95b544cf2b9f8fd7dc4cca7c9342a9563a7 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 19 Jan 2023 21:53:29 +0000 Subject: [PATCH] [v9.2.x] SearchV2: Fix star query when no stars exist (#61818) SearchV2: Fix star query when no stars exist (#61726) (cherry picked from commit c315946a9196c51c5c48ee5c1ceb1c509b709e5a) Co-authored-by: Ryan McKinley --- public/app/features/search/service/bluge.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/public/app/features/search/service/bluge.ts b/public/app/features/search/service/bluge.ts index 7dce0584bfb..c65cc5a4586 100644 --- a/public/app/features/search/service/bluge.ts +++ b/public/app/features/search/service/bluge.ts @@ -42,11 +42,23 @@ export class BlugeSearcher implements GrafanaSearcher { } // get the starred dashboards const starsUIDS = await getBackendSrv().get('api/user/stars'); - const starredQuery = { - uid: starsUIDS, - query: query.query ?? '*', + if (starsUIDS?.length) { + return this.doSearchQuery({ + uid: starsUIDS, + query: query.query ?? '*', + }); + } + // Nothing is starred + return { + view: new DataFrameView({ length: 0, fields: [] }), + totalRows: 0, + loadMoreItems: async (startIndex: number, stopIndex: number): Promise => { + return; + }, + isItemLoaded: (index: number): boolean => { + return true; + }, }; - return this.doSearchQuery(starredQuery); } async tags(query: SearchQuery): Promise {