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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../base/i18n';
  5. import { kickParticipant } from '../../base/participants';
  6. import RemoteVideoMenuButton from './RemoteVideoMenuButton';
  7. /**
  8. * Implements a React {@link Component} which displays a button for kicking out
  9. * a participant from the conference.
  10. *
  11. * @extends Component
  12. */
  13. class KickButton extends Component {
  14. /**
  15. * {@code KickButton} component's property types.
  16. *
  17. * @static
  18. */
  19. static propTypes = {
  20. /**
  21. * Invoked to signal the participant with the passed in participantID
  22. * should be removed from the conference.
  23. */
  24. dispatch: PropTypes.func,
  25. /**
  26. * Callback to invoke when {@code KickButton} is clicked.
  27. */
  28. onClick: PropTypes.func,
  29. /**
  30. * The ID of the participant linked to the onClick callback.
  31. */
  32. participantID: PropTypes.string,
  33. /**
  34. * Invoked to obtain translated strings.
  35. */
  36. t: PropTypes.func
  37. };
  38. /**
  39. * Initializes a new {@code KickButton} instance.
  40. *
  41. * @param {Object} props - The read-only React Component props with which
  42. * the new instance is to be initialized.
  43. */
  44. constructor(props) {
  45. super(props);
  46. // Bind event handlers so they are only bound once for every instance.
  47. this._onClick = this._onClick.bind(this);
  48. }
  49. /**
  50. * Implements React's {@link Component#render()}.
  51. *
  52. * @inheritdoc
  53. * @returns {ReactElement}
  54. */
  55. render() {
  56. const { participantID, t } = this.props;
  57. return (
  58. <RemoteVideoMenuButton
  59. buttonText = { t('videothumbnail.kick') }
  60. iconClass = 'icon-kick'
  61. id = { `ejectlink_${participantID}` }
  62. onClick = { this._onClick } />
  63. );
  64. }
  65. /**
  66. * Remove the participant with associated participantID from the conference.
  67. *
  68. * @private
  69. * @returns {void}
  70. */
  71. _onClick() {
  72. const { dispatch, onClick, participantID } = this.props;
  73. dispatch(kickParticipant(participantID));
  74. if (onClick) {
  75. onClick();
  76. }
  77. }
  78. }
  79. export default translate(connect()(KickButton));