2022-07-27 09:33:50 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-09-13 07:36:00 +00:00
|
|
|
|
|
|
|
import { Theme } from '@mui/material';
|
2021-10-22 13:23:52 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useDispatch } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2022-07-27 09:33:50 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
import { approveParticipant } from '../../../av-moderation/actions';
|
2022-07-27 09:33:50 +00:00
|
|
|
import Button from '../../../base/ui/components/web/Button';
|
2022-09-13 07:36:00 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
import { QUICK_ACTION_BUTTON } from '../../constants';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The translated ask unmute aria label.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
ariaLabel?: boolean;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The translated "ask unmute" text.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
askUnmuteText: string;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of button to be displayed.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
buttonType: string;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback used to open a confirmation dialog for audio muting.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
muteAudio: Function;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Label for mute participant button.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
muteParticipantButtonText: string;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantID: string;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the participant.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantName: string;
|
|
|
|
};
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()((theme: Theme) => {
|
2021-10-22 13:23:52 +00:00
|
|
|
return {
|
|
|
|
button: {
|
2022-09-13 07:36:00 +00:00
|
|
|
marginRight: theme.spacing(2)
|
2021-10-22 13:23:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const ParticipantQuickAction = ({
|
|
|
|
askUnmuteText,
|
|
|
|
buttonType,
|
|
|
|
muteAudio,
|
|
|
|
muteParticipantButtonText,
|
|
|
|
participantID,
|
|
|
|
participantName
|
|
|
|
}: Props) => {
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes: styles } = useStyles();
|
2021-10-22 13:23:52 +00:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
const askToUnmute = useCallback(() => {
|
|
|
|
dispatch(approveParticipant(participantID));
|
|
|
|
}, [ dispatch, participantID ]);
|
|
|
|
|
|
|
|
switch (buttonType) {
|
|
|
|
case QUICK_ACTION_BUTTON.MUTE: {
|
|
|
|
return (
|
2022-07-27 09:33:50 +00:00
|
|
|
<Button
|
2021-10-22 13:23:52 +00:00
|
|
|
accessibilityLabel = { `${t('participantsPane.actions.mute')} ${participantName}` }
|
|
|
|
className = { styles.button }
|
2022-07-27 09:33:50 +00:00
|
|
|
label = { muteParticipantButtonText }
|
2021-10-22 13:23:52 +00:00
|
|
|
onClick = { muteAudio(participantID) }
|
2022-07-27 09:33:50 +00:00
|
|
|
size = 'small'
|
|
|
|
testId = { `mute-${participantID}` } />
|
2021-10-22 13:23:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
case QUICK_ACTION_BUTTON.ASK_TO_UNMUTE: {
|
|
|
|
return (
|
2022-07-27 09:33:50 +00:00
|
|
|
<Button
|
2021-10-22 13:23:52 +00:00
|
|
|
accessibilityLabel = { `${t('participantsPane.actions.askUnmute')} ${participantName}` }
|
|
|
|
className = { styles.button }
|
2022-07-27 09:33:50 +00:00
|
|
|
label = { askUnmuteText }
|
2021-10-22 13:23:52 +00:00
|
|
|
onClick = { askToUnmute }
|
2022-07-27 09:33:50 +00:00
|
|
|
size = 'small'
|
|
|
|
testId = { `unmute-${participantID}` } />
|
2021-10-22 13:23:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ParticipantQuickAction;
|