您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MuteRemoteParticipantDialog.web.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. REMOTE_VIDEO_MENU_MUTE_CONFIRMED,
  8. sendAnalyticsEvent
  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 {void}
  72. */
  73. _onSubmit() {
  74. const { dispatch, participantID } = this.props;
  75. sendAnalyticsEvent(
  76. REMOTE_VIDEO_MENU_MUTE_CONFIRMED,
  77. {
  78. value: 1,
  79. label: participantID
  80. }
  81. );
  82. dispatch(muteRemoteParticipant(participantID));
  83. return true;
  84. }
  85. /**
  86. * Renders the content of the dialog.
  87. *
  88. * @private
  89. * @returns {Component} The React {@code Component} which is the view of the
  90. * dialog content.
  91. */
  92. _renderContent() {
  93. const { t } = this.props;
  94. return (
  95. <div>
  96. { t('dialog.muteParticipantBody') }
  97. </div>
  98. );
  99. }
  100. }
  101. export default translate(connect()(MuteRemoteParticipantDialog));