jiti-meet/react/features/remote-video-menu/components/web/KickButton.js

84 lines
2.2 KiB
JavaScript
Raw Normal View History

/* @flow */
2019-01-05 16:49:21 +00:00
import React from 'react';
2018-12-19 18:40:17 +00:00
import { translate } from '../../../base/i18n';
2019-08-30 16:39:06 +00:00
import { IconKick } from '../../../base/icons';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../base/redux';
2019-01-05 16:49:21 +00:00
import AbstractKickButton, {
type Props
} from '../AbstractKickButton';
2019-01-05 16:49:21 +00:00
import RemoteVideoMenuButton from './RemoteVideoMenuButton';
declare var interfaceConfig: Object;
/**
* Implements a React {@link Component} which displays a button for kicking out
* a participant from the conference.
*
2019-01-05 16:49:21 +00:00
* NOTE: At the time of writing this is a button that doesn't use the
* {@code AbstractButton} base component, but is inherited from the same
* super class ({@code AbstractKickButton} that extends {@code AbstractButton})
* for the sake of code sharing between web and mobile. Once web uses the
* {@code AbstractButton} base component, this can be fully removed.
*/
2019-01-05 16:49:21 +00:00
class KickButton extends AbstractKickButton {
/**
2019-01-05 16:49:21 +00:00
* Instantiates a new {@code Component}.
*
2019-01-05 16:49:21 +00:00
* @inheritdoc
*/
2019-01-05 16:49:21 +00:00
constructor(props: Props) {
super(props);
2019-01-05 16:49:21 +00:00
this._handleClick = this._handleClick.bind(this);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const { participantID, t, visible } = this.props;
if (!visible) {
return null;
}
return (
<RemoteVideoMenuButton
buttonText = { t('videothumbnail.kick') }
displayClass = 'kicklink'
2019-08-30 16:39:06 +00:00
icon = { IconKick }
id = { `ejectlink_${participantID}` }
2019-01-05 16:49:21 +00:00
// eslint-disable-next-line react/jsx-handler-names
onClick = { this._handleClick } />
);
}
2019-01-05 16:49:21 +00:00
_handleClick: () => void
}
/**
* Maps (parts of) the redux state to {@link KickButton}'s React {@code Component}
* props.
*
* @param {Object} state - The redux store/state.
* @private
* @returns {Object}
*/
function _mapStateToProps(state: Object) {
const shouldHide = interfaceConfig.HIDE_KICK_BUTTON_FOR_GUESTS && state['features/base/jwt'].isGuest;
return {
visible: !shouldHide
};
}
export default translate(connect(_mapStateToProps)(KickButton));