/* eslint-disable lines-around-comment */ import { withStyles } from '@mui/styles'; import React, { Component } from 'react'; import { WithTranslation } from 'react-i18next'; import { batch } from 'react-redux'; import { IState } from '../../../app/types'; import { isMobileBrowser } from '../../../base/environment/utils'; // @ts-ignore import { translate } from '../../../base/i18n'; import { IconHorizontalPoints } from '../../../base/icons/svg'; import { getLocalParticipant, getParticipantById } from '../../../base/participants/functions'; import { Participant } from '../../../base/participants/types'; // @ts-ignore import { Popover } from '../../../base/popover'; import { connect } from '../../../base/redux/functions'; // @ts-ignore import { setParticipantContextMenuOpen } from '../../../base/responsive-ui/actions'; import Button from '../../../base/ui/components/web/Button'; import ConnectionIndicatorContent from // @ts-ignore '../../../connection-indicator/components/web/ConnectionIndicatorContent'; import { THUMBNAIL_TYPE } from '../../../filmstrip/constants'; // @ts-ignore import { renderConnectionStatus } from '../../actions.web'; import FakeParticipantContextMenu from './FakeParticipantContextMenu'; import ParticipantContextMenu from './ParticipantContextMenu'; // @ts-ignore import { REMOTE_CONTROL_MENU_STATES } from './RemoteControlButton'; /** * The type of the React {@code Component} props of * {@link RemoteVideoMenuTriggerButton}. */ interface Props extends WithTranslation { /** * Whether the remote video context menu is disabled. */ _disabled: Boolean; /** * Shared video local participant owner. */ _localVideoOwner?: boolean; /** * The position relative to the trigger the remote 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; /** * Participant reference. */ _participant: Participant; /** * The ID for the participant on which the remote video menu will act. */ _participantDisplayName: string; /** * The current state of the participant's remote control session. */ _remoteControlState: number; /** * Whether the popover should render the Connection Info stats. */ _showConnectionInfo: Boolean; /** * Whether or not the button should be visible. */ buttonVisible: boolean; /** * An object containing the CSS classes. */ classes: any; /** * The redux dispatch function. */ dispatch: Function; /** * Hides popover. */ hidePopover: Function; /** * The ID for the participant on which the remote video menu will act. */ participantID: string; /** * Whether the popover is visible or not. */ popoverVisible: boolean; /** * Shows popover. */ showPopover: Function; /** * The type of the thumbnail. */ thumbnailType: string; } const styles = () => { return { triggerButton: { padding: '3px !important', borderRadius: '4px' }, contextMenu: { position: 'relative' as const, marginTop: 0, right: 'auto', padding: '0', marginRight: '4px', marginBottom: '4px' } }; }; /** * React {@code Component} for displaying an icon associated with opening the * the {@code VideoMenu}. * * @augments {Component} */ class RemoteVideoMenuTriggerButton extends Component { /** * 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); this._onPopoverOpen = this._onPopoverOpen.bind(this); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { _disabled, _overflowDrawer, _showConnectionInfo, _participantDisplayName, buttonVisible, classes, participantID, popoverVisible } = this.props; let content; if (_showConnectionInfo) { content = ; } else if (!_disabled) { content = this._renderRemoteVideoMenu(); } if (!content) { return null; } const username = _participantDisplayName; return ( {!_overflowDrawer && buttonVisible && !_disabled && ( !isMobileBrowser() &&