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

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