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

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