2021-01-21 20:46:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
import { withStyles } from '@material-ui/styles';
|
2021-06-30 16:12:12 +00:00
|
|
|
import React, { Component } from 'react';
|
2021-09-14 07:43:52 +00:00
|
|
|
import { batch } from 'react-redux';
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
import ContextMenu from '../../../base/components/context-menu/ContextMenu';
|
|
|
|
import ContextMenuItemGroup from '../../../base/components/context-menu/ContextMenuItemGroup';
|
2021-06-30 16:12:12 +00:00
|
|
|
import { isMobileBrowser } from '../../../base/environment/utils';
|
2021-06-10 12:48:44 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2021-12-15 13:18:41 +00:00
|
|
|
import { Icon, IconHorizontalPoints } from '../../../base/icons';
|
2021-06-30 16:12:12 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant
|
|
|
|
} from '../../../base/participants';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { Popover } from '../../../base/popover';
|
|
|
|
import { connect } from '../../../base/redux';
|
2021-09-14 07:43:52 +00:00
|
|
|
import { setParticipantContextMenuOpen } from '../../../base/responsive-ui/actions';
|
2021-12-16 16:55:45 +00:00
|
|
|
import { getHideSelfView } from '../../../base/settings';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { getLocalVideoTrack } from '../../../base/tracks';
|
2021-06-30 16:12:12 +00:00
|
|
|
import ConnectionIndicatorContent from '../../../connection-indicator/components/web/ConnectionIndicatorContent';
|
2022-04-12 13:19:10 +00:00
|
|
|
import { THUMBNAIL_TYPE } from '../../../filmstrip';
|
2022-03-29 08:45:09 +00:00
|
|
|
import { isStageFilmstripEnabled } from '../../../filmstrip/functions.web';
|
2021-06-30 16:12:12 +00:00
|
|
|
import { renderConnectionStatus } from '../../actions.web';
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
import ConnectionStatusButton from './ConnectionStatusButton';
|
2021-01-21 20:46:47 +00:00
|
|
|
import FlipLocalVideoButton from './FlipLocalVideoButton';
|
2021-12-07 08:24:00 +00:00
|
|
|
import HideSelfViewVideoButton from './HideSelfViewVideoButton';
|
2022-03-29 08:45:09 +00:00
|
|
|
import TogglePinToStageButton from './TogglePinToStageButton';
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link LocalVideoMenuTriggerButton}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* Whether or not the button should be visible.
|
|
|
|
*/
|
|
|
|
buttonVisible: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object containing the CSS classes.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
classes: Object,
|
2021-06-30 16:12:12 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* The redux dispatch function.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
dispatch: Function,
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
/**
|
|
|
|
* Hides popover.
|
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
hidePopover: Function,
|
2021-11-01 09:39:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the popover is visible or not.
|
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
popoverVisible: boolean,
|
2021-11-01 09:39:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows popover.
|
|
|
|
*/
|
2021-12-15 13:18:41 +00:00
|
|
|
showPopover: Function,
|
2021-11-01 09:39:19 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
|
|
|
* The id of the local participant.
|
|
|
|
*/
|
|
|
|
_localParticipantId: string,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* The position relative to the trigger the local video menu should display
|
|
|
|
* from. Valid values are those supported by AtlasKit
|
|
|
|
* {@code InlineDialog}.
|
|
|
|
*/
|
|
|
|
_menuPosition: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to display the Popover as a drawer.
|
|
|
|
*/
|
|
|
|
_overflowDrawer: boolean,
|
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
|
|
|
* Whether to render the connection info pane.
|
|
|
|
*/
|
|
|
|
_showConnectionInfo: boolean,
|
|
|
|
|
2021-12-16 16:55:45 +00:00
|
|
|
/**
|
|
|
|
* Whether to render the hide self view button.
|
|
|
|
*/
|
|
|
|
_showHideSelfViewButton: boolean,
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides the local video flip button.
|
|
|
|
*/
|
2021-06-10 12:48:44 +00:00
|
|
|
_showLocalVideoFlipButton: boolean,
|
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
|
|
|
* Whether to render the pin to stage button.
|
|
|
|
*/
|
|
|
|
_showPinToStage: boolean,
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
2021-01-21 20:46:47 +00:00
|
|
|
};
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
const styles = theme => {
|
|
|
|
return {
|
|
|
|
triggerButton: {
|
|
|
|
backgroundColor: theme.palette.action01,
|
|
|
|
padding: '3px',
|
|
|
|
display: 'inline-block',
|
|
|
|
borderRadius: '4px'
|
|
|
|
},
|
|
|
|
|
|
|
|
contextMenu: {
|
|
|
|
position: 'relative',
|
|
|
|
marginTop: 0,
|
|
|
|
right: 'auto',
|
|
|
|
padding: '0',
|
|
|
|
minWidth: '200px'
|
|
|
|
},
|
|
|
|
|
|
|
|
flipText: {
|
|
|
|
marginLeft: '36px'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* React Component for displaying an icon associated with opening the
|
|
|
|
* the video menu for the local participant.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments {Component}
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2021-06-30 16:12:12 +00:00
|
|
|
class LocalVideoMenuTriggerButton extends Component<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new LocalVideoMenuTriggerButton instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onPopoverClose = this._onPopoverClose.bind(this);
|
2021-09-10 12:17:57 +00:00
|
|
|
this._onPopoverOpen = this._onPopoverOpen.bind(this);
|
2021-06-30 16:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
_localParticipantId,
|
|
|
|
_menuPosition,
|
|
|
|
_overflowDrawer,
|
2021-12-16 16:55:45 +00:00
|
|
|
_showConnectionInfo,
|
|
|
|
_showHideSelfViewButton,
|
2021-06-30 16:12:12 +00:00
|
|
|
_showLocalVideoFlipButton,
|
2022-03-29 08:45:09 +00:00
|
|
|
_showPinToStage,
|
2021-12-15 13:18:41 +00:00
|
|
|
buttonVisible,
|
|
|
|
classes,
|
2021-11-01 09:39:19 +00:00
|
|
|
hidePopover,
|
|
|
|
popoverVisible,
|
2021-06-30 16:12:12 +00:00
|
|
|
t
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const content = _showConnectionInfo
|
|
|
|
? <ConnectionIndicatorContent participantId = { _localParticipantId } />
|
|
|
|
: (
|
2021-12-15 13:18:41 +00:00
|
|
|
<ContextMenu
|
|
|
|
className = { classes.contextMenu }
|
|
|
|
hidden = { false }
|
|
|
|
inDrawer = { _overflowDrawer }>
|
|
|
|
<ContextMenuItemGroup>
|
2022-01-10 14:34:01 +00:00
|
|
|
{ _showLocalVideoFlipButton
|
|
|
|
&& <FlipLocalVideoButton
|
|
|
|
className = { _overflowDrawer ? classes.flipText : '' }
|
|
|
|
onClick = { hidePopover } />
|
|
|
|
}
|
2021-12-16 16:55:45 +00:00
|
|
|
{ _showHideSelfViewButton
|
|
|
|
&& <HideSelfViewVideoButton
|
|
|
|
className = { _overflowDrawer ? classes.flipText : '' }
|
|
|
|
onClick = { hidePopover } />
|
|
|
|
}
|
2022-03-29 08:45:09 +00:00
|
|
|
{
|
|
|
|
_showPinToStage && <TogglePinToStageButton
|
|
|
|
className = { _overflowDrawer ? classes.flipText : '' }
|
|
|
|
noIcon = { true }
|
|
|
|
onClick = { hidePopover }
|
|
|
|
participantID = { _localParticipantId } />
|
|
|
|
}
|
2021-12-15 13:18:41 +00:00
|
|
|
{ isMobileBrowser()
|
2022-03-29 08:45:09 +00:00
|
|
|
&& <ConnectionStatusButton participantId = { _localParticipantId } />
|
2021-12-15 13:18:41 +00:00
|
|
|
}
|
|
|
|
</ContextMenuItemGroup>
|
|
|
|
</ContextMenu>
|
2021-06-30 16:12:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2022-01-10 14:34:01 +00:00
|
|
|
isMobileBrowser() || _showLocalVideoFlipButton || _showHideSelfViewButton
|
2021-06-30 16:12:12 +00:00
|
|
|
? <Popover
|
|
|
|
content = { content }
|
2021-11-01 09:39:19 +00:00
|
|
|
id = 'local-video-menu-trigger'
|
2021-06-30 16:12:12 +00:00
|
|
|
onPopoverClose = { this._onPopoverClose }
|
2021-09-10 12:17:57 +00:00
|
|
|
onPopoverOpen = { this._onPopoverOpen }
|
2021-06-30 16:12:12 +00:00
|
|
|
overflowDrawer = { _overflowDrawer }
|
|
|
|
position = { _menuPosition }
|
2021-11-01 09:39:19 +00:00
|
|
|
visible = { popoverVisible }>
|
2021-12-15 13:18:41 +00:00
|
|
|
{!_overflowDrawer && buttonVisible && (
|
2021-06-30 16:12:12 +00:00
|
|
|
<span
|
2021-12-15 13:18:41 +00:00
|
|
|
className = { classes.triggerButton }
|
|
|
|
role = 'button'>
|
2021-09-14 07:43:52 +00:00
|
|
|
{!isMobileBrowser() && <Icon
|
2021-06-30 16:12:12 +00:00
|
|
|
ariaLabel = { t('dialog.localUserControls') }
|
2021-12-15 13:18:41 +00:00
|
|
|
size = { 18 }
|
|
|
|
src = { IconHorizontalPoints }
|
2021-06-30 16:12:12 +00:00
|
|
|
tabIndex = { 0 }
|
|
|
|
title = { t('dialog.localUserControls') } />
|
2021-09-14 07:43:52 +00:00
|
|
|
}
|
2021-06-30 16:12:12 +00:00
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
: null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-10 12:17:57 +00:00
|
|
|
_onPopoverOpen: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable and hide toolbox while context menu is open.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onPopoverOpen() {
|
2021-11-01 09:39:19 +00:00
|
|
|
const { dispatch, showPopover } = this.props;
|
|
|
|
|
|
|
|
showPopover();
|
|
|
|
dispatch(setParticipantContextMenuOpen(true));
|
2021-09-10 12:17:57 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
_onPopoverClose: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render normal context menu next time popover dialog opens.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onPopoverClose() {
|
2021-11-01 09:39:19 +00:00
|
|
|
const { hidePopover, dispatch } = this.props;
|
2021-09-14 07:43:52 +00:00
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
hidePopover();
|
2021-09-14 07:43:52 +00:00
|
|
|
batch(() => {
|
|
|
|
dispatch(setParticipantContextMenuOpen(false));
|
|
|
|
dispatch(renderConnectionStatus(false));
|
|
|
|
});
|
2021-06-30 16:12:12 +00:00
|
|
|
}
|
2021-01-21 20:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code LocalVideoMenuTriggerButton}'s props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
2022-03-29 08:45:09 +00:00
|
|
|
* @param {Object} ownProps - The own props of the component.
|
2021-01-21 20:46:47 +00:00
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-03-29 08:45:09 +00:00
|
|
|
function _mapStateToProps(state, ownProps) {
|
2022-04-12 13:19:10 +00:00
|
|
|
const { thumbnailType } = ownProps;
|
2021-06-30 16:12:12 +00:00
|
|
|
const localParticipant = getLocalParticipant(state);
|
2021-12-16 16:55:45 +00:00
|
|
|
const { disableLocalVideoFlip, disableSelfViewSettings } = state['features/base/config'];
|
2021-01-21 20:46:47 +00:00
|
|
|
const videoTrack = getLocalVideoTrack(state['features/base/tracks']);
|
|
|
|
const { overflowDrawer } = state['features/toolbox'];
|
2021-06-30 16:12:12 +00:00
|
|
|
const { showConnectionInfo } = state['features/base/connection'];
|
2021-12-16 16:55:45 +00:00
|
|
|
const showHideSelfViewButton = !disableSelfViewSettings && !getHideSelfView(state);
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
let _menuPosition;
|
|
|
|
|
2022-04-12 13:19:10 +00:00
|
|
|
switch (thumbnailType) {
|
|
|
|
case THUMBNAIL_TYPE.TILE:
|
2021-01-21 20:46:47 +00:00
|
|
|
_menuPosition = 'left-start';
|
|
|
|
break;
|
2022-04-12 13:19:10 +00:00
|
|
|
case THUMBNAIL_TYPE.VERTICAL:
|
2021-12-15 13:18:41 +00:00
|
|
|
_menuPosition = 'left-start';
|
2021-01-21 20:46:47 +00:00
|
|
|
break;
|
2022-04-12 13:19:10 +00:00
|
|
|
case THUMBNAIL_TYPE.HORIZONTAL:
|
2021-12-15 13:18:41 +00:00
|
|
|
_menuPosition = 'top-start';
|
2021-08-16 09:58:48 +00:00
|
|
|
break;
|
2021-01-21 20:46:47 +00:00
|
|
|
default:
|
|
|
|
_menuPosition = 'auto';
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
_menuPosition,
|
|
|
|
_showLocalVideoFlipButton: !disableLocalVideoFlip && videoTrack?.videoType !== 'desktop',
|
2021-12-16 16:55:45 +00:00
|
|
|
_showHideSelfViewButton: showHideSelfViewButton,
|
2021-06-30 16:12:12 +00:00
|
|
|
_overflowDrawer: overflowDrawer,
|
|
|
|
_localParticipantId: localParticipant.id,
|
2022-03-29 08:45:09 +00:00
|
|
|
_showConnectionInfo: showConnectionInfo,
|
|
|
|
_showPinToStage: isStageFilmstripEnabled(state)
|
2021-01-21 20:46:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(withStyles(styles)(LocalVideoMenuTriggerButton)));
|