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:
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user