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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* @flow */
  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. * The type of the React {@code Component} props of
  13. * {@link MuteRemoteParticipantDialog}.
  14. */
  15. type Props = {
  16. /**
  17. * Invoked to send a request for muting the participant with the passed
  18. * in participantID.
  19. */
  20. dispatch: Dispatch<*>,
  21. /**
  22. * The ID of the participant linked to the onClick callback.
  23. */
  24. participantID: string,
  25. /**
  26. * Invoked to obtain translated strings.
  27. */
  28. t: Function
  29. };
  30. /**
  31. * A React Component with the contents for a dialog that asks for confirmation
  32. * from the user before muting a remote participant.
  33. *
  34. * @extends Component
  35. */
  36. class MuteRemoteParticipantDialog extends Component<Props> {
  37. /**
  38. * Initializes a new {@code MuteRemoteParticipantDialog} instance.
  39. *
  40. * @param {Object} props - The read-only properties with which the new
  41. * instance is to be initialized.
  42. */
  43. constructor(props: Props) {
  44. super(props);
  45. // Bind event handlers so they are only bound once per instance.
  46. this._onSubmit = this._onSubmit.bind(this);
  47. this._renderContent = this._renderContent.bind(this);
  48. }
  49. /**
  50. * Implements React's {@link Component#render()}.
  51. *
  52. * @inheritdoc
  53. * @returns {ReactElement}
  54. */
  55. render() {
  56. return (
  57. <Dialog
  58. okTitleKey = 'dialog.muteParticipantButton'
  59. onSubmit = { this._onSubmit }
  60. titleKey = 'dialog.muteParticipantTitle'
  61. width = 'small'>
  62. { this._renderContent() }
  63. </Dialog>
  64. );
  65. }
  66. _onSubmit: () => void;
  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. _renderContent: () => React$Element<*>;
  80. /**
  81. * Renders the content of the dialog.
  82. *
  83. * @private
  84. * @returns {Component} The React {@code Component} which is the view of the
  85. * dialog content.
  86. */
  87. _renderContent() {
  88. const { t } = this.props;
  89. return (
  90. <div>
  91. { t('dialog.muteParticipantBody') }
  92. </div>
  93. );
  94. }
  95. }
  96. export default translate(connect()(MuteRemoteParticipantDialog));