]> source.dussan.org Git - sonarqube.git/commitdiff
Revert some changes of 788f8da breaking the project search
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 10 Mar 2017 14:32:25 +0000 (15:32 +0100)
committerGrégoire Aubert <gregaubert@users.noreply.github.com>
Mon, 13 Mar 2017 09:03:16 +0000 (10:03 +0100)
it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java
server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js
server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js
server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js

index 29128f155566b043ee1267287c5a08729b833dab..25fe5b94f58fed954122a9c1f02b43b6d1401de5 100644 (file)
@@ -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);
+  }
 }
index f4f2614ac60e877e0b703acb6f54e0cdc583990a..a7e2788bc445b11461888322ea37bab236c9a1a2 100644 (file)
@@ -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 (
-        <div className="search-navigator-facets-list">
-          <div className="projects-facets-header clearfix">
-            {isFiltered && (
-                <div className="projects-facets-reset">
-                  <Link to={pathname} className="button button-red">
-                    {translate('projects.clear_all_filters')}
-                  </Link>
-                </div>
-            )}
+      <div className="search-navigator-facets-list">
+        <div className="projects-facets-header clearfix">
+          {isFiltered &&
+            <div className="projects-facets-reset">
+              <Link to={pathname} className="button button-red">
+                {translate('projects.clear_all_filters')}
+              </Link>
+            </div>}
 
-            <h3>{translate('filters')}</h3>
-            <SearchFilterContainer
-                query={this.props.query.search}
-                isFavorite={this.props.isFavorite}
-                organization={this.props.organization}/>
-          </div>
-
-          <QualityGateFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <ReliabilityFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <SecurityFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <MaintainabilityFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <CoverageFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <DuplicationsFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <SizeFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
-          <LanguageFilter
-              query={this.props.query}
-              isFavorite={this.props.isFavorite}
-              organization={this.props.organization}/>
+          <h3>{translate('filters')}</h3>
+          <SearchFilterContainer
+            query={this.props.query}
+            isFavorite={this.props.isFavorite}
+            organization={this.props.organization}/>
         </div>
+
+        <QualityGateFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <ReliabilityFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <SecurityFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <MaintainabilityFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <CoverageFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <DuplicationsFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <SizeFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+        <LanguageFilter
+          query={this.props.query}
+          isFavorite={this.props.isFavorite}
+          organization={this.props.organization}/>
+      </div>
     );
   }
 }
index 1bfd44d5e9fe65d0abec859b6d219b7a10f9b96c..ea5a493b33fa37ad6bffa33468f758b176ae35ff 100644 (file)
  * 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 (
index c65d92c21801792b1f74f2ffe447afac7c2e23c4..696bf7acc127b39a5d3f1f4e3961f4e324548235 100644 (file)
@@ -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 (
-      <SearchFilter
-        query={this.props.query}
-        handleSearch={this.handleSearch}/>
-    );
+    return <SearchFilter query={this.props.query} handleSearch={this.handleSearch}/>;
   }
 }