NestedFolderPicker: Correctly handle pagination (#72030)

correctly handle pagination in the folder picker when there is more than 1 page of dashboards
This commit is contained in:
Ashley Harrison 2023-07-21 13:08:19 +01:00 committed by GitHub
parent 4e42f9b619
commit 8f464ac66e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));
}