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

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