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.

MuteEveryoneButton.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  3. import { openDialog } from '../../base/dialog';
  4. import { translate } from '../../base/i18n';
  5. import { IconMuteEveryone } from '../../base/icons';
  6. import { getLocalParticipant, isLocalParticipantModerator } from '../../base/participants';
  7. import { connect } from '../../base/redux';
  8. import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
  9. import { MuteEveryoneDialog } from '../../video-menu/components';
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * The Redux dispatch function.
  13. */
  14. dispatch: Function,
  15. /**
  16. * The ID of the local participant.
  17. */
  18. localParticipantId: string
  19. };
  20. /**
  21. * Implements a React {@link Component} which displays a button for audio muting
  22. * every participant (except the local one)
  23. */
  24. class MuteEveryoneButton extends AbstractButton<Props, *> {
  25. accessibilityLabel = 'toolbar.accessibilityLabel.muteEveryone';
  26. icon = IconMuteEveryone;
  27. label = 'toolbar.muteEveryone';
  28. tooltip = 'toolbar.muteEveryone';
  29. /**
  30. * Handles clicking / pressing the button, and opens a confirmation dialog.
  31. *
  32. * @private
  33. * @returns {void}
  34. */
  35. _handleClick() {
  36. const { dispatch, localParticipantId, handleClick } = this.props;
  37. if (handleClick) {
  38. handleClick();
  39. return;
  40. }
  41. sendAnalytics(createToolbarEvent('mute.everyone.pressed'));
  42. dispatch(openDialog(MuteEveryoneDialog, {
  43. exclude: [ localParticipantId ]
  44. }));
  45. }
  46. }
  47. /**
  48. * Maps part of the redux state to the component's props.
  49. *
  50. * @param {Object} state - The redux store/state.
  51. * @param {Props} ownProps - The component's own props.
  52. * @returns {Object}
  53. */
  54. function _mapStateToProps(state: Object, ownProps: Props) {
  55. const localParticipant = getLocalParticipant(state);
  56. const { disableRemoteMute } = state['features/base/config'];
  57. const { visible = isLocalParticipantModerator(state) && !disableRemoteMute } = ownProps;
  58. return {
  59. localParticipantId: localParticipant.id,
  60. visible
  61. };
  62. }
  63. export default translate(connect(_mapStateToProps)(MuteEveryoneButton));