From 6297a95ee597f6b14d2f44cf8356ffaf26b9f9e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 16 May 2017 13:39:01 +0200 Subject: [PATCH] SQCOM-7 Add a custom footer for sonarqube.com --- it/it-tests/src/test/java/it/ui/UiTest.java | 13 ++ .../main/js/app/components/GlobalContainer.js | 4 +- .../main/js/app/components/GlobalFooter.js | 22 ++- .../app/components/GlobalFooterContainer.js | 31 ++++ .../GlobalFooterForSonarQubeDotCom.js | 50 +++++ .../main/js/app/components/SimpleContainer.js | 4 +- .../components/__tests__/GlobalFooter-test.js | 65 +++++++ .../GlobalFooterForSonarQubeDotCom-test.js | 26 +++ .../__snapshots__/GlobalFooter-test.js.snap | 173 ++++++++++++++++++ ...lobalFooterForSonarQubeDotCom-test.js.snap | 59 ++++++ .../resources/org/sonar/l10n/core.properties | 5 + 11 files changed, 438 insertions(+), 14 deletions(-) create mode 100644 server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js create mode 100644 server/sonar-web/src/main/js/app/components/GlobalFooterForSonarQubeDotCom.js create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.js create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/GlobalFooterForSonarQubeDotCom-test.js create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooter-test.js.snap create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooterForSonarQubeDotCom-test.js.snap 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 b60c9e2768c..9c002a029a1 100644 --- a/it/it-tests/src/test/java/it/ui/UiTest.java +++ b/it/it-tests/src/test/java/it/ui/UiTest.java @@ -22,12 +22,14 @@ package it.ui; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category4Suite; +import it.user.ForceAuthenticationTest; import java.util.Map; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; +import org.sonarqube.ws.client.setting.SetRequest; import pageobjects.Navigation; import util.ItUtils; @@ -38,6 +40,7 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.WebDriverRunner.url; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; public class UiTest { @@ -71,6 +74,16 @@ public class UiTest { nav.getFooter().shouldNot(hasText((String) statusMap.get("version"))); } + @Test + public void footer_doesnt_contains_about_when_not_logged_in() { + setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", "true"); + nav.openLogin(); + nav.getFooter() + .shouldNot(hasText("About")) + .shouldNot(hasText("Web API")); + setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", null); + } + @Test public void many_page_transitions() { analyzeSampleProject(); diff --git a/server/sonar-web/src/main/js/app/components/GlobalContainer.js b/server/sonar-web/src/main/js/app/components/GlobalContainer.js index 181cdb9ac86..284cba8d436 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalContainer.js +++ b/server/sonar-web/src/main/js/app/components/GlobalContainer.js @@ -20,7 +20,7 @@ // @flow import React from 'react'; import GlobalNav from './nav/global/GlobalNav'; -import GlobalFooter from './GlobalFooter'; +import GlobalFooterContainer from './GlobalFooterContainer'; import GlobalMessagesContainer from './GlobalMessagesContainer'; export default function GlobalContainer(props: Object) { @@ -35,7 +35,7 @@ export default function GlobalContainer(props: Object) { {props.children} - + ); } 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 ef7c0658246..030a255ca00 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.js +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.js @@ -20,18 +20,27 @@ // @flow import React from 'react'; import { Link } from 'react-router'; -import { connect } from 'react-redux'; -import { getAppState } from '../../store/rootReducer'; +import GlobalFooterForSonarQubeDotCom from './GlobalFooterForSonarQubeDotCom'; import GlobalFooterBranding from './GlobalFooterBranding'; import { translate, translateWithParameters } from '../../helpers/l10n'; type Props = { hideLoggedInInfo?: boolean, productionDatabase: boolean, + sonarqubeDotCom: boolean, sonarqubeVersion?: string }; -function GlobalFooter({ hideLoggedInInfo, sonarqubeVersion, productionDatabase }: Props) { +export default function GlobalFooter({ + hideLoggedInInfo, + productionDatabase, + sonarqubeDotCom, + sonarqubeVersion +}: Props) { + if (sonarqubeDotCom) { + return ; + } + return ( ); } - -const mapStateToProps = state => ({ - sonarqubeVersion: getAppState(state).version, - productionDatabase: getAppState(state).productionDatabase -}); - -export default connect(mapStateToProps)(GlobalFooter); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js new file mode 100644 index 00000000000..46c834a15d0 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js @@ -0,0 +1,31 @@ +/* + * 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 { connect } from 'react-redux'; +import { getAppState, getSettingValue } from '../../store/rootReducer'; +import GlobalFooter from './GlobalFooter'; + +const mapStateToProps = state => ({ + sonarqubeVersion: getAppState(state).version, + productionDatabase: getAppState(state).productionDatabase, + sonarqubeDotCom: getSettingValue(state, 'sonar.lf.sonarqube.com.enabled') +}); + +export default connect(mapStateToProps)(GlobalFooter); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterForSonarQubeDotCom.js b/server/sonar-web/src/main/js/app/components/GlobalFooterForSonarQubeDotCom.js new file mode 100644 index 00000000000..0297cce903d --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterForSonarQubeDotCom.js @@ -0,0 +1,50 @@ +/* + * 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 { Link } from 'react-router'; +import { translate } from '../../helpers/l10n'; + +export default function GlobalFooterForSonarQubeDotCom() { + 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 a661748ec07..7d9396e7bf0 100644 --- a/server/sonar-web/src/main/js/app/components/SimpleContainer.js +++ b/server/sonar-web/src/main/js/app/components/SimpleContainer.js @@ -19,7 +19,7 @@ */ // @flow import React from 'react'; -import GlobalFooter from './GlobalFooter'; +import GlobalFooterContainer from './GlobalFooterContainer'; type Props = { children?: React.Element<*> | Array>, @@ -57,7 +57,7 @@ export default class SimpleContainer extends React.PureComponent { - + ); } diff --git a/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.js b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.js new file mode 100644 index 00000000000..49c8f690bab --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.js @@ -0,0 +1,65 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import React from 'react'; +import GlobalFooter from '../GlobalFooter'; + +it('should render the only logged in information', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); + +it('should not render the only logged in information', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('should show the db warning message', () => { + expect( + shallow().find('.alert') + ).toMatchSnapshot(); +}); + +it('should display the sq version', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('should render SonarqubeDotCom footer', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooterForSonarQubeDotCom-test.js b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooterForSonarQubeDotCom-test.js new file mode 100644 index 00000000000..38610ea8353 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooterForSonarQubeDotCom-test.js @@ -0,0 +1,26 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import React from 'react'; +import GlobalFooterForSonarQubeDotCom from '../GlobalFooterForSonarQubeDotCom'; + +it('should render correctly', () => { + expect(shallow()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooter-test.js.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooter-test.js.snap new file mode 100644 index 00000000000..19b4e955356 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooter-test.js.snap @@ -0,0 +1,173 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display the sq version 1`] = ` + +`; + +exports[`should not render the only logged in information 1`] = ` + +`; + +exports[`should render SonarqubeDotCom footer 1`] = ``; + +exports[`should render the only logged in information 1`] = ` + +`; + +exports[`should show the db warning message 1`] = ` +
+

+ footer.production_database_warning +

+

+ footer.production_database_explanation +

+
+`; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooterForSonarQubeDotCom-test.js.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooterForSonarQubeDotCom-test.js.snap new file mode 100644 index 00000000000..ce3665ec957 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooterForSonarQubeDotCom-test.js.snap @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +`; 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 6506122b3b1..890acc19a6b 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2884,10 +2884,15 @@ organization.change_visibility_form.submit=Change Default Visibility footer.about=About footer.community=Community footer.documentation=Documentation +footer.get_started=Get Started +footer.help=Help footer.licence=LGPL v3 +footer.news=News 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.terms=Terms +footer.twitter=Twitter footer.version_x=Version {0} footer.web_api=Web API -- 2.39.5