Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

InviteButton.native.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import type { Dispatch } from 'redux';
  4. import { translate } from '../../base/i18n';
  5. import { AbstractButton } from '../../base/toolbox';
  6. import type { AbstractButtonProps } from '../../base/toolbox';
  7. import { beginShareRoom } from '../../share-room';
  8. import { beginAddPeople } from '../actions';
  9. import { isAddPeopleEnabled, isDialOutEnabled } from '../functions';
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * Whether or not the feature to directly invite people into the
  13. * conference is available.
  14. */
  15. _addPeopleEnabled: boolean,
  16. /**
  17. * Whether or not the feature to dial out to number to join the
  18. * conference is available.
  19. */
  20. _dialOutEnabled: boolean,
  21. /**
  22. * Launches native invite dialog.
  23. *
  24. * @protected
  25. */
  26. _onAddPeople: Function,
  27. /**
  28. * Begins the UI procedure to share the conference/room URL.
  29. */
  30. _onShareRoom: Function
  31. };
  32. /**
  33. * Implements an {@link AbstractButton} to enter add/invite people to the
  34. * current call/conference/meeting.
  35. */
  36. class InviteButton extends AbstractButton<Props, *> {
  37. accessibilityLabel = 'toolbar.accessibilityLabel.shareRoom';
  38. iconName = 'icon-link';
  39. label = 'toolbar.shareRoom';
  40. /**
  41. * Handles clicking / pressing the button, and opens the appropriate dialog.
  42. *
  43. * @private
  44. * @returns {void}
  45. */
  46. _handleClick() {
  47. // FIXME: dispatch _onAddPeople here, when we have a dialog for it.
  48. const {
  49. _onShareRoom
  50. } = this.props;
  51. _onShareRoom();
  52. }
  53. }
  54. /**
  55. * Maps redux actions to {@link InviteButton}'s React
  56. * {@code Component} props.
  57. *
  58. * @param {Function} dispatch - The redux action {@code dispatch} function.
  59. * @returns {{
  60. * _onAddPeople,
  61. * _onShareRoom
  62. * }}
  63. * @private
  64. */
  65. function _mapDispatchToProps(dispatch: Dispatch<*>) {
  66. return {
  67. /**
  68. * Launches the add people dialog.
  69. *
  70. * @private
  71. * @returns {void}
  72. * @type {Function}
  73. */
  74. _onAddPeople() {
  75. dispatch(beginAddPeople());
  76. },
  77. /**
  78. * Begins the UI procedure to share the conference/room URL.
  79. *
  80. * @private
  81. * @returns {void}
  82. * @type {Function}
  83. */
  84. _onShareRoom() {
  85. dispatch(beginShareRoom());
  86. }
  87. };
  88. }
  89. /**
  90. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  91. * props.
  92. *
  93. * @param {Object} state - The redux store/state.
  94. * @private
  95. * @returns {{
  96. * }}
  97. */
  98. function _mapStateToProps(state) {
  99. return {
  100. /**
  101. * Whether or not the feature to directly invite people into the
  102. * conference is available.
  103. *
  104. * @type {boolean}
  105. */
  106. _addPeopleEnabled: isAddPeopleEnabled(state),
  107. /**
  108. * Whether or not the feature to dial out to number to join the
  109. * conference is available.
  110. *
  111. * @type {boolean}
  112. */
  113. _dialOutEnabled: isDialOutEnabled(state)
  114. };
  115. }
  116. export default translate(
  117. connect(_mapStateToProps, _mapDispatchToProps)(InviteButton));