2021-02-24 21:45:07 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
|
|
import { openDialog } from '../../base/dialog';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
import { IconMuteVideoEveryone } from '../../base/icons';
|
2021-05-12 12:06:09 +00:00
|
|
|
import { getLocalParticipant, isLocalParticipantModerator } from '../../base/participants';
|
2021-02-24 21:45:07 +00:00
|
|
|
import { connect } from '../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { MuteEveryonesVideoDialog } from '../../video-menu/components';
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the local participant.
|
|
|
|
*/
|
|
|
|
localParticipantId: string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which displays a button for disabling the camera of
|
|
|
|
* every participant (except the local one)
|
|
|
|
*/
|
|
|
|
class MuteEveryonesVideoButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.muteEveryonesVideo';
|
|
|
|
icon = IconMuteVideoEveryone;
|
|
|
|
label = 'toolbar.muteEveryonesVideo';
|
2021-07-08 13:42:07 +00:00
|
|
|
tooltip = 'toolbar.muteEveryonesVideo';
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens a confirmation dialog.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2021-09-14 07:07:20 +00:00
|
|
|
const { dispatch, localParticipantId, handleClick } = this.props;
|
|
|
|
|
|
|
|
if (handleClick) {
|
|
|
|
handleClick();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('mute.everyone.pressed'));
|
|
|
|
dispatch(openDialog(MuteEveryonesVideoDialog, {
|
|
|
|
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 { disableRemoteMute } = state['features/base/config'];
|
2021-05-12 12:06:09 +00:00
|
|
|
const { visible = isLocalParticipantModerator(state) && !disableRemoteMute } = ownProps;
|
2021-02-24 21:45:07 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
localParticipantId: localParticipant.id,
|
2021-05-12 12:06:09 +00:00
|
|
|
visible
|
2021-02-24 21:45:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(MuteEveryonesVideoButton));
|