您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LobbyModeButton.js 2.1KB

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