From 645082de0eba5c5a043328b2d55f3682f95a785d Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 4 Mar 2024 14:55:28 +0100 Subject: [PATCH] SONAR-21656 Remove legacy Dropdown component --- .../main/js/components/controls/Dropdown.tsx | 68 ----- .../main/js/components/controls/Toggler.tsx | 89 ------- .../controls/__tests__/Toggler-test.tsx | 237 ------------------ .../issue/components/IssueActionsBar.tsx | 20 -- .../issue/components/IssueCommentAction.tsx | 71 ------ .../components/issue/popups/CommentForm.tsx | 95 ------- .../components/issue/popups/CommentPopup.tsx | 56 ----- 7 files changed, 636 deletions(-) delete mode 100644 server/sonar-web/src/main/js/components/controls/Dropdown.tsx delete mode 100644 server/sonar-web/src/main/js/components/controls/Toggler.tsx delete mode 100644 server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx delete mode 100644 server/sonar-web/src/main/js/components/issue/popups/CommentForm.tsx delete mode 100644 server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx diff --git a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx b/server/sonar-web/src/main/js/components/controls/Dropdown.tsx deleted file mode 100644 index 96cf2efb049..00000000000 --- a/server/sonar-web/src/main/js/components/controls/Dropdown.tsx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 * as React from 'react'; -import { Popup, PopupPlacement } from '../ui/popups'; -import ScreenPositionFixer from './ScreenPositionFixer'; - -interface OverlayProps { - className?: string; - children: React.ReactNode; - noPadding?: boolean; - placement?: PopupPlacement; - useEventBoundary?: boolean; -} - -export class DropdownOverlay extends React.Component { - get placement() { - return this.props.placement || PopupPlacement.Bottom; - } - - renderPopup = (leftFix?: number, topFix?: number) => ( - - {this.props.children} - - ); - - render() { - if (this.placement === PopupPlacement.Bottom) { - return ( - - {({ leftFix, topFix }) => this.renderPopup(leftFix, topFix)} - - ); - } - return this.renderPopup(); - } -} diff --git a/server/sonar-web/src/main/js/components/controls/Toggler.tsx b/server/sonar-web/src/main/js/components/controls/Toggler.tsx deleted file mode 100644 index 125d7a63b7b..00000000000 --- a/server/sonar-web/src/main/js/components/controls/Toggler.tsx +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 * as React from 'react'; -import DocumentClickHandler from './DocumentClickHandler'; -import EscKeydownHandler from './EscKeydownHandler'; -import FocusOutHandler from './FocusOutHandler'; -import OutsideClickHandler from './OutsideClickHandler'; -import UpDownKeyboardHanlder from './UpDownKeyboardHandler'; - -interface Props { - children?: React.ReactNode; - closeOnClick?: boolean; - closeOnClickOutside?: boolean; - closeOnEscape?: boolean; - closeOnFocusOut?: boolean; - navigateWithKeyboard?: boolean; - onRequestClose: () => void; - open: boolean; - overlay: React.ReactNode; -} - -export default class Toggler extends React.Component { - renderOverlay() { - const { - closeOnClick = false, - closeOnClickOutside = true, - closeOnEscape = true, - closeOnFocusOut = true, - navigateWithKeyboard = true, - onRequestClose, - overlay, - } = this.props; - - let renderedOverlay = overlay; - - if (navigateWithKeyboard) { - renderedOverlay = {renderedOverlay}; - } - - if (closeOnFocusOut) { - renderedOverlay = ( - {renderedOverlay} - ); - } - - if (closeOnEscape) { - renderedOverlay = ( - {renderedOverlay} - ); - } - - if (closeOnClick) { - return ( - {renderedOverlay} - ); - } else if (closeOnClickOutside) { - return ( - {renderedOverlay} - ); - } - return renderedOverlay; - } - - render() { - return ( - <> - {this.props.children} - {this.props.open && this.renderOverlay()} - - ); - } -} diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx deleted file mode 100644 index 4b8352ff59b..00000000000 --- a/server/sonar-web/src/main/js/components/controls/__tests__/Toggler-test.tsx +++ /dev/null @@ -1,237 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 { render } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; -import * as React from 'react'; -import { byRole } from '../../../helpers/testSelector'; -import Toggler from '../Toggler'; - -const ui = { - toggleButton: byRole('button', { name: 'toggle' }), - outButton: byRole('button', { name: 'out' }), - overlayButton: byRole('button', { name: 'overlay' }), - nextOverlayButton: byRole('button', { name: 'next overlay' }), - overlayTextarea: byRole('textbox'), - overlayLatButton: byRole('button', { name: 'last' }), -}; - -async function openToggler(user: UserEvent) { - await user.click(ui.toggleButton.get()); - expect(ui.overlayButton.get()).toBeInTheDocument(); -} - -async function focusOut() { - await userEvent.click(ui.outButton.get()); -} - -it('should handle key up/down', async () => { - const user = userEvent.setup({ delay: null }); - const rerender = renderToggler( - {}, - <> -