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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. import { isVpaasMeeting } from '../../jaas/functions';
  9. type Props = 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<Props, *> {
  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, handleClick } = this.props;
  31. if (handleClick) {
  32. handleClick();
  33. return;
  34. }
  35. sendAnalytics(createToolbarEvent('download.pressed'));
  36. openURLInBrowser(_downloadAppsUrl);
  37. }
  38. }
  39. /**
  40. * Maps part of the redux state to the component's props.
  41. *
  42. * @param {Object} state - The redux store/state.
  43. * @returns {Object}
  44. */
  45. function _mapStateToProps(state: Object) {
  46. const { downloadAppsUrl } = state['features/base/config'].deploymentUrls || {};
  47. const visible = typeof downloadAppsUrl === 'string' && !isVpaasMeeting(state);
  48. return {
  49. _downloadAppsUrl: downloadAppsUrl,
  50. visible
  51. };
  52. }
  53. export default translate(connect(_mapStateToProps)(DownloadButton));