2022-08-01 07:05:17 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-09-13 07:36:00 +00:00
|
|
|
import { withStyles } from '@mui/styles';
|
2021-06-30 16:12:12 +00:00
|
|
|
import React, { Component } from 'react';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { batch, connect } from 'react-redux';
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
2021-06-30 16:12:12 +00:00
|
|
|
import { isMobileBrowser } from '../../../base/environment/utils';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
2022-09-06 17:32:20 +00:00
|
|
|
import { IconHorizontalPoints } from '../../../base/icons/svg';
|
2022-08-08 08:12:22 +00:00
|
|
|
import { getLocalParticipant } from '../../../base/participants/functions';
|
2022-10-24 09:51:18 +00:00
|
|
|
import Popover from '../../../base/popover/components/Popover.web';
|
2021-09-14 07:43:52 +00:00
|
|
|
import { setParticipantContextMenuOpen } from '../../../base/responsive-ui/actions';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { getHideSelfView } from '../../../base/settings/functions.web';
|
|
|
|
import { getLocalVideoTrack } from '../../../base/tracks/functions';
|
2022-08-01 07:05:17 +00:00
|
|
|
import Button from '../../../base/ui/components/web/Button';
|
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-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2021-06-30 16:12:12 +00:00
|
|
|
import ConnectionIndicatorContent from '../../../connection-indicator/components/web/ConnectionIndicatorContent';
|
2022-09-05 11:24:13 +00:00
|
|
|
import { THUMBNAIL_TYPE } from '../../../filmstrip/constants';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2022-06-17 12:15:14 +00:00
|
|
|
import { isStageFilmstripAvailable } from '../../../filmstrip/functions.web';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2021-06-30 16:12:12 +00:00
|
|
|
import { renderConnectionStatus } from '../../actions.web';
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2021-06-30 16:12:12 +00:00
|
|
|
import ConnectionStatusButton from './ConnectionStatusButton';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2021-01-21 20:46:47 +00:00
|
|
|
import FlipLocalVideoButton from './FlipLocalVideoButton';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2021-12-07 08:24:00 +00:00
|
|
|
import HideSelfViewVideoButton from './HideSelfViewVideoButton';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
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}.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
interface IProps extends WithTranslation {
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* The id of the local participant.
|
2021-12-15 13:18:41 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_localParticipantId: string;
|
2021-12-15 13:18:41 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* The position relative to the trigger the local video menu should display
|
|
|
|
* from. Valid values are those supported by AtlasKit
|
|
|
|
* {@code InlineDialog}.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_menuPosition: string;
|
2021-06-30 16:12:12 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether to display the Popover as a drawer.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_overflowDrawer: boolean;
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether to render the connection info pane.
|
2021-11-01 09:39:19 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showConnectionInfo: boolean;
|
2021-11-01 09:39:19 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether to render the hide self view button.
|
2021-11-01 09:39:19 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showHideSelfViewButton: boolean;
|
2021-11-01 09:39:19 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Shows/hides the local video flip button.
|
2021-11-01 09:39:19 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showLocalVideoFlipButton: boolean;
|
2021-11-01 09:39:19 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether to render the pin to stage button.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showPinToStage: boolean;
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether or not the button should be visible.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
buttonVisible: boolean;
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* An object containing the CSS classes.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
classes: any;
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* The redux dispatch function.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
dispatch: Function;
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2021-12-16 16:55:45 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Hides popover.
|
2021-12-16 16:55:45 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
hidePopover: Function;
|
2021-12-16 16:55:45 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether the popover is visible or not.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
popoverVisible: boolean;
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Shows popover.
|
2022-03-29 08:45:09 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
showPopover: Function;
|
2022-08-01 07:05:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the thumbnail.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
thumbnailType: string;
|
2022-08-08 09:36:06 +00:00
|
|
|
}
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2022-08-01 07:05:17 +00:00
|
|
|
const styles = () => {
|
2021-12-15 13:18:41 +00:00
|
|
|
return {
|
|
|
|
triggerButton: {
|
2022-08-01 07:05:17 +00:00
|
|
|
padding: '3px !important',
|
2021-12-15 13:18:41 +00:00
|
|
|
borderRadius: '4px'
|
|
|
|
},
|
|
|
|
|
|
|
|
contextMenu: {
|
2022-09-13 07:36:00 +00:00
|
|
|
position: 'relative' as const,
|
2021-12-15 13:18:41 +00:00
|
|
|
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
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
class LocalVideoMenuTriggerButton extends Component<IProps> {
|
2021-06-30 16:12:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new LocalVideoMenuTriggerButton instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
constructor(props: IProps) {
|
2021-06-30 16:12:12 +00:00
|
|
|
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 }>
|
2022-08-01 07:05:17 +00:00
|
|
|
{!_overflowDrawer && buttonVisible && !isMobileBrowser() && (
|
|
|
|
<Button
|
|
|
|
accessibilityLabel = { t('dialog.localUserControls') }
|
2021-12-15 13:18:41 +00:00
|
|
|
className = { classes.triggerButton }
|
2022-08-01 07:05:17 +00:00
|
|
|
icon = { IconHorizontalPoints }
|
|
|
|
size = 'small' />
|
2021-06-30 16:12:12 +00:00
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
: null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-10 12:17:57 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
* 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
|
2022-10-20 09:11:27 +00:00
|
|
|
* @returns {IProps}
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
function _mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
|
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,
|
2022-10-11 10:47:54 +00:00
|
|
|
_localParticipantId: localParticipant?.id ?? '',
|
|
|
|
_showConnectionInfo: Boolean(showConnectionInfo),
|
2022-06-17 12:15:14 +00:00
|
|
|
_showPinToStage: isStageFilmstripAvailable(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)));
|