diff --git a/public/app/AppWrapper.tsx b/public/app/AppWrapper.tsx index b4a79094bba..89c1b48eab2 100644 --- a/public/app/AppWrapper.tsx +++ b/public/app/AppWrapper.tsx @@ -9,7 +9,7 @@ import { getAppRoutes } from 'app/routes/routes'; import { ConfigContext, ThemeProvider } from './core/utils/ConfigProvider'; import { RouteDescriptor } from './core/navigation/types'; import { contextSrv } from './core/services/context_srv'; -import { SideMenu } from './core/components/sidemenu/SideMenu'; +import { NavBar } from './core/components/NavBar/NavBar'; import { GrafanaRoute } from './core/navigation/GrafanaRoute'; import { AppNotificationList } from './core/components/AppNotifications/AppNotificationList'; import { SearchWrapper } from 'app/features/search'; @@ -96,7 +96,7 @@ export class AppWrapper extends React.Component
- +
{!isSignedIn && ( - + - + )} {bottomNav.map((link, index) => { let menuItems = link.children || []; @@ -75,7 +75,7 @@ export default function BottomSection() { } return ( - {link.icon && } {link.img && {`${link.text}} - + ); })} {showSwitcherModal && } diff --git a/public/app/core/components/sidemenu/DropDownChild.test.tsx b/public/app/core/components/NavBar/DropdownChild.test.tsx similarity index 81% rename from public/app/core/components/sidemenu/DropDownChild.test.tsx rename to public/app/core/components/NavBar/DropdownChild.test.tsx index 99bf45df025..1552b1a5958 100644 --- a/public/app/core/components/sidemenu/DropDownChild.test.tsx +++ b/public/app/core/components/NavBar/DropdownChild.test.tsx @@ -1,15 +1,15 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; -import DropDownChild from './DropDownChild'; +import DropdownChild from './DropdownChild'; -describe('DropDownChild', () => { +describe('DropdownChild', () => { const mockText = 'MyChildItem'; const mockUrl = '/route'; const mockIcon = 'home-alt'; it('displays the text', () => { - render(); + render(); const text = screen.getByText(mockText); expect(text).toBeInTheDocument(); }); @@ -17,7 +17,7 @@ describe('DropDownChild', () => { it('attaches the url to the text if provided', () => { render( - + ); const link = screen.getByRole('link', { name: mockText }); @@ -26,13 +26,13 @@ describe('DropDownChild', () => { }); it('displays an icon if a valid icon is provided', () => { - render(); + render(); const icon = screen.getByTestId('dropdown-child-icon'); expect(icon).toBeInTheDocument(); }); it('displays a divider instead when isDivider is true', () => { - render(); + render(); // Check the divider is shown const divider = screen.getByTestId('dropdown-child-divider'); diff --git a/public/app/core/components/sidemenu/DropDownChild.tsx b/public/app/core/components/NavBar/DropdownChild.tsx similarity index 93% rename from public/app/core/components/sidemenu/DropDownChild.tsx rename to public/app/core/components/NavBar/DropdownChild.tsx index b69f4b233fe..6badadb67d7 100644 --- a/public/app/core/components/sidemenu/DropDownChild.tsx +++ b/public/app/core/components/NavBar/DropdownChild.tsx @@ -12,7 +12,7 @@ export interface Props { url?: string; } -const DropDownChild = ({ isDivider = false, icon, onClick, target, text, url }: Props) => { +const DropdownChild = ({ isDivider = false, icon, onClick, target, text, url }: Props) => { const theme = useTheme2(); const styles = getStyles(theme); @@ -44,7 +44,7 @@ const DropDownChild = ({ isDivider = false, icon, onClick, target, text, url }: return isDivider ?
  • :
  • {element}
  • ; }; -export default DropDownChild; +export default DropdownChild; const getStyles = (theme: GrafanaTheme2) => ({ element: css` diff --git a/public/app/core/components/sidemenu/SideMenu.test.tsx b/public/app/core/components/NavBar/NavBar.test.tsx similarity index 94% rename from public/app/core/components/sidemenu/SideMenu.test.tsx rename to public/app/core/components/NavBar/NavBar.test.tsx index f0798c2c13a..751a7d2f58d 100644 --- a/public/app/core/components/sidemenu/SideMenu.test.tsx +++ b/public/app/core/components/NavBar/NavBar.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { SideMenu } from './SideMenu'; +import { NavBar } from './NavBar'; import { render, screen } from '@testing-library/react'; import { Router } from 'react-router-dom'; import { locationService } from '@grafana/runtime'; @@ -23,7 +23,7 @@ const setup = () => { return render( - + ); diff --git a/public/app/core/components/sidemenu/SideMenu.tsx b/public/app/core/components/NavBar/NavBar.tsx similarity index 94% rename from public/app/core/components/sidemenu/SideMenu.tsx rename to public/app/core/components/NavBar/NavBar.tsx index f22e7a2b91b..19296b11984 100644 --- a/public/app/core/components/sidemenu/SideMenu.tsx +++ b/public/app/core/components/NavBar/NavBar.tsx @@ -12,14 +12,14 @@ import BottomSection from './BottomSection'; const homeUrl = config.appSubUrl || '/'; -export const SideMenu: FC = React.memo(() => { +export const NavBar: FC = React.memo(() => { const theme = useTheme2(); const styles = getStyles(theme); const location = useLocation(); const query = new URLSearchParams(location.search); const kiosk = query.get('kiosk') as KioskMode; - const toggleSideMenuSmallBreakpoint = useCallback(() => { + const toggleNavBarSmallBreakpoint = useCallback(() => { appEvents.emit(CoreEvents.toggleSidemenuMobile); }, []); @@ -32,7 +32,7 @@ export const SideMenu: FC = React.memo(() => { -
    +
    @@ -45,7 +45,7 @@ export const SideMenu: FC = React.memo(() => { ); }); -SideMenu.displayName = 'SideMenu'; +NavBar.displayName = 'NavBar'; const getStyles = (theme: GrafanaTheme2) => ({ sidemenu: css` diff --git a/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx b/public/app/core/components/NavBar/NavBarDropdown.test.tsx similarity index 75% rename from public/app/core/components/sidemenu/SideMenuDropDown.test.tsx rename to public/app/core/components/NavBar/NavBarDropdown.test.tsx index 287427ff9b2..8083daed70a 100644 --- a/public/app/core/components/sidemenu/SideMenuDropDown.test.tsx +++ b/public/app/core/components/NavBar/NavBarDropdown.test.tsx @@ -2,9 +2,9 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; -import SideMenuDropDown from './SideMenuDropDown'; +import NavBarDropdown from './NavBarDropdown'; -describe('SideMenuDropDown', () => { +describe('NavBarDropdown', () => { const mockHeaderText = 'MyHeaderText'; const mockHeaderUrl = '/route'; const mockOnHeaderClick = jest.fn(); @@ -18,7 +18,7 @@ describe('SideMenuDropDown', () => { ]; it('displays the header text', () => { - render(); + render(); const text = screen.getByText(mockHeaderText); expect(text).toBeInTheDocument(); }); @@ -26,7 +26,7 @@ describe('SideMenuDropDown', () => { it('attaches the header url to the header text if provided', () => { render( - + ); const link = screen.getByRole('link', { name: mockHeaderText }); @@ -35,7 +35,7 @@ describe('SideMenuDropDown', () => { }); it('calls the onHeaderClick function when the header is clicked', () => { - render(); + render(); const text = screen.getByText(mockHeaderText); expect(text).toBeInTheDocument(); userEvent.click(text); @@ -43,7 +43,7 @@ describe('SideMenuDropDown', () => { }); it('displays the items', () => { - render(); + render(); mockItems.forEach(({ text }) => { const childItem = screen.getByText(text); expect(childItem).toBeInTheDocument(); diff --git a/public/app/core/components/sidemenu/SideMenuDropDown.tsx b/public/app/core/components/NavBar/NavBarDropdown.tsx similarity index 96% rename from public/app/core/components/sidemenu/SideMenuDropDown.tsx rename to public/app/core/components/NavBar/NavBarDropdown.tsx index 5f92097198a..1c2bea6b726 100644 --- a/public/app/core/components/sidemenu/SideMenuDropDown.tsx +++ b/public/app/core/components/NavBar/NavBarDropdown.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { css } from '@emotion/css'; import { GrafanaTheme2, NavModelItem } from '@grafana/data'; import { IconName, Link, useTheme2 } from '@grafana/ui'; -import DropDownChild from './DropDownChild'; +import DropdownChild from './DropdownChild'; interface Props { headerTarget?: HTMLAnchorElement['target']; @@ -14,7 +14,7 @@ interface Props { subtitleText?: string; } -const SideMenuDropDown = ({ +const NavBarDropdown = ({ headerTarget, headerText, headerUrl, @@ -50,7 +50,7 @@ const SideMenuDropDown = ({ {items .filter((item) => !item.hideFromMenu) .map((child, index) => ( - ({ header: css` diff --git a/public/app/core/components/sidemenu/SideMenuItem.test.tsx b/public/app/core/components/NavBar/NavBarItem.test.tsx similarity index 80% rename from public/app/core/components/sidemenu/SideMenuItem.test.tsx rename to public/app/core/components/NavBar/NavBarItem.test.tsx index e93f83b29b5..402b2a589f7 100644 --- a/public/app/core/components/sidemenu/SideMenuItem.test.tsx +++ b/public/app/core/components/NavBar/NavBarItem.test.tsx @@ -2,16 +2,16 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; -import SideMenuItem from './SideMenuItem'; +import NavBarItem from './NavBarItem'; -describe('SideMenuItem', () => { +describe('NavBarItem', () => { it('renders the children', () => { const mockLabel = 'Hello'; render( - +
    - + ); @@ -24,9 +24,9 @@ describe('SideMenuItem', () => { const mockUrl = '/route'; render( - +
    - + ); @@ -41,9 +41,9 @@ describe('SideMenuItem', () => { const mockOnClick = jest.fn(); render( - +
    - + ); diff --git a/public/app/core/components/sidemenu/SideMenuItem.tsx b/public/app/core/components/NavBar/NavBarItem.tsx similarity index 96% rename from public/app/core/components/sidemenu/SideMenuItem.tsx rename to public/app/core/components/NavBar/NavBarItem.tsx index c3a5d21cbdd..134d67b2b61 100644 --- a/public/app/core/components/sidemenu/SideMenuItem.tsx +++ b/public/app/core/components/NavBar/NavBarItem.tsx @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2, NavModelItem } from '@grafana/data'; import { Link, useTheme2 } from '@grafana/ui'; -import SideMenuDropDown from './SideMenuDropDown'; +import NavBarDropdown from './NavBarDropdown'; export interface Props { isActive?: boolean; @@ -16,7 +16,7 @@ export interface Props { url?: string; } -const SideMenuItem = ({ +const NavBarItem = ({ isActive = false, children, label, @@ -58,7 +58,7 @@ const SideMenuItem = ({ return (
    {element} - ({ container: css` diff --git a/public/app/core/components/sidemenu/TopSection.test.tsx b/public/app/core/components/NavBar/TopSection.test.tsx similarity index 100% rename from public/app/core/components/sidemenu/TopSection.test.tsx rename to public/app/core/components/NavBar/TopSection.test.tsx diff --git a/public/app/core/components/sidemenu/TopSection.tsx b/public/app/core/components/NavBar/TopSection.tsx similarity index 88% rename from public/app/core/components/sidemenu/TopSection.tsx rename to public/app/core/components/NavBar/TopSection.tsx index e385aa297cd..4c2b0ad2357 100644 --- a/public/app/core/components/sidemenu/TopSection.tsx +++ b/public/app/core/components/NavBar/TopSection.tsx @@ -7,7 +7,7 @@ import { locationService } from '@grafana/runtime'; import { Icon, IconName, useTheme2 } from '@grafana/ui'; import config from '../../config'; import { isLinkActive, isSearchActive } from './utils'; -import SideMenuItem from './SideMenuItem'; +import NavBarItem from './NavBarItem'; const TopSection = () => { const location = useLocation(); @@ -23,12 +23,12 @@ const TopSection = () => { return (
    - + - + {mainLinks.map((link, index) => { return ( - { > {link.icon && } {link.img && {`${link.text}} - + ); })}
    diff --git a/public/app/core/components/sidemenu/utils.test.ts b/public/app/core/components/NavBar/utils.test.ts similarity index 100% rename from public/app/core/components/sidemenu/utils.test.ts rename to public/app/core/components/NavBar/utils.test.ts diff --git a/public/app/core/components/sidemenu/utils.ts b/public/app/core/components/NavBar/utils.ts similarity index 100% rename from public/app/core/components/sidemenu/utils.ts rename to public/app/core/components/NavBar/utils.ts