aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx')
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx44
1 files changed, 27 insertions, 17 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx
index c5d4197f1be..56d148f82b2 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx
@@ -19,12 +19,15 @@
*/
import * as React from 'react';
import * as PropTypes from 'prop-types';
-import AllProjects from './AllProjects';
+import AllProjectsContainer from './AllProjectsContainer';
import { isFavoriteSet, isAllSet } from '../../../helpers/storage';
import { searchProjects } from '../../../api/components';
+import { CurrentUser, isLoggedIn } from '../../../app/types';
interface Props {
+ currentUser: CurrentUser;
location: { pathname: string; query: { [x: string]: string } };
+ onSonarCloud: boolean;
}
interface State {
@@ -34,7 +37,6 @@ interface State {
export default class DefaultPageSelector extends React.PureComponent<Props, State> {
static contextTypes = {
- currentUser: PropTypes.object.isRequired,
router: PropTypes.object.isRequired
};
@@ -44,22 +46,26 @@ export default class DefaultPageSelector extends React.PureComponent<Props, Stat
}
componentDidMount() {
- this.defineIfShouldBeRedirected();
+ if (!this.props.onSonarCloud) {
+ this.defineIfShouldBeRedirected();
+ }
}
componentDidUpdate(prevProps: Props) {
- if (prevProps.location !== this.props.location) {
- this.defineIfShouldBeRedirected();
- } else if (this.state.shouldBeRedirected === true) {
- this.context.router.replace({ ...this.props.location, pathname: '/projects/favorite' });
- } else if (this.state.shouldForceSorting != null) {
- this.context.router.replace({
- ...this.props.location,
- query: {
- ...this.props.location.query,
- sort: this.state.shouldForceSorting
- }
- });
+ if (!this.props.onSonarCloud) {
+ if (prevProps.location !== this.props.location) {
+ this.defineIfShouldBeRedirected();
+ } else if (this.state.shouldBeRedirected === true) {
+ this.context.router.replace({ ...this.props.location, pathname: '/projects/favorite' });
+ } else if (this.state.shouldForceSorting != null) {
+ this.context.router.replace({
+ ...this.props.location,
+ query: {
+ ...this.props.location.query,
+ sort: this.state.shouldForceSorting
+ }
+ });
+ }
}
}
@@ -67,7 +73,7 @@ export default class DefaultPageSelector extends React.PureComponent<Props, Stat
if (Object.keys(this.props.location.query).length > 0) {
// show ALL projects when there are some filters
this.setState({ shouldBeRedirected: false, shouldForceSorting: undefined });
- } else if (!this.context.currentUser.isLoggedIn) {
+ } else if (!isLoggedIn(this.props.currentUser)) {
// show ALL projects if user is anonymous
if (!this.props.location.query || !this.props.location.query.sort) {
// force default sorting to last analysis date
@@ -92,11 +98,15 @@ export default class DefaultPageSelector extends React.PureComponent<Props, Stat
}
render() {
+ if (this.props.onSonarCloud) {
+ return <AllProjectsContainer isFavorite={true} location={this.props.location} />;
+ }
+
const { shouldBeRedirected, shouldForceSorting } = this.state;
if (shouldBeRedirected == null || shouldBeRedirected === true || shouldForceSorting != null) {
return null;
} else {
- return <AllProjects isFavorite={false} location={this.props.location} />;
+ return <AllProjectsContainer isFavorite={false} location={this.props.location} />;
}
}
}