diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2017-03-28 17:44:50 +0200 |
---|---|---|
committer | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-04-03 10:38:52 +0200 |
commit | 0f56fb56a40c1ee72f68dd170b12202e690086d9 (patch) | |
tree | 4998dad2652b99b0607be8045f7169cb1c5e8ea2 /server/sonar-web | |
parent | adb4265900d35345f8d900dca47cc6c2f490cb21 (diff) | |
download | sonarqube-0f56fb56a40c1ee72f68dd170b12202e690086d9.tar.gz sonarqube-0f56fb56a40c1ee72f68dd170b12202e690086d9.zip |
SONAR-9005 redirect from global to organization rules page
Diffstat (limited to 'server/sonar-web')
-rw-r--r-- | server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js | 2 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js | 30 |
2 files changed, 29 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js index 90249a0e7e2..1c7f395f741 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js @@ -150,7 +150,7 @@ export default class GlobalNavMenu extends React.Component { {this.renderProjects()} {governanceInstalled && this.renderPortfolios()} {this.renderIssuesLink()} - {this.renderRulesLink()} + {!organizationsEnabled && this.renderRulesLink()} {!organizationsEnabled && this.renderProfilesLink()} {this.renderQualityGatesLink()} {this.renderAdministrationLink()} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js index c7bb6c70ed3..de34c58dd33 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js @@ -19,18 +19,38 @@ */ // @flow import React from 'react'; +import { connect } from 'react-redux'; +import { withRouter } from 'react-router'; +import { getAppState } from '../../../store/rootReducer'; import init from '../init'; -export default class CodingRulesAppContainer extends React.PureComponent { +class CodingRulesAppContainer extends React.PureComponent { stop: ?() => void; props: { + appState: { + defaultOrganization: string, + organizationsEnabled: boolean + }, params: { organizationKey?: string + }, + router: { + replace: (string) => void } }; componentDidMount() { - this.stop = init(this.refs.container, this.props.params.organizationKey); + if (this.props.appState.organizationsEnabled && !this.props.params.organizationKey) { + // redirect to organization-level rules page + this.props.router.replace( + '/organizations/' + + this.props.appState.defaultOrganization + + '/rules' + + window.location.hash + ); + } else { + this.stop = init(this.refs.container, this.props.params.organizationKey); + } } componentWillUnmount() { @@ -51,3 +71,9 @@ export default class CodingRulesAppContainer extends React.PureComponent { ); } } + +const mapStateToProps = state => ({ + appState: getAppState(state) +}); + +export default connect(mapStateToProps)(withRouter(CodingRulesAppContainer)); |