From: Grégoire Aubert Date: Fri, 10 Mar 2017 14:32:25 +0000 (+0100) Subject: Revert some changes of 788f8da breaking the project search X-Git-Tag: 6.4-RC1~781 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35c9fca6f04c5bf3e9da0841f142005ea37ec1d6;p=sonarqube.git Revert some changes of 788f8da breaking the project search --- diff --git a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java index 29128f15556..25fe5b94f58 100644 --- a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java +++ b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java @@ -126,4 +126,13 @@ public class ProjectsPageTest { page.searchProject("s").shouldHaveTotal(2); page.searchProject("sam").shouldHaveTotal(1); } + + @Test + public void should_search_for_project_and_keep_other_filters() { + ProjectsPage page = nav.openProjects(); + page.shouldHaveTotal(2); + page.getFacetByProperty("duplications").selectValue("3"); + page.shouldHaveTotal(1); + page.searchProject("sample").shouldHaveTotal(0); + } } diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js index f4f2614ac60..a7e2788bc44 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js @@ -40,62 +40,61 @@ export default class PageSidebar extends React.PureComponent { render () { const isFiltered = Object.keys(this.props.query).some(key => this.props.query[key] != null); - const basePathName = this.props.organization ? - `/organizations/${this.props.organization.key}/projects` : - '/projects'; + const basePathName = this.props.organization + ? `/organizations/${this.props.organization.key}/projects` + : '/projects'; const pathname = basePathName + (this.props.isFavorite ? '/favorite' : ''); return ( -
-
- {isFiltered && ( -
- - {translate('projects.clear_all_filters')} - -
- )} +
+
+ {isFiltered && +
+ + {translate('projects.clear_all_filters')} + +
} -

{translate('filters')}

- -
- - - - - - - - - +

{translate('filters')}

+
+ + + + + + + + + +
); } } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js index 1bfd44d5e9f..ea5a493b33f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js @@ -17,24 +17,32 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +// @flow import React from 'react'; import classNames from 'classnames'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -export default class SearchFilter extends React.Component { - static propTypes = { - query: React.PropTypes.object.isRequired, - handleSearch: React.PropTypes.func.isRequired - } +type Props = { + handleSearch: (userString?: string) => void, + query: {} +}; + +type State = { + userQuery?: string +}; - constructor (props) { +export default class SearchFilter extends React.PureComponent { + props: Props; + state: State; + + constructor (props: Props) { super(props); this.state = { userQuery: props.query.search }; } - componentWillReceiveProps (nextProps) { + componentWillReceiveProps (nextProps: Props) { if (this.props.query.search === this.state.userQuery && nextProps.query.search !== this.props.query.search) { this.setState({ userQuery: nextProps.query.search || '' @@ -47,12 +55,12 @@ export default class SearchFilter extends React.Component { if (!target.value || target.value.length >= 2) { this.props.handleSearch(target.value); } - } + }; render () { const { userQuery } = this.state; const inputClassName = classNames('input-super-large', { - 'touched': userQuery && userQuery.length < 2 + touched: userQuery && userQuery.length < 2 }); return ( diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js index c65d92c2180..696bf7acc12 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js @@ -23,29 +23,29 @@ import debounce from 'lodash/debounce'; import { getFilterUrl } from './utils'; import SearchFilter from './SearchFilter'; +type Props = { + query: {}, + router: { push: (string) => void }, + isFavorite?: boolean, + organization?: {} +}; + class SearchFilterContainer extends React.Component { - static propTypes = { - query: React.PropTypes.object.isRequired, - isFavorite: React.PropTypes.bool, - organization: React.PropTypes.object - } + handleSearch: (userQuery?: string) => void; + props: Props; - constructor (props) { + constructor (props: Props) { super(props); this.handleSearch = debounce(this.handleSearch.bind(this), 250); } - handleSearch (userQuery) { + handleSearch (userQuery?: string) { const path = getFilterUrl(this.props, { search: userQuery || null }); this.props.router.push(path); } render () { - return ( - - ); + return ; } }