aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Perrin <philippe.perrin@sonarsource.com>2022-04-13 13:37:50 +0200
committersonartech <sonartech@sonarsource.com>2022-04-13 20:03:17 +0000
commita7ec93c39c39d487f67e7bbfa0cda4d4999c0bdc (patch)
tree173e35e48d7138ebf92f78d915b71fe0460e3af8
parentb3421b53d4da4ae97625a5e147d8f1fe06af0251 (diff)
downloadsonarqube-a7ec93c39c39d487f67e7bbfa0cda4d4999c0bdc.tar.gz
sonarqube-a7ec93c39c39d487f67e7bbfa0cda4d4999c0bdc.zip
SONAR-16093 Remove SelectLegacy dependency
-rw-r--r--server/sonar-web/package.json2
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts2
-rw-r--r--server/sonar-web/src/main/js/components/controls/SelectLegacy.tsx58
-rw-r--r--server/sonar-web/src/main/js/components/controls/__tests__/SelectLegacy-test.tsx84
-rw-r--r--server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SelectLegacy-test.tsx.snap50
-rw-r--r--server/sonar-web/yarn.lock38
6 files changed, 1 insertions, 233 deletions
diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json
index c49173640a5..8df1496ed3b 100644
--- a/server/sonar-web/package.json
+++ b/server/sonar-web/package.json
@@ -35,7 +35,6 @@
"react-redux": "5.1.1",
"react-router": "3.2.6",
"react-select": "4.3.1",
- "react-select-legacy": "npm:react-select@1.2.1",
"react-virtualized": "9.22.3",
"redux": "4.1.2",
"redux-thunk": "2.4.1",
@@ -78,7 +77,6 @@
"@types/react-redux": "6.0.6",
"@types/react-router": "3.0.20",
"@types/react-select": "4.0.16",
- "@types/react-select-legacy": "npm:@types/react-select@1.2.6",
"@types/react-virtualized": "9.21.20",
"@types/valid-url": "1.0.3",
"@typescript-eslint/eslint-plugin": "4.33.0",
diff --git a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
index 429cb1ae374..7650130479e 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
+++ b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
@@ -42,7 +42,6 @@ import RadioToggle from '../../../components/controls/RadioToggle';
import ReloadButton from '../../../components/controls/ReloadButton';
import SearchBox from '../../../components/controls/SearchBox';
import Select, { SearchSelect } from '../../../components/controls/Select';
-import SelectLegacy from '../../../components/controls/SelectLegacy';
import SelectList, { SelectListFilter } from '../../../components/controls/SelectList';
import SimpleModal from '../../../components/controls/SimpleModal';
import Tooltip from '../../../components/controls/Tooltip';
@@ -247,7 +246,6 @@ const exposeLibraries = () => {
SearchSelect,
SecurityHotspotIcon,
Select,
- SelectLegacy,
SelectList,
SelectListFilter,
SimpleModal,
diff --git a/server/sonar-web/src/main/js/components/controls/SelectLegacy.tsx b/server/sonar-web/src/main/js/components/controls/SelectLegacy.tsx
deleted file mode 100644
index d4906283a82..00000000000
--- a/server/sonar-web/src/main/js/components/controls/SelectLegacy.tsx
+++ /dev/null
@@ -1,58 +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 * as React from 'react';
-import ReactSelectClass, {
- ReactAsyncSelectProps,
- ReactCreatableSelectProps,
- ReactSelectProps
-} from 'react-select-legacy';
-import { lazyLoadComponent } from '../lazyLoadComponent';
-import { ClearButton } from './buttons';
-
-const ReactSelectLib = import('react-select-legacy');
-const ReactSelect = lazyLoadComponent(() => ReactSelectLib);
-const ReactCreatable = lazyLoadComponent(() =>
- ReactSelectLib.then(lib => ({ default: lib.Creatable }))
-);
-const ReactAsync = lazyLoadComponent(() => ReactSelectLib.then(lib => ({ default: lib.Async })));
-
-function renderInput() {
- return <ClearButton className="button-tiny spacer-left text-middle" iconProps={{ size: 12 }} />;
-}
-
-export interface WithInnerRef {
- innerRef?: React.Ref<ReactSelectClass<unknown>>;
-}
-
-export default function SelectLegacy({ innerRef, ...props }: WithInnerRef & ReactSelectProps) {
- // hide the "x" icon when select is empty
- const clearable = props.clearable ? Boolean(props.value) : false;
- return (
- <ReactSelect {...props} clearable={clearable} clearRenderer={renderInput} ref={innerRef} />
- );
-}
-
-export function CreatableLegacy(props: ReactCreatableSelectProps) {
- return <ReactCreatable {...props} clearRenderer={renderInput} />;
-}
-
-export function AsyncSelectLegacy(props: ReactAsyncSelectProps & WithInnerRef) {
- return <ReactAsync {...props} />;
-}
diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/SelectLegacy-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/SelectLegacy-test.tsx
deleted file mode 100644
index 2208185dd53..00000000000
--- a/server/sonar-web/src/main/js/components/controls/__tests__/SelectLegacy-test.tsx
+++ /dev/null
@@ -1,84 +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 {
- ReactAsyncSelectProps,
- ReactCreatableSelectProps,
- ReactSelectProps
-} from 'react-select-legacy';
-import SelectLegacy, { AsyncSelectLegacy, CreatableLegacy, WithInnerRef } from '../SelectLegacy';
-
-describe('Select', () => {
- it('should render correctly', () => {
- return new Promise<void>((resolve, reject) => {
- expect(shallowRender()).toMatchSnapshot('default');
- expect(shallowRender({ clearable: true, value: undefined })).toMatchSnapshot(
- 'disable clear button if no value'
- );
-
- const clearRenderFn = shallowRender().props().clearRenderer;
- if (!clearRenderFn) {
- reject();
- return;
- }
- expect(clearRenderFn()).toMatchSnapshot('clear button');
-
- resolve();
- });
- });
-
- function shallowRender(props: Partial<WithInnerRef & ReactSelectProps> = {}) {
- return shallow<WithInnerRef & ReactSelectProps>(<SelectLegacy value="foo" {...props} />);
- }
-});
-
-describe('Creatable', () => {
- it('should render correctly', () => {
- return new Promise<void>((resolve, reject) => {
- expect(shallowRender()).toMatchSnapshot('default');
-
- const clearRenderFn = shallowRender().props().clearRenderer;
- if (!clearRenderFn) {
- reject();
- return;
- }
- expect(clearRenderFn()).toMatchSnapshot('clear button');
-
- resolve();
- });
- });
-
- function shallowRender(props: Partial<ReactCreatableSelectProps> = {}) {
- return shallow<ReactCreatableSelectProps>(<CreatableLegacy {...props} />);
- }
-});
-
-describe('AsyncSelect', () => {
- it('should render correctly', () => {
- expect(shallowRender()).toMatchSnapshot('default');
- });
-
- function shallowRender(props: Partial<WithInnerRef & ReactAsyncSelectProps> = {}) {
- return shallow<WithInnerRef & ReactAsyncSelectProps>(
- <AsyncSelectLegacy loadOptions={jest.fn()} {...props} />
- );
- }
-});
diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SelectLegacy-test.tsx.snap b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SelectLegacy-test.tsx.snap
deleted file mode 100644
index c96f416934c..00000000000
--- a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SelectLegacy-test.tsx.snap
+++ /dev/null
@@ -1,50 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AsyncSelect should render correctly: default 1`] = `
-<LazyComponentWrapper
- loadOptions={[MockFunction]}
-/>
-`;
-
-exports[`Creatable should render correctly: clear button 1`] = `
-<ClearButton
- className="button-tiny spacer-left text-middle"
- iconProps={
- Object {
- "size": 12,
- }
- }
-/>
-`;
-
-exports[`Creatable should render correctly: default 1`] = `
-<LazyComponentWrapper
- clearRenderer={[Function]}
-/>
-`;
-
-exports[`Select should render correctly: clear button 1`] = `
-<ClearButton
- className="button-tiny spacer-left text-middle"
- iconProps={
- Object {
- "size": 12,
- }
- }
-/>
-`;
-
-exports[`Select should render correctly: default 1`] = `
-<LazyComponentWrapper
- clearRenderer={[Function]}
- clearable={false}
- value="foo"
-/>
-`;
-
-exports[`Select should render correctly: disable clear button if no value 1`] = `
-<LazyComponentWrapper
- clearRenderer={[Function]}
- clearable={false}
-/>
-`;
diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock
index b704409f7b3..666869997a2 100644
--- a/server/sonar-web/yarn.lock
+++ b/server/sonar-web/yarn.lock
@@ -2043,15 +2043,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/react-select-legacy@npm:@types/react-select@1.2.6":
- version: 1.2.6
- resolution: "@types/react-select@npm:1.2.6"
- dependencies:
- "@types/react": "*"
- checksum: ab22a7d050bc6e3bc5fbe19d9d89c5df458a0b748acace3bacfbc3d03c906775f2cf7864e13e87865d5fe0d6641a055c4907b7adf7cf3b2b038cf1466cebec07
- languageName: node
- linkType: hard
-
"@types/react-select@npm:4.0.16":
version: 4.0.16
resolution: "@types/react-select@npm:4.0.16"
@@ -2340,7 +2331,6 @@ __metadata:
"@types/react-redux": 6.0.6
"@types/react-router": 3.0.20
"@types/react-select": 4.0.16
- "@types/react-select-legacy": "npm:@types/react-select@1.2.6"
"@types/react-virtualized": 9.21.20
"@types/valid-url": 1.0.3
"@typescript-eslint/eslint-plugin": 4.33.0
@@ -2402,7 +2392,6 @@ __metadata:
react-router: 3.2.6
react-select: 4.3.1
react-select-event: 5.4.0
- react-select-legacy: "npm:react-select@1.2.1"
react-virtualized: 9.22.3
redux: 4.1.2
redux-thunk: 2.4.1
@@ -3299,7 +3288,7 @@ __metadata:
languageName: node
linkType: hard
-"classnames@npm:*, classnames@npm:2.3.1, classnames@npm:^2.2.4":
+"classnames@npm:*, classnames@npm:2.3.1":
version: 2.3.1
resolution: "classnames@npm:2.3.1"
checksum: 14db8889d56c267a591f08b0834989fe542d47fac659af5a539e110cc4266694e8de86e4e3bbd271157dbd831361310a8293e0167141e80b0f03a0f175c80960
@@ -9115,17 +9104,6 @@ __metadata:
languageName: node
linkType: hard
-"react-input-autosize@npm:^2.1.2":
- version: 2.2.2
- resolution: "react-input-autosize@npm:2.2.2"
- dependencies:
- prop-types: ^15.5.8
- peerDependencies:
- react: ^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0
- checksum: 5164cbbff5091618f889a2a68368ef95460423dd3addd32d7db7cbde2f880816552ed750839baa278b28c210d77b9e3fbae48faf62ba90f3838abef1cfde58e6
- languageName: node
- linkType: hard
-
"react-input-autosize@npm:^3.0.0":
version: 3.0.0
resolution: "react-input-autosize@npm:3.0.0"
@@ -9254,20 +9232,6 @@ __metadata:
languageName: node
linkType: hard
-"react-select-legacy@npm:react-select@1.2.1":
- version: 1.2.1
- resolution: "react-select@npm:1.2.1"
- dependencies:
- classnames: ^2.2.4
- prop-types: ^15.5.8
- react-input-autosize: ^2.1.2
- peerDependencies:
- react: ^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0
- react-dom: ^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0
- checksum: 9ffa62be99dc4d6e8170093fc2acfe44bdcc1bf96b5564c12094afa537302fe17309260b847f53c3fbdd9c283c20b8548cbafe7145786e004bcf96211ec21cb0
- languageName: node
- linkType: hard
-
"react-select@npm:4.3.1":
version: 4.3.1
resolution: "react-select@npm:4.3.1"