2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
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-08-14 15:02:58 +00:00
|
|
|
import { kickParticipant } from '../../base/participants';
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
import RemoteVideoMenuButton from './RemoteVideoMenuButton';
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} state of {@link KickButton}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to signal the participant with the passed in participantID
|
|
|
|
* should be removed from the conference.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<*>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to invoke when {@code KickButton} is clicked.
|
|
|
|
*/
|
|
|
|
onClick: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant linked to the onClick callback.
|
|
|
|
*/
|
|
|
|
participantID: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
};
|
|
|
|
|
2017-05-31 15:42:50 +00:00
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which displays a button for kicking out
|
|
|
|
* a participant from the conference.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
class KickButton extends Component<Props> {
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code KickButton} 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 { participantID, t } = this.props;
|
2017-05-31 15:42:50 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<RemoteVideoMenuButton
|
|
|
|
buttonText = { t('videothumbnail.kick') }
|
|
|
|
iconClass = 'icon-kick'
|
|
|
|
id = { `ejectlink_${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
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
_onClick: () => void;
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Remove the participant with associated participantID from the conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { dispatch, onClick, participantID } = this.props;
|
|
|
|
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createRemoteVideoMenuButtonEvent(
|
|
|
|
'kick.button',
|
2017-09-29 21:27:53 +00:00
|
|
|
{
|
2018-01-03 21:24:07 +00:00
|
|
|
'participant_id': participantID
|
|
|
|
}));
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
dispatch(kickParticipant(participantID));
|
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
onClick();
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 15:42:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
export default translate(connect()(KickButton));
|