2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
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
|
|
|
|
2017-12-11 18:48:32 +00:00
|
|
|
import {
|
2018-01-03 21:24:07 +00:00
|
|
|
createRemoteVideoMenuButtonEvent,
|
|
|
|
sendAnalytics
|
2017-12-11 18:48:32 +00:00
|
|
|
} from '../../analytics';
|
2017-05-31 15:42:50 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2017-11-09 17:23:17 +00:00
|
|
|
import { openDialog } from '../../base/dialog';
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
import RemoteVideoMenuButton from './RemoteVideoMenuButton';
|
2017-11-09 17:23:17 +00:00
|
|
|
import MuteRemoteParticipantDialog from './MuteRemoteParticipantDialog';
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
dispatch: PropTypes.func,
|
2017-08-14 15:02:58 +00:00
|
|
|
|
2017-05-31 15:42:50 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the participant is currently audio muted.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
isAudioMuted: PropTypes.bool,
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
/**
|
2017-08-14 15:02:58 +00:00
|
|
|
* Callback to invoke when {@code MuteButton} is clicked.
|
2017-05-31 15:42:50 +00:00
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
onClick: PropTypes.func,
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant linked to the onClick callback.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
participantID: PropTypes.string,
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
t: PropTypes.func
|
2017-05-31 15:42:50 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createRemoteVideoMenuButtonEvent(
|
|
|
|
'mute.button',
|
2017-09-29 21:27:53 +00:00
|
|
|
{
|
2018-01-03 21:24:07 +00:00
|
|
|
'participant_id': participantID
|
|
|
|
}));
|
2017-09-29 21:27:53 +00:00
|
|
|
|
2017-11-09 17:23:17 +00:00
|
|
|
dispatch(openDialog(MuteRemoteParticipantDialog, { participantID }));
|
2017-08-14 15:02:58 +00:00
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
onClick();
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 15:42:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
export default translate(connect()(MuteButton));
|