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.

MuteRemoteParticipantDialog.web.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { Dialog } from '../../base/dialog';
  5. import { translate } from '../../base/i18n';
  6. import {
  7. createRemoteMuteConfirmedEvent,
  8. sendAnalytics
  9. } from '../../analytics';
  10. import { muteRemoteParticipant } from '../../base/participants';
  11. /**
  12. * A React Component with the contents for a dialog that asks for confirmation
  13. * from the user before muting a remote participant.
  14. *
  15. * @extends Component
  16. */
  17. class MuteRemoteParticipantDialog extends Component {
  18. /**
  19. * {@code MuteRemoteParticipantDialog} component's property types.
  20. *
  21. * @static
  22. */
  23. static propTypes = {
  24. /**
  25. * Invoked to send a request for muting the participant with the passed
  26. * in participantID.
  27. */
  28. dispatch: 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 MuteRemoteParticipantDialog} instance.
  40. *
  41. * @param {Object} props - The read-only properties with which the new
  42. * instance is to be initialized.
  43. */
  44. constructor(props) {
  45. super(props);
  46. // Bind event handlers so they are only bound once per instance.
  47. this._onSubmit = this._onSubmit.bind(this);
  48. this._renderContent = this._renderContent.bind(this);
  49. }
  50. /**
  51. * Implements React's {@link Component#render()}.
  52. *
  53. * @inheritdoc
  54. * @returns {ReactElement}
  55. */
  56. render() {
  57. return (
  58. <Dialog
  59. okTitleKey = 'dialog.muteParticipantButton'
  60. onSubmit = { this._onSubmit }
  61. titleKey = 'dialog.muteParticipantTitle'
  62. width = 'small'>
  63. { this._renderContent() }
  64. </Dialog>
  65. );
  66. }
  67. /**
  68. * Handles the submit button action.
  69. *
  70. * @private
  71. * @returns {boolean} - True (to note that the modal should be closed).
  72. */
  73. _onSubmit() {
  74. const { dispatch, participantID } = this.props;
  75. sendAnalytics(createRemoteMuteConfirmedEvent(participantID));
  76. dispatch(muteRemoteParticipant(participantID));
  77. return true;
  78. }
  79. /**
  80. * Renders the content of the dialog.
  81. *
  82. * @private
  83. * @returns {Component} The React {@code Component} which is the view of the
  84. * dialog content.
  85. */
  86. _renderContent() {
  87. const { t } = this.props;
  88. return (
  89. <div>
  90. { t('dialog.muteParticipantBody') }
  91. </div>
  92. );
  93. }
  94. }
  95. export default translate(connect()(MuteRemoteParticipantDialog));