Files
Josh Hunt 394ff9fcde NestedFolders: Improve performance of Browse Dashboards by loading one page at a time (#68617)
* wip for pagination

* kind of doing pagination, but only for the root folder

* wip

* wip

* refactor paginated fetchChildren

* make sure dashboards are loaded if a folder contains only dashboards

* rename lastKindHasMoreItems

* load additional root pages

* undo accidental commit

* return promise from loadMoreChildren, and prevent loading additional page while a request is already in flight

* rename browseDashboards/fetchChildren action so it's more clear

* starting to revalidate children after an action

* unset general uid

* comment

* clean up

* fix tests omg

* cleanup

* fix items not loading after invalidating loaded cache

* comment

* fix lints
2023-06-05 10:21:45 +00:00

31 lines
649 B
TypeScript

import { DashboardViewItem } from 'app/features/search/types';
import { BrowseDashboardsState } from '../types';
export function findItem(
rootItems: DashboardViewItem[],
childrenByUID: BrowseDashboardsState['childrenByParentUID'],
uid: string
): DashboardViewItem | undefined {
for (const item of rootItems) {
if (item.uid === uid) {
return item;
}
}
for (const parentUID in childrenByUID) {
const children = childrenByUID[parentUID];
if (!children) {
continue;
}
for (const child of children.items) {
if (child.uid === uid) {
return child;
}
}
}
return undefined;
}