您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DownloadButton.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 { openURLInBrowser } from '../../base/util';
  7. import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox';
  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. /**
  22. * Handles clicking / pressing the button, and opens a new window with the user documentation.
  23. *
  24. * @private
  25. * @returns {void}
  26. */
  27. _handleClick() {
  28. sendAnalytics(createToolbarEvent('download.pressed'));
  29. openURLInBrowser(this.props._downloadAppsUrl);
  30. }
  31. }
  32. /**
  33. * Maps part of the redux state to the component's props.
  34. *
  35. * @param {Object} state - The redux store/state.
  36. * @returns {Object}
  37. */
  38. function _mapStateToProps(state: Object) {
  39. const { downloadAppsUrl } = state['features/base/config'].deploymentUrls || {};
  40. const visible = typeof downloadAppsUrl === 'string';
  41. return {
  42. _downloadAppsUrl: downloadAppsUrl,
  43. visible
  44. };
  45. }
  46. export default translate(connect(_mapStateToProps)(DownloadButton));