From c315946a9196c51c5c48ee5c1ceb1c509b709e5a Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 19 Jan 2023 13:37:06 -0800 Subject: [PATCH] SearchV2: Fix star query when no stars exist (#61726) --- 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 {