選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ParticipantQuickAction.tsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* eslint-disable lines-around-comment */
  2. import { makeStyles } from '@material-ui/styles';
  3. import React, { useCallback } from 'react';
  4. import { useTranslation } from 'react-i18next';
  5. import { useDispatch } from 'react-redux';
  6. // @ts-ignore
  7. import { approveParticipant } from '../../../av-moderation/actions';
  8. import Button from '../../../base/ui/components/web/Button';
  9. import { Theme } from '../../../base/ui/types';
  10. // @ts-ignore
  11. import { QUICK_ACTION_BUTTON } from '../../constants';
  12. type Props = {
  13. /**
  14. * The translated ask unmute aria label.
  15. */
  16. ariaLabel?: boolean,
  17. /**
  18. * The translated "ask unmute" text.
  19. */
  20. askUnmuteText: string,
  21. /**
  22. * The type of button to be displayed.
  23. */
  24. buttonType: string,
  25. /**
  26. * Callback used to open a confirmation dialog for audio muting.
  27. */
  28. muteAudio: Function,
  29. /**
  30. * Label for mute participant button.
  31. */
  32. muteParticipantButtonText: string,
  33. /**
  34. * The ID of the participant.
  35. */
  36. participantID: string,
  37. /**
  38. * The name of the participant.
  39. */
  40. participantName: string
  41. }
  42. const useStyles = makeStyles((theme: Theme) => {
  43. return {
  44. button: {
  45. marginRight: `${theme.spacing(2)}px`
  46. }
  47. };
  48. });
  49. const ParticipantQuickAction = ({
  50. askUnmuteText,
  51. buttonType,
  52. muteAudio,
  53. muteParticipantButtonText,
  54. participantID,
  55. participantName
  56. }: Props) => {
  57. const styles = useStyles();
  58. const dispatch = useDispatch();
  59. const { t } = useTranslation();
  60. const askToUnmute = useCallback(() => {
  61. dispatch(approveParticipant(participantID));
  62. }, [ dispatch, participantID ]);
  63. switch (buttonType) {
  64. case QUICK_ACTION_BUTTON.MUTE: {
  65. return (
  66. <Button
  67. accessibilityLabel = { `${t('participantsPane.actions.mute')} ${participantName}` }
  68. className = { styles.button }
  69. label = { muteParticipantButtonText }
  70. onClick = { muteAudio(participantID) }
  71. size = 'small'
  72. testId = { `mute-${participantID}` } />
  73. );
  74. }
  75. case QUICK_ACTION_BUTTON.ASK_TO_UNMUTE: {
  76. return (
  77. <Button
  78. accessibilityLabel = { `${t('participantsPane.actions.askUnmute')} ${participantName}` }
  79. className = { styles.button }
  80. label = { askUnmuteText }
  81. onClick = { askToUnmute }
  82. size = 'small'
  83. testId = { `unmute-${participantID}` } />
  84. );
  85. }
  86. default: {
  87. return null;
  88. }
  89. }
  90. };
  91. export default ParticipantQuickAction;