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.

DownloadButton.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  3. import { translate } from '../../base/i18n';
  4. import { IconDownload } from '../../base/icons';
  5. import { connect } from '../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
  7. import { openURLInBrowser } from '../../base/util';
  8. type Props = AbstractButtonProps & {
  9. /**
  10. * The URL to the applications page.
  11. */
  12. _downloadAppsUrl: string
  13. };
  14. /**
  15. * Implements an {@link AbstractButton} to open the applications page in a new window.
  16. */
  17. class DownloadButton extends AbstractButton<Props, *> {
  18. accessibilityLabel = 'toolbar.accessibilityLabel.download';
  19. icon = IconDownload;
  20. label = 'toolbar.download';
  21. tooltip = 'toolbar.download';
  22. /**
  23. * Handles clicking / pressing the button, and opens a new window with the user documentation.
  24. *
  25. * @private
  26. * @returns {void}
  27. */
  28. _handleClick() {
  29. const { _downloadAppsUrl } = this.props;
  30. sendAnalytics(createToolbarEvent('download.pressed'));
  31. openURLInBrowser(_downloadAppsUrl);
  32. }
  33. }
  34. /**
  35. * Maps part of the redux state to the component's props.
  36. *
  37. * @param {Object} state - The redux store/state.
  38. * @returns {Object}
  39. */
  40. function _mapStateToProps(state: Object) {
  41. const { downloadAppsUrl } = state['features/base/config'].deploymentUrls || {};
  42. const visible = typeof downloadAppsUrl === 'string';
  43. return {
  44. _downloadAppsUrl: downloadAppsUrl,
  45. visible
  46. };
  47. }
  48. export default translate(connect(_mapStateToProps)(DownloadButton));