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.

InviteButton.native.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { AbstractButton } from '../../base/toolbox';
  4. import type { AbstractButtonProps } from '../../base/toolbox';
  5. import { beginShareRoom } from '../../share-room';
  6. import { beginAddPeople } from '../actions';
  7. import { isAddPeopleEnabled, isDialOutEnabled } from '../functions';
  8. type Props = AbstractButtonProps & {
  9. /**
  10. * Whether or not the feature to directly invite people into the
  11. * conference is available.
  12. */
  13. _addPeopleEnabled: boolean,
  14. /**
  15. * Whether or not the feature to dial out to number to join the
  16. * conference is available.
  17. */
  18. _dialOutEnabled: boolean,
  19. /**
  20. * Launches native invite dialog.
  21. *
  22. * @protected
  23. */
  24. _onAddPeople: Function,
  25. /**
  26. * Begins the UI procedure to share the conference/room URL.
  27. */
  28. _onShareRoom: Function
  29. };
  30. /**
  31. * The indicator which determines (at bundle time) whether there should be a
  32. * button in {@code Toolbox} to expose the functionality of the feature
  33. * share-room in the user interface of the app.
  34. *
  35. * @private
  36. * @type {boolean}
  37. */
  38. const _SHARE_ROOM_TOOLBAR_BUTTON = true;
  39. /**
  40. * Implements an {@link AbstractButton} to enter add/invite people to the
  41. * current call/conference/meeting.
  42. */
  43. class InviteButton extends AbstractButton<Props, *> {
  44. accessibilityLabel = 'Share room';
  45. iconName = 'icon-link';
  46. label = 'toolbar.shareRoom';
  47. /**
  48. * Handles clicking / pressing the button, and opens the appropriate dialog.
  49. *
  50. * @private
  51. * @returns {void}
  52. */
  53. _handleClick() {
  54. const {
  55. _addPeopleEnabled,
  56. _dialOutEnabled,
  57. _onAddPeople,
  58. _onShareRoom
  59. } = this.props;
  60. if (_addPeopleEnabled || _dialOutEnabled) {
  61. _onAddPeople();
  62. } else if (_SHARE_ROOM_TOOLBAR_BUTTON) {
  63. _onShareRoom();
  64. }
  65. }
  66. /**
  67. * Implements React's {@link Component#render()}.
  68. *
  69. * @inheritdoc
  70. * @returns {React$Node}
  71. */
  72. render() {
  73. const { _addPeopleEnabled, _dialOutEnabled } = this.props;
  74. return (
  75. _SHARE_ROOM_TOOLBAR_BUTTON
  76. || _addPeopleEnabled
  77. || _dialOutEnabled
  78. ? super.render()
  79. : null);
  80. }
  81. }
  82. /**
  83. * Maps redux actions to {@link InviteButton}'s React
  84. * {@code Component} props.
  85. *
  86. * @param {Function} dispatch - The redux action {@code dispatch} function.
  87. * @returns {{
  88. * _onAddPeople,
  89. * _onShareRoom
  90. * }}
  91. * @private
  92. */
  93. function _mapDispatchToProps(dispatch) {
  94. return {
  95. /**
  96. * Launches native invite dialog.
  97. *
  98. * @private
  99. * @returns {void}
  100. * @type {Function}
  101. */
  102. _onAddPeople() {
  103. dispatch(beginAddPeople());
  104. },
  105. /**
  106. * Begins the UI procedure to share the conference/room URL.
  107. *
  108. * @private
  109. * @returns {void}
  110. * @type {Function}
  111. */
  112. _onShareRoom() {
  113. dispatch(beginShareRoom());
  114. }
  115. };
  116. }
  117. /**
  118. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  119. * props.
  120. *
  121. * @param {Object} state - The redux store/state.
  122. * @private
  123. * @returns {{
  124. * }}
  125. */
  126. function _mapStateToProps(state) {
  127. return {
  128. /**
  129. * Whether or not the feature to directly invite people into the
  130. * conference is available.
  131. *
  132. * @type {boolean}
  133. */
  134. _addPeopleEnabled: isAddPeopleEnabled(state),
  135. /**
  136. * Whether or not the feature to dial out to number to join the
  137. * conference is available.
  138. *
  139. * @type {boolean}
  140. */
  141. _dialOutEnabled: isDialOutEnabled(state)
  142. };
  143. }
  144. export default connect(_mapStateToProps, _mapDispatchToProps)(InviteButton);