fix: dashboard list page bugs while in mode 3 (#110568)

* fix infinite scroll when using folder tree view in dashboard page inside folders with more than 50 items

* fix off-by-one error when fetching in list view
This commit is contained in:
Will Assis
2025-09-03 19:50:58 -04:00
committed by GitHub
parent 6c9faa7595
commit d9c875d343
4 changed files with 8 additions and 1 deletions
@@ -44,6 +44,7 @@ describe('browse-dashboards services', () => {
location: 'abc-123',
from: expectedFrom,
limit: PAGE_SIZE,
offset: expectedFrom,
});
});
});
@@ -51,6 +51,7 @@ export async function listDashboards(parentUID?: string, page = 1, pageSize = PA
location: parentUID || 'general',
from: (page - 1) * pageSize, // our pages are 1-indexed, so we need to -1 to convert that to correct value to skip
limit: pageSize,
offset: (page - 1) * pageSize,
});
return dashboardsResults.view.map((item) => {
@@ -41,6 +41,7 @@ export interface SearchQuery {
starred?: boolean;
permission?: PermissionLevelString;
deleted?: boolean;
offset?: number;
}
export interface DashboardQueryResult {
@@ -202,7 +202,7 @@ export class UnifiedSearcher implements GrafanaSearcher {
totalRows: meta.count ?? first.length,
view,
loadMoreItems: async (startIndex: number, stopIndex: number): Promise<void> => {
loadMax = Math.max(loadMax, stopIndex);
loadMax = Math.max(loadMax, stopIndex + 1);
if (!pending) {
pending = getNextPage();
}
@@ -260,6 +260,10 @@ export class UnifiedSearcher implements GrafanaSearcher {
uri += `?query=${encodeURIComponent(query.query ?? '*')}`;
uri += `&limit=${query.limit ?? pageSize}`;
if (query.offset) {
uri += `&offset=${query.offset}`;
}
if (!isEmpty(query.location)) {
uri += `&folder=${query.location}`;
}