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.

SharedDocumentButton.native.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { createToolbarEvent } from '../../analytics/AnalyticsEvents';
  4. import { sendAnalytics } from '../../analytics/functions';
  5. import { translate } from '../../base/i18n/functions';
  6. import { IconShareDoc } from '../../base/icons/svg';
  7. import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
  8. import { navigate } from '../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  9. import { screen } from '../../mobile/navigation/routes';
  10. type Props = AbstractButtonProps;
  11. /**
  12. * Implements an {@link AbstractButton} to open the chat screen on mobile.
  13. */
  14. class SharedDocumentButton extends AbstractButton<Props, *> {
  15. accessibilityLabel = 'toolbar.accessibilityLabel.document';
  16. icon = IconShareDoc;
  17. label = 'toolbar.documentOpen';
  18. tooltip = 'toolbar.documentOpen';
  19. /**
  20. * Handles clicking / pressing the button, and opens / closes the appropriate dialog.
  21. *
  22. * @private
  23. * @returns {void}
  24. */
  25. _handleClick() {
  26. const { handleClick } = this.props;
  27. if (handleClick) {
  28. handleClick();
  29. return;
  30. }
  31. sendAnalytics(createToolbarEvent(
  32. 'toggle.etherpad',
  33. {
  34. enable: true
  35. }));
  36. navigate(screen.conference.sharedDocument);
  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. * @param {Object} ownProps - The properties explicitly passed to the component
  44. * instance.
  45. * @returns {Object}
  46. */
  47. function _mapStateToProps(state: Object, ownProps: Object) {
  48. const { documentUrl } = state['features/etherpad'];
  49. const { visible = Boolean(documentUrl) } = ownProps;
  50. return {
  51. visible
  52. };
  53. }
  54. export default translate(connect(_mapStateToProps)(SharedDocumentButton));