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.

MuteEveryoneDialog.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // @flow
  2. import React from 'react';
  3. import { Dialog } from '../../../base/dialog';
  4. import { translate } from '../../../base/i18n';
  5. import { connect } from '../../../base/redux';
  6. import { muteAllParticipants } from '../../actions';
  7. import AbstractMuteRemoteParticipantDialog, {
  8. type Props as AbstractProps
  9. } from '../AbstractMuteRemoteParticipantDialog';
  10. declare var APP: Object;
  11. /**
  12. * The type of the React {@code Component} props of
  13. * {@link MuteEveryoneDialog}.
  14. */
  15. type Props = AbstractProps & {
  16. /**
  17. * The IDs of the remote participants to exclude from being muted.
  18. */
  19. exclude: Array<string>
  20. };
  21. /**
  22. * Translations needed for dialog rendering.
  23. */
  24. type Translations = {
  25. /**
  26. * Content text.
  27. */
  28. content: string,
  29. /**
  30. * Title text.
  31. */
  32. title: string
  33. }
  34. /**
  35. * A React Component with the contents for a dialog that asks for confirmation
  36. * from the user before muting a remote participant.
  37. *
  38. * @extends Component
  39. */
  40. class MuteEveryoneDialog extends AbstractMuteRemoteParticipantDialog<Props> {
  41. static defaultProps = {
  42. exclude: [],
  43. muteLocal: false
  44. };
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {ReactElement}
  50. */
  51. render() {
  52. const { content, title } = this._getTranslations();
  53. return (
  54. <Dialog
  55. okKey = 'dialog.muteParticipantButton'
  56. onSubmit = { this._onSubmit }
  57. titleString = { title }
  58. width = 'small'>
  59. <div>
  60. { content }
  61. </div>
  62. </Dialog>
  63. );
  64. }
  65. _onSubmit: () => boolean;
  66. /**
  67. * Callback to be invoked when the value of this dialog is submitted.
  68. *
  69. * @returns {boolean}
  70. */
  71. _onSubmit() {
  72. const {
  73. dispatch,
  74. exclude
  75. } = this.props;
  76. dispatch(muteAllParticipants(exclude));
  77. return true;
  78. }
  79. /**
  80. * Method to get translations depending on whether we have an exclusive
  81. * mute or not.
  82. *
  83. * @returns {Translations}
  84. * @private
  85. */
  86. _getTranslations(): Translations {
  87. const { exclude, t } = this.props;
  88. const { conference } = APP;
  89. const whom = exclude
  90. // eslint-disable-next-line no-confusing-arrow
  91. .map(id => conference.isLocalId(id)
  92. ? t('dialog.muteEveryoneSelf')
  93. : conference.getParticipantDisplayName(id))
  94. .join(', ');
  95. return whom.length ? {
  96. content: t('dialog.muteEveryoneElseDialog'),
  97. title: t('dialog.muteEveryoneElseTitle', { whom })
  98. } : {
  99. content: t('dialog.muteEveryoneDialog'),
  100. title: t('dialog.muteEveryoneTitle')
  101. };
  102. }
  103. }
  104. export default translate(connect()(MuteEveryoneDialog));