2020-02-24 12:47:37 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../../analytics';
|
|
|
|
import { openDialog } from '../../../base/dialog';
|
|
|
|
import { translate } from '../../../base/i18n';
|
2020-03-13 12:14:18 +00:00
|
|
|
import { IconMuteEveryone } from '../../../base/icons';
|
2020-02-24 12:47:37 +00:00
|
|
|
import { getLocalParticipant, PARTICIPANT_ROLE } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2020-02-24 12:47:37 +00:00
|
|
|
import { MuteEveryoneDialog } from '../../../remote-video-menu';
|
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Whether the local participant is a moderator or not.
|
|
|
|
*/
|
|
|
|
isModerator: Boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the local participant.
|
|
|
|
*/
|
|
|
|
localParticipantId: string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which displays a button for audio muting
|
|
|
|
* every participant (except the local one)
|
|
|
|
*/
|
|
|
|
class MuteEveryoneButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.muteEveryone';
|
2020-03-13 12:14:18 +00:00
|
|
|
icon = IconMuteEveryone;
|
2020-02-24 12:47:37 +00:00
|
|
|
label = 'toolbar.muteEveryone';
|
|
|
|
tooltip = 'toolbar.muteEveryone';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens a confirmation dialog.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
const { dispatch, localParticipantId } = this.props;
|
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('mute.everyone.pressed'));
|
|
|
|
dispatch(openDialog(MuteEveryoneDialog, {
|
|
|
|
exclude: [ localParticipantId ]
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the redux state to the component's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @param {Props} ownProps - The component's own props.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state: Object, ownProps: Props) {
|
|
|
|
const localParticipant = getLocalParticipant(state);
|
|
|
|
const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
|
|
|
|
const { visible } = ownProps;
|
2020-03-25 21:28:31 +00:00
|
|
|
const { disableRemoteMute } = state['features/base/config'];
|
2020-02-24 12:47:37 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
isModerator,
|
|
|
|
localParticipantId: localParticipant.id,
|
2020-03-25 21:28:31 +00:00
|
|
|
visible: visible && isModerator && !disableRemoteMute
|
2020-02-24 12:47:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(MuteEveryoneButton));
|