mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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({});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user