SearchV2: Fix star query when no stars exist (#61726)

This commit is contained in:
Ryan McKinley 2023-01-19 13:37:06 -08:00 committed by GitHub
parent 845128dde9
commit c315946a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<void> => {
return;
},
isItemLoaded: (index: number): boolean => {
return true;
},
};
return this.doSearchQuery(starredQuery);
}
async tags(query: SearchQuery): Promise<TermCount[]> {