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

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