mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 06:41:49 +08:00
NestedFolders: Ensure New dashboard
page has the correct breadcrumb hierarchy (#69758)
ensure new dashboard page has the correct breadcrumb hierarchy
This commit is contained in:
@ -437,16 +437,17 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if folder changed
|
|
||||||
const { folderTitle, folderUid } = dashboard.meta;
|
const { folderTitle, folderUid } = dashboard.meta;
|
||||||
if (folderTitle && folderUid && pageNav && pageNav.parentItem?.text !== folderTitle) {
|
if (folderUid && pageNav) {
|
||||||
if (config.featureToggles.nestedFolders) {
|
if (config.featureToggles.nestedFolders) {
|
||||||
const folderNavModel = folderUid ? getNavModel(navIndex, `folder-dashboards-${folderUid}`).main : undefined;
|
const folderNavModel = getNavModel(navIndex, `folder-dashboards-${folderUid}`).main;
|
||||||
pageNav = {
|
pageNav = {
|
||||||
...pageNav,
|
...pageNav,
|
||||||
parentItem: folderNavModel,
|
parentItem: folderNavModel,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
// Check if folder changed
|
||||||
|
if (folderTitle && pageNav.parentItem?.text !== folderTitle) {
|
||||||
pageNav = {
|
pageNav = {
|
||||||
...pageNav,
|
...pageNav,
|
||||||
parentItem: {
|
parentItem: {
|
||||||
@ -456,6 +457,7 @@ function updateStatePageNavFromProps(props: Props, state: State): State {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (props.route.routeName === DashboardRoutes.Path) {
|
if (props.route.routeName === DashboardRoutes.Path) {
|
||||||
sectionNav = getRootContentNavModel();
|
sectionNav = getRootContentNavModel();
|
||||||
|
@ -104,6 +104,12 @@ async function fetchDashboard(
|
|||||||
return dashDTO;
|
return dashDTO;
|
||||||
}
|
}
|
||||||
case DashboardRoutes.New: {
|
case DashboardRoutes.New: {
|
||||||
|
// only the folder API has information about ancestors
|
||||||
|
// get parent folder (if it exists) and put it in the store
|
||||||
|
// this will be used to populate the full breadcrumb trail
|
||||||
|
if (config.featureToggles.nestedFolders && args.urlFolderUid) {
|
||||||
|
await dispatch(getFolderByUid(args.urlFolderUid));
|
||||||
|
}
|
||||||
return getNewDashboardModelData(args.urlFolderUid, args.panelType);
|
return getNewDashboardModelData(args.urlFolderUid, args.panelType);
|
||||||
}
|
}
|
||||||
case DashboardRoutes.Path: {
|
case DashboardRoutes.Path: {
|
||||||
|
Reference in New Issue
Block a user