You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KickButton.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* @flow */
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { IconKick } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import AbstractKickButton, {
  7. type Props
  8. } from '../AbstractKickButton';
  9. import RemoteVideoMenuButton from './RemoteVideoMenuButton';
  10. declare var interfaceConfig: Object;
  11. /**
  12. * Implements a React {@link Component} which displays a button for kicking out
  13. * a participant from the conference.
  14. *
  15. * NOTE: At the time of writing this is a button that doesn't use the
  16. * {@code AbstractButton} base component, but is inherited from the same
  17. * super class ({@code AbstractKickButton} that extends {@code AbstractButton})
  18. * for the sake of code sharing between web and mobile. Once web uses the
  19. * {@code AbstractButton} base component, this can be fully removed.
  20. */
  21. class KickButton extends AbstractKickButton {
  22. /**
  23. * Instantiates a new {@code Component}.
  24. *
  25. * @inheritdoc
  26. */
  27. constructor(props: Props) {
  28. super(props);
  29. this._handleClick = this._handleClick.bind(this);
  30. }
  31. /**
  32. * Implements React's {@link Component#render()}.
  33. *
  34. * @inheritdoc
  35. * @returns {ReactElement}
  36. */
  37. render() {
  38. const { participantID, t, visible } = this.props;
  39. if (!visible) {
  40. return null;
  41. }
  42. return (
  43. <RemoteVideoMenuButton
  44. buttonText = { t('videothumbnail.kick') }
  45. displayClass = 'kicklink'
  46. icon = { IconKick }
  47. id = { `ejectlink_${participantID}` }
  48. // eslint-disable-next-line react/jsx-handler-names
  49. onClick = { this._handleClick } />
  50. );
  51. }
  52. _handleClick: () => void
  53. }
  54. /**
  55. * Maps (parts of) the redux state to {@link KickButton}'s React {@code Component}
  56. * props.
  57. *
  58. * @param {Object} state - The redux store/state.
  59. * @private
  60. * @returns {Object}
  61. */
  62. function _mapStateToProps(state: Object) {
  63. const shouldHide = interfaceConfig.HIDE_KICK_BUTTON_FOR_GUESTS && state['features/base/jwt'].isGuest;
  64. return {
  65. visible: !shouldHide
  66. };
  67. }
  68. export default translate(connect(_mapStateToProps)(KickButton));