1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/*
* 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 PageHeaderContainer from './PageHeaderContainer';
import ProjectsListContainer from './ProjectsListContainer';
import ProjectsListFooterContainer from './ProjectsListFooterContainer';
import PageSidebar from './PageSidebar';
import VisualizationsContainer from '../visualizations/VisualizationsContainer';
import { parseUrlQuery } from '../store/utils';
import Page from '../../../components/layout/Page';
import PageMain from '../../../components/layout/PageMain';
import PageMainInner from '../../../components/layout/PageMainInner';
import PageSide from '../../../components/layout/PageSide';
import PageFilters from '../../../components/layout/PageFilters';
import '../styles.css';
export default class AllProjects extends React.Component {
static propTypes = {
isFavorite: React.PropTypes.bool.isRequired,
location: React.PropTypes.object.isRequired,
fetchProjects: React.PropTypes.func.isRequired,
organization: React.PropTypes.object,
router: React.PropTypes.object.isRequired
};
state = {
query: {}
};
componentDidMount() {
this.handleQueryChange();
document.getElementById('footer').classList.add('search-navigator-footer');
}
componentDidUpdate(prevProps) {
if (prevProps.location.query !== this.props.location.query) {
this.handleQueryChange();
}
}
componentWillUnmount() {
document.getElementById('footer').classList.remove('search-navigator-footer');
}
handleQueryChange() {
const query = parseUrlQuery(this.props.location.query);
this.setState({ query });
this.props.fetchProjects(query, this.props.isFavorite, this.props.organization);
}
handleViewChange = view => {
const query = {
...this.props.location.query,
view: view === 'list' ? undefined : view
};
if (query.view !== 'visualizations') {
Object.assign(query, { visualization: undefined });
}
this.props.router.push({
pathname: this.props.location.pathname,
query
});
};
handleVisualizationChange = visualization => {
this.props.router.push({
pathname: this.props.location.pathname,
query: {
...this.props.location.query,
view: 'visualizations',
visualization
}
});
};
render() {
const { query } = this.state;
const isFiltered = Object.keys(query).some(key => query[key] != null);
const view = query.view || 'list';
const visualization = query.visualization || 'quality';
const top = this.props.organization ? 95 : 30;
return (
<Page className="projects-page">
<PageSide top={top}>
<PageFilters>
<PageSidebar
query={query}
isFavorite={this.props.isFavorite}
organization={this.props.organization}
/>
</PageFilters>
</PageSide>
<PageMain>
<PageMainInner>
<PageHeaderContainer onViewChange={this.handleViewChange} view={view} />
{view === 'list' &&
<ProjectsListContainer
isFavorite={this.props.isFavorite}
isFiltered={isFiltered}
organization={this.props.organization}
/>}
{view === 'list' &&
<ProjectsListFooterContainer
query={query}
isFavorite={this.props.isFavorite}
organization={this.props.organization}
/>}
{view === 'visualizations' &&
<VisualizationsContainer
onVisualizationChange={this.handleVisualizationChange}
sort={query.sort}
visualization={visualization}
/>}
</PageMainInner>
</PageMain>
</Page>
);
}
}
|