From dd9e1498f9813cb138e465c32c9621ccf033eebf Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Wed, 12 Oct 2022 10:01:33 +0100 Subject: [PATCH] only render direct children on the landing page routes (#56720) --- pkg/services/navtree/models.go | 3 +- pkg/services/navtree/navtreeimpl/admin.go | 6 +++- .../AppChrome/NavLandingPage.test.tsx | 20 ------------- .../components/AppChrome/NavLandingPage.tsx | 29 ++----------------- .../plugins/components/AppRootPage.tsx | 2 +- 5 files changed, 10 insertions(+), 50 deletions(-) diff --git a/pkg/services/navtree/models.go b/pkg/services/navtree/models.go index 5e1b9ef6144..b2e92021885 100644 --- a/pkg/services/navtree/models.go +++ b/pkg/services/navtree/models.go @@ -115,8 +115,7 @@ func (root *NavTreeRoot) RemoveEmptySectionsAndApplyNewInformationArchitecture(t } if serverAdminNode := root.FindById(NavIDAdmin); serverAdminNode != nil { - serverAdminNode.Url = "/admin/settings" - serverAdminNode.Text = "Server admin" + serverAdminNode.Url = "/admin/server" serverAdminNode.SortWeight = 0 if orgAdminNode != nil { diff --git a/pkg/services/navtree/navtreeimpl/admin.go b/pkg/services/navtree/navtreeimpl/admin.go index d6016f1f1ab..c024aeb7f97 100644 --- a/pkg/services/navtree/navtreeimpl/admin.go +++ b/pkg/services/navtree/navtreeimpl/admin.go @@ -171,7 +171,11 @@ func (s *ServiceImpl) getServerAdminNode(c *models.ReqContext) *navtree.NavLink } if len(adminNavLinks) > 0 { - adminNode.Url = adminNavLinks[0].Url + if s.cfg.IsFeatureToggleEnabled(featuremgmt.FlagTopnav) { + adminNode.Url = s.cfg.AppSubURL + "/admin/server" + } else { + adminNode.Url = adminNavLinks[0].Url + } } return adminNode diff --git a/public/app/core/components/AppChrome/NavLandingPage.test.tsx b/public/app/core/components/AppChrome/NavLandingPage.test.tsx index 3e19f2b7131..ca54b24a845 100644 --- a/public/app/core/components/AppChrome/NavLandingPage.test.tsx +++ b/public/app/core/components/AppChrome/NavLandingPage.test.tsx @@ -80,24 +80,4 @@ describe('NavLandingPage', () => { expect(screen.getByText(mockChild1.subTitle)).toBeInTheDocument(); expect(screen.getByText(mockChild2.subTitle)).toBeInTheDocument(); }); - - it('renders the heading for nested sections', () => { - setup(); - expect(screen.getByRole('heading', { name: mockChild3.text })).toBeInTheDocument(); - }); - - it('renders the subTitle for a nested section', () => { - setup(); - expect(screen.getByText(mockChild3.subTitle)).toBeInTheDocument(); - }); - - it('renders a link for a nested child', () => { - setup(); - expect(screen.getByRole('link', { name: mockChild3.children[0].text })).toBeInTheDocument(); - }); - - it('renders the subTitle for a nested child', () => { - setup(); - expect(screen.getByText(mockChild3.children[0].subTitle)).toBeInTheDocument(); - }); }); diff --git a/public/app/core/components/AppChrome/NavLandingPage.tsx b/public/app/core/components/AppChrome/NavLandingPage.tsx index 44422afe11b..461e16cdd19 100644 --- a/public/app/core/components/AppChrome/NavLandingPage.tsx +++ b/public/app/core/components/AppChrome/NavLandingPage.tsx @@ -17,16 +17,15 @@ interface Props { export function NavLandingPage({ navId }: Props) { const { node } = useNavModel(navId); const styles = useStyles2(getStyles); - const directChildren = node.children?.filter((child) => !child.hideFromTabs && !child.children); - const nestedChildren = node.children?.filter((child) => child.children && child.children.length); + const children = node.children?.filter((child) => !child.hideFromTabs); return (
- {directChildren && directChildren.length > 0 && ( + {children && children.length > 0 && (
- {directChildren?.map((child) => ( + {children?.map((child) => ( )} - {nestedChildren?.map((child) => ( -
-

{getNavTitle(child.id) ?? child.text}

-
{getNavSubTitle(child.id) ?? child.subTitle}
-
- {child.children?.map((child) => ( - - ))} -
-
- ))}
@@ -71,10 +54,4 @@ const getStyles = (theme: GrafanaTheme2) => ({ gridAutoRows: '130px', padding: theme.spacing(2, 0), }), - nestedTitle: css({ - margin: theme.spacing(2, 0), - }), - nestedDescription: css({ - color: theme.colors.text.secondary, - }), }); diff --git a/public/app/features/plugins/components/AppRootPage.tsx b/public/app/features/plugins/components/AppRootPage.tsx index 7f34d68b22e..8469224964f 100644 --- a/public/app/features/plugins/components/AppRootPage.tsx +++ b/public/app/features/plugins/components/AppRootPage.tsx @@ -60,7 +60,7 @@ export function AppRootPage({ match, queryParams, location }: Props) { if (!plugin.root) { return ( -
No root app page component found
; +
No root app page component found
); }