From 45dc7f616c7fe192a5e7ca2899f3a6126e2ad06e Mon Sep 17 00:00:00 2001 From: Arsen Simonyan <103444767+simonyandev@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:05:58 +0400 Subject: [PATCH] Add logout button UI (#1854) * add logout button ui * adding redirect to /logout Co-authored-by: rAzizbekyan Co-authored-by: Robert Azizbekyan <103438454+rAzizbekyan@users.noreply.github.com> --- .../src/components/App.styled.ts | 18 ++++++++ kafka-ui-react-app/src/components/App.tsx | 42 +++++++++++-------- .../src/components/__tests__/App.spec.tsx | 12 +++++- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/kafka-ui-react-app/src/components/App.styled.ts b/kafka-ui-react-app/src/components/App.styled.ts index b35b324828..64f3296861 100644 --- a/kafka-ui-react-app/src/components/App.styled.ts +++ b/kafka-ui-react-app/src/components/App.styled.ts @@ -1,6 +1,8 @@ import styled, { css } from 'styled-components'; import { Link } from 'react-router-dom'; +import { Button } from './common/Button/Button'; + export const Layout = styled.div` min-width: 1200px; @@ -108,6 +110,8 @@ export const Navbar = styled.nav( export const NavbarBrand = styled.div` display: flex; + justify-content: space-between; + align-items: center !important; flex-shrink: 0; align-items: stretch; min-height: 3.25rem; @@ -205,3 +209,17 @@ export const AlertsContainer = styled.div` max-width: initial; } `; + +export const LogoutButton = styled(Button)( + ({ theme }) => css` + color: ${theme.button.primary.invertedColors.normal}; + background: none !important; + padding: 0 8px; + ` +); + +export const LogoutLink = styled(Link)( + () => css` + margin-right: 16px; + ` +); diff --git a/kafka-ui-react-app/src/components/App.tsx b/kafka-ui-react-app/src/components/App.tsx index 5f4824f125..c0740f7941 100644 --- a/kafka-ui-react-app/src/components/App.tsx +++ b/kafka-ui-react-app/src/components/App.tsx @@ -44,25 +44,33 @@ const App: React.FC = () => { - - - - - + + + + + + - - - UI for Apache Kafka - + + + UI for Apache Kafka + - - {GIT_TAG && } - + + {GIT_TAG && } + + + + + Log out + + diff --git a/kafka-ui-react-app/src/components/__tests__/App.spec.tsx b/kafka-ui-react-app/src/components/__tests__/App.spec.tsx index c7cf41ecd8..9f48fb25ad 100644 --- a/kafka-ui-react-app/src/components/__tests__/App.spec.tsx +++ b/kafka-ui-react-app/src/components/__tests__/App.spec.tsx @@ -6,6 +6,9 @@ import { clustersPayload } from 'redux/reducers/clusters/__test__/fixtures'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; +const burgerButtonOptions = { name: 'burger' }; +const logoutButtonOptions = { name: 'Log out' }; + describe('App', () => { describe('initial state', () => { beforeEach(() => { @@ -24,11 +27,16 @@ describe('App', () => { within(header).getByText('UI for Apache Kafka') ).toBeInTheDocument(); expect(within(header).getAllByRole('separator').length).toEqual(3); - expect(within(header).getByRole('button')).toBeInTheDocument(); + expect( + within(header).getByRole('button', burgerButtonOptions) + ).toBeInTheDocument(); + expect( + within(header).getByRole('button', logoutButtonOptions) + ).toBeInTheDocument(); }); it('handle burger click correctly', () => { const header = screen.getByLabelText('Page Header'); - const burger = within(header).getByRole('button'); + const burger = within(header).getByRole('button', burgerButtonOptions); const sidebar = screen.getByLabelText('Sidebar'); const overlay = screen.getByLabelText('Overlay'); expect(sidebar).toBeInTheDocument();