From cccb2e9097073eca88067d20cb14ecdd199e34d2 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 3 Nov 2016 16:04:56 +0100 Subject: [PATCH] SONAR-8300 open all facets --- .../src/main/js/app/store/rootReducer.js | 4 -- .../main/js/apps/projects/components/App.js | 4 +- .../apps/projects/components/PageSidebar.js | 5 +- .../components/PageSidebarContainer.js | 27 ---------- .../main/js/apps/projects/filters/Filter.js | 53 ++----------------- .../apps/projects/filters/FilterContainer.js | 16 +----- .../js/apps/projects/store/filters/reducer.js | 29 ---------- .../store/filters/statuses/actions.js | 38 ------------- .../store/filters/statuses/reducer.js | 48 ----------------- .../main/js/apps/projects/store/reducer.js | 7 +-- 10 files changed, 12 insertions(+), 219 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/PageSidebarContainer.js delete mode 100644 server/sonar-web/src/main/js/apps/projects/store/filters/reducer.js delete mode 100644 server/sonar-web/src/main/js/apps/projects/store/filters/statuses/actions.js delete mode 100644 server/sonar-web/src/main/js/apps/projects/store/filters/statuses/reducer.js diff --git a/server/sonar-web/src/main/js/app/store/rootReducer.js b/server/sonar-web/src/main/js/app/store/rootReducer.js index 202a0562579..a46042491fa 100644 --- a/server/sonar-web/src/main/js/app/store/rootReducer.js +++ b/server/sonar-web/src/main/js/app/store/rootReducer.js @@ -81,10 +81,6 @@ export const getProjectsAppState = state => ( fromProjectsApp.getState(state.projectsApp) ); -export const getProjectsAppFilterStatus = (state, key) => ( - fromProjectsApp.getFilterStatus(state.projectsApp, key) -); - export const getProjectsAppFacetByProperty = (state, property) => ( fromProjectsApp.getFacetByProperty(state.projectsApp, property) ); diff --git a/server/sonar-web/src/main/js/apps/projects/components/App.js b/server/sonar-web/src/main/js/apps/projects/components/App.js index c4ca1fbf0f6..665683cd689 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/App.js +++ b/server/sonar-web/src/main/js/apps/projects/components/App.js @@ -22,7 +22,7 @@ import Helmet from 'react-helmet'; import PageHeaderContainer from './PageHeaderContainer'; import ProjectsListContainer from './ProjectsListContainer'; import ProjectsListFooterContainer from './ProjectsListFooterContainer'; -import PageSidebarContainer from './PageSidebarContainer'; +import PageSidebar from './PageSidebar'; import ProjectsListHeaderContainer from './ProjectsListHeaderContainer'; import GlobalMessagesContainer from '../../../app/components/GlobalMessagesContainer'; import { parseUrlQuery } from '../store/utils'; @@ -81,7 +81,7 @@ export default class App extends React.Component { 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 1b4baa2f1c7..087f1cc7904 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 @@ -29,8 +29,7 @@ import MaintainabilityFilter from '../filters/MaintainabilityFilter'; export default class PageSidebar extends React.Component { static propTypes = { - query: React.PropTypes.object.isRequired, - closeAllFilters: React.PropTypes.func.isRequired + query: React.PropTypes.object.isRequired }; render () { @@ -41,7 +40,7 @@ export default class PageSidebar extends React.Component {
{isFiltered && (
- + Clear All Filters
diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebarContainer.js b/server/sonar-web/src/main/js/apps/projects/components/PageSidebarContainer.js deleted file mode 100644 index c61e554c94b..00000000000 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebarContainer.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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 PageSidebar from './PageSidebar'; -import { closeAllFilters } from '../store/filters/statuses/actions'; - -export default connect( - () => ({}), - { closeAllFilters } -)(PageSidebar); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js index ec975cf5270..1b0a7ad8c82 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js @@ -24,7 +24,6 @@ import { formatMeasure } from '../../../helpers/measures'; export default class Filter extends React.Component { static propTypes = { - isOpen: React.PropTypes.bool.isRequired, value: React.PropTypes.any, property: React.PropTypes.string.isRequired, options: React.PropTypes.array.isRequired, @@ -39,8 +38,6 @@ export default class Filter extends React.Component { halfWidth: React.PropTypes.bool, getFilterUrl: React.PropTypes.func.isRequired, - openFilter: React.PropTypes.func.isRequired, - closeFilter: React.PropTypes.func.isRequired, router: React.PropTypes.object }; @@ -49,36 +46,11 @@ export default class Filter extends React.Component { halfWidth: false }; - handleHeaderClick = e => { - e.preventDefault(); - e.target.blur(); - - const { value, isOpen, property } = this.props; - const hasValue = value != null; - const isDisplayedOpen = isOpen || hasValue; - - if (isDisplayedOpen) { - this.props.closeFilter(); - } else { - this.props.openFilter(); - } - - if (hasValue) { - this.props.router.push(this.props.getFilterUrl({ [property]: null })); - } - }; - renderHeader () { - const { value, isOpen, renderName } = this.props; - const hasValue = value != null; - const checkboxClassName = classNames('icon-checkbox', { - 'icon-checkbox-checked': hasValue || isOpen - }); - return ( - - {renderName()} - +
+ {this.props.renderName()} +
); } @@ -124,31 +96,16 @@ export default class Filter extends React.Component { } renderOptions () { - const { value, isOpen, options } = this.props; - const hasValue = value != null; - - if (!hasValue && !isOpen) { - return null; - } - return (
- {this.props.children} - - {options.map(option => this.renderOption(option))} + {this.props.options.map(option => this.renderOption(option))}
); } render () { - const { value, isOpen } = this.props; - const hasValue = value != null; - const className = classNames('search-navigator-facet-box', { - 'search-navigator-facet-box-collapsed': !hasValue && !isOpen - }); - return ( -
+
{this.renderHeader()} {this.renderOptions()}
diff --git a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js index 48e6bf07726..7f030717c34 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js @@ -22,16 +22,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import omitBy from 'lodash/omitBy'; import isNil from 'lodash/isNil'; -import { - getProjectsAppFilterStatus, - getProjectsAppFacetByProperty, - getProjectsAppMaxFacetValue -} from '../../../app/store/rootReducer'; -import { openFilter, closeFilter } from '../store/filters/statuses/actions'; -import { OPEN } from '../store/filters/statuses/reducer'; +import { getProjectsAppFacetByProperty, getProjectsAppMaxFacetValue } from '../../../app/store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ - isOpen: getProjectsAppFilterStatus(state, ownProps.property) === OPEN, value: ownProps.query[ownProps.property], facet: getProjectsAppFacetByProperty(state, ownProps.property), maxFacetValue: getProjectsAppMaxFacetValue(state), @@ -41,9 +34,4 @@ const mapStateToProps = (state, ownProps) => ({ } }); -const mapDispatchToProps = (dispatch, ownProps) => ({ - openFilter: () => dispatch(openFilter(ownProps.property)), - closeFilter: () => dispatch(closeFilter(ownProps.property)) -}); - -export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Filter)); +export default connect(mapStateToProps)(withRouter(Filter)); diff --git a/server/sonar-web/src/main/js/apps/projects/store/filters/reducer.js b/server/sonar-web/src/main/js/apps/projects/store/filters/reducer.js deleted file mode 100644 index 830f667057c..00000000000 --- a/server/sonar-web/src/main/js/apps/projects/store/filters/reducer.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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 { combineReducers } from 'redux'; -import statuses, * as fromStatuses from './statuses/reducer'; - -const reducer = combineReducers({ statuses }); - -export default reducer; - -export const getFilterStatus = (state, key) => ( - fromStatuses.getStatus(state.statuses, key) -); diff --git a/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/actions.js b/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/actions.js deleted file mode 100644 index d67bbc2bf57..00000000000 --- a/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/actions.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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. - */ -export const OPEN_FILTER = 'projects/OPEN_FILTER'; - -export const openFilter = key => ({ - type: OPEN_FILTER, - key -}); - -export const CLOSE_FILTER = 'projects/CLOSE_FILTER'; - -export const closeFilter = key => ({ - type: CLOSE_FILTER, - key -}); - -export const CLOSE_ALL_FILTERS = 'projects/CLOSE_ALL_FILTERS'; - -export const closeAllFilters = () => ({ - type: CLOSE_ALL_FILTERS -}); diff --git a/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/reducer.js b/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/reducer.js deleted file mode 100644 index 6606f476a7b..00000000000 --- a/server/sonar-web/src/main/js/apps/projects/store/filters/statuses/reducer.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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 { OPEN_FILTER, CLOSE_FILTER, CLOSE_ALL_FILTERS } from './actions'; - -export const OPEN = 'OPEN'; -export const CLOSED = 'CLOSED'; - -const closeAll = state => { - const newState = { ...state }; - Object.keys(newState).forEach(key => newState[key] = CLOSED); - return newState; -}; - -const reducer = (state = {}, action = {}) => { - switch (action.type) { - case OPEN_FILTER: - return { ...state, [action.key]: OPEN }; - case CLOSE_FILTER: - return { ...state, [action.key]: CLOSED }; - case CLOSE_ALL_FILTERS: - return closeAll(state); - default: - return state; - } -}; - -export default reducer; - -export const getStatus = (state, key) => ( - state[key] -); diff --git a/server/sonar-web/src/main/js/apps/projects/store/reducer.js b/server/sonar-web/src/main/js/apps/projects/store/reducer.js index de306baa99d..1e2487aa794 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/reducer.js +++ b/server/sonar-web/src/main/js/apps/projects/store/reducer.js @@ -20,10 +20,9 @@ import { combineReducers } from 'redux'; import projects, * as fromProjects from './projects/reducer'; import state from './state/reducer'; -import filters, * as fromFilters from './filters/reducer'; import facets, * as fromFacets from './facets/reducer'; -export default combineReducers({ projects, state, filters, facets }); +export default combineReducers({ projects, state, facets }); export const getProjects = state => ( fromProjects.getProjects(state.projects) @@ -33,10 +32,6 @@ export const getState = state => ( state.state ); -export const getFilterStatus = (state, key) => ( - fromFilters.getFilterStatus(state.filters, key) -); - export const getFacetByProperty = (state, property) => ( fromFacets.getFacetByProperty(state.facets, property) ); -- 2.39.5