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.

LobbyModeButton.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // @flow
  2. import { getCurrentConference } from '../../../base/conference';
  3. import { translate } from '../../../base/i18n';
  4. import { IconMeetingUnlocked, IconMeetingLocked } from '../../../base/icons';
  5. import { isLocalParticipantModerator } from '../../../base/participants';
  6. import { connect } from '../../../base/redux';
  7. import AbstractButton, { type Props as AbstractProps } from '../../../base/toolbox/components/AbstractButton';
  8. import { showDisableLobbyModeDialog, showEnableLobbyModeDialog } from '../../actions.native';
  9. type Props = AbstractProps & {
  10. /**
  11. * The Redux Dispatch function.
  12. */
  13. dispatch: Function,
  14. /**
  15. * True if the lobby mode is currently enabled for this conference.
  16. */
  17. lobbyEnabled: boolean
  18. };
  19. /**
  20. * Component to render the lobby mode initiator button.
  21. */
  22. class LobbyModeButton extends AbstractButton<Props, any> {
  23. accessibilityLabel = 'toolbar.accessibilityLabel.lobbyButton';
  24. icon = IconMeetingUnlocked;
  25. label = 'toolbar.lobbyButtonEnable';
  26. toggledLabel = 'toolbar.lobbyButtonDisable'
  27. toggledIcon = IconMeetingLocked;
  28. /**
  29. * Callback for the click event of the button.
  30. *
  31. * @returns {void}
  32. */
  33. _handleClick() {
  34. const { dispatch } = this.props;
  35. if (this._isToggled()) {
  36. dispatch(showDisableLobbyModeDialog());
  37. } else {
  38. dispatch(showEnableLobbyModeDialog());
  39. }
  40. }
  41. /**
  42. * Function to define the button state.
  43. *
  44. * @returns {boolean}
  45. */
  46. _isToggled() {
  47. return this.props.lobbyEnabled;
  48. }
  49. }
  50. /**
  51. * Maps part of the Redux store to the props of this component.
  52. *
  53. * @param {Object} state - The Redux state.
  54. * @param {Props} ownProps - The own props of the component.
  55. * @returns {Props}
  56. */
  57. export function _mapStateToProps(state: Object): $Shape<Props> {
  58. const conference = getCurrentConference(state);
  59. const { lobbyEnabled } = state['features/lobby'];
  60. const { hideLobbyButton } = state['features/base/config'];
  61. const lobbySupported = conference && conference.isLobbySupported();
  62. return {
  63. lobbyEnabled,
  64. visible: lobbySupported && isLocalParticipantModerator(state) && !hideLobbyButton
  65. };
  66. }
  67. export default translate(connect(_mapStateToProps)(LobbyModeButton));