*/
// @flow
import React from 'react';
-import { connect } from 'react-redux';
import FavoriteProjectsContainer from '../../projects/components/FavoriteProjectsContainer';
-import { getOrganizationByKey } from '../../../store/rootReducer';
-import { updateOrganization } from '../actions';
-class OrganizationFavoriteProjects extends React.PureComponent {
+export default class OrganizationFavoriteProjects extends React.PureComponent {
props: {
children?: React.Element<*>,
+ currentUser: { isLoggedIn: boolean },
location: Object,
optionBarOpen: boolean,
optionBarToggle: (open: boolean) => void,
return (
<div id="projects-page">
<FavoriteProjectsContainer
+ currentUser={this.props.currentUser}
location={this.props.location}
optionBarOpen={this.props.optionBarOpen}
optionBarToggle={this.props.optionBarToggle}
);
}
}
-
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-const mapDispatchToProps = { updateOrganization };
-
-export default connect(mapStateToProps, mapDispatchToProps)(OrganizationFavoriteProjects);
};
type State = {
- loading: boolean,
- optionBarOpen: boolean
+ loading: boolean
};
class OrganizationPage extends React.PureComponent {
mounted: boolean;
props: Props;
- state: State = { loading: true, optionBarOpen: false };
+ state: State = { loading: true };
componentDidMount() {
this.mounted = true;
});
};
- handleOptionBarToggle = (open: boolean) => this.setState({ optionBarOpen: open });
-
render() {
const { organization } = this.props;
<div>
<Helmet defaultTitle={organization.name} titleTemplate={'%s - ' + organization.name} />
<OrganizationNavigation organization={organization} location={this.props.location} />
- {this.props.children &&
- React.cloneElement(this.props.children, {
- optionBarOpen: this.state.optionBarOpen,
- optionBarToggle: this.handleOptionBarToggle
- })}
+ {this.props.children}
</div>
);
}
*/
// @flow
import React from 'react';
-import { connect } from 'react-redux';
import AllProjectsContainer from '../../projects/components/AllProjectsContainer';
-import { getOrganizationByKey } from '../../../store/rootReducer';
-import { updateOrganization } from '../actions';
-class OrganizationProjects extends React.PureComponent {
+export default class OrganizationProjects extends React.PureComponent {
props: {
children?: React.Element<*>,
+ currentUser: { isLoggedIn: boolean },
location: Object,
optionBarOpen: boolean,
optionBarToggle: (open: boolean) => void,
return (
<div id="projects-page">
<AllProjectsContainer
+ currentUser={this.props.currentUser}
isFavorite={false}
location={this.props.location}
optionBarOpen={this.props.optionBarOpen}
);
}
}
-
-const mapStateToProps = (state, ownProps) => ({
- organization: getOrganizationByKey(state, ownProps.params.organizationKey)
-});
-
-const mapDispatchToProps = { updateOrganization };
-
-export default connect(mapStateToProps, mapDispatchToProps)(OrganizationProjects);
--- /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.
+ */
+//@flow
+import React from 'react';
+import { connect } from 'react-redux';
+import { getCurrentUser, getOrganizationByKey } from '../../../store/rootReducer';
+import { updateOrganization } from '../actions';
+
+type State = {
+ optionBarOpen: boolean
+};
+
+class OrganizationProjectsContainer extends React.PureComponent {
+ state: State = { optionBarOpen: false };
+
+ handleOptionBarToggle = (open: boolean) => this.setState({ optionBarOpen: open });
+
+ render() {
+ return React.cloneElement(this.props.children, {
+ currentUser: this.props.currentUser,
+ optionBarOpen: this.state.optionBarOpen,
+ optionBarToggle: this.handleOptionBarToggle,
+ organization: this.props.organization
+ });
+ }
+}
+
+const mapStateToProps = (state, ownProps) => ({
+ organization: getOrganizationByKey(state, ownProps.params.organizationKey),
+ currentUser: getCurrentUser(state)
+});
+
+const mapDispatchToProps = { updateOrganization };
+
+export default connect(mapStateToProps, mapDispatchToProps)(OrganizationProjectsContainer);
}
}
/>
- <div
- optionBarOpen={false}
- optionBarToggle={[Function]}
- >
+ <div>
hello
</div>
</div>
import OrganizationPage from './components/OrganizationPage';
import OrganizationPageExtension from '../../app/components/extensions/OrganizationPageExtension';
import OrganizationProjects from './components/OrganizationProjects';
+import OrganizationProjectsContainer from './components/OrganizationProjectsContainer';
import OrganizationFavoriteProjects from './components/OrganizationFavoriteProjects';
import OrganizationRules from './components/OrganizationRules';
import OrganizationAdmin from './components/OrganizationAdmin';
},
{
path: 'projects',
- component: OrganizationProjects
- },
- {
- path: 'projects/favorite',
- component: OrganizationFavoriteProjects
+ component: OrganizationProjectsContainer,
+ childRoutes: [
+ {
+ indexRoute: {
+ component: OrganizationProjects
+ }
+ },
+ {
+ path: 'favorite',
+ component: OrganizationFavoriteProjects
+ }
+ ]
},
{
path: 'members',
optionBarToggle: (open: boolean) => void,
organization?: { key: string },
router: { push: ({ pathname: string, query?: {} }) => void },
- user?: { isLoggedIn: boolean }
+ currentUser?: { isLoggedIn: boolean }
};
type State = {
onToggleOptionBar={this.props.optionBarToggle}
open={optionBarOpen}
selectedSort={selectedSort}
- user={this.props.user}
+ currentUser={this.props.currentUser}
view={view}
visualization={visualization}
/>
location={this.props.location}
optionBarOpen={this.props.optionBarOpen}
optionBarToggle={this.props.optionBarToggle}
- user={this.props.currentUser}
+ currentUser={this.props.currentUser}
/>
);
}
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import AllProjects from './AllProjects';
-import { fetchProjects } from '../store/actions';
import { getCurrentUser } from '../../../store/rootReducer';
+import { fetchProjects } from '../store/actions';
const mapStateToProps = state => ({
- user: getCurrentUser(state),
- isFavorite: true
+ isFavorite: true,
+ currentUser: getCurrentUser(state)
});
export default connect(mapStateToProps, { fetchProjects })(withRouter(AllProjects));
projects: Array<*>,
projectsAppState: { loading: boolean, total?: number },
selectedSort: string,
- user?: { isLoggedIn: boolean },
+ currentUser?: { isLoggedIn: boolean },
view: string,
visualization?: string
};
};
renderSortingSelect() {
- const { projectsAppState, projects, user, view } = this.props;
+ const { projectsAppState, projects, currentUser, view } = this.props;
const limitReached =
projects != null &&
projectsAppState.total != null &&
projects.length < projectsAppState.total;
- const defaultOption = user && user.isLoggedIn ? 'name' : 'analysis_date';
+ const defaultOption = currentUser && currentUser.isLoggedIn ? 'name' : 'analysis_date';
if (view === 'visualizations' && !limitReached) {
return (
<Tooltip overlay={translate('projects.sort.disabled')}>
visualization="risk"
projects={[1, 2, 3]}
projectsAppState={{ total: 3 }}
- user={{ isLoggedIn: true }}
+ currentUser={{ isLoggedIn: true }}
/>
)
).toMatchSnapshot();
open={true}
view="overall"
visualization="risk"
- user={{ isLoggedIn: true }}
+ currentUser={{ isLoggedIn: true }}
/>
).find('ProjectsSortingSelect')
).toMatchSnapshot();
open={true}
view="leak"
visualization="risk"
- user={{ isLoggedIn: false }}
+ currentUser={{ isLoggedIn: false }}
/>
).find('ProjectsSortingSelect')
).toMatchSnapshot();