diff --git a/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx b/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx index c98d78ca021..3b8a2df2aec 100644 --- a/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx +++ b/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx @@ -32,4 +32,19 @@ describe('Render', () => { expect(wrapper).toMatchSnapshot(); }); + + it('should not render hideFromMenu children', () => { + const wrapper = setup({ + link: { + text: 'link', + children: [ + { id: 1, hideFromMenu: false }, + { id: 2, hideFromMenu: true }, + { id: 3, hideFromMenu: false }, + ], + }, + }); + + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/public/app/core/components/sidemenu/SideMenuDropDown.tsx b/public/app/core/components/sidemenu/SideMenuDropDown.tsx index bd1e3a7dfd6..d1a23413939 100644 --- a/public/app/core/components/sidemenu/SideMenuDropDown.tsx +++ b/public/app/core/components/sidemenu/SideMenuDropDown.tsx @@ -1,4 +1,5 @@ import React, { FC } from 'react'; +import _ from 'lodash'; import DropDownChild from './DropDownChild'; import { NavModelItem } from '@grafana/data'; @@ -8,6 +9,11 @@ interface Props { const SideMenuDropDown: FC = props => { const { link } = props; + let childrenLinks: NavModelItem[] = []; + if (link.children) { + childrenLinks = _.filter(link.children, item => !item.hideFromMenu); + } + return ( ); }; diff --git a/public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap b/public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap index 20d0a3ef3a4..d5f6440b899 100644 --- a/public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap +++ b/public/app/core/components/sidemenu/__snapshots__/SideMenuDropDown.test.tsx.snap @@ -1,5 +1,44 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Render should not render hideFromMenu children 1`] = ` + +`; + exports[`Render should render children 1`] = `