From 45ded483c3a4a70112f4db19d31baa67a349ac44 Mon Sep 17 00:00:00 2001 From: Revanshu Paliwal Date: Wed, 30 Mar 2022 14:35:03 +0200 Subject: [PATCH] SONAR-16089 Remove select legacy from permission, projectActivity and projectManagement --- .../filters/SearchableFilterFooter.tsx | 22 +++- .../__tests__/SearchableFilterFooter-test.tsx | 30 ++++- .../SearchableFilterFooter-test.tsx.snap | 17 +++ .../BulkApplyTemplateModal.tsx | 46 +++++--- .../js/apps/projectsManagement/Search.tsx | 60 ++++++---- .../__tests__/BulkApplyTemplateModal-test.tsx | 22 ++++ .../__tests__/Search-test.tsx | 19 +++- .../BulkApplyTemplateModal-test.tsx.snap | 106 ++++++++++++++---- .../__snapshots__/Search-test.tsx.snap | 102 ++++++++++++++--- 9 files changed, 341 insertions(+), 83 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx index f789c1fdb3d..db7a854de11 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx @@ -18,7 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import SelectLegacy from '../../../components/controls/SelectLegacy'; +import { components, InputProps, OptionProps } from 'react-select'; +import Select from '../../../components/controls/Select'; import { translate } from '../../../helpers/l10n'; import { Dict, RawQuery } from '../../../types/types'; @@ -39,19 +40,32 @@ export default class SearchableFilterFooter extends React.PureComponent { this.props.onQueryChange({ [this.props.property]: urlOptions }); }; + optionRenderer = (props: OptionProps<{ value: string }, false>) => ( + + ); + + inputRenderer = (props: InputProps) => ( + + ); + render() { return (
-
); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchableFilterFooter-test.tsx b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchableFilterFooter-test.tsx index 6d4d3024347..2568a0ced0e 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchableFilterFooter-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchableFilterFooter-test.tsx @@ -19,7 +19,12 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import SelectLegacy from '../../../../components/controls/SelectLegacy'; +import { SelectComponentsProps } from 'react-select/src/Select'; +import { + mockReactSelectInputProps, + mockReactSelectOptionProps +} from '../../../../helpers/mocks/react-select'; +import Select from '../../../../components/controls/Select'; import SearchableFilterFooter from '../SearchableFilterFooter'; const options = [ @@ -37,7 +42,7 @@ it('should render items without the ones in the facet', () => { query={{ languages: ['java'] }} /> ); - expect(wrapper.find(SelectLegacy).prop('options')).toMatchSnapshot(); + expect(wrapper.find(Select).props().options).toMatchSnapshot(); }); it('should properly handle a change of the facet value', () => { @@ -50,6 +55,25 @@ it('should properly handle a change of the facet value', () => { query={{ languages: ['java'] }} /> ); - (wrapper.find(SelectLegacy).prop('onChange') as Function)({ value: 'js' }); + wrapper.find(Select).simulate('change', { value: 'js' }); expect(onQueryChange).toBeCalledWith({ languages: 'java,js' }); }); + +it('renders optionrenderer and inputrenderer', () => { + const wrapper = shallow( + + ); + const OptionRendererer = wrapper.instance().optionRenderer; + const InputRendererer = wrapper.instance().inputRenderer; + expect( + shallow() + ).toMatchSnapshot('option renderer'); + expect(shallow()).toMatchSnapshot( + 'input renderer' + ); +}); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchableFilterFooter-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchableFilterFooter-test.tsx.snap index 6cf27012dfd..1da4f7f6256 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchableFilterFooter-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchableFilterFooter-test.tsx.snap @@ -1,5 +1,22 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`renders optionrenderer and inputrenderer: input renderer 1`] = ` + +`; + +exports[`renders optionrenderer and inputrenderer: option renderer 1`] = ` +