From 8f464ac66ebd996ba5eaebb13b3457e65d0bc989 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 21 Jul 2023 13:08:19 +0100 Subject: [PATCH] NestedFolderPicker: Correctly handle pagination (#72030) correctly handle pagination in the folder picker when there is more than 1 page of dashboards --- public/app/features/browse-dashboards/state/hooks.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/app/features/browse-dashboards/state/hooks.ts b/public/app/features/browse-dashboards/state/hooks.ts index b0f37738bb9..30ff91e4685 100644 --- a/public/app/features/browse-dashboards/state/hooks.ts +++ b/public/app/features/browse-dashboards/state/hooks.ts @@ -193,7 +193,16 @@ export function createFlatTree( return mapItem(item, folderUID, level); }); - if ((level === 0 && !collection) || (isOpen && collection && !collection.isFullyLoaded)) { + // this is very custom to the folder picker right now + // we exclude dashboards, but if you have more than 1 page of dashboards collection.isFullyLoaded is false + // so we need to check that we're ignoring dashboards and we've fetched all the folders + // TODO generalize this properly (e.g. split state by kind?) + const isConsideredLoaded = excludeKinds.includes('dashboard') && collection?.lastFetchedKind === 'dashboard'; + + const showPlaceholders = + (level === 0 && !collection) || (isOpen && collection && !(collection.isFullyLoaded || isConsideredLoaded)); + + if (showPlaceholders) { children = children.concat(getPaginationPlaceholders(PAGE_SIZE, folderUID, level)); }