diff --git a/public/app/core/components/sidemenu/BottomSection.test.tsx b/public/app/core/components/sidemenu/BottomSection.test.tsx index e0dca14ef2c..891c59b4937 100644 --- a/public/app/core/components/sidemenu/BottomSection.test.tsx +++ b/public/app/core/components/sidemenu/BottomSection.test.tsx @@ -1,11 +1,15 @@ 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 { ShowModalReactEvent } from '../../../types/events'; import { HelpModal } from '../help/HelpModal'; import appEvents from '../../app_events'; import BottomSection from './BottomSection'; +jest.mock('./utils', () => ({ + getForcedLoginUrl: () => '/mockForcedLoginUrl', +})); jest.mock('../../app_events', () => ({ publish: jest.fn(), })); @@ -44,13 +48,21 @@ jest.mock('app/core/services/context_srv', () => ({ describe('BottomSection', () => { it('should render the correct children', () => { - render(); + render( + + + + ); expect(screen.getByTestId('bottom-section-items').children.length).toBe(3); }); it('creates the correct children for the help link', () => { - render(); + render( + + + + ); const documentation = screen.getByRole('link', { name: 'Documentation' }); const support = screen.getByRole('link', { name: 'Support' }); @@ -63,7 +75,11 @@ describe('BottomSection', () => { }); it('clicking the keyboard shortcuts button shows the modal', () => { - render(); + render( + + + + ); const keyboardShortcuts = screen.getByText('Keyboard shortcuts'); expect(keyboardShortcuts).toBeInTheDocument(); @@ -73,7 +89,11 @@ describe('BottomSection', () => { }); it('shows the current organization and organization switcher if showOrgSwitcher is true', () => { - render(); + render( + + + + ); const currentOrg = screen.getByText(new RegExp('Grafana', 'i')); const orgSwitcher = screen.getByText('Switch organization'); diff --git a/public/app/core/components/sidemenu/BottomSection.tsx b/public/app/core/components/sidemenu/BottomSection.tsx index 5677d5d670b..d094df99b4b 100644 --- a/public/app/core/components/sidemenu/BottomSection.tsx +++ b/public/app/core/components/sidemenu/BottomSection.tsx @@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'; import { NavModelItem } from '@grafana/data'; import { Icon, IconName } from '@grafana/ui'; import appEvents from '../../app_events'; -import { SignIn } from './SignIn'; +import { useLocation } from 'react-router-dom'; import SideMenuItem from './SideMenuItem'; import { ShowModalReactEvent } from '../../../types/events'; import { contextSrv } from 'app/core/services/context_srv'; @@ -11,11 +11,14 @@ import { OrgSwitcher } from '../OrgSwitcher'; import { getFooterLinks } from '../Footer/Footer'; import { HelpModal } from '../help/HelpModal'; import config from '../../config'; +import { getForcedLoginUrl } from './utils'; export default function BottomSection() { const navTree: NavModelItem[] = cloneDeep(config.bootData.navTree); const bottomNav = navTree.filter((item) => item.hideFromMenu); const isSignedIn = contextSrv.isSignedIn; + const location = useLocation(); + const forcedLoginUrl = getForcedLoginUrl(location.pathname + location.search); const user = contextSrv.user; const [showSwitcherModal, setShowSwitcherModal] = useState(false); @@ -37,7 +40,11 @@ export default function BottomSection() { return (
- {!isSignedIn && } + {!isSignedIn && ( + + + + )} {bottomNav.map((link, index) => { let menuItems = link.children || []; diff --git a/public/app/core/components/sidemenu/SideMenuDropDown.tsx b/public/app/core/components/sidemenu/SideMenuDropDown.tsx index bec8ecac45f..a7371b58bc6 100644 --- a/public/app/core/components/sidemenu/SideMenuDropDown.tsx +++ b/public/app/core/components/sidemenu/SideMenuDropDown.tsx @@ -2,7 +2,7 @@ import React from 'react'; import DropDownChild from './DropDownChild'; import { NavModelItem } from '@grafana/data'; import { IconName, Link } from '@grafana/ui'; -import { css, cx } from '@emotion/css'; +import { css } from '@emotion/css'; interface Props { headerText: string; @@ -21,17 +21,13 @@ const SideMenuDropDown = ({ reverseDirection = false, subtitleText, }: Props) => { - const resetButtonStyles = css` - background-color: transparent; - font-size: inherit; - `; const headerContent = {headerText}; const header = headerUrl ? ( {headerContent} ) : ( - ); diff --git a/public/app/core/components/sidemenu/SideMenuItem.tsx b/public/app/core/components/sidemenu/SideMenuItem.tsx index 7a39cdb583f..325553abaf0 100644 --- a/public/app/core/components/sidemenu/SideMenuItem.tsx +++ b/public/app/core/components/sidemenu/SideMenuItem.tsx @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'; import SideMenuDropDown from './SideMenuDropDown'; import { Link } from '@grafana/ui'; import { NavModelItem } from '@grafana/data'; -import { css, cx } from '@emotion/css'; +import { cx } from '@emotion/css'; export interface Props { children: ReactNode; @@ -25,10 +25,6 @@ const SideMenuItem = ({ target, url, }: Props) => { - const resetButtonStyles = css` - background-color: transparent; - `; - const anchor = url ? ( {children} ) : ( - ); diff --git a/public/app/core/components/sidemenu/SignIn.test.tsx b/public/app/core/components/sidemenu/SignIn.test.tsx deleted file mode 100644 index b57391fb5ef..00000000000 --- a/public/app/core/components/sidemenu/SignIn.test.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import { SignIn } from './SignIn'; -import { Router } from 'react-router-dom'; -import { locationService } from '@grafana/runtime'; - -describe('Render', () => { - it('should render component', async () => { - render( - - - - ); - - const link = await screen.getByText('Sign In'); - expect(link).toBeInTheDocument(); - }); -}); diff --git a/public/app/core/components/sidemenu/SignIn.tsx b/public/app/core/components/sidemenu/SignIn.tsx deleted file mode 100644 index 10a7db9637a..00000000000 --- a/public/app/core/components/sidemenu/SignIn.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React, { FC } from 'react'; -import { Icon } from '@grafana/ui'; -import { useLocation } from 'react-router-dom'; -import { getForcedLoginUrl } from './utils'; - -export const SignIn: FC = () => { - const location = useLocation(); - const forcedLoginUrl = getForcedLoginUrl(location.pathname + location.search); - - return ( - - ); -}; diff --git a/public/sass/components/_sidemenu.scss b/public/sass/components/_sidemenu.scss index afa778e7304..bcf555ec015 100644 --- a/public/sass/components/_sidemenu.scss +++ b/public/sass/components/_sidemenu.scss @@ -85,6 +85,7 @@ $mobile-menu-breakpoint: md; } .sidemenu-link { + background-color: transparent; color: $side-menu-icon-color !important; line-height: 42px; padding: 0px 10px 0px 10px; @@ -132,8 +133,10 @@ $mobile-menu-breakpoint: md; } .side-menu-header-link { - color: $side-menu-header-color !important; + background-color: transparent; border: none !important; + color: $side-menu-header-color !important; + font-size: inherit; padding: 0 !important; }