From 27e0b0190229a78b0d57907b3b49e2ea381826ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Fri, 12 Jan 2018 17:50:03 +0100 Subject: [PATCH] SONAR-10284 Retreive onSonarCloud param in SimpleContainer --- .../src/main/js/app/components/App.tsx | 6 +- .../main/js/app/components/GlobalFooter.tsx | 118 +++++++++--------- .../app/components/GlobalFooterContainer.tsx | 12 +- .../app/components/GlobalFooterSonarCloud.tsx | 2 +- .../js/app/components/SimpleContainer.tsx | 70 +++++++++-- .../__tests__/GlobalFooter-test.tsx | 27 ++-- .../GlobalFooterSonarCloud-test.tsx.snap | 2 +- .../components/LoginFormContainer.tsx | 23 ++-- 8 files changed, 154 insertions(+), 106 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/App.tsx b/server/sonar-web/src/main/js/app/components/App.tsx index b23af2a3dca..2b83e2a6468 100644 --- a/server/sonar-web/src/main/js/app/components/App.tsx +++ b/server/sonar-web/src/main/js/app/components/App.tsx @@ -91,9 +91,9 @@ class App extends React.PureComponent { this.setState({ branchesEnabled: appState.branchesEnabled, canAdmin: appState.canAdmin, - onSonarCloud: - appState.settings !== undefined && - appState.settings['sonar.sonarcloud.enabled'] === 'true' + onSonarCloud: Boolean( + appState.settings && appState.settings['sonar.sonarcloud.enabled'] === 'true' + ) }); } return appState; diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx index 4f548848452..eacbe1883b0 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import * as PropTypes from 'prop-types'; import { Link } from 'react-router'; import GlobalFooterSonarCloud from './GlobalFooterSonarCloud'; import GlobalFooterBranding from './GlobalFooterBranding'; @@ -26,72 +27,73 @@ import { translate, translateWithParameters } from '../../helpers/l10n'; interface Props { hideLoggedInInfo?: boolean; productionDatabase: boolean; - onSonarCloud?: { value: string }; sonarqubeVersion?: string; } -export default function GlobalFooter({ - hideLoggedInInfo, - productionDatabase, - onSonarCloud, - sonarqubeVersion -}: Props) { - if (onSonarCloud && onSonarCloud.value === 'true') { - return ; - } +export default class GlobalFooter extends React.PureComponent { + static contextTypes = { + onSonarCloud: PropTypes.bool + }; - return ( - + ); + } } diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx index cde158c45fc..9524c6de7b6 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx @@ -18,19 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { connect } from 'react-redux'; -import { getAppState, getGlobalSettingValue } from '../../store/rootReducer'; +import { getAppState } from '../../store/rootReducer'; import GlobalFooter from './GlobalFooter'; interface StateProps { - onSonarCloud?: { value: string }; productionDatabase: boolean; sonarqubeVersion?: string; } +interface OwnProps { + hideLoggedInInfo?: boolean; +} + const mapStateToProps = (state: any): StateProps => ({ sonarqubeVersion: getAppState(state).version, - productionDatabase: getAppState(state).productionDatabase, - onSonarCloud: getGlobalSettingValue(state, 'sonar.sonarcloud.enabled') + productionDatabase: getAppState(state).productionDatabase }); -export default connect(mapStateToProps)(GlobalFooter); +export default connect(mapStateToProps)(GlobalFooter); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterSonarCloud.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooterSonarCloud.tsx index 875a0aecb51..c98b4415059 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooterSonarCloud.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterSonarCloud.tsx @@ -24,7 +24,7 @@ export default function GlobalFooterSonarCloud() { return (