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

ParticipantQuickAction.tsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch } from 'react-redux';
  4. import { makeStyles } from 'tss-react/mui';
  5. import { approveParticipantAudio, approveParticipantVideo } from '../../../av-moderation/actions';
  6. import Button from '../../../base/ui/components/web/Button';
  7. import { QUICK_ACTION_BUTTON } from '../../constants';
  8. interface IProps {
  9. /**
  10. * The translated ask unmute aria label.
  11. */
  12. ariaLabel?: boolean;
  13. /**
  14. * The translated "ask unmute" text.
  15. */
  16. askUnmuteText?: string;
  17. /**
  18. * The type of button to be displayed.
  19. */
  20. buttonType: string;
  21. /**
  22. * Callback used to open a confirmation dialog for audio muting.
  23. */
  24. muteAudio: Function;
  25. /**
  26. * Label for mute participant button.
  27. */
  28. muteParticipantButtonText?: string;
  29. /**
  30. * The ID of the participant.
  31. */
  32. participantID: string;
  33. /**
  34. * The name of the participant.
  35. */
  36. participantName: string;
  37. /**
  38. * Callback used to stop a participant's video.
  39. */
  40. stopVideo: Function;
  41. }
  42. const useStyles = makeStyles()(theme => {
  43. return {
  44. button: {
  45. marginRight: theme.spacing(2)
  46. }
  47. };
  48. });
  49. const ParticipantQuickAction = ({
  50. buttonType,
  51. muteAudio,
  52. participantID,
  53. participantName,
  54. stopVideo
  55. }: IProps) => {
  56. const { classes: styles } = useStyles();
  57. const dispatch = useDispatch();
  58. const { t } = useTranslation();
  59. const askToUnmute = useCallback(() => {
  60. dispatch(approveParticipantAudio(participantID));
  61. }, [ dispatch, participantID ]);
  62. const allowVideo = useCallback(() => {
  63. dispatch(approveParticipantVideo(participantID));
  64. }, [ dispatch, participantID ]);
  65. switch (buttonType) {
  66. case QUICK_ACTION_BUTTON.MUTE: {
  67. return (
  68. <Button
  69. accessibilityLabel = { `${t('participantsPane.actions.mute')} ${participantName}` }
  70. className = { styles.button }
  71. label = { t('participantsPane.actions.mute') }
  72. onClick = { muteAudio(participantID) }
  73. size = 'small'
  74. testId = { `mute-audio-${participantID}` } />
  75. );
  76. }
  77. case QUICK_ACTION_BUTTON.ASK_TO_UNMUTE: {
  78. return (
  79. <Button
  80. accessibilityLabel = { `${t('participantsPane.actions.askUnmute')} ${participantName}` }
  81. className = { styles.button }
  82. label = { t('participantsPane.actions.askUnmute') }
  83. onClick = { askToUnmute }
  84. size = 'small'
  85. testId = { `unmute-audio-${participantID}` } />
  86. );
  87. }
  88. case QUICK_ACTION_BUTTON.ALLOW_VIDEO: {
  89. return (
  90. <Button
  91. accessibilityLabel = { `${t('participantsPane.actions.askUnmute')} ${participantName}` }
  92. className = { styles.button }
  93. label = { t('participantsPane.actions.allowVideo') }
  94. onClick = { allowVideo }
  95. size = 'small'
  96. testId = { `unmute-video-${participantID}` } />
  97. );
  98. }
  99. case QUICK_ACTION_BUTTON.STOP_VIDEO: {
  100. return (
  101. <Button
  102. accessibilityLabel = { `${t('participantsPane.actions.mute')} ${participantName}` }
  103. className = { styles.button }
  104. label = { t('participantsPane.actions.stopVideo') }
  105. onClick = { stopVideo(participantID) }
  106. size = 'small'
  107. testId = { `mute-video-${participantID}` } />
  108. );
  109. }
  110. default: {
  111. return null;
  112. }
  113. }
  114. };
  115. export default ParticipantQuickAction;