From bbb679575728427efa199f9526f7eb13bc2921ff Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Wed, 17 May 2023 10:16:37 +0100 Subject: [PATCH] NestedFolders: make sure DashboardPage code is feature toggled correctly (#68602) make sure DashboardPage code is feature toggled correctly --- .../dashboard/containers/DashboardPage.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index 8308a42d93c..7a06821851a 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -4,7 +4,7 @@ import { connect, ConnectedProps } from 'react-redux'; import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; -import { locationService } from '@grafana/runtime'; +import { config, locationService } from '@grafana/runtime'; import { Themeable2, withTheme2 } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { Page } from 'app/core/components/Page/Page'; @@ -439,12 +439,22 @@ function updateStatePageNavFromProps(props: Props, state: State): State { // Check if folder changed const { folderTitle, folderUid } = dashboard.meta; - const folderNavModel = folderUid ? getNavModel(navIndex, `folder-dashboards-${folderUid}`).main : undefined; if (folderTitle && folderUid && pageNav && pageNav.parentItem?.text !== folderTitle) { - pageNav = { - ...pageNav, - parentItem: folderNavModel, - }; + if (config.featureToggles.nestedFolders) { + const folderNavModel = folderUid ? getNavModel(navIndex, `folder-dashboards-${folderUid}`).main : undefined; + pageNav = { + ...pageNav, + parentItem: folderNavModel, + }; + } else { + pageNav = { + ...pageNav, + parentItem: { + text: folderTitle, + url: `/dashboards/f/${dashboard.meta.folderUid}`, + }, + }; + } } if (props.route.routeName === DashboardRoutes.Path) {