Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

ParticipantQuickAction.tsx 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 { approveParticipant } 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. const useStyles = makeStyles()(theme => {
  39. return {
  40. button: {
  41. marginRight: theme.spacing(2)
  42. }
  43. };
  44. });
  45. const ParticipantQuickAction = ({
  46. askUnmuteText,
  47. buttonType,
  48. muteAudio,
  49. muteParticipantButtonText,
  50. participantID,
  51. participantName
  52. }: IProps) => {
  53. const { classes: styles } = useStyles();
  54. const dispatch = useDispatch();
  55. const { t } = useTranslation();
  56. const askToUnmute = useCallback(() => {
  57. dispatch(approveParticipant(participantID));
  58. }, [ dispatch, participantID ]);
  59. switch (buttonType) {
  60. case QUICK_ACTION_BUTTON.MUTE: {
  61. return (
  62. <Button
  63. accessibilityLabel = { `${t('participantsPane.actions.mute')} ${participantName}` }
  64. className = { styles.button }
  65. label = { muteParticipantButtonText }
  66. onClick = { muteAudio(participantID) }
  67. size = 'small'
  68. testId = { `mute-${participantID}` } />
  69. );
  70. }
  71. case QUICK_ACTION_BUTTON.ASK_TO_UNMUTE: {
  72. return (
  73. <Button
  74. accessibilityLabel = { `${t('participantsPane.actions.askUnmute')} ${participantName}` }
  75. className = { styles.button }
  76. label = { askUnmuteText }
  77. onClick = { askToUnmute }
  78. size = 'small'
  79. testId = { `unmute-${participantID}` } />
  80. );
  81. }
  82. default: {
  83. return null;
  84. }
  85. }
  86. };
  87. export default ParticipantQuickAction;