diff --git a/packages/grafana-data/src/types/navModel.ts b/packages/grafana-data/src/types/navModel.ts index 781a6610270..66b1fe81737 100644 --- a/packages/grafana-data/src/types/navModel.ts +++ b/packages/grafana-data/src/types/navModel.ts @@ -22,6 +22,7 @@ export interface NavModelItem { highlightText?: string; highlightId?: string; tabSuffix?: ComponentType<{ className?: string }>; + hideFromNavbar?: boolean; } export enum NavSection { diff --git a/packages/grafana-ui/src/types/icon.ts b/packages/grafana-ui/src/types/icon.ts index 3d55da853b3..0b7e64c937a 100644 --- a/packages/grafana-ui/src/types/icon.ts +++ b/packages/grafana-ui/src/types/icon.ts @@ -5,6 +5,7 @@ export type IconSize = ComponentSize | 'xl' | 'xxl' | 'xxxl'; export const getAvailableIcons = () => [ + 'anchor', 'angle-double-down', 'angle-double-right', 'angle-double-up', diff --git a/public/app/core/components/NavBar/NavBarItem.tsx b/public/app/core/components/NavBar/NavBarItem.tsx index 67efefbf768..cf91ade17a4 100644 --- a/public/app/core/components/NavBar/NavBarItem.tsx +++ b/public/app/core/components/NavBar/NavBarItem.tsx @@ -33,7 +33,9 @@ const NavBarItem = ({ const { i18n } = useLingui(); const theme = useTheme2(); const menuItems = link.children ?? []; - const menuItemsSorted = reverseMenuDirection ? menuItems.reverse() : menuItems; + + // Spreading `menuItems` here as otherwise we'd be mutating props + const menuItemsSorted = reverseMenuDirection ? [...menuItems].reverse() : menuItems; const filteredItems = menuItemsSorted .filter((item) => !item.hideFromMenu) .map((i) => ({ ...i, menuItemType: NavMenuItemType.Item })); diff --git a/public/app/core/components/NavBar/NavBarMenu.test.tsx b/public/app/core/components/NavBar/NavBarMenu.test.tsx index 08f1acd6c39..0c65010c21d 100644 --- a/public/app/core/components/NavBar/NavBarMenu.test.tsx +++ b/public/app/core/components/NavBar/NavBarMenu.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { NavModelItem } from '@grafana/data'; -import { render, screen } from '@testing-library/react'; +import { render, screen } from 'test/redux-rtl'; import userEvent from '@testing-library/user-event'; import { NavBarMenu } from './NavBarMenu'; diff --git a/public/app/core/components/NavBar/NavBarMenu.tsx b/public/app/core/components/NavBar/NavBarMenu.tsx index ae35bde4235..f4c6823f4c3 100644 --- a/public/app/core/components/NavBar/NavBarMenu.tsx +++ b/public/app/core/components/NavBar/NavBarMenu.tsx @@ -6,6 +6,9 @@ import { useDialog } from '@react-aria/dialog'; import { useOverlay } from '@react-aria/overlays'; import { css } from '@emotion/css'; import { NavBarMenuItem } from './NavBarMenuItem'; +import { useDispatch } from 'react-redux'; +import { togglePin } from 'app/core/reducers/navBarTree'; +import { getConfig } from 'app/core/config'; export interface Props { activeItem?: NavModelItem; @@ -14,6 +17,11 @@ export interface Props { } export function NavBarMenu({ activeItem, navItems, onClose }: Props) { + const dispatch = useDispatch(); + const toggleItemPin = (id: string) => { + dispatch(togglePin({ id })); + }; + const theme = useTheme2(); const styles = getStyles(theme); const ref = useRef(null); @@ -27,6 +35,7 @@ export function NavBarMenu({ activeItem, navItems, onClose }: Props) { ref ); + const newNavigationEnabled = getConfig().featureToggles.newNavigation; return (
@@ -37,8 +46,8 @@ export function NavBarMenu({ activeItem, navItems, onClose }: Props) {