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

AbstractMuteEveryonesVideoDialog.js 2.8KB

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