import SecurityFilter from '../filters/SecurityFilter';
import MaintainabilityFilter from '../filters/MaintainabilityFilter';
import LanguageFilter from '../filters/LanguageFilter';
-import SearchFilter from '../filters/SearchFilter';
+import SearchFilterContainer from '../filters/SearchFilterContainer';
import { translate } from '../../../helpers/l10n';
export default class PageSidebar extends React.PureComponent {
)}
<h3>{translate('filters')}</h3>
- <SearchFilter
+ <SearchFilterContainer
query={this.props.query.search}
isFavorite={this.props.isFavorite}
organization={this.props.organization}/>
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import FilterContainer from './FilterContainer';
+import { FilterContainer } from './containers';
import SortingFilter from './SortingFilter';
import CoverageRating from '../../../components/ui/CoverageRating';
import { getCoverageRatingLabel, getCoverageRatingAverageValue } from '../../../helpers/ratings';
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import FilterContainer from './FilterContainer';
+import { FilterContainer } from './containers';
import SortingFilter from './SortingFilter';
import DuplicationsRating from '../../../components/ui/DuplicationsRating';
import {
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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 { connect } from 'react-redux';
-import { withRouter } from 'react-router';
-import Filter from './Filter';
-import { getProjectsAppFacetByProperty, getProjectsAppMaxFacetValue } from '../../../store/rootReducer';
-
-const mapStateToProps = (state, ownProps) => ({
- value: ownProps.query[ownProps.property],
- facet: getProjectsAppFacetByProperty(state, ownProps.property),
- maxFacetValue: getProjectsAppMaxFacetValue(state),
- // override query value to avoid re-rendering
- query: undefined
-});
-
-export default connect(mapStateToProps)(withRouter(Filter));
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import FilterContainer from './FilterContainer';
+import { FilterContainer } from './containers';
import SortingFilter from './SortingFilter';
import Rating from '../../../components/ui/Rating';
*/
import React from 'react';
import sortBy from 'lodash/sortBy';
-import FilterContainer from './FilterContainer';
-import LanguageFilterOption from './LanguageFilterOption';
-import LanguageFilterFooter from './LanguageFilterFooter';
+import {
+ FilterContainer,
+ LanguageFilterFooterContainer,
+ LanguageFilterOptionContainer
+} from './containers';
export default class LanguageFilter extends React.PureComponent {
static propTypes = {
property = 'languages';
renderOption = option => {
- return <LanguageFilterOption languageKey={option}/>;
+ return <LanguageFilterOptionContainer languageKey={option}/>;
};
getSortedOptions (facet) {
}
renderFooter = () => (
- <LanguageFilterFooter
+ <LanguageFilterFooterContainer
property={this.property}
query={this.props.query}
isFavorite={this.props.isFavorite}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import { connect } from 'react-redux';
-import { withRouter } from 'react-router';
import Select from 'react-select';
import difference from 'lodash/difference';
import { getFilterUrl } from './utils';
-import { getProjectsAppFacetByProperty, getLanguages } from '../../../store/rootReducer';
import { translate } from '../../../helpers/l10n';
-class LanguageFilterFooter extends React.Component {
+export default class LanguageFilterFooter extends React.Component {
static propTypes = {
property: React.PropTypes.string.isRequired,
query: React.PropTypes.object.isRequired,
- isFavorite: React.PropTypes.bool,
- organization: React.PropTypes.object,
languages: React.PropTypes.object,
value: React.PropTypes.any,
facet: React.PropTypes.object
);
}
}
-
-const mapStateToProps = (state, ownProps) => ({
- languages: getLanguages(state),
- value: ownProps.query[ownProps.property],
- facet: getProjectsAppFacetByProperty(state, ownProps.property)
-});
-
-export default connect(mapStateToProps)(withRouter(LanguageFilterFooter));
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { connect } from 'react-redux';
import React from 'react';
import { translate } from '../../../helpers/l10n';
-import { getLanguageByKey } from '../../../store/rootReducer';
-class LanguageFilterOption extends React.Component {
+export default class LanguageFilterOption extends React.Component {
static propTypes = {
languageKey: React.PropTypes.string.isRequired,
language: React.PropTypes.object
);
}
}
-
-const mapStateToProps = (state, ownProps) => ({
- language: getLanguageByKey(state, ownProps.languageKey)
-});
-
-export default connect(mapStateToProps)(LanguageFilterOption);
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import FilterContainer from './FilterContainer';
+import { FilterContainer } from './containers';
import Level from '../../../components/ui/Level';
export default class QualityGateFilter extends React.PureComponent {
* 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 { withRouter } from 'react-router';
import classNames from 'classnames';
-import debounce from 'lodash/debounce';
-import { getFilterUrl } from './utils';
import { translate, translateWithParameters } from '../../../helpers/l10n';
-type Props = {
- query?: string,
- router: { push: (string) => void },
- isFavorite?: boolean,
- organization?: {}
-};
-
-type State = {
- userQuery?: string
-};
-
-class SearchFilter extends React.PureComponent {
- handleSearch: (string) => void;
- props: Props;
- state: State;
+export default class SearchFilter extends React.Component {
+ static propTypes = {
+ query: React.PropTypes.object.isRequired,
+ handleSearch: React.PropTypes.func.isRequired
+ }
- constructor (props: Props) {
+ constructor (props) {
super(props);
- this.state = { userQuery: props.query };
- this.handleSearch = debounce(this.handleSearch.bind(this), 250);
+ this.state = {
+ userQuery: props.query.search
+ };
}
- componentWillReceiveProps (nextProps: Props) {
- if (this.props.query === this.state.userQuery && nextProps.query !== this.props.query) {
- this.setState({ userQuery: nextProps.query || '' });
+ componentWillReceiveProps (nextProps) {
+ if (this.props.query.search === this.state.userQuery && nextProps.query.search !== this.props.query.search) {
+ this.setState({
+ userQuery: nextProps.query.search || ''
+ });
}
}
- handleSearch (userQuery) {
- const path = getFilterUrl(this.props, { search: userQuery || null });
- this.props.router.push(path);
- }
-
- handleQueryChange (userQuery) {
- this.setState({ userQuery });
- if (!userQuery || userQuery.length >= 2) {
- this.handleSearch(userQuery);
+ handleQueryChange = ({ target }) => {
+ this.setState({ userQuery: target.value });
+ 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 (
value={userQuery || ''}
className={inputClassName}
placeholder={translate('projects.search')}
- onChange={event => this.handleQueryChange(event.target.value)}
+ onChange={this.handleQueryChange}
autoComplete="off"/>
<span className="note spacer-left">
{translateWithParameters('select2.tooShort', 2)}
);
}
}
-
-export default withRouter(SearchFilter);
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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 React from 'react';
+import { withRouter } from 'react-router';
+import debounce from 'lodash/debounce';
+import { getFilterUrl } from './utils';
+import SearchFilter from './SearchFilter';
+
+class SearchFilterContainer extends React.Component {
+ static propTypes = {
+ query: React.PropTypes.object.isRequired,
+ isFavorite: React.PropTypes.bool,
+ organization: React.PropTypes.object
+ }
+
+ constructor (props) {
+ super(props);
+ this.handleSearch = debounce(this.handleSearch.bind(this), 250);
+ }
+
+ handleSearch (userQuery) {
+ const path = getFilterUrl(this.props, { search: userQuery || null });
+ this.props.router.push(path);
+ }
+
+ render () {
+ return (
+ <SearchFilter
+ query={this.props.query}
+ handleSearch={this.handleSearch}/>
+ );
+ }
+}
+
+export default withRouter(SearchFilterContainer);
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
-import FilterContainer from './FilterContainer';
+import { FilterContainer } from './containers';
import SortingFilter from './SortingFilter';
import SizeRating from '../../../components/ui/SizeRating';
import { translate } from '../../../helpers/l10n';
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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 { connect } from 'react-redux';
+import { withRouter } from 'react-router';
+import Filter from './Filter';
+import LanguageFilterFooter from './LanguageFilterFooter';
+import LanguageFilterOption from './LanguageFilterOption';
+import {
+ getProjectsAppFacetByProperty,
+ getProjectsAppMaxFacetValue,
+ getLanguages,
+ getLanguageByKey
+} from '../../../store/rootReducer';
+
+export const FilterContainer = (function () {
+ const mapStateToProps = (state, ownProps) => ({
+ value: ownProps.query[ownProps.property],
+ facet: getProjectsAppFacetByProperty(state, ownProps.property),
+ maxFacetValue: getProjectsAppMaxFacetValue(state)
+ });
+ return connect(mapStateToProps)(withRouter(Filter));
+})();
+
+export const LanguageFilterFooterContainer = (function () {
+ const mapStateToProps = (state, ownProps) => ({
+ languages: getLanguages(state),
+ value: ownProps.query[ownProps.property],
+ facet: getProjectsAppFacetByProperty(state, ownProps.property)
+ });
+ return connect(mapStateToProps)(withRouter(LanguageFilterFooter));
+})();
+
+export const LanguageFilterOptionContainer = (function () {
+ const mapStateToProps = (state, ownProps) => ({
+ language: getLanguageByKey(state, ownProps.languageKey)
+ });
+ return connect(mapStateToProps)(LanguageFilterOption);
+})();