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';
|
2017-08-14 15:02:58 +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';
|
2017-08-14 15:02:58 +00:00
|
|
|
|
2022-09-05 11:24:13 +00:00
|
|
|
import { IState } from '../../../app/types';
|
2021-12-15 13:18:41 +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-09-30 14:50:45 +00:00
|
|
|
import { getLocalParticipant, getParticipantById } from '../../../base/participants/functions';
|
2022-09-06 17:32:20 +00:00
|
|
|
import { Participant } from '../../../base/participants/types';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2018-12-19 18:40:17 +00:00
|
|
|
import { Popover } from '../../../base/popover';
|
2021-09-14 07:43:52 +00:00
|
|
|
import { setParticipantContextMenuOpen } from '../../../base/responsive-ui/actions';
|
2022-08-01 07:05:17 +00:00
|
|
|
import Button from '../../../base/ui/components/web/Button';
|
|
|
|
import ConnectionIndicatorContent from
|
|
|
|
// @ts-ignore
|
|
|
|
'../../../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
|
2021-06-30 16:12:12 +00:00
|
|
|
import { renderConnectionStatus } from '../../actions.web';
|
2017-09-27 21:23:31 +00:00
|
|
|
|
2022-09-30 14:50:45 +00:00
|
|
|
import FakeParticipantContextMenu from './FakeParticipantContextMenu';
|
2021-12-15 13:18:41 +00:00
|
|
|
import ParticipantContextMenu from './ParticipantContextMenu';
|
2022-08-01 07:05:17 +00:00
|
|
|
// @ts-ignore
|
2020-11-14 04:09:25 +00:00
|
|
|
import { REMOTE_CONTROL_MENU_STATES } from './RemoteControlButton';
|
2020-11-10 14:49:38 +00:00
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link RemoteVideoMenuTriggerButton}.
|
|
|
|
*/
|
2022-08-08 09:36:06 +00:00
|
|
|
interface Props extends WithTranslation {
|
2018-07-23 21:18:20 +00:00
|
|
|
|
2021-11-01 09:39:19 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether the remote video context menu is disabled.
|
2021-11-01 09:39:19 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_disabled: Boolean;
|
2020-02-18 16:31:04 +00:00
|
|
|
|
2022-09-30 14:50:45 +00:00
|
|
|
/**
|
|
|
|
* Shared video local participant owner.
|
|
|
|
*/
|
|
|
|
_localVideoOwner?: boolean;
|
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
2020-11-14 04:09:25 +00:00
|
|
|
* The position relative to the trigger the remote menu should display
|
|
|
|
* from. Valid values are those supported by AtlasKit
|
|
|
|
* {@code InlineDialog}.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_menuPosition: string;
|
2018-07-23 21:18:20 +00:00
|
|
|
|
2021-01-04 13:30:23 +00:00
|
|
|
/**
|
|
|
|
* Whether to display the Popover as a drawer.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_overflowDrawer: boolean;
|
2021-01-04 13:30:23 +00:00
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* Participant reference.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_participant: Participant;
|
2020-11-14 04:09:25 +00:00
|
|
|
|
2022-08-01 07:05:17 +00:00
|
|
|
/**
|
|
|
|
* The ID for the participant on which the remote video menu will act.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_participantDisplayName: string;
|
2022-08-01 07:05:17 +00:00
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* The current state of the participant's remote control session.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_remoteControlState: number;
|
2018-07-23 21:18:20 +00:00
|
|
|
|
2022-08-01 07:05:17 +00:00
|
|
|
/**
|
|
|
|
* Whether the popover should render the Connection Info stats.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showConnectionInfo: Boolean;
|
2022-08-01 07:05:17 +00:00
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* Whether or not the button should be visible.
|
2021-06-30 16:12:12 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
buttonVisible: boolean;
|
2021-06-30 16:12:12 +00:00
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* An object containing the CSS classes.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
classes: any;
|
2018-07-23 21:18:20 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-15 13:18:41 +00:00
|
|
|
* The redux dispatch function.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
dispatch: Function;
|
2018-07-23 21:18:20 +00:00
|
|
|
|
2022-08-01 07:05:17 +00:00
|
|
|
/**
|
|
|
|
* Hides popover.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
hidePopover: Function;
|
2022-08-01 07:05:17 +00:00
|
|
|
|
2018-07-23 21:18:20 +00:00
|
|
|
/**
|
2020-11-14 04:09:25 +00:00
|
|
|
* The ID for the participant on which the remote video menu will act.
|
2018-07-23 21:18:20 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantID: string;
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2022-03-14 14:46:19 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Whether the popover is visible or not.
|
2022-03-14 14:46:19 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
popoverVisible: boolean;
|
2022-03-14 14:46:19 +00:00
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* Shows popover.
|
2021-06-10 12:48:44 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
showPopover: Function;
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-01 07:05:17 +00:00
|
|
|
* The type of the thumbnail.
|
2021-06-10 12:48:44 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
thumbnailType: string;
|
2022-08-08 09:36:06 +00:00
|
|
|
}
|
2018-07-23 21:18:20 +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',
|
|
|
|
marginRight: '4px',
|
|
|
|
marginBottom: '4px'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* React {@code Component} for displaying an icon associated with opening the
|
2021-01-21 20:46:47 +00:00
|
|
|
* the {@code VideoMenu}.
|
2017-08-14 15:02:58 +00:00
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments {Component}
|
2017-08-14 15:02:58 +00:00
|
|
|
*/
|
2018-07-23 21:18:20 +00:00
|
|
|
class RemoteVideoMenuTriggerButton extends Component<Props> {
|
2021-06-30 16:12:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new RemoteVideoMenuTriggerButton 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
|
|
|
}
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2021-11-01 09:39:19 +00:00
|
|
|
const {
|
2022-03-14 14:46:19 +00:00
|
|
|
_disabled,
|
2021-11-01 09:39:19 +00:00
|
|
|
_overflowDrawer,
|
|
|
|
_showConnectionInfo,
|
|
|
|
_participantDisplayName,
|
2021-12-15 13:18:41 +00:00
|
|
|
buttonVisible,
|
|
|
|
classes,
|
2021-11-01 09:39:19 +00:00
|
|
|
participantID,
|
|
|
|
popoverVisible
|
|
|
|
} = this.props;
|
2022-03-14 14:46:19 +00:00
|
|
|
let content;
|
|
|
|
|
|
|
|
if (_showConnectionInfo) {
|
|
|
|
content = <ConnectionIndicatorContent participantId = { participantID } />;
|
|
|
|
} else if (!_disabled) {
|
|
|
|
content = this._renderRemoteVideoMenu();
|
|
|
|
}
|
2017-08-17 16:43:22 +00:00
|
|
|
|
|
|
|
if (!content) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-06-30 16:12:12 +00:00
|
|
|
const username = _participantDisplayName;
|
2021-06-10 12:48:44 +00:00
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
return (
|
2017-08-22 19:22:06 +00:00
|
|
|
<Popover
|
|
|
|
content = { content }
|
2021-11-01 09:39:19 +00:00
|
|
|
id = 'remote-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
|
|
|
position = { this.props._menuPosition }
|
2021-11-01 09:39:19 +00:00
|
|
|
visible = { popoverVisible }>
|
2022-03-14 14:46:19 +00:00
|
|
|
{!_overflowDrawer && buttonVisible && !_disabled && (
|
2022-08-01 07:05:17 +00:00
|
|
|
!isMobileBrowser() && <Button
|
|
|
|
accessibilityLabel = { this.props.t('dialog.remoteUserControls', { username }) }
|
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
|
|
|
)}
|
2017-08-22 19:22:06 +00:00
|
|
|
</Popover>
|
2017-08-14 15:02:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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 { dispatch, hidePopover } = 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
|
|
|
}
|
|
|
|
|
2017-08-14 15:02:58 +00:00
|
|
|
/**
|
2021-01-21 20:46:47 +00:00
|
|
|
* Creates a new {@code VideoMenu} with buttons for interacting with
|
2017-08-14 15:02:58 +00:00
|
|
|
* the remote participant.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderRemoteVideoMenu() {
|
2022-09-30 14:50:45 +00:00
|
|
|
const { _localVideoOwner, _participant, _remoteControlState, classes } = this.props;
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
className: classes.contextMenu,
|
|
|
|
onSelect: this._onPopoverClose,
|
|
|
|
participant: _participant,
|
|
|
|
thumbnailMenu: true
|
|
|
|
};
|
|
|
|
|
2022-10-06 11:12:57 +00:00
|
|
|
if (_participant?.fakeParticipant) {
|
2022-09-30 14:50:45 +00:00
|
|
|
return (
|
|
|
|
<FakeParticipantContextMenu
|
|
|
|
{ ...props }
|
|
|
|
localVideoOwner = { _localVideoOwner } />
|
|
|
|
);
|
|
|
|
}
|
2017-08-14 15:02:58 +00:00
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
return (
|
|
|
|
<ParticipantContextMenu
|
2022-09-30 14:50:45 +00:00
|
|
|
{ ...props }
|
|
|
|
remoteControlState = { _remoteControlState } />
|
2019-10-07 12:35:04 +00:00
|
|
|
);
|
2017-08-14 15:02:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 16:31:04 +00:00
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code RemoteVideoMenuTriggerButton}'s props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - The own props of the component.
|
|
|
|
* @private
|
2021-01-04 13:30:23 +00:00
|
|
|
* @returns {Props}
|
2020-02-18 16:31:04 +00:00
|
|
|
*/
|
2022-09-05 11:24:13 +00:00
|
|
|
function _mapStateToProps(state: IState, ownProps: Partial<Props>) {
|
2022-04-12 13:19:10 +00:00
|
|
|
const { participantID, thumbnailType } = ownProps;
|
2020-11-14 04:09:25 +00:00
|
|
|
let _remoteControlState = null;
|
2022-09-30 14:50:45 +00:00
|
|
|
const localParticipantId = getLocalParticipant(state)?.id;
|
2022-08-08 08:12:22 +00:00
|
|
|
const participant = getParticipantById(state, participantID ?? '');
|
2021-09-17 19:29:17 +00:00
|
|
|
const _participantDisplayName = participant?.name;
|
2020-11-14 04:09:25 +00:00
|
|
|
const _isRemoteControlSessionActive = participant?.remoteControlSessionStatus ?? false;
|
|
|
|
const _supportsRemoteControl = participant?.supportsRemoteControl ?? false;
|
|
|
|
const { active, controller } = state['features/remote-control'];
|
|
|
|
const { requestedParticipant, controlled } = controller;
|
|
|
|
const activeParticipant = requestedParticipant || controlled;
|
2021-01-04 13:30:23 +00:00
|
|
|
const { overflowDrawer } = state['features/toolbox'];
|
2021-06-30 16:12:12 +00:00
|
|
|
const { showConnectionInfo } = state['features/base/connection'];
|
2022-03-14 14:46:19 +00:00
|
|
|
const { remoteVideoMenu } = state['features/base/config'];
|
2022-09-30 14:50:45 +00:00
|
|
|
const { ownerId } = state['features/shared-video'];
|
2020-11-14 04:09:25 +00:00
|
|
|
|
|
|
|
if (_supportsRemoteControl
|
|
|
|
&& ((!active && !_isRemoteControlSessionActive) || activeParticipant === participantID)) {
|
|
|
|
if (requestedParticipant === participantID) {
|
|
|
|
_remoteControlState = REMOTE_CONTROL_MENU_STATES.REQUESTING;
|
|
|
|
} else if (controlled) {
|
|
|
|
_remoteControlState = REMOTE_CONTROL_MENU_STATES.STARTED;
|
|
|
|
} else {
|
|
|
|
_remoteControlState = REMOTE_CONTROL_MENU_STATES.NOT_STARTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let _menuPosition;
|
|
|
|
|
2022-04-12 13:19:10 +00:00
|
|
|
switch (thumbnailType) {
|
|
|
|
case THUMBNAIL_TYPE.TILE:
|
2021-01-14 16:12:08 +00:00
|
|
|
_menuPosition = 'left-start';
|
2020-11-14 04:09:25 +00:00
|
|
|
break;
|
2022-04-12 13:19:10 +00:00
|
|
|
case THUMBNAIL_TYPE.VERTICAL:
|
2021-01-14 16:12:08 +00:00
|
|
|
_menuPosition = 'left-end';
|
2020-11-14 04:09:25 +00:00
|
|
|
break;
|
2022-04-12 13:19:10 +00:00
|
|
|
case THUMBNAIL_TYPE.HORIZONTAL:
|
2021-08-16 09:58:48 +00:00
|
|
|
_menuPosition = 'top';
|
|
|
|
break;
|
2020-11-14 04:09:25 +00:00
|
|
|
default:
|
2021-01-14 16:12:08 +00:00
|
|
|
_menuPosition = 'auto';
|
2020-11-14 04:09:25 +00:00
|
|
|
}
|
2020-02-18 16:31:04 +00:00
|
|
|
|
|
|
|
return {
|
2022-10-11 10:47:54 +00:00
|
|
|
_disabled: Boolean(remoteVideoMenu?.disabled),
|
2022-09-30 14:50:45 +00:00
|
|
|
_localVideoOwner: Boolean(ownerId === localParticipantId),
|
2021-01-04 13:30:23 +00:00
|
|
|
_menuPosition,
|
2021-04-30 16:22:36 +00:00
|
|
|
_overflowDrawer: overflowDrawer,
|
2022-09-13 07:36:00 +00:00
|
|
|
_participant: participant ?? { id: '' },
|
|
|
|
_participantDisplayName: _participantDisplayName ?? '',
|
2021-12-15 13:18:41 +00:00
|
|
|
_remoteControlState,
|
2022-10-11 10:47:54 +00:00
|
|
|
_showConnectionInfo: Boolean(showConnectionInfo)
|
2020-02-18 16:31:04 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-15 13:18:41 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(
|
|
|
|
withStyles(styles)(RemoteVideoMenuTriggerButton)));
|