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.

AbstractMuteEveryoneDialog.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // @flow
  2. import React from 'react';
  3. import { Dialog } from '../../base/dialog';
  4. import { getLocalParticipant, getParticipantDisplayName } from '../../base/participants';
  5. import { muteAllParticipants } from '../actions';
  6. import AbstractMuteRemoteParticipantDialog, {
  7. type Props as AbstractProps
  8. } from './AbstractMuteRemoteParticipantDialog';
  9. /**
  10. * The type of the React {@code Component} props of
  11. * {@link AbstractMuteEveryoneDialog}.
  12. */
  13. export type Props = AbstractProps & {
  14. content: string,
  15. exclude: Array<string>,
  16. title: string
  17. };
  18. /**
  19. *
  20. * An abstract Component with the contents for a dialog that asks for confirmation
  21. * from the user before muting all remote participants.
  22. *
  23. * @extends AbstractMuteRemoteParticipantDialog
  24. */
  25. export default class AbstractMuteEveryoneDialog<P: Props> extends AbstractMuteRemoteParticipantDialog<P> {
  26. static defaultProps = {
  27. exclude: [],
  28. muteLocal: false
  29. };
  30. /**
  31. * Implements React's {@link Component#render()}.
  32. *
  33. * @inheritdoc
  34. * @returns {ReactElement}
  35. */
  36. render() {
  37. const { content, title } = this.props;
  38. return (
  39. <Dialog
  40. okKey = 'dialog.muteParticipantButton'
  41. onSubmit = { this._onSubmit }
  42. titleString = { title }
  43. width = 'small'>
  44. <div>
  45. { content }
  46. </div>
  47. </Dialog>
  48. );
  49. }
  50. _onSubmit: () => boolean;
  51. /**
  52. * Callback to be invoked when the value of this dialog is submitted.
  53. *
  54. * @returns {boolean}
  55. */
  56. _onSubmit() {
  57. const {
  58. dispatch,
  59. exclude
  60. } = this.props;
  61. dispatch(muteAllParticipants(exclude));
  62. return true;
  63. }
  64. }
  65. /**
  66. * Maps (parts of) the Redux state to the associated {@code AbstractMuteEveryoneDialog}'s props.
  67. *
  68. * @param {Object} state - The redux state.
  69. * @param {Object} ownProps - The properties explicitly passed to the component.
  70. * @returns {Props}
  71. */
  72. export function abstractMapStateToProps(state: Object, ownProps: Props) {
  73. const { exclude, t } = ownProps;
  74. const whom = exclude
  75. // eslint-disable-next-line no-confusing-arrow
  76. .map(id => id === getLocalParticipant(state).id
  77. ? t('dialog.muteEveryoneSelf')
  78. : getParticipantDisplayName(state, id))
  79. .join(', ');
  80. return whom.length ? {
  81. content: t('dialog.muteEveryoneElseDialog'),
  82. title: t('dialog.muteEveryoneElseTitle', { whom })
  83. } : {
  84. content: t('dialog.muteEveryoneDialog'),
  85. title: t('dialog.muteEveryoneTitle')
  86. };
  87. }