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.

MuteEveryonesVideoButton.js 2.3KB

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