From 03c2e9a2ec801217ed5299b66f72eaec50d28914 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Mon, 18 Jun 2018 10:10:14 +0200 Subject: [PATCH] SONARCLOUD-52 Serve SonarCloud logo directly from the app --- .../app/components/nav/global/GlobalNav.tsx | 4 +- ...alNavBranding.js => GlobalNavBranding.tsx} | 53 ++++++++++--------- 2 files changed, 30 insertions(+), 27 deletions(-) rename server/sonar-web/src/main/js/app/components/nav/global/{GlobalNavBranding.js => GlobalNavBranding.tsx} (56%) diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx index 0f596735299..c3241fc8643 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx @@ -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 { render() { return ( - + {isSonarCloud ? : } 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.tsx similarity index 56% rename from server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js rename to server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.tsx index 3eb739a4620..b7d7cef1f92 100644 --- 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.tsx @@ -17,41 +17,44 @@ * 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 * 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'; -class GlobalNavBranding extends React.PureComponent { - static propTypes = { - customLogoUrl: PropTypes.string, - customLogoWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) - }; +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; - 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 {title}; - } + return ( +
+ + {title} + +
+ ); +} - render() { - return ( -
- - {this.renderLogo()} - -
- ); - } +export function SonarCloudNavBranding() { + return ( + + ); } -const mapStateToProps = state => ({ +const mapStateToProps = (state: any): StateProps => ({ customLogoUrl: (getGlobalSettingValue(state, 'sonar.lf.logoUrl') || {}).value, customLogoWidth: (getGlobalSettingValue(state, 'sonar.lf.logoWidthPx') || {}).value }); -export default connect(mapStateToProps)(GlobalNavBranding); +export default connect(mapStateToProps)(GlobalNavBranding); -- 2.39.5