123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- /*
- * SonarQube
- * Copyright (C) 2009-2021 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 { DropdownOverlay } from 'sonar-ui-common/components/controls/Dropdown';
- import { translate } from 'sonar-ui-common/helpers/l10n';
- import { getBaseUrl } from 'sonar-ui-common/helpers/urls';
- import { isSonarCloud } from '../../../helpers/system';
- import ProductNewsMenuItem from './ProductNewsMenuItem';
- import { SuggestionsContext } from './SuggestionsContext';
-
- interface Props {
- onClose: () => void;
- }
-
- export default class EmbedDocsPopup extends React.PureComponent<Props> {
- renderTitle(text: string) {
- return <li className="menu-header">{text}</li>;
- }
-
- renderSuggestions = ({ suggestions }: { suggestions: T.SuggestionLink[] }) => {
- if (suggestions.length === 0) {
- return null;
- }
- return (
- <>
- {this.renderTitle(translate('embed_docs.suggestion'))}
- {suggestions.map((suggestion, index) => (
- <li key={index}>
- <Link onClick={this.props.onClose} target="_blank" to={suggestion.link}>
- {suggestion.text}
- </Link>
- </li>
- ))}
- <li className="divider" />
- </>
- );
- };
-
- renderIconLink(link: string, icon: string, text: string) {
- return (
- <a href={link} rel="noopener noreferrer" target="_blank">
- <img
- alt={text}
- className="spacer-right"
- height="18"
- src={`${getBaseUrl()}/images/${icon}`}
- width="18"
- />
- {text}
- </a>
- );
- }
-
- renderSonarCloudLinks() {
- return (
- <>
- <li className="divider" />
- <li>
- <a
- href="https://community.sonarsource.com/c/help/sc"
- rel="noopener noreferrer"
- target="_blank">
- {translate('embed_docs.get_help')}
- </a>
- </li>
- <li className="divider" />
- {this.renderTitle(translate('embed_docs.stay_connected'))}
- <li>
- {this.renderIconLink(
- 'https://twitter.com/sonarcloud',
- 'embed-doc/twitter-icon.svg',
- 'Twitter'
- )}
- </li>
- <li>
- {this.renderIconLink(
- 'https://blog.sonarsource.com/product/SonarCloud',
- 'sonarcloud-square-logo.svg',
- translate('embed_docs.blog')
- )}
- </li>
- <li>
- <ProductNewsMenuItem tag="SonarCloud" />
- </li>
- </>
- );
- }
-
- renderSonarQubeLinks() {
- return (
- <>
- <li className="divider" />
- <li>
- <a href="https://community.sonarsource.com/" rel="noopener noreferrer" target="_blank">
- {translate('embed_docs.get_help')}
- </a>
- </li>
- <li className="divider" />
- {this.renderTitle(translate('embed_docs.stay_connected'))}
- <li>
- {this.renderIconLink(
- 'https://www.sonarqube.org/whats-new/?referrer=sonarqube',
- 'embed-doc/sq-icon.svg',
- translate('embed_docs.news')
- )}
- </li>
- <li>
- {this.renderIconLink(
- 'https://twitter.com/SonarQube',
- 'embed-doc/twitter-icon.svg',
- 'Twitter'
- )}
- </li>
- </>
- );
- }
-
- render() {
- return (
- <DropdownOverlay>
- <ul className="menu abs-width-240">
- <SuggestionsContext.Consumer>{this.renderSuggestions}</SuggestionsContext.Consumer>
- <li>
- <Link onClick={this.props.onClose} target="_blank" to="/documentation">
- {translate('embed_docs.documentation')}
- </Link>
- </li>
- <li>
- <Link onClick={this.props.onClose} to="/web_api">
- {translate('api_documentation.page')}
- </Link>
- </li>
- {isSonarCloud() ? this.renderSonarCloudLinks() : this.renderSonarQubeLinks()}
- </ul>
- </DropdownOverlay>
- );
- }
- }
|