NestedFolders: New Browse Dashboards views (#66003)

* scaffold new browse routes

* a part of rtk query

* load nested data

* .

* link nested dashboards items

* add comment about bad code, update codeowners

* tidies
This commit is contained in:
Josh Hunt
2023-04-12 10:44:01 +01:00
committed by GitHub
parent 52f39e6fa0
commit 5df33c0dc1
11 changed files with 282 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ export const DashboardListPage = memo(({ match, location }: Props) => {
const { loading, value } = useAsync<() => Promise<{ folder?: FolderDTO; pageNav?: NavModelItem }>>(() => {
const uid = match.params.uid;
const url = location.pathname;
if (!uid || !url.startsWith('/dashboards')) {
return Promise.resolve({});
}

View File

@@ -7,13 +7,17 @@ import { getGrafanaSearcher } from './searcher';
import { NestedFolderDTO } from './types';
import { queryResultToViewItem } from './utils';
export async function getFolderChildren(parentUid?: string, parentTitle?: string): Promise<DashboardViewItem[]> {
export async function getFolderChildren(
parentUid?: string,
parentTitle?: string,
dashboardsAtRoot = false
): Promise<DashboardViewItem[]> {
if (!config.featureToggles.nestedFolders) {
console.error('getFolderChildren requires nestedFolders feature toggle');
return [];
}
if (!parentUid) {
if (!dashboardsAtRoot && !parentUid) {
// We don't show dashboards at root in folder view yet - they're shown under a dummy 'general'
// folder that FolderView adds in
const folders = await getChildFolders();
@@ -24,7 +28,7 @@ export async function getFolderChildren(parentUid?: string, parentTitle?: string
const dashboardsResults = await searcher.search({
kind: ['dashboard'],
query: '*',
location: parentUid,
location: parentUid ?? 'general',
limit: 1000,
});