From 282c729e2aed2e3362c89e60ada017dbdf51f6dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 2 May 2017 15:18:15 +0200 Subject: [PATCH] SONAR-9173 Hide some elements of the footer when the user is not logged --- it/it-tests/src/test/java/it/ui/UiTest.java | 9 ++++ .../main/js/app/components/GlobalFooter.js | 47 +++++++++++-------- .../main/js/app/components/SimpleContainer.js | 14 +++--- .../src/main/js/app/utils/startReactApp.js | 3 +- .../components/SimpleSessionsContainer.js | 30 ++++++++++++ .../resources/org/sonar/l10n/core.properties | 16 +++++++ 6 files changed, 92 insertions(+), 27 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/sessions/components/SimpleSessionsContainer.js diff --git a/it/it-tests/src/test/java/it/ui/UiTest.java b/it/it-tests/src/test/java/it/ui/UiTest.java index b75534fd12f..b60c9e2768c 100644 --- a/it/it-tests/src/test/java/it/ui/UiTest.java +++ b/it/it-tests/src/test/java/it/ui/UiTest.java @@ -62,6 +62,15 @@ public class UiTest { nav.getFooter().should(hasText((String) statusMap.get("version"))); } + @Test + public void footer_doesnt_contains_version_on_login_page() { + WsResponse status = ItUtils.newAdminWsClient(ORCHESTRATOR).wsConnector().call(new GetRequest("api/navigation/global")); + Map statusMap = ItUtils.jsonToMap(status.content()); + + nav.openLogin(); + nav.getFooter().shouldNot(hasText((String) statusMap.get("version"))); + } + @Test public void many_page_transitions() { analyzeSampleProject(); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooter.js b/server/sonar-web/src/main/js/app/components/GlobalFooter.js index 0a8dd3789ab..ef7c0658246 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.js +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.js @@ -23,44 +23,53 @@ import { Link } from 'react-router'; import { connect } from 'react-redux'; import { getAppState } from '../../store/rootReducer'; import GlobalFooterBranding from './GlobalFooterBranding'; +import { translate, translateWithParameters } from '../../helpers/l10n'; -function GlobalFooter(props: Object) { - const { sonarqubeVersion, productionDatabase } = props; +type Props = { + hideLoggedInInfo?: boolean, + productionDatabase: boolean, + sonarqubeVersion?: string +}; +function GlobalFooter({ hideLoggedInInfo, sonarqubeVersion, productionDatabase }: Props) { return ( ); diff --git a/server/sonar-web/src/main/js/app/components/SimpleContainer.js b/server/sonar-web/src/main/js/app/components/SimpleContainer.js index cc3309d0a25..a661748ec07 100644 --- a/server/sonar-web/src/main/js/app/components/SimpleContainer.js +++ b/server/sonar-web/src/main/js/app/components/SimpleContainer.js @@ -21,13 +21,13 @@ import React from 'react'; import GlobalFooter from './GlobalFooter'; +type Props = { + children?: React.Element<*> | Array>, + hideLoggedInInfo?: boolean +}; + export default class SimpleContainer extends React.PureComponent { - static propTypes = { - children: React.PropTypes.oneOfType([ - React.PropTypes.element, - React.PropTypes.arrayOf(React.PropTypes.element) - ]) - }; + props: Props; componentDidMount() { const html = document.querySelector('html'); @@ -57,7 +57,7 @@ export default class SimpleContainer extends React.PureComponent { - + ); } diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.js b/server/sonar-web/src/main/js/app/utils/startReactApp.js index 932192fabc3..fa8714220bf 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.js +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.js @@ -26,6 +26,7 @@ import MigrationContainer from '../components/MigrationContainer'; import App from '../components/App'; import GlobalContainer from '../components/GlobalContainer'; import SimpleContainer from '../components/SimpleContainer'; +import SimpleSessionsContainer from '../../apps/sessions/components/SimpleSessionsContainer'; import Landing from '../components/Landing'; import ProjectContainer from '../components/ProjectContainer'; import ProjectAdminContainer from '../components/ProjectAdminContainer'; @@ -133,7 +134,7 @@ const startReactApp = () => { - + {sessionsRoutes} diff --git a/server/sonar-web/src/main/js/apps/sessions/components/SimpleSessionsContainer.js b/server/sonar-web/src/main/js/apps/sessions/components/SimpleSessionsContainer.js new file mode 100644 index 00000000000..1973d6fd996 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/sessions/components/SimpleSessionsContainer.js @@ -0,0 +1,30 @@ +/* + * 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 SimpleContainer from '../../../app/components/SimpleContainer'; + +type Props = { + children?: React.Element<*> | Array> +}; + +export default function SimpleSessionsContainer({ children }: Props) { + return {children}; +} diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index c61609ac996..09ef00e5afe 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2869,3 +2869,19 @@ organization.default_visibility_of_new_projects=Default visibility of new projec organization.change_visibility_form.header=Set Default Visibility of New Projects organization.change_visibility_form.warning=This will not change the visibility of already existing projects. organization.change_visibility_form.submit=Change Default Visibility + +#------------------------------------------------------------------------------ +# +# GLOBAL FOOTER +# +#------------------------------------------------------------------------------ +footer.about=About +footer.community=Community +footer.documentation=Documentation +footer.licence=LGPL v3 +footer.plugins=Plugins +footer.production_database_explanation=The embedded database will not scale, it will not support upgrading to newer versions of SonarQube, and there is no support for migrating your data out of it into a different database engine. +footer.production_database_warning=Embedded database should be used for evaluation purpose only +footer.support=Get Support +footer.version_x=Version {0} +footer.web_api=Web API -- 2.39.5