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

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