import ProjectsListContainer from './ProjectsListContainer';
import ProjectsListFooterContainer from './ProjectsListFooterContainer';
import PageSidebar from './PageSidebar';
-import NoProjects from './NoProjects';
import { parseUrlQuery } from '../store/utils';
export default class AllProjects extends React.Component {
static propTypes = {
user: React.PropTypes.oneOfType([React.PropTypes.object, React.PropTypes.bool]),
+ isFavorite: React.PropTypes.bool.isRequired,
fetchProjects: React.PropTypes.func.isRequired
};
handleQueryChange () {
const query = parseUrlQuery(this.props.location.query);
this.setState({ query });
- this.props.fetchProjects(query);
+ this.props.fetchProjects(query, this.props.isFavorite);
}
render () {
return null;
}
+ const favoriteAndNoFilters = this.props.isFavorite &&
+ !Object.keys(this.state.query).some(key => this.state.query[key] != null);
+
return (
<div className="page-with-sidebar projects-page">
<div className="page-main">
- <ProjectsListContainer noProjectsComponent={<NoProjects/>}/>
- <ProjectsListFooterContainer query={this.state.query}/>
+ <ProjectsListContainer favoriteAndNoFilters={favoriteAndNoFilters}/>
+ <ProjectsListFooterContainer query={this.state.query} isFavorite={this.props.isFavorite}/>
</div>
<aside className="page-sidebar-fixed projects-sidebar">
- <PageSidebar query={this.state.query}/>
+ <PageSidebar query={this.state.query} isFavorite={this.props.isFavorite}/>
</aside>
</div>
);
import { getCurrentUser } from '../../../app/store/rootReducer';
const mapStateToProps = state => ({
- user: getCurrentUser(state)
+ user: getCurrentUser(state),
+ isFavorite: false
});
export default connect(
+++ /dev/null
-/*
- * 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 React from 'react';
-import ProjectsListContainer from './ProjectsListContainer';
-import NoFavoriteProjects from './NoFavoriteProjects';
-
-export default class FavoriteProjects extends React.Component {
- static propTypes = {
- user: React.PropTypes.object,
- fetchFavoriteProjects: React.PropTypes.func.isRequired
- };
-
- componentDidMount () {
- this.props.fetchFavoriteProjects();
- }
-
- render () {
- if (!this.props.user) {
- return null;
- }
-
- return (
- <div className="page-with-sidebar">
- <div className="page-main">
- <div className="projects-list-container">
- <ProjectsListContainer noProjectsComponent={<NoFavoriteProjects/>}/>
- </div>
- </div>
- <aside className="page-sidebar-fixed projects-sidebar"/>
- </div>
- );
- }
-}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { connect } from 'react-redux';
-import FavoriteProjects from './FavoriteProjects';
-import { fetchFavoriteProjects } from '../store/actions';
+import AllProjects from './AllProjects';
+import { fetchProjects } from '../store/actions';
import { getCurrentUser } from '../../../app/store/rootReducer';
const mapStateToProps = state => ({
- user: getCurrentUser(state)
+ user: getCurrentUser(state),
+ isFavorite: true
});
export default connect(
mapStateToProps,
- { fetchFavoriteProjects }
-)(FavoriteProjects);
+ { fetchProjects }
+)(AllProjects);
export default class PageSidebar extends React.Component {
static propTypes = {
- query: React.PropTypes.object.isRequired
+ query: React.PropTypes.object.isRequired,
+ isFavorite: React.PropTypes.bool.isRequired
};
render () {
const isFiltered = Object.keys(this.props.query).some(key => this.props.query[key] != null);
+ const pathname = this.props.isFavorite ? '/projects/favorite' : '/projects';
+
return (
<div className="search-navigator-facets-list">
<div className="projects-facets-header clearfix">
{isFiltered && (
<div className="projects-facets-reset">
- <Link to="/projects" className="button button-red">
+ <Link to={pathname} className="button button-red">
{translate('projects.clear_all_filters')}
</Link>
</div>
<h3>{translate('filters')}</h3>
</div>
- <QualityGateFilter query={this.props.query}/>
- <ReliabilityFilter query={this.props.query}/>
- <SecurityFilter query={this.props.query}/>
- <MaintainabilityFilter query={this.props.query}/>
- <CoverageFilter query={this.props.query}/>
- <DuplicationsFilter query={this.props.query}/>
- <SizeFilter query={this.props.query}/>
+ <QualityGateFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <ReliabilityFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <SecurityFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <MaintainabilityFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <CoverageFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <DuplicationsFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
+ <SizeFilter query={this.props.query} isFavorite={this.props.isFavorite}/>
</div>
);
}
*/
import React from 'react';
import ProjectCardContainer from './ProjectCardContainer';
+import NoProjects from './NoProjects';
+import NoFavoriteProjects from './NoFavoriteProjects';
export default class ProjectsList extends React.Component {
static propTypes = {
projects: React.PropTypes.arrayOf(React.PropTypes.string),
- noProjectsComponent: React.PropTypes.element.isRequired
+ favoriteAndNoFilters: React.PropTypes.bool.isRequired
};
+ renderNoProjects () {
+ return this.props.favoriteAndNoFilters ? (
+ <NoFavoriteProjects/>
+ ) : (
+ <NoProjects/>
+ );
+ }
+
render () {
const { projects } = this.props;
<ProjectCardContainer key={projectKey} projectKey={projectKey}/>
))
) : (
- this.props.noProjectsComponent
+ this.renderNoProjects()
)}
</div>
);
};
const mapDispatchToProps = (dispatch, ownProps) => ({
- loadMore: () => dispatch(fetchMoreProjects(ownProps.query))
+ loadMore: () => dispatch(fetchMoreProjects(ownProps.query, ownProps.isFavorite))
});
export default connect(
renderName={() => 'Coverage'}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
- query={this.props.query}/>
+ query={this.props.query}
+ isFavorite={this.props.isFavorite}/>
);
}
}
renderName={() => 'Duplications'}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
- query={this.props.query}/>
+ query={this.props.query}
+ isFavorite={this.props.isFavorite}/>
);
}
}
facet: getProjectsAppFacetByProperty(state, ownProps.property),
maxFacetValue: getProjectsAppMaxFacetValue(state),
getFilterUrl: part => {
+ const pathname = ownProps.isFavorite ? '/projects/favorite': '/projects';
const query = omitBy({ ...ownProps.query, ...part }, isNil);
- return { pathname: '/projects', query };
+ return { pathname, query };
}
});
renderName={() => this.props.name}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
- query={this.props.query}/>
+ query={this.props.query}
+ isFavorite={this.props.isFavorite}/>
);
}
}
renderName={() => 'Quality Gate'}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
- query={this.props.query}/>
+ query={this.props.query}
+ isFavorite={this.props.isFavorite}/>
);
}
}
renderName={() => 'Size'}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
- query={this.props.query}/>
+ query={this.props.query}
+ isFavorite={this.props.isFavorite}/>
);
}
}
dispatch(updateState({ pageIndex: response.paging.pageIndex }));
};
-export const fetchProjects = query => dispatch => {
+export const fetchProjects = (query, isFavorite) => dispatch => {
dispatch(updateState({ loading: true }));
const data = { ps: PAGE_SIZE, facets: FACETS.join() };
- const filter = convertToFilter(query);
+ const filter = convertToFilter(query, isFavorite);
if (filter) {
data.filter = filter;
}
return searchProjects(data).then(onReceiveProjects(dispatch), onFail(dispatch));
};
-export const fetchMoreProjects = query => (dispatch, getState) => {
+export const fetchMoreProjects = (query, isFavorite) => (dispatch, getState) => {
dispatch(updateState({ loading: true }));
const state = getState();
const { pageIndex } = getProjectsAppState(state);
const data = { ps: PAGE_SIZE, p: pageIndex + 1 };
- const filter = convertToFilter(query);
+ const filter = convertToFilter(query, isFavorite);
if (filter) {
data.filter = filter;
}
}
};
-export const convertToFilter = query => {
+export const convertToFilter = (query, isFavorite) => {
const conditions = [];
+ if (isFavorite) {
+ conditions.push('isFavorite');
+ }
+
if (query['gate'] != null) {
conditions.push('alert_status = ' + query['gate']);
}