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

DownloadButton.ts 1.7KB

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