2022-08-25 11:35:19 +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, useSelector } 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
|
|
|
|
|
|
|
import {
|
|
|
|
requestDisableAudioModeration,
|
|
|
|
requestDisableVideoModeration,
|
|
|
|
requestEnableAudioModeration,
|
|
|
|
requestEnableVideoModeration
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
} from '../../../av-moderation/actions';
|
|
|
|
import {
|
|
|
|
isEnabled as isAvModerationEnabled,
|
|
|
|
isSupported as isAvModerationSupported
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
} from '../../../av-moderation/functions';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
import { openDialog } from '../../../base/dialog';
|
2021-11-10 11:19:40 +00:00
|
|
|
import {
|
|
|
|
IconCheck,
|
|
|
|
IconHorizontalPoints,
|
|
|
|
IconVideoOff
|
2022-08-25 11:35:19 +00:00
|
|
|
} from '../../../base/icons/svg';
|
|
|
|
import { MEDIA_TYPE } from '../../../base/media/constants';
|
2021-10-22 13:23:52 +00:00
|
|
|
import {
|
|
|
|
getParticipantCount,
|
|
|
|
isEveryoneModerator
|
2022-08-25 11:35:19 +00:00
|
|
|
} from '../../../base/participants/functions';
|
2022-10-06 10:09:40 +00:00
|
|
|
import ContextMenu from '../../../base/ui/components/web/ContextMenu';
|
|
|
|
import ContextMenuItemGroup from '../../../base/ui/components/web/ContextMenuItemGroup';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2022-02-14 14:47:14 +00:00
|
|
|
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2022-01-27 08:22:26 +00:00
|
|
|
import {
|
|
|
|
openSettingsDialog,
|
|
|
|
shouldShowModeratorSettings
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2022-01-27 08:22:26 +00:00
|
|
|
} from '../../../settings';
|
2022-09-09 09:22:30 +00:00
|
|
|
import { SETTINGS_TABS } from '../../../settings/constants';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-10-22 13:23:52 +00:00
|
|
|
import { MuteEveryonesVideoDialog } from '../../../video-menu/components';
|
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()((theme: Theme) => {
|
2021-10-22 13:23:52 +00:00
|
|
|
return {
|
|
|
|
contextMenu: {
|
|
|
|
bottom: 'auto',
|
|
|
|
margin: '0',
|
|
|
|
right: 0,
|
|
|
|
top: '-8px',
|
|
|
|
transform: 'translateY(-100%)',
|
|
|
|
width: '283px'
|
|
|
|
},
|
|
|
|
|
|
|
|
text: {
|
|
|
|
color: theme.palette.text02,
|
|
|
|
padding: '10px 16px',
|
|
|
|
height: '40px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
boxSizing: 'border-box'
|
|
|
|
},
|
|
|
|
|
|
|
|
indentedLabel: {
|
|
|
|
'& > span': {
|
|
|
|
marginLeft: '36px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the menu is open.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
isOpen: boolean;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drawer close callback.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
onDrawerClose: (e?: React.MouseEvent) => void;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback for the mouse leaving this item.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
onMouseLeave?: (e?: React.MouseEvent) => void;
|
2021-10-22 13:23:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const FooterContextMenu = ({ isOpen, onDrawerClose, onMouseLeave }: Props) => {
|
|
|
|
const dispatch = useDispatch();
|
2022-05-19 08:43:36 +00:00
|
|
|
const isModerationSupported = useSelector(isAvModerationSupported);
|
2021-10-22 13:23:52 +00:00
|
|
|
const allModerators = useSelector(isEveryoneModerator);
|
2022-01-27 08:22:26 +00:00
|
|
|
const isModeratorSettingsTabEnabled = useSelector(shouldShowModeratorSettings);
|
2021-10-22 13:23:52 +00:00
|
|
|
const participantCount = useSelector(getParticipantCount);
|
|
|
|
const isAudioModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.AUDIO));
|
|
|
|
const isVideoModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.VIDEO));
|
2022-02-14 14:47:14 +00:00
|
|
|
const isBreakoutRoom = useSelector(isInBreakoutRoom);
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
const disableAudioModeration = useCallback(() => dispatch(requestDisableAudioModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const disableVideoModeration = useCallback(() => dispatch(requestDisableVideoModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const enableAudioModeration = useCallback(() => dispatch(requestEnableAudioModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const enableVideoModeration = useCallback(() => dispatch(requestEnableVideoModeration()), [ dispatch ]);
|
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes } = useStyles();
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
const muteAllVideo = useCallback(
|
|
|
|
() => dispatch(openDialog(MuteEveryonesVideoDialog)), [ dispatch ]);
|
|
|
|
|
2021-11-10 11:19:40 +00:00
|
|
|
const openModeratorSettings = () => dispatch(openSettingsDialog(SETTINGS_TABS.MODERATOR));
|
|
|
|
|
2021-10-22 13:23:52 +00:00
|
|
|
const actions = [
|
|
|
|
{
|
|
|
|
accessibilityLabel: t('participantsPane.actions.audioModeration'),
|
|
|
|
className: isAudioModerationEnabled ? classes.indentedLabel : '',
|
|
|
|
id: isAudioModerationEnabled
|
|
|
|
? 'participants-pane-context-menu-stop-audio-moderation'
|
|
|
|
: 'participants-pane-context-menu-start-audio-moderation',
|
|
|
|
icon: !isAudioModerationEnabled && IconCheck,
|
|
|
|
onClick: isAudioModerationEnabled ? disableAudioModeration : enableAudioModeration,
|
|
|
|
text: t('participantsPane.actions.audioModeration')
|
|
|
|
}, {
|
|
|
|
accessibilityLabel: t('participantsPane.actions.videoModeration'),
|
|
|
|
className: isVideoModerationEnabled ? classes.indentedLabel : '',
|
|
|
|
id: isVideoModerationEnabled
|
|
|
|
? 'participants-pane-context-menu-stop-video-moderation'
|
|
|
|
: 'participants-pane-context-menu-start-video-moderation',
|
|
|
|
icon: !isVideoModerationEnabled && IconCheck,
|
|
|
|
onClick: isVideoModerationEnabled ? disableVideoModeration : enableVideoModeration,
|
|
|
|
text: t('participantsPane.actions.videoModeration')
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ContextMenu
|
|
|
|
className = { classes.contextMenu }
|
|
|
|
hidden = { !isOpen }
|
|
|
|
isDrawerOpen = { isOpen }
|
|
|
|
onDrawerClose = { onDrawerClose }
|
|
|
|
onMouseLeave = { onMouseLeave }>
|
|
|
|
<ContextMenuItemGroup
|
|
|
|
actions = { [ {
|
|
|
|
accessibilityLabel: t('participantsPane.actions.stopEveryonesVideo'),
|
|
|
|
id: 'participants-pane-context-menu-stop-video',
|
|
|
|
icon: IconVideoOff,
|
|
|
|
onClick: muteAllVideo,
|
|
|
|
text: t('participantsPane.actions.stopEveryonesVideo')
|
|
|
|
} ] } />
|
2022-02-14 14:47:14 +00:00
|
|
|
{!isBreakoutRoom && isModerationSupported && (participantCount === 1 || !allModerators) && (
|
2021-10-22 13:23:52 +00:00
|
|
|
<ContextMenuItemGroup actions = { actions }>
|
|
|
|
<div className = { classes.text }>
|
|
|
|
<span>{t('participantsPane.actions.allow')}</span>
|
|
|
|
</div>
|
|
|
|
</ContextMenuItemGroup>
|
|
|
|
)}
|
2022-01-27 08:22:26 +00:00
|
|
|
{isModeratorSettingsTabEnabled && (
|
|
|
|
<ContextMenuItemGroup
|
|
|
|
actions = { [ {
|
|
|
|
accessibilityLabel: t('participantsPane.actions.moreModerationControls'),
|
|
|
|
id: 'participants-pane-open-moderation-control-settings',
|
|
|
|
icon: IconHorizontalPoints,
|
|
|
|
onClick: openModeratorSettings,
|
|
|
|
text: t('participantsPane.actions.moreModerationControls')
|
|
|
|
} ] } />
|
|
|
|
)}
|
2021-10-22 13:23:52 +00:00
|
|
|
</ContextMenu>
|
|
|
|
);
|
|
|
|
};
|