2017-05-31 15:42:50 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-08-14 15:02:58 +00:00
|
|
|
import { connect } from 'react-redux';
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
2017-08-14 15:02:58 +00:00
|
|
|
import { muteRemoteParticipant } from '../../base/participants';
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
import RemoteVideoMenuButton from './RemoteVideoMenuButton';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which displays a button for audio muting
|
|
|
|
* a participant in the conference.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class MuteButton extends Component {
|
|
|
|
/**
|
|
|
|
* {@code MuteButton} component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Invoked to send a request for muting the participant with the passed
|
|
|
|
* in participantID.
|
|
|
|
*/
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
|
2017-05-31 15:42:50 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the participant is currently audio muted.
|
|
|
|
*/
|
|
|
|
isAudioMuted: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
2017-08-14 15:02:58 +00:00
|
|
|
* Callback to invoke when {@code MuteButton} is clicked.
|
2017-05-31 15:42:50 +00:00
|
|
|
*/
|
|
|
|
onClick: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant linked to the onClick callback.
|
|
|
|
*/
|
|
|
|
participantID: React.PropTypes.string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: React.PropTypes.func
|
|
|
|
};
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code MuteButton} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
2017-05-31 15:42:50 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-08-14 15:02:58 +00:00
|
|
|
const { isAudioMuted, participantID, t } = this.props;
|
2017-05-31 15:42:50 +00:00
|
|
|
const muteConfig = isAudioMuted ? {
|
|
|
|
translationKey: 'videothumbnail.muted',
|
|
|
|
muteClassName: 'mutelink disabled'
|
|
|
|
} : {
|
|
|
|
translationKey: 'videothumbnail.domute',
|
|
|
|
muteClassName: 'mutelink'
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<RemoteVideoMenuButton
|
|
|
|
buttonText = { t(muteConfig.translationKey) }
|
|
|
|
displayClass = { muteConfig.muteClassName }
|
|
|
|
iconClass = 'icon-mic-disabled'
|
|
|
|
id = { `mutelink_${participantID}` }
|
2017-08-14 15:02:58 +00:00
|
|
|
onClick = { this._onClick } />
|
2017-05-31 15:42:50 +00:00
|
|
|
);
|
|
|
|
}
|
2017-08-14 15:02:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches a request to mute the participant with the passed in
|
|
|
|
* participantID.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { dispatch, onClick, participantID } = this.props;
|
|
|
|
|
|
|
|
dispatch(muteRemoteParticipant(participantID));
|
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
onClick();
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 15:42:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
export default translate(connect()(MuteButton));
|