You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReloadButton.tsx 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as classNames from 'classnames';
  21. import * as React from 'react';
  22. import { translate } from '../../helpers/l10n';
  23. import { ThemeConsumer } from '../theme';
  24. import Tooltip from './Tooltip';
  25. interface Props {
  26. className?: string;
  27. tooltip?: string;
  28. onClick: () => void;
  29. }
  30. export default class ReloadButton extends React.PureComponent<Props> {
  31. handleClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => {
  32. event.preventDefault();
  33. event.currentTarget.blur();
  34. this.props.onClick();
  35. };
  36. render() {
  37. const { tooltip = translate('reload') } = this.props;
  38. return (
  39. <Tooltip overlay={tooltip}>
  40. <a
  41. className={classNames('link-no-underline', this.props.className)}
  42. href="#"
  43. onClick={this.handleClick}>
  44. {
  45. <ThemeConsumer>
  46. {(theme) => (
  47. <svg height="24" viewBox="0 0 18 24" width="18">
  48. <path
  49. d="M16.6454 8.1084c-.3-.5-.9-.7-1.4-.4-.5.3-.7.9-.4 1.4.9 1.6 1.1 3.4.6 5.1-.5 1.7-1.7 3.2-3.2 4-3.3 1.8-7.4.6-9.1-2.7-1.8-3.1-.8-6.9 2.1-8.8v3.3h2v-7h-7v2h3.9c-3.7 2.5-5 7.5-2.8 11.4 1.6 3 4.6 4.6 7.7 4.6 1.4 0 2.8-.3 4.2-1.1 2-1.1 3.5-3 4.2-5.2.6-2.2.3-4.6-.8-6.6z"
  50. fill={theme.colors.secondFontColor}
  51. />
  52. </svg>
  53. )}
  54. </ThemeConsumer>
  55. }
  56. </a>
  57. </Tooltip>
  58. );
  59. }
  60. }