Skip to content

Commit 8f464ac

Browse files
NestedFolderPicker: Correctly handle pagination (grafana#72030)
correctly handle pagination in the folder picker when there is more than 1 page of dashboards
1 parent 4e42f9b commit 8f464ac

File tree

1 file changed

+10
-1
lines changed
  • public/app/features/browse-dashboards/state

1 file changed

+10
-1
lines changed

public/app/features/browse-dashboards/state/hooks.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,16 @@ export function createFlatTree(
193193
return mapItem(item, folderUID, level);
194194
});
195195

196-
if ((level === 0 && !collection) || (isOpen && collection && !collection.isFullyLoaded)) {
196+
// this is very custom to the folder picker right now
197+
// we exclude dashboards, but if you have more than 1 page of dashboards collection.isFullyLoaded is false
198+
// so we need to check that we're ignoring dashboards and we've fetched all the folders
199+
// TODO generalize this properly (e.g. split state by kind?)
200+
const isConsideredLoaded = excludeKinds.includes('dashboard') && collection?.lastFetchedKind === 'dashboard';
201+
202+
const showPlaceholders =
203+
(level === 0 && !collection) || (isOpen && collection && !(collection.isFullyLoaded || isConsideredLoaded));
204+
205+
if (showPlaceholders) {
197206
children = children.concat(getPaginationPlaceholders(PAGE_SIZE, folderUID, level));
198207
}
199208

0 commit comments

Comments
 (0)