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

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