From: Grégoire Aubert Date: Mon, 18 Jun 2018 08:10:14 +0000 (+0200) Subject: SONARCLOUD-52 Serve SonarCloud logo directly from the app X-Git-Tag: 7.5~951 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=03c2e9a2ec801217ed5299b66f72eaec50d28914;p=sonarqube.git SONARCLOUD-52 Serve SonarCloud logo directly from the app --- 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.js deleted file mode 100644 index 3eb739a4620..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js +++ /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 {title}; - } - - render() { - return ( -
- - {this.renderLogo()} - -
- ); - } -} - -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 index 00000000000..b7d7cef1f92 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.tsx @@ -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 ( +
+ + {title} + +
+ ); +} + +export function SonarCloudNavBranding() { + return ( + + ); +} + +const mapStateToProps = (state: any): StateProps => ({ + customLogoUrl: (getGlobalSettingValue(state, 'sonar.lf.logoUrl') || {}).value, + customLogoWidth: (getGlobalSettingValue(state, 'sonar.lf.logoWidthPx') || {}).value +}); + +export default connect(mapStateToProps)(GlobalNavBranding);