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

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