]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-52 Serve SonarCloud logo directly from the app
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 18 Jun 2018 08:10:14 +0000 (10:10 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 21 Jun 2018 18:21:29 +0000 (20:21 +0200)
server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js [deleted file]
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.tsx [new file with mode: 0644]

index 0f596735299d9b6fa0b19c9d2fb300005ea0c08a..c3241fc86431a9f35adea3cd34f08b1376bffe2f 100644 (file)
@@ -20,7 +20,7 @@
 import * as React from 'react';
 import * as PropTypes from 'prop-types';
 import { connect } from 'react-redux';
-import GlobalNavBranding from './GlobalNavBranding';
+import GlobalNavBranding, { SonarCloudNavBranding } from './GlobalNavBranding';
 import GlobalNavMenu from './GlobalNavMenu';
 import GlobalNavExplore from './GlobalNavExplore';
 import GlobalNavUserContainer from './GlobalNavUserContainer';
@@ -55,7 +55,7 @@ class GlobalNav extends React.PureComponent<Props> {
   render() {
     return (
       <NavBar className="navbar-global" height={theme.globalNavHeightRaw} id="global-navigation">
-        <GlobalNavBranding />
+        {isSonarCloud ? <SonarCloudNavBranding /> : <GlobalNavBranding />}
 
         <GlobalNavMenu {...this.props} />
 
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js
deleted file mode 100644 (file)
index 3eb739a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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 React from 'react';
-import PropTypes from 'prop-types';
-import { Link } from 'react-router';
-import { connect } from 'react-redux';
-import { getGlobalSettingValue } from '../../../../store/rootReducer';
-import { translate } from '../../../../helpers/l10n';
-
-class GlobalNavBranding extends React.PureComponent {
-  static propTypes = {
-    customLogoUrl: PropTypes.string,
-    customLogoWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
-  };
-
-  renderLogo() {
-    const url = this.props.customLogoUrl || `${window.baseUrl}/images/logo.svg?v=6.6`;
-    const width = this.props.customLogoUrl ? this.props.customLogoWidth || 100 : 83;
-    const height = 30;
-    const title = translate('layout.sonar.slogan');
-    return <img src={url} width={width} height={height} alt={title} title={title} />;
-  }
-
-  render() {
-    return (
-      <div className="pull-left">
-        <Link to="/" className="navbar-brand">
-          {this.renderLogo()}
-        </Link>
-      </div>
-    );
-  }
-}
-
-const mapStateToProps = state => ({
-  customLogoUrl: (getGlobalSettingValue(state, 'sonar.lf.logoUrl') || {}).value,
-  customLogoWidth: (getGlobalSettingValue(state, 'sonar.lf.logoWidthPx') || {}).value
-});
-
-export default connect(mapStateToProps)(GlobalNavBranding);
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.tsx
new file mode 100644 (file)
index 0000000..b7d7cef
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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 * as React from 'react';
+import { Link } from 'react-router';
+import { connect } from 'react-redux';
+import { getGlobalSettingValue } from '../../../../store/rootReducer';
+import { translate } from '../../../../helpers/l10n';
+import { getBaseUrl } from '../../../../helpers/urls';
+
+interface StateProps {
+  customLogoUrl?: string;
+  customLogoWidth?: string | number;
+}
+
+export function GlobalNavBranding({ customLogoUrl, customLogoWidth }: StateProps) {
+  const title = translate('layout.sonar.slogan');
+  const url = customLogoUrl || `${getBaseUrl()}/images/logo.svg?v=6.6`;
+  const width = customLogoUrl ? customLogoWidth || 100 : 83;
+
+  return (
+    <div className="pull-left">
+      <Link className="navbar-brand" to="/">
+        <img alt={title} height={30} src={url} title={title} width={width} />
+      </Link>
+    </div>
+  );
+}
+
+export function SonarCloudNavBranding() {
+  return (
+    <GlobalNavBranding
+      customLogoUrl={`${getBaseUrl()}/images/sonarcloud-logo.svg`}
+      customLogoWidth={105}
+    />
+  );
+}
+
+const mapStateToProps = (state: any): StateProps => ({
+  customLogoUrl: (getGlobalSettingValue(state, 'sonar.lf.logoUrl') || {}).value,
+  customLogoWidth: (getGlobalSettingValue(state, 'sonar.lf.logoWidthPx') || {}).value
+});
+
+export default connect<StateProps>(mapStateToProps)(GlobalNavBranding);