2021-06-23 11:23:44 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { makeStyles } from '@material-ui/core/styles';
|
2021-09-10 11:05:16 +00:00
|
|
|
import clsx from 'clsx';
|
2021-06-23 11:23:44 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
import {
|
|
|
|
requestDisableAudioModeration,
|
|
|
|
requestDisableVideoModeration,
|
|
|
|
requestEnableAudioModeration,
|
|
|
|
requestEnableVideoModeration
|
|
|
|
} from '../../av-moderation/actions';
|
2021-07-09 12:36:19 +00:00
|
|
|
import {
|
|
|
|
isEnabled as isAvModerationEnabled,
|
|
|
|
isSupported as isAvModerationSupported
|
|
|
|
} from '../../av-moderation/functions';
|
2021-06-23 11:23:44 +00:00
|
|
|
import { openDialog } from '../../base/dialog';
|
|
|
|
import { Icon, IconCheck, IconVideoOff } from '../../base/icons';
|
|
|
|
import { MEDIA_TYPE } from '../../base/media';
|
2021-09-10 11:05:16 +00:00
|
|
|
import {
|
|
|
|
getParticipantCount,
|
|
|
|
isEveryoneModerator
|
|
|
|
} from '../../base/participants';
|
2021-06-23 11:23:44 +00:00
|
|
|
import { MuteEveryonesVideoDialog } from '../../video-menu/components';
|
|
|
|
|
|
|
|
import {
|
|
|
|
ContextMenu,
|
2021-08-20 08:23:37 +00:00
|
|
|
ContextMenuItem,
|
|
|
|
ContextMenuItemGroup
|
2021-06-24 13:26:55 +00:00
|
|
|
} from './web/styled';
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
const useStyles = makeStyles(() => {
|
|
|
|
return {
|
|
|
|
contextMenu: {
|
|
|
|
bottom: 'auto',
|
|
|
|
margin: '0',
|
|
|
|
padding: '8px 0',
|
|
|
|
right: 0,
|
|
|
|
top: '-8px',
|
|
|
|
transform: 'translateY(-100%)',
|
2021-08-20 08:23:37 +00:00
|
|
|
width: '283px'
|
2021-06-23 11:23:44 +00:00
|
|
|
},
|
2021-09-10 11:05:16 +00:00
|
|
|
drawer: {
|
|
|
|
width: '100%',
|
|
|
|
top: 'auto',
|
|
|
|
bottom: 0,
|
|
|
|
transform: 'none',
|
|
|
|
position: 'relative',
|
|
|
|
|
|
|
|
'& > div': {
|
|
|
|
lineHeight: '32px'
|
|
|
|
}
|
|
|
|
},
|
2021-06-23 11:23:44 +00:00
|
|
|
text: {
|
2021-08-20 08:23:37 +00:00
|
|
|
color: '#C2C2C2',
|
2021-09-15 08:28:44 +00:00
|
|
|
padding: '10px 16px'
|
2021-06-23 11:23:44 +00:00
|
|
|
},
|
|
|
|
paddedAction: {
|
2021-09-15 08:28:44 +00:00
|
|
|
marginLeft: '36px'
|
2021-06-23 11:23:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
/**
|
|
|
|
* Whether the menu is displayed inside a drawer.
|
|
|
|
*/
|
|
|
|
inDrawer?: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback for the mouse leaving this item.
|
|
|
|
*/
|
|
|
|
onMouseLeave?: Function
|
2021-06-23 11:23:44 +00:00
|
|
|
};
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
export const FooterContextMenu = ({ inDrawer, onMouseLeave }: Props) => {
|
2021-06-23 11:23:44 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-07-09 12:36:19 +00:00
|
|
|
const isModerationSupported = useSelector(isAvModerationSupported());
|
2021-09-10 11:05:16 +00:00
|
|
|
const allModerators = useSelector(isEveryoneModerator);
|
|
|
|
const participantCount = useSelector(getParticipantCount);
|
|
|
|
const isAudioModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.AUDIO));
|
|
|
|
const isVideoModerationEnabled = useSelector(isAvModerationEnabled(MEDIA_TYPE.VIDEO));
|
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
const disableAudioModeration = useCallback(() => dispatch(requestDisableAudioModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const disableVideoModeration = useCallback(() => dispatch(requestDisableVideoModeration()), [ dispatch ]);
|
2021-06-23 11:23:44 +00:00
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
const enableAudioModeration = useCallback(() => dispatch(requestEnableAudioModeration()), [ dispatch ]);
|
|
|
|
|
|
|
|
const enableVideoModeration = useCallback(() => dispatch(requestEnableVideoModeration()), [ dispatch ]);
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
const classes = useStyles();
|
|
|
|
|
|
|
|
const muteAllVideo = useCallback(
|
2021-09-10 11:05:16 +00:00
|
|
|
() => dispatch(openDialog(MuteEveryonesVideoDialog)), [ dispatch ]);
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ContextMenu
|
2021-09-10 11:05:16 +00:00
|
|
|
className = { clsx(classes.contextMenu, inDrawer && clsx(classes.drawer)) }
|
2021-06-23 11:23:44 +00:00
|
|
|
onMouseLeave = { onMouseLeave }>
|
2021-08-20 08:23:37 +00:00
|
|
|
<ContextMenuItemGroup>
|
|
|
|
<ContextMenuItem
|
|
|
|
id = 'participants-pane-context-menu-stop-video'
|
|
|
|
onClick = { muteAllVideo }>
|
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconVideoOff } />
|
|
|
|
<span>{ t('participantsPane.actions.stopEveryonesVideo') }</span>
|
|
|
|
</ContextMenuItem>
|
|
|
|
</ContextMenuItemGroup>
|
2021-09-10 11:05:16 +00:00
|
|
|
{isModerationSupported && (participantCount === 1 || !allModerators) ? (
|
2021-08-20 08:23:37 +00:00
|
|
|
<ContextMenuItemGroup>
|
2021-07-09 12:36:19 +00:00
|
|
|
<div className = { classes.text }>
|
|
|
|
{t('participantsPane.actions.allow')}
|
|
|
|
</div>
|
2021-09-10 11:05:16 +00:00
|
|
|
{ isAudioModerationEnabled ? (
|
|
|
|
<ContextMenuItem
|
|
|
|
id = 'participants-pane-context-menu-stop-audio-moderation'
|
|
|
|
onClick = { disableAudioModeration }>
|
|
|
|
<span className = { classes.paddedAction }>
|
|
|
|
{t('participantsPane.actions.audioModeration') }
|
|
|
|
</span>
|
|
|
|
</ContextMenuItem>
|
|
|
|
) : (
|
|
|
|
<ContextMenuItem
|
|
|
|
id = 'participants-pane-context-menu-start-audio-moderation'
|
|
|
|
onClick = { enableAudioModeration }>
|
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconCheck } />
|
|
|
|
<span>{t('participantsPane.actions.audioModeration') }</span>
|
|
|
|
</ContextMenuItem>
|
|
|
|
)}
|
|
|
|
{ isVideoModerationEnabled ? (
|
2021-07-09 12:36:19 +00:00
|
|
|
<ContextMenuItem
|
2021-09-10 11:05:16 +00:00
|
|
|
id = 'participants-pane-context-menu-stop-video-moderation'
|
|
|
|
onClick = { disableVideoModeration }>
|
2021-07-09 12:36:19 +00:00
|
|
|
<span className = { classes.paddedAction }>
|
2021-09-10 11:05:16 +00:00
|
|
|
{t('participantsPane.actions.videoModeration')}
|
2021-07-09 12:36:19 +00:00
|
|
|
</span>
|
|
|
|
</ContextMenuItem>
|
|
|
|
) : (
|
|
|
|
<ContextMenuItem
|
2021-09-10 11:05:16 +00:00
|
|
|
id = 'participants-pane-context-menu-start-video-moderation'
|
|
|
|
onClick = { enableVideoModeration }>
|
2021-07-09 12:36:19 +00:00
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconCheck } />
|
2021-09-10 11:05:16 +00:00
|
|
|
<span>{t('participantsPane.actions.videoModeration')}</span>
|
2021-07-09 12:36:19 +00:00
|
|
|
</ContextMenuItem>
|
|
|
|
)}
|
2021-08-20 08:23:37 +00:00
|
|
|
</ContextMenuItemGroup>
|
2021-07-09 12:36:19 +00:00
|
|
|
) : undefined
|
|
|
|
}
|
2021-06-23 11:23:44 +00:00
|
|
|
</ContextMenu>
|
|
|
|
);
|
|
|
|
};
|