From 96e31b19fa1dbfc7a5c5b4db69c4c976fc96281f Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 21 Feb 2022 14:19:13 +0100 Subject: [PATCH] [NO JIRA] Remove unused component Tabs --- .../src/main/js/components/controls/Tabs.css | 60 -------------- .../src/main/js/components/controls/Tabs.tsx | 77 ------------------ .../controls/__tests__/Tabs-test.tsx | 81 ------------------- .../__snapshots__/Tabs-test.tsx.snap | 52 ------------ 4 files changed, 270 deletions(-) delete mode 100644 server/sonar-web/src/main/js/components/controls/Tabs.css delete mode 100644 server/sonar-web/src/main/js/components/controls/Tabs.tsx delete mode 100644 server/sonar-web/src/main/js/components/controls/__tests__/Tabs-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap diff --git a/server/sonar-web/src/main/js/components/controls/Tabs.css b/server/sonar-web/src/main/js/components/controls/Tabs.css deleted file mode 100644 index 5761ae25218..00000000000 --- a/server/sonar-web/src/main/js/components/controls/Tabs.css +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -.flex-tabs { - display: flex; - clear: left; - margin-bottom: calc(3 * var(--gridSize)); - border-bottom: 1px solid var(--barBorderColor); - font-size: var(--mediumFontSize); -} - -.flex-tabs > li > a { - position: relative; - display: block; - top: 1px; - height: 100%; - width: 100%; - box-sizing: border-box; - color: var(--secondFontColor); - font-weight: 600; - cursor: pointer; - padding-bottom: calc(1.5 * var(--gridSize)); - border-bottom: 3px solid transparent; - transition: color 0.2s ease; -} - -.flex-tabs > li ~ li { - margin-left: calc(4 * var(--gridSize)); -} - -.flex-tabs > li > a:hover { - color: var(--baseFontColor); -} - -.flex-tabs > li > a.selected { - color: var(--blue); - border-bottom-color: var(--blue); -} - -.flex-tabs > li > a.disabled { - color: var(--disableGrayText) !important; - cursor: not-allowed !important; - pointer-events: none !important; -} diff --git a/server/sonar-web/src/main/js/components/controls/Tabs.tsx b/server/sonar-web/src/main/js/components/controls/Tabs.tsx deleted file mode 100644 index d5457d833b7..00000000000 --- a/server/sonar-web/src/main/js/components/controls/Tabs.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import classNames from 'classnames'; -import * as React from 'react'; -import './Tabs.css'; - -interface Props { - onChange: (tab: T) => void; - selected?: T; - tabs: Array<{ disabled?: boolean; key: T; node: React.ReactNode }>; -} - -export default function Tabs({ onChange, selected, tabs }: Props) { - return ( -
    - {tabs.map(tab => ( - - {tab.node} - - ))} -
- ); -} - -interface TabProps { - children: React.ReactNode; - disabled?: boolean; - name: T; - onSelect: (tab: T) => void; - selected: boolean; -} - -export class Tab extends React.PureComponent> { - handleClick = (event: React.MouseEvent) => { - event.preventDefault(); - event.stopPropagation(); - if (!this.props.disabled) { - this.props.onSelect(this.props.name); - } - }; - - render() { - const { children, disabled, name, selected } = this.props; - return ( -
  • - - {children} - -
  • - ); - } -} diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/Tabs-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/Tabs-test.tsx deleted file mode 100644 index 5e7be097f3a..00000000000 --- a/server/sonar-web/src/main/js/components/controls/__tests__/Tabs-test.tsx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { click } from '../../../helpers/testUtils'; -import Tabs, { Tab } from '../Tabs'; - -it('should render correctly', () => { - const wrapper = shallow( - - ); - - expect(wrapper).toMatchSnapshot(); -}); - -it('should switch tabs', () => { - const onChange = jest.fn(); - const wrapper = shallow( - - ); - - click(shallow(wrapper.find('Tab').get(0)).find('.js-foo')); - expect(onChange).toBeCalledWith('foo'); - click(shallow(wrapper.find('Tab').get(1)).find('.js-bar')); - expect(onChange).toBeCalledWith('bar'); -}); - -it('should render single tab correctly', () => { - const onSelect = jest.fn(); - const wrapper = shallow( - - Foo - - ); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onSelect).toBeCalledWith('foo'); -}); - -it('should disable single tab', () => { - const onSelect = jest.fn(); - const wrapper = shallow( - - Foo - - ); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onSelect).not.toBeCalled(); -}); diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap deleted file mode 100644 index 2db4cec05a8..00000000000 --- a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap +++ /dev/null @@ -1,52 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should disable single tab 1`] = ` -
  • - - - Foo - - -
  • -`; - -exports[`should render correctly 1`] = ` -
      - - Foo - - - Bar - -
    -`; - -exports[`should render single tab correctly 1`] = ` -
  • - - - Foo - - -
  • -`; -- 2.39.5