From 5d6e45f4c20587aba520ffbaf0d7e60820f1e958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Tue, 30 Apr 2024 08:37:28 +0200 Subject: [PATCH] Change: Remove obsolete TitleBar component The TitleBar is not used anymore. --- src/web/components/bar/__tests__/titlebar.jsx | 60 --------- src/web/components/bar/titlebar.jsx | 117 ------------------ 2 files changed, 177 deletions(-) delete mode 100644 src/web/components/bar/__tests__/titlebar.jsx delete mode 100644 src/web/components/bar/titlebar.jsx diff --git a/src/web/components/bar/__tests__/titlebar.jsx b/src/web/components/bar/__tests__/titlebar.jsx deleted file mode 100644 index 2381f8c37f..0000000000 --- a/src/web/components/bar/__tests__/titlebar.jsx +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2019-2022 Greenbone AG - * - * SPDX-License-Identifier: AGPL-3.0-or-later - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -import {describe, test, expect} from '@gsa/testing'; - -import {rendererWith} from 'web/utils/testing'; - -import Titlebar from '../titlebar'; -import {setIsLoggedIn, setUsername} from 'web/store/usersettings/actions'; - -import {setLocale} from 'gmp/locale/lang'; - -setLocale('en'); - -describe('Titlebar tests', () => { - test('should render content if user is logged in', () => { - const gmp = {settings: {vendorVersion: ''}}; - - const {render, store} = rendererWith({gmp, router: true, store: true}); - - store.dispatch(setUsername('username')); - store.dispatch(setIsLoggedIn(true)); - - const {baseElement, getByTestId} = render(); - const menuElement = getByTestId('usermenu'); - - expect(baseElement).toMatchSnapshot(); - expect(menuElement).toBeDefined(); - expect(baseElement).not.toHaveTextContent('Vendor Version'); - }); - - test('should not render content if user is logged out', () => { - const gmp = {settings: {vendorVersion: 'Vendor Version'}}; - - const {render, store} = rendererWith({gmp, router: true, store: true}); - - store.dispatch(setUsername('username')); - store.dispatch(setIsLoggedIn(false)); - - const {baseElement} = render(); - - expect(baseElement).toMatchSnapshot(); - expect(baseElement).not.toHaveTextContent('username'); - expect(baseElement).toHaveTextContent('Vendor Version'); - }); -}); diff --git a/src/web/components/bar/titlebar.jsx b/src/web/components/bar/titlebar.jsx deleted file mode 100644 index 33568c7da9..0000000000 --- a/src/web/components/bar/titlebar.jsx +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2016-2022 Greenbone AG - * - * SPDX-License-Identifier: AGPL-3.0-or-later - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import React from 'react'; - -import {connect} from 'react-redux'; - -import styled from 'styled-components'; - -import _ from 'gmp/locale'; - -import Logo from 'web/components/img/greenbone'; -import Img from 'web/components/img/img'; - -import Layout from 'web/components/layout/layout'; - -import Link from 'web/components/link/link'; - -import UserMenu from 'web/components/menu/usermenu'; - -import {isLoggedIn} from 'web/store/usersettings/selectors'; - -import PropTypes from 'web/utils/proptypes'; -import Theme from 'web/utils/theme'; -import useGmp from 'web/utils/useGmp'; - -const TITLE_BAR_HEIGHT = '42px'; - -const GreenboneIcon = styled(Logo)` - width: 40px; - height: 40px; - margin-right: 4px; - margin-top: 1px; - margin-bottom: 1px; -`; - -const GsaIcon = styled(Img)` - height: 40px; - padding-top: 1px; - padding-bottom: 1px; -`; - -const Greenbone = () => ( - - - - -); - -const TitlebarLayout = styled.div` - display: flex; - justify-content: space-between; - align-items: center; - height: ${TITLE_BAR_HEIGHT}; - background-color: ${Theme.green}; - padding: 0px 5px 0px 5px; - position: fixed; - top: 0; - left: 0; - right: 0; - z-index: ${Theme.Layers.menu}; -`; - -const TitlebarPlaceholder = styled.div` - height: ${TITLE_BAR_HEIGHT}; -`; - -const Titlebar = ({loggedIn}) => { - const gmp = useGmp(); - return ( - - - - {loggedIn ? ( - - - - - - - ) : ( - - -
{gmp.settings.vendorVersion}
-
- )} -
-
- ); -} - -Titlebar.propTypes = { - loggedIn: PropTypes.bool.isRequired, -}; - -const mapStateToProps = rootState => ({ - loggedIn: isLoggedIn(rootState), -}); - -export default connect(mapStateToProps)(Titlebar); - -// vim: set ts=2 sw=2 tw=80: