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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 { setAddPeopleDialogVisible } from '../../../actions';
  8. import { isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
  9. type Props = AbstractButtonProps & {
  10. /**
  11. * The Redux dispatch function.
  12. */
  13. dispatch: Dispatch<any>
  14. };
  15. /**
  16. * Implements an {@link AbstractButton} to enter add/invite people to the
  17. * current call/conference/meeting.
  18. */
  19. class InviteButton extends AbstractButton<Props, *> {
  20. accessibilityLabel = 'toolbar.accessibilityLabel.shareRoom';
  21. iconName = 'icon-link';
  22. label = 'toolbar.shareRoom';
  23. /**
  24. * Handles clicking / pressing the button, and opens the appropriate dialog.
  25. *
  26. * @private
  27. * @returns {void}
  28. */
  29. _handleClick() {
  30. this.props.dispatch(setAddPeopleDialogVisible(true));
  31. }
  32. }
  33. /**
  34. * Maps (parts of) the redux state to {@link InviteButton}'s React {@code Component}
  35. * props.
  36. *
  37. * @param {Object} state - The redux store/state.
  38. * @param {Object} ownProps - The properties explicitly passed to the component
  39. * instance.
  40. * @private
  41. * @returns {Object}
  42. */
  43. function _mapStateToProps(state: Object, ownProps: Object) {
  44. const addPeopleEnabled = isAddPeopleEnabled(state) || isDialOutEnabled(state);
  45. const { visible = Boolean(addPeopleEnabled) } = ownProps;
  46. return {
  47. visible
  48. };
  49. }
  50. export default translate(connect(_mapStateToProps)(InviteButton));