]> source.dussan.org Git - sonarqube.git/commitdiff
SQCOM-7 Add a custom footer for sonarqube.com
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 16 May 2017 11:39:01 +0000 (13:39 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 18 May 2017 09:11:38 +0000 (11:11 +0200)
it/it-tests/src/test/java/it/ui/UiTest.java
server/sonar-web/src/main/js/app/components/GlobalContainer.js
server/sonar-web/src/main/js/app/components/GlobalFooter.js
server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/GlobalFooterForSonarQubeDotCom.js [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/SimpleContainer.js
server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.js [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/__tests__/GlobalFooterForSonarQubeDotCom-test.js [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooter-test.js.snap [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/GlobalFooterForSonarQubeDotCom-test.js.snap [new file with mode: 0644]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index b60c9e2768c0395cf2f90d22951c03472fb413c7..9c002a029a1608100a5d7c66500d3acf7f0bf308 100644 (file)
@@ -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();
index 181cdb9ac867c237bfd77d33ffabb71d358fe7e7..284cba8d4360b48b3f2f02a727bedff453888d11 100644 (file)
@@ -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}
         </div>
       </div>
-      <GlobalFooter />
+      <GlobalFooterContainer />
     </div>
   );
 }
index ef7c06582464d3883cf4f2a0389ded50757ef55e..030a255ca005f458721e848797245ed8f23d29ca 100644 (file)
 // @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 <GlobalFooterForSonarQubeDotCom hideLoggedInInfo={hideLoggedInInfo} />;
+  }
+
   return (
     <div id="footer" className="page-footer page-container">
       {productionDatabase === false &&
@@ -74,10 +83,3 @@ function GlobalFooter({ hideLoggedInInfo, sonarqubeVersion, productionDatabase }
     </div>
   );
 }
-
-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 (file)
index 0000000..46c834a
--- /dev/null
@@ -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 (file)
index 0000000..0297cce
--- /dev/null
@@ -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 (
+    <div id="footer" className="page-footer page-container">
+      <div>
+        © 2008-2017, SonarQube.com by
+        {' '}
+        <a href="http://www.sonarsource.com" title="SonarSource SA">SonarSource SA</a>
+        . All rights reserved.
+      </div>
+
+      <div>
+        <a href="https://about.sonarqube.com/news/">{translate('footer.news')}</a>
+        {' - '}
+        <a href="https://about.sonarqube.com/Terms_of_service.pdf">{translate('footer.terms')}</a>
+        {' - '}
+        <a href="https://twitter.com/sonarqube">{translate('footer.twitter')}</a>
+        {' - '}
+        <a href="https://about.sonarqube.com/get-started/">{translate('footer.get_started')}</a>
+        {' - '}
+        <a href="https://about.sonarqube.com/contact/">{translate('footer.help')}</a>
+        {' - '}
+        {<Link to="/about">{translate('footer.about')}</Link>}
+      </div>
+    </div>
+  );
+}
index a661748ec07bbe4a184fcf69429ab5ffef865c7e..7d9396e7bf0107c20638c4515f62072d28d8d185 100644 (file)
@@ -19,7 +19,7 @@
  */
 // @flow
 import React from 'react';
-import GlobalFooter from './GlobalFooter';
+import GlobalFooterContainer from './GlobalFooterContainer';
 
 type Props = {
   children?: React.Element<*> | Array<React.Element<*>>,
@@ -57,7 +57,7 @@ export default class SimpleContainer extends React.PureComponent {
             </div>
           </div>
         </div>
-        <GlobalFooter hideLoggedInInfo={this.props.hideLoggedInInfo} />
+        <GlobalFooterContainer hideLoggedInInfo={this.props.hideLoggedInInfo} />
       </div>
     );
   }
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 (file)
index 0000000..49c8f69
--- /dev/null
@@ -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(<GlobalFooter productionDatabase={true} sonarqubeDotCom={false} />)
+  ).toMatchSnapshot();
+});
+
+it('should not render the only logged in information', () => {
+  expect(
+    shallow(
+      <GlobalFooter
+        hideLoggedInInfo={true}
+        productionDatabase={true}
+        sonarqubeDotCom={false}
+        sonarqubeVersion="6.4-SNAPSHOT"
+      />
+    )
+  ).toMatchSnapshot();
+});
+
+it('should show the db warning message', () => {
+  expect(
+    shallow(<GlobalFooter productionDatabase={false} sonarqubeDotCom={false} />).find('.alert')
+  ).toMatchSnapshot();
+});
+
+it('should display the sq version', () => {
+  expect(
+    shallow(
+      <GlobalFooter
+        productionDatabase={true}
+        sonarqubeDotCom={false}
+        sonarqubeVersion="6.4-SNAPSHOT"
+      />
+    )
+  ).toMatchSnapshot();
+});
+
+it('should render SonarqubeDotCom footer', () => {
+  expect(
+    shallow(<GlobalFooter productionDatabase={true} sonarqubeDotCom={true} />)
+  ).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 (file)
index 0000000..38610ea
--- /dev/null
@@ -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(<GlobalFooterForSonarQubeDotCom />)).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 (file)
index 0000000..19b4e95
--- /dev/null
@@ -0,0 +1,173 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should display the sq version 1`] = `
+<div
+  className="page-footer page-container"
+  id="footer"
+>
+  <GlobalFooterBranding />
+  <div>
+    footer.version_x.6.4-SNAPSHOT
+     - 
+    <a
+      href="http://www.gnu.org/licenses/lgpl-3.0.txt"
+    >
+      footer.licence
+    </a>
+     - 
+    <a
+      href="http://www.sonarqube.org"
+    >
+      footer.community
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/home.html"
+    >
+      footer.documentation
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/community.html"
+    >
+      footer.support
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/plugin-library.html"
+    >
+      footer.plugins
+    </a>
+     - 
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to="/web_api"
+    >
+      footer.web_api
+    </Link>
+     - 
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to="/about"
+    >
+      footer.about
+    </Link>
+  </div>
+</div>
+`;
+
+exports[`should not render the only logged in information 1`] = `
+<div
+  className="page-footer page-container"
+  id="footer"
+>
+  <GlobalFooterBranding />
+  <div>
+    <a
+      href="http://www.gnu.org/licenses/lgpl-3.0.txt"
+    >
+      footer.licence
+    </a>
+     - 
+    <a
+      href="http://www.sonarqube.org"
+    >
+      footer.community
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/home.html"
+    >
+      footer.documentation
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/community.html"
+    >
+      footer.support
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/plugin-library.html"
+    >
+      footer.plugins
+    </a>
+  </div>
+</div>
+`;
+
+exports[`should render SonarqubeDotCom footer 1`] = `<GlobalFooterForSonarQubeDotCom />`;
+
+exports[`should render the only logged in information 1`] = `
+<div
+  className="page-footer page-container"
+  id="footer"
+>
+  <GlobalFooterBranding />
+  <div>
+    <a
+      href="http://www.gnu.org/licenses/lgpl-3.0.txt"
+    >
+      footer.licence
+    </a>
+     - 
+    <a
+      href="http://www.sonarqube.org"
+    >
+      footer.community
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/home.html"
+    >
+      footer.documentation
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/community.html"
+    >
+      footer.support
+    </a>
+     - 
+    <a
+      href="https://redirect.sonarsource.com/doc/plugin-library.html"
+    >
+      footer.plugins
+    </a>
+     - 
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to="/web_api"
+    >
+      footer.web_api
+    </Link>
+     - 
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to="/about"
+    >
+      footer.about
+    </Link>
+  </div>
+</div>
+`;
+
+exports[`should show the db warning message 1`] = `
+<div
+  className="alert alert-danger"
+>
+  <p
+    className="big"
+    id="evaluation_warning"
+  >
+    footer.production_database_warning
+  </p>
+  <p>
+    footer.production_database_explanation
+  </p>
+</div>
+`;
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 (file)
index 0000000..ce3665e
--- /dev/null
@@ -0,0 +1,59 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<div
+  className="page-footer page-container"
+  id="footer"
+>
+  <div>
+    © 2008-2017, SonarQube.com by
+     
+    <a
+      href="http://www.sonarsource.com"
+      title="SonarSource SA"
+    >
+      SonarSource SA
+    </a>
+    . All rights reserved.
+  </div>
+  <div>
+    <a
+      href="https://about.sonarqube.com/news/"
+    >
+      footer.news
+    </a>
+     - 
+    <a
+      href="https://about.sonarqube.com/Terms_of_service.pdf"
+    >
+      footer.terms
+    </a>
+     - 
+    <a
+      href="https://twitter.com/sonarqube"
+    >
+      footer.twitter
+    </a>
+     - 
+    <a
+      href="https://about.sonarqube.com/get-started/"
+    >
+      footer.get_started
+    </a>
+     - 
+    <a
+      href="https://about.sonarqube.com/contact/"
+    >
+      footer.help
+    </a>
+     - 
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to="/about"
+    >
+      footer.about
+    </Link>
+  </div>
+</div>
+`;
index 6506122b3b14500d67970734ef8fc4c22a19bb75..890acc19a6bd0d5aa7e3a73d37618ce4bcf3d5bf 100644 (file)
@@ -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