mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 21:02:16 +08:00

* 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
31 lines
649 B
TypeScript
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;
|
|
}
|