1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585 |
- /* eslint-disable lines-around-comment */
- import { withStyles } from '@mui/styles';
- import React, { Component } from 'react';
- import { WithTranslation } from 'react-i18next';
- import { batch, connect } from 'react-redux';
-
- // @ts-expect-error
- import keyboardShortcut from '../../../../../modules/keyboardshortcut/keyboardshortcut';
- import { isSpeakerStatsDisabled } from '../../../../features/speaker-stats/functions';
- import { ACTION_SHORTCUT_TRIGGERED, createShortcutEvent, createToolbarEvent } from '../../../analytics/AnalyticsEvents';
- import { sendAnalytics } from '../../../analytics/functions';
- import { IReduxState } from '../../../app/types';
- import { IJitsiConference } from '../../../base/conference/reducer';
- import {
- getMultipleVideoSendingSupportFeatureFlag,
- getToolbarButtons,
- isToolbarButtonEnabled
- } from '../../../base/config/functions.web';
- import { openDialog, toggleDialog } from '../../../base/dialog/actions';
- import { isIosMobileBrowser, isMobileBrowser } from '../../../base/environment/utils';
- import { translate } from '../../../base/i18n/functions';
- import JitsiMeetJS from '../../../base/lib-jitsi-meet';
- import {
- raiseHand
- } from '../../../base/participants/actions';
- import {
- getLocalParticipant,
- hasRaisedHand,
- isLocalParticipantModerator
- } from '../../../base/participants/functions';
- import { getLocalVideoTrack } from '../../../base/tracks/functions';
- import { ITrack } from '../../../base/tracks/types';
- import ContextMenu from '../../../base/ui/components/web/ContextMenu';
- import ContextMenuItemGroup from '../../../base/ui/components/web/ContextMenuItemGroup';
- import { toggleChat } from '../../../chat/actions.web';
- // @ts-ignore
- import { ChatButton } from '../../../chat/components';
- // @ts-ignore
- import { EmbedMeetingButton } from '../../../embed-meeting';
- // @ts-ignore
- import { SharedDocumentButton } from '../../../etherpad';
- // @ts-ignore
- import { FeedbackButton } from '../../../feedback';
- import { setGifMenuVisibility } from '../../../gifs/actions';
- import { isGifEnabled } from '../../../gifs/functions';
- // @ts-ignore
- import { InviteButton } from '../../../invite/components/add-people-dialog';
- import { isVpaasMeeting } from '../../../jaas/functions';
- // @ts-ignore
- import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
- import { NoiseSuppressionButton } from '../../../noise-suppression/components';
- import {
- close as closeParticipantsPane,
- open as openParticipantsPane
- } from '../../../participants-pane/actions';
- // @ts-ignore
- import { ParticipantsPaneButton } from '../../../participants-pane/components/web';
- import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
- import { addReactionToBuffer } from '../../../reactions/actions.any';
- import { toggleReactionsMenuVisibility } from '../../../reactions/actions.web';
- import ReactionsMenuButton from '../../../reactions/components/web/ReactionsMenuButton';
- import { REACTIONS } from '../../../reactions/constants';
- import { isReactionsEnabled } from '../../../reactions/functions.any';
- import {
- LiveStreamButton,
- RecordButton
- // @ts-ignore
- } from '../../../recording';
- import { isSalesforceEnabled } from '../../../salesforce/functions';
- import {
- startScreenShareFlow
- } from '../../../screen-share/actions.web';
- // @ts-ignore
- import ShareAudioButton from '../../../screen-share/components/web/ShareAudioButton';
- import {
- isScreenAudioSupported,
- isScreenVideoShared
- } from '../../../screen-share/functions';
- // @ts-ignore
- import SecurityDialogButton from '../../../security/components/security-dialog/web/SecurityDialogButton';
- // @ts-ignore
- import { SettingsButton } from '../../../settings';
- // @ts-ignore
- import { SharedVideoButton } from '../../../shared-video/components';
- // @ts-ignore
- import { SpeakerStatsButton } from '../../../speaker-stats/components/web';
- import SpeakerStats from '../../../speaker-stats/components/web/SpeakerStats';
- import {
- ClosedCaptionButton
- // @ts-ignore
- } from '../../../subtitles';
- import {
- TileViewButton,
- shouldDisplayTileView,
- toggleTileView
- // @ts-ignore
- } from '../../../video-layout';
- // @ts-ignore
- import { VideoQualityButton, VideoQualityDialog } from '../../../video-quality/components';
- // @ts-ignore
- import { VideoBackgroundButton } from '../../../virtual-background';
- import WhiteboardButton from '../../../whiteboard/components/web/WhiteboardButton';
- import { isWhiteboardButtonVisible } from '../../../whiteboard/functions';
- import {
- setFullScreen,
- setHangupMenuVisible,
- setOverflowMenuVisible,
- setToolbarHovered,
- showToolbox
- } from '../../actions';
- import { NOTIFY_CLICK_MODE, NOT_APPLICABLE, THRESHOLDS } from '../../constants';
- import { isDesktopShareButtonDisabled, isToolboxVisible } from '../../functions';
- import { getJwtDisabledButtons } from '../../functions.any';
- // @ts-ignore
- import DownloadButton from '../DownloadButton';
- // @ts-ignore
- import HangupButton from '../HangupButton';
- // @ts-ignore
- import HelpButton from '../HelpButton';
-
- // @ts-ignore
- import AudioSettingsButton from './AudioSettingsButton';
- import { EndConferenceButton } from './EndConferenceButton';
- // @ts-ignore
- import FullscreenButton from './FullscreenButton';
- import HangupMenuButton from './HangupMenuButton';
- import { LeaveConferenceButton } from './LeaveConferenceButton';
- // @ts-ignore
- import LinkToSalesforceButton from './LinkToSalesforceButton';
- // @ts-ignore
- import OverflowMenuButton from './OverflowMenuButton';
- // @ts-ignore
- import ProfileButton from './ProfileButton';
- // @ts-ignore
- import Separator from './Separator';
- // @ts-ignore
- import ShareDesktopButton from './ShareDesktopButton';
- // @ts-ignore
- import ToggleCameraButton from './ToggleCameraButton';
- // @ts-ignore
- import VideoSettingsButton from './VideoSettingsButton';
- /* eslint-enable lines-around-comment */
-
- /**
- * The type of the React {@code Component} props of {@link Toolbox}.
- */
- interface IProps extends WithTranslation {
-
- /**
- * String showing if the virtual background type is desktop-share.
- */
- _backgroundType: string;
-
- /**
- * Toolbar buttons which have their click exposed through the API.
- */
- _buttonsWithNotifyClick?: Array<string | {
- key: string;
- preventExecution: boolean;
- }>;
-
- /**
- * Whether or not the chat feature is currently displayed.
- */
- _chatOpen: boolean;
-
- /**
- * The width of the client.
- */
- _clientWidth: number;
-
- /**
- * The {@code JitsiConference} for the current conference.
- */
- _conference?: IJitsiConference;
-
- /**
- * Whether or not screensharing button is disabled.
- */
- _desktopSharingButtonDisabled: boolean;
-
- /**
- * Whether or not screensharing is initialized.
- */
- _desktopSharingEnabled: boolean;
-
- /**
- * Whether or not a dialog is displayed.
- */
- _dialog: boolean;
-
- /**
- * Whether or not the toolbox is disabled. It is for recorders.
- */
- _disabled: boolean;
-
- /**
- * Whether the end conference feature is supported.
- */
- _endConferenceSupported: boolean;
-
- /**
- * Whether or not call feedback can be sent.
- */
- _feedbackConfigured: boolean;
-
- /**
- * Whether or not the app is currently in full screen.
- */
- _fullScreen?: boolean;
-
- /**
- * Whether or not the GIFs feature is enabled.
- */
- _gifsEnabled: boolean;
-
- /**
- * Whether the hangup menu is visible.
- */
- _hangupMenuVisible: boolean;
-
- /**
- * Whether the app has Salesforce integration.
- */
- _hasSalesforce: boolean;
-
- /**
- * Whether or not the app is running in an ios mobile browser.
- */
- _isIosMobile: boolean;
-
- /**
- * Whether or not the app is running in mobile browser.
- */
- _isMobile: boolean;
-
- /**
- * Whether we are in narrow layout mode.
- */
- _isNarrowLayout: boolean;
-
- /**
- * Whether or not the profile is disabled.
- */
- _isProfileDisabled: boolean;
-
- /**
- * Whether or not speaker stats is disable.
- */
- _isSpeakerStatsDisabled?: boolean;
-
-
- /**
- * Whether or not the current meeting belongs to a JaaS user.
- */
- _isVpaasMeeting: boolean;
-
- /**
- * The array of toolbar buttons disabled through jwt features.
- */
- _jwtDisabledButons: string[];
-
- /**
- * The ID of the local participant.
- */
- _localParticipantID?: string;
-
- /**
- * The JitsiLocalTrack to display.
- */
- _localVideo?: ITrack;
-
- /**
- * Whether or not multi-stream send support is enabled.
- */
- _multiStreamModeEnabled: boolean;
-
- /**
- * Whether or not the overflow menu is displayed in a drawer drawer.
- */
- _overflowDrawer: boolean;
-
- /**
- * Whether or not the overflow menu is visible.
- */
- _overflowMenuVisible: boolean;
-
- /**
- * Whether or not the participants pane is open.
- */
- _participantsPaneOpen: boolean;
-
- /**
- * Whether or not the local participant's hand is raised.
- */
- _raisedHand: boolean;
-
- /**
- * Whether or not reactions feature is enabled.
- */
- _reactionsEnabled: boolean;
-
- /**
- * Whether or not the local participant is screenSharing.
- */
- _screenSharing: boolean;
-
- /**
- * Whether or not the local participant is sharing a YouTube video.
- */
- _sharingVideo?: boolean;
-
- /**
- * Whether or not the tile view is enabled.
- */
- _tileViewEnabled: boolean;
-
- /**
- * The enabled buttons.
- */
- _toolbarButtons: Array<string>;
-
- /**
- * Returns the selected virtual source object.
- */
- _virtualSource: any;
-
- /**
- * Flag showing whether toolbar is visible.
- */
- _visible: boolean;
-
- /**
- * Whether the whiteboard is visible.
- */
- _whiteboardEnabled: boolean;
-
- /**
- * An object containing the CSS classes.
- */
- classes: any;
-
- /**
- * Invoked to active other features of the app.
- */
- dispatch: Function;
-
- /**
- * Explicitly passed array with the buttons which this Toolbox should display.
- */
- toolbarButtons: Array<string>;
- }
-
- const styles = () => {
- return {
- contextMenu: {
- position: 'relative' as const,
- right: 'auto',
- margin: 0,
- marginBottom: '8px',
- maxHeight: 'calc(100vh - 100px)',
- width: '240px'
- },
-
- hangupMenu: {
- position: 'relative' as const,
- right: 'auto',
- display: 'flex',
- flexDirection: 'column' as const,
- rowGap: '8px',
- margin: 0,
- padding: '16px',
- marginBottom: '8px'
- }
- };
- };
-
- /**
- * Implements the conference toolbox on React/Web.
- *
- * @augments Component
- */
- class Toolbox extends Component<IProps> {
- /**
- * Initializes a new {@code Toolbox} instance.
- *
- * @param {IProps} props - The read-only React {@code Component} props with
- * which the new instance is to be initialized.
- */
- constructor(props: IProps) {
- super(props);
-
- // Bind event handlers so they are only bound once per instance.
- this._onMouseOut = this._onMouseOut.bind(this);
- this._onMouseOver = this._onMouseOver.bind(this);
- this._onSetHangupVisible = this._onSetHangupVisible.bind(this);
- this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
- this._onTabIn = this._onTabIn.bind(this);
-
- this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
- this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
- this._onShortcutToggleParticipantsPane = this._onShortcutToggleParticipantsPane.bind(this);
- this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
- this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
- this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
- this._onToolbarToggleParticipantsPane = this._onToolbarToggleParticipantsPane.bind(this);
- this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
- this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
- this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
- this._onToolbarToggleRaiseHand = this._onToolbarToggleRaiseHand.bind(this);
- this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
- this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
- this._onShortcutSpeakerStats = this._onShortcutSpeakerStats.bind(this);
- this._onEscKey = this._onEscKey.bind(this);
- }
-
- /**
- * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
- *
- * @inheritdoc
- * @returns {void}
- */
- componentDidMount() {
- const { _toolbarButtons, t, dispatch, _reactionsEnabled, _gifsEnabled, _isSpeakerStatsDisabled } = this.props;
-
- const KEYBOARD_SHORTCUTS = [
- isToolbarButtonEnabled('videoquality', _toolbarButtons) && {
- character: 'A',
- exec: this._onShortcutToggleVideoQuality,
- helpDescription: 'toolbar.callQuality'
- },
- isToolbarButtonEnabled('chat', _toolbarButtons) && {
- character: 'C',
- exec: this._onShortcutToggleChat,
- helpDescription: 'keyboardShortcuts.toggleChat'
- },
- isToolbarButtonEnabled('desktop', _toolbarButtons) && {
- character: 'D',
- exec: this._onShortcutToggleScreenshare,
- helpDescription: 'keyboardShortcuts.toggleScreensharing'
- },
- isToolbarButtonEnabled('participants-pane', _toolbarButtons) && {
- character: 'P',
- exec: this._onShortcutToggleParticipantsPane,
- helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
- },
- isToolbarButtonEnabled('raisehand', _toolbarButtons) && {
- character: 'R',
- exec: this._onShortcutToggleRaiseHand,
- helpDescription: 'keyboardShortcuts.raiseHand'
- },
- isToolbarButtonEnabled('fullscreen', _toolbarButtons) && {
- character: 'S',
- exec: this._onShortcutToggleFullScreen,
- helpDescription: 'keyboardShortcuts.fullScreen'
- },
- isToolbarButtonEnabled('tileview', _toolbarButtons) && {
- character: 'W',
- exec: this._onShortcutToggleTileView,
- helpDescription: 'toolbar.tileViewToggle'
- },
- !_isSpeakerStatsDisabled && isToolbarButtonEnabled('stats', _toolbarButtons) && {
- character: 'T',
- exec: this._onShortcutSpeakerStats,
- helpDescription: 'keyboardShortcuts.showSpeakerStats'
- }
- ];
-
- KEYBOARD_SHORTCUTS.forEach(shortcut => {
- if (typeof shortcut === 'object') {
- APP.keyboardshortcut.registerShortcut(
- shortcut.character,
- null,
- shortcut.exec,
- shortcut.helpDescription);
- }
- });
-
- if (_reactionsEnabled) {
- const REACTION_SHORTCUTS = Object.keys(REACTIONS).map(key => {
- const onShortcutSendReaction = () => {
- dispatch(addReactionToBuffer(key));
- sendAnalytics(createShortcutEvent(
- `reaction.${key}`
- ));
- };
-
- return {
- character: REACTIONS[key].shortcutChar,
- exec: onShortcutSendReaction,
- helpDescription: t(`toolbar.reaction${key.charAt(0).toUpperCase()}${key.slice(1)}`),
- altKey: true
- };
- });
-
- REACTION_SHORTCUTS.forEach(shortcut => {
- APP.keyboardshortcut.registerShortcut(
- shortcut.character,
- null,
- shortcut.exec,
- shortcut.helpDescription,
- shortcut.altKey);
- });
-
- if (_gifsEnabled) {
- const onGifShortcut = () => {
- batch(() => {
- dispatch(toggleReactionsMenuVisibility());
- dispatch(setGifMenuVisibility(true));
- });
- };
-
- APP.keyboardshortcut.registerShortcut(
- 'G',
- null,
- onGifShortcut,
- t('keyboardShortcuts.giphyMenu')
- );
- }
- }
- }
-
- /**
- * Update the visibility of the {@code OverflowMenuButton}.
- *
- * @inheritdoc
- */
- componentDidUpdate(prevProps: IProps) {
- const { _dialog, _visible, dispatch } = this.props;
-
-
- if (prevProps._overflowMenuVisible
- && !prevProps._dialog
- && _dialog) {
- this._onSetOverflowVisible(false);
- dispatch(setToolbarHovered(false));
- }
- if (prevProps._hangupMenuVisible
- && prevProps._visible
- && !_visible) {
- this._onSetHangupVisible(false);
- dispatch(setToolbarHovered(false));
- }
- }
-
- /**
- * Removes keyboard shortcuts registered by this component.
- *
- * @inheritdoc
- * @returns {void}
- */
- componentWillUnmount() {
- [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
- APP.keyboardshortcut.unregisterShortcut(letter));
-
- if (this.props._reactionsEnabled) {
- Object.keys(REACTIONS).map(key => REACTIONS[key].shortcutChar)
- .forEach(letter =>
- APP.keyboardshortcut.unregisterShortcut(letter, true));
- }
- }
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- if (this.props._disabled) {
- return null;
- }
-
- const { _chatOpen, _visible, _toolbarButtons } = this.props;
- const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
- _toolbarButtons.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
-
- return (
- <div
- className = { rootClassNames }
- id = 'new-toolbox'>
- { this._renderToolboxContent() }
- </div>
- );
- }
-
- /**
- * Key handler for overflow/hangup menus.
- *
- * @param {KeyboardEvent} e - Esc key click to close the popup.
- * @returns {void}
- */
- _onEscKey(e?: React.KeyboardEvent) {
- if (e?.key === 'Escape') {
- e?.stopPropagation();
- this._closeHangupMenuIfOpen();
- this._closeOverflowMenuIfOpen();
- }
- }
-
- /**
- * Closes the hangup menu if opened.
- *
- * @private
- * @returns {void}
- */
- _closeHangupMenuIfOpen() {
- const { dispatch, _hangupMenuVisible } = this.props;
-
- _hangupMenuVisible && dispatch(setHangupMenuVisible(false));
- }
-
- /**
- * Closes the overflow menu if opened.
- *
- * @private
- * @returns {void}
- */
- _closeOverflowMenuIfOpen() {
- const { dispatch, _overflowMenuVisible } = this.props;
-
- _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
- }
-
- /**
- * Dispatches an action to open the video quality dialog.
- *
- * @private
- * @returns {void}
- */
- _doOpenVideoQuality() {
- this.props.dispatch(openDialog(VideoQualityDialog));
- }
-
- /**
- * Dispatches an action to toggle the display of chat.
- *
- * @private
- * @returns {void}
- */
- _doToggleChat() {
- this.props.dispatch(toggleChat());
- }
-
- /**
- * Dispatches an action to toggle screensharing.
- *
- * @private
- * @returns {void}
- */
- _doToggleFullScreen() {
- const fullScreen = !this.props._fullScreen;
-
- this.props.dispatch(setFullScreen(fullScreen));
- }
-
- /**
- * Dispatches an action to toggle the local participant's raised hand state.
- *
- * @private
- * @returns {void}
- */
- _doToggleRaiseHand() {
- const { _raisedHand } = this.props;
-
- this.props.dispatch(raiseHand(!_raisedHand));
- }
-
- /**
- * Dispatches an action to toggle screensharing.
- *
- * @private
- * @param {boolean} enabled - The state to toggle screen sharing to.
- * @param {boolean} audioOnly - Only share system audio.
- * @returns {void}
- */
- _doToggleScreenshare() {
- const {
- _desktopSharingButtonDisabled,
- _desktopSharingEnabled,
- _screenSharing,
- dispatch
- } = this.props;
-
- if (_desktopSharingEnabled && !_desktopSharingButtonDisabled) {
- dispatch(startScreenShareFlow(!_screenSharing));
- }
- }
-
- /**
- * Dispatches an action to toggle the video quality dialog.
- *
- * @private
- * @returns {void}
- */
- _doToggleVideoQuality() {
- this.props.dispatch(toggleDialog(VideoQualityDialog));
- }
-
- /**
- * Dispaches an action to toggle tile view.
- *
- * @private
- * @returns {void}
- */
- _doToggleTileView() {
- this.props.dispatch(toggleTileView());
- }
-
- /**
- * Returns all buttons that could be rendered.
- *
- * @param {Object} state - The redux state.
- * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
- */
- _getAllButtons() {
- const {
- _feedbackConfigured,
- _hasSalesforce,
- _isIosMobile,
- _isMobile,
- _isNarrowLayout,
- _isSpeakerStatsDisabled,
- _multiStreamModeEnabled,
- _reactionsEnabled,
- _screenSharing,
- _whiteboardEnabled
- } = this.props;
-
- const microphone = {
- key: 'microphone',
- Content: AudioSettingsButton,
- group: 0
- };
-
- const camera = {
- key: 'camera',
- Content: VideoSettingsButton,
- group: 0
- };
-
- const profile = this._isProfileVisible() && {
- key: 'profile',
- Content: ProfileButton,
- group: 1
- };
-
- const chat = {
- key: 'chat',
- Content: ChatButton,
- handleClick: this._onToolbarToggleChat,
- group: 2
- };
-
- const desktop = this._showDesktopSharingButton() && {
- key: 'desktop',
- Content: ShareDesktopButton,
- handleClick: this._onToolbarToggleScreenshare,
- group: 2
- };
-
- const raisehand = (!_reactionsEnabled || (!_isNarrowLayout && !_isMobile)) && {
- key: 'raisehand',
- Content: ReactionsMenuButton,
- handleClick: this._onToolbarToggleRaiseHand,
- group: 2
- };
-
- const participants = {
- key: 'participants-pane',
- Content: ParticipantsPaneButton,
- handleClick: this._onToolbarToggleParticipantsPane,
- group: 2
- };
-
- const invite = {
- key: 'invite',
- Content: InviteButton,
- group: 2
- };
-
- const tileview = {
- key: 'tileview',
- Content: TileViewButton,
- group: 2
- };
-
- const toggleCamera = {
- key: 'toggle-camera',
- Content: ToggleCameraButton,
- group: 2
- };
-
- const videoQuality = {
- key: 'videoquality',
- Content: VideoQualityButton,
- handleClick: this._onToolbarOpenVideoQuality,
- group: 2
- };
-
- const fullscreen = !_isIosMobile && {
- key: 'fullscreen',
- Content: FullscreenButton,
- handleClick: this._onToolbarToggleFullScreen,
- group: 2
- };
-
- const security = {
- key: 'security',
- alias: 'info',
- Content: SecurityDialogButton,
- group: 2
- };
-
- const cc = {
- key: 'closedcaptions',
- Content: ClosedCaptionButton,
- group: 2
- };
-
- const recording = {
- key: 'recording',
- Content: RecordButton,
- group: 2
- };
-
- const livestreaming = {
- key: 'livestreaming',
- Content: LiveStreamButton,
- group: 2
- };
-
- const linkToSalesforce = _hasSalesforce && {
- key: 'linktosalesforce',
- Content: LinkToSalesforceButton,
- group: 2
- };
-
- const shareVideo = {
- key: 'sharedvideo',
- Content: SharedVideoButton,
- group: 3
- };
-
- const shareAudio = this._showAudioSharingButton() && {
- key: 'shareaudio',
- Content: ShareAudioButton,
- group: 3
- };
-
- const noiseSuppression = {
- key: 'noisesuppression',
- Content: NoiseSuppressionButton,
- group: 3
- };
-
-
- const whiteboard = _whiteboardEnabled && {
- key: 'whiteboard',
- Content: WhiteboardButton,
- group: 3
- };
-
- const etherpad = {
- key: 'etherpad',
- Content: SharedDocumentButton,
- group: 3
- };
-
- const virtualBackground = (_multiStreamModeEnabled || !_screenSharing) && {
- key: 'select-background',
- Content: VideoBackgroundButton,
- group: 3
- };
-
- const speakerStats = !_isSpeakerStatsDisabled && {
- key: 'stats',
- Content: SpeakerStatsButton,
- group: 3
- };
-
- const settings = {
- key: 'settings',
- Content: SettingsButton,
- group: 4
- };
-
- const shortcuts = !_isMobile && keyboardShortcut.getEnabled() && {
- key: 'shortcuts',
- Content: KeyboardShortcutsButton,
- group: 4
- };
-
- const embed = this._isEmbedMeetingVisible() && {
- key: 'embedmeeting',
- Content: EmbedMeetingButton,
- group: 4
- };
-
- const feedback = _feedbackConfigured && {
- key: 'feedback',
- Content: FeedbackButton,
- group: 4
- };
-
- const download = {
- key: 'download',
- Content: DownloadButton,
- group: 4
- };
-
- const help = {
- key: 'help',
- Content: HelpButton,
- group: 4
- };
-
- return {
- microphone,
- camera,
- profile,
- desktop,
- chat,
- raisehand,
- participants,
- invite,
- tileview,
- toggleCamera,
- videoQuality,
- fullscreen,
- security,
- cc,
- recording,
- livestreaming,
- linkToSalesforce,
- shareVideo,
- shareAudio,
- noiseSuppression,
- whiteboard,
- etherpad,
- virtualBackground,
- speakerStats,
- settings,
- shortcuts,
- embed,
- feedback,
- download,
- help
- };
- }
-
-
- /**
- * Returns the notify mode of the given toolbox button.
- *
- * @param {string} btnName - The toolbar button's name.
- * @returns {string|undefined} - The button's notify mode.
- */
- _getButtonNotifyMode(btnName: string) {
- const notify = this.props._buttonsWithNotifyClick?.find(
- btn =>
- (typeof btn === 'string' && btn === btnName)
- || (typeof btn === 'object' && btn.key === btnName)
- );
-
- if (notify) {
- return typeof notify === 'string' || notify.preventExecution
- ? NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
- : NOTIFY_CLICK_MODE.ONLY_NOTIFY;
- }
- }
-
- /**
- * Sets the notify click mode for the buttons.
- *
- * @param {Object} buttons - The list of toolbar buttons.
- * @returns {void}
- */
- _setButtonsNotifyClickMode(buttons: Object) {
- if (typeof APP === 'undefined' || !this.props._buttonsWithNotifyClick?.length) {
- return;
- }
-
- Object.values(buttons).forEach((button: any) => {
- if (typeof button === 'object') {
- button.notifyMode = this._getButtonNotifyMode(button.key);
- }
- });
- }
-
- /**
- * Returns all buttons that need to be rendered.
- *
- * @param {Object} state - The redux state.
- * @returns {Object} The visible buttons arrays .
- */
- _getVisibleButtons() {
- const {
- _clientWidth,
- _toolbarButtons,
- _jwtDisabledButons
- } = this.props;
-
- const buttons = this._getAllButtons();
-
- this._setButtonsNotifyClickMode(buttons);
- const isHangupVisible = isToolbarButtonEnabled('hangup', _toolbarButtons);
- const { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
- || THRESHOLDS[THRESHOLDS.length - 1];
- let sliceIndex = order.length + 2;
-
- const keys = Object.keys(buttons);
-
- const filtered = [
- ...order.map(key => buttons[key as keyof typeof buttons]),
- ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
- ].filter(Boolean).filter(({ key, alias = NOT_APPLICABLE }) =>
- !_jwtDisabledButons.includes(key)
- && (isToolbarButtonEnabled(key, _toolbarButtons) || isToolbarButtonEnabled(alias, _toolbarButtons))
- );
-
- if (isHangupVisible) {
- sliceIndex -= 1;
- }
-
- // This implies that the overflow button will be displayed, so save some space for it.
- if (sliceIndex < filtered.length) {
- sliceIndex -= 1;
- }
-
- return {
- mainMenuButtons: filtered.slice(0, sliceIndex),
- overflowMenuButtons: filtered.slice(sliceIndex)
- };
- }
-
- /**
- * Dispatches an action signaling the toolbar is not being hovered.
- *
- * @private
- * @returns {void}
- */
- _onMouseOut() {
- const { _overflowMenuVisible, dispatch } = this.props;
-
- !_overflowMenuVisible && dispatch(setToolbarHovered(false));
- }
-
- /**
- * Dispatches an action signaling the toolbar is being hovered.
- *
- * @private
- * @returns {void}
- */
- _onMouseOver() {
- this.props.dispatch(setToolbarHovered(true));
- }
-
- /**
- * Sets the visibility of the hangup menu.
- *
- * @param {boolean} visible - Whether or not the hangup menu should be
- * displayed.
- * @private
- * @returns {void}
- */
- _onSetHangupVisible(visible: boolean) {
- this.props.dispatch(setHangupMenuVisible(visible));
- this.props.dispatch(setToolbarHovered(visible));
- }
-
- /**
- * Sets the visibility of the overflow menu.
- *
- * @param {boolean} visible - Whether or not the overflow menu should be
- * displayed.
- * @private
- * @returns {void}
- */
- _onSetOverflowVisible(visible: boolean) {
- this.props.dispatch(setOverflowMenuVisible(visible));
- this.props.dispatch(setToolbarHovered(visible));
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling the display of chat.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleChat() {
- sendAnalytics(createShortcutEvent(
- 'toggle.chat',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._chatOpen
- }));
-
- // Checks if there was any text selected by the user.
- // Used for when we press simultaneously keys for copying
- // text messages from the chat board
- if (window.getSelection()?.toString() !== '') {
- return false;
- }
-
- this._doToggleChat();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling the display of the participants pane.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleParticipantsPane() {
- sendAnalytics(createShortcutEvent(
- 'toggle.participants-pane',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._participantsPaneOpen
- }));
-
- this._onToolbarToggleParticipantsPane();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling the display of Video Quality.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleVideoQuality() {
- sendAnalytics(createShortcutEvent('video.quality'));
-
- this._doToggleVideoQuality();
- }
-
- /**
- * Dispatches an action for toggling the tile view.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleTileView() {
- sendAnalytics(createShortcutEvent(
- 'toggle.tileview',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._tileViewEnabled
- }));
-
- this._doToggleTileView();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling full screen mode.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleFullScreen() {
- sendAnalytics(createShortcutEvent(
- 'toggle.fullscreen',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._fullScreen
- }));
-
- this._doToggleFullScreen();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling raise hand.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleRaiseHand() {
- sendAnalytics(createShortcutEvent(
- 'toggle.raise.hand',
- ACTION_SHORTCUT_TRIGGERED,
- { enable: !this.props._raisedHand }));
-
- this._doToggleRaiseHand();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling screensharing.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleScreenshare() {
- // Ignore the shortcut if the button is disabled.
- if (this.props._desktopSharingButtonDisabled) {
- return;
- }
- sendAnalytics(createShortcutEvent(
- 'toggle.screen.sharing',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._screenSharing
- }));
-
- this._doToggleScreenshare();
- }
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling speaker stats.
- *
- * @private
- * @returns {void}
- */
- _onShortcutSpeakerStats() {
- sendAnalytics(createShortcutEvent(
- 'speaker.stats'
- ));
-
- this._doToggleSpekearStats();
- }
-
- /**
- * Dispatches an action to toggle speakerStats.
- *
- * @private
- * @returns {void}
- */
- _doToggleSpekearStats() {
- const { dispatch } = this.props;
-
- dispatch(toggleDialog(SpeakerStats, {
- conference: APP.conference
- }));
- }
-
- /**
- * Toggle the toolbar visibility when tabbing into it.
- *
- * @returns {void}
- */
- _onTabIn() {
- if (!this.props._visible) {
- this.props.dispatch(showToolbox());
- }
- }
-
- /**
- * Dispatches an action for toggling the participants pane.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleParticipantsPane() {
- const { dispatch, _participantsPaneOpen } = this.props;
-
- if (_participantsPaneOpen) {
- dispatch(closeParticipantsPane());
- } else {
- dispatch(openParticipantsPane());
- }
- }
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * open the video quality dialog.
- *
- * @private
- * @returns {void}
- */
- _onToolbarOpenVideoQuality() {
- sendAnalytics(createToolbarEvent('video.quality'));
-
- this._doOpenVideoQuality();
- }
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * the display of chat.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleChat() {
- sendAnalytics(createToolbarEvent(
- 'toggle.chat',
- {
- enable: !this.props._chatOpen
- }));
- this._closeOverflowMenuIfOpen();
- this._doToggleChat();
- }
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * full screen mode.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleFullScreen() {
- sendAnalytics(createToolbarEvent(
- 'toggle.fullscreen',
- {
- enable: !this.props._fullScreen
- }));
- this._closeOverflowMenuIfOpen();
- this._doToggleFullScreen();
- }
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * raise hand.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleRaiseHand() {
- sendAnalytics(createToolbarEvent(
- 'raise.hand',
- { enable: !this.props._raisedHand }));
-
- this._doToggleRaiseHand();
- }
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * screensharing.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleScreenshare() {
- sendAnalytics(createToolbarEvent(
- 'toggle.screen.sharing',
- { enable: !this.props._screenSharing }));
-
- this._closeOverflowMenuIfOpen();
- this._doToggleScreenshare();
- }
-
- /**
- * Returns true if the audio sharing button should be visible and
- * false otherwise.
- *
- * @returns {boolean}
- */
- _showAudioSharingButton() {
- const {
- _desktopSharingEnabled
- } = this.props;
-
- return _desktopSharingEnabled && isScreenAudioSupported();
- }
-
- /**
- * Returns true if the desktop sharing button should be visible and
- * false otherwise.
- *
- * @returns {boolean}
- */
- _showDesktopSharingButton() {
- return this.props._desktopSharingEnabled;
- }
-
- /**
- * Returns true if the embed meeting button is visible and false otherwise.
- *
- * @returns {boolean}
- */
- _isEmbedMeetingVisible() {
- return !this.props._isVpaasMeeting
- && !this.props._isMobile;
- }
-
- /**
- * Returns true if the profile button is visible and false otherwise.
- *
- * @returns {boolean}
- */
- _isProfileVisible() {
- return !this.props._isProfileDisabled;
- }
-
- /**
- * Renders the toolbox content.
- *
- * @returns {ReactElement}
- */
- _renderToolboxContent() {
- const {
- _endConferenceSupported,
- _hangupMenuVisible,
- _isMobile,
- _isNarrowLayout,
- _overflowDrawer,
- _overflowMenuVisible,
- _reactionsEnabled,
- _toolbarButtons,
- classes,
- t
- } = this.props;
-
- const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
- const containerClassName = `toolbox-content${_isMobile || _isNarrowLayout ? ' toolbox-content-mobile' : ''}`;
-
- const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
-
- return (
- <div className = { containerClassName }>
- <div
- className = 'toolbox-content-wrapper'
- onFocus = { this._onTabIn }
- { ...(_isMobile ? {} : {
- onMouseOut: this._onMouseOut,
- onMouseOver: this._onMouseOver
- }) }>
-
- <div className = 'toolbox-content-items'>
- {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
- <Content
- { ...rest }
- buttonKey = { key }
- key = { key } />))}
-
- {Boolean(overflowMenuButtons.length) && (
- <OverflowMenuButton
- ariaControls = 'overflow-menu'
- isOpen = { _overflowMenuVisible }
- key = 'overflow-menu'
- onVisibilityChange = { this._onSetOverflowVisible }
- showMobileReactions = {
- _reactionsEnabled && (_isMobile || _isNarrowLayout)
- }>
- <ContextMenu
- accessibilityLabel = { t(toolbarAccLabel) }
- className = { classes.contextMenu }
- hidden = { false }
- inDrawer = { _overflowDrawer }
- onKeyDown = { this._onEscKey }>
- {overflowMenuButtons.reduce((acc, val) => {
- if (acc.length) {
- const prev = acc[acc.length - 1];
- const group = prev[prev.length - 1].group;
-
- if (group === val.group) {
- prev.push(val);
- } else {
- acc.push([ val ]);
- }
- } else {
- acc.push([ val ]);
- }
-
- return acc;
- }, []).map((buttonGroup: any) => (
- <ContextMenuItemGroup key = { `group-${buttonGroup[0].group}` }>
- {buttonGroup.map(({ key, Content, ...rest }: any) => (
- key !== 'raisehand' || !_reactionsEnabled)
- && <Content
- { ...rest }
- buttonKey = { key }
- contextMenu = { true }
- key = { key }
- showLabel = { true } />)}
- </ContextMenuItemGroup>))}
- </ContextMenu>
- </OverflowMenuButton>
- )}
-
- { isToolbarButtonEnabled('hangup', _toolbarButtons) && (
- _endConferenceSupported
- ? <HangupMenuButton
- ariaControls = 'hangup-menu'
- isOpen = { _hangupMenuVisible }
- key = 'hangup-menu'
- notifyMode = { this._getButtonNotifyMode('hangup-menu') }
- onVisibilityChange = { this._onSetHangupVisible }>
- <ContextMenu
- accessibilityLabel = { t(toolbarAccLabel) }
- className = { classes.hangupMenu }
- hidden = { false }
- inDrawer = { _overflowDrawer }
- onKeyDown = { this._onEscKey }>
- <EndConferenceButton
- buttonKey = 'end-meeting'
- notifyMode = { this._getButtonNotifyMode('end-meeting') } />
- <LeaveConferenceButton
- buttonKey = 'hangup'
- notifyMode = { this._getButtonNotifyMode('hangup') } />
- </ContextMenu>
- </HangupMenuButton>
- : <HangupButton
- buttonKey = 'hangup'
- customClass = 'hangup-button'
- key = 'hangup-button'
- notifyMode = { this._getButtonNotifyMode('hangup') }
- visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
- )}
- </div>
- </div>
- </div>
- );
- }
- }
-
- /**
- * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
- * props.
- *
- * @param {Object} state - The redux store/state.
- * @param {Object} ownProps - The props explicitly passed.
- * @private
- * @returns {{}}
- */
- function _mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
- const { conference } = state['features/base/conference'];
- const { isNarrowLayout } = state['features/base/responsive-ui'];
- const endConferenceSupported = conference?.isEndConferenceSupported() && isLocalParticipantModerator(state);
-
- const {
- buttonsWithNotifyClick,
- callStatsID,
- disableProfile,
- iAmRecorder,
- iAmSipGateway
- } = state['features/base/config'];
- const {
- fullScreen,
- hangupMenuVisible,
- overflowMenuVisible,
- overflowDrawer
- } = state['features/toolbox'];
- const localParticipant = getLocalParticipant(state);
- const localVideo = getLocalVideoTrack(state['features/base/tracks']);
- const { clientWidth } = state['features/base/responsive-ui'];
- const toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
-
- return {
- _backgroundType: state['features/virtual-background'].backgroundType ?? '',
- _buttonsWithNotifyClick: buttonsWithNotifyClick,
- _chatOpen: state['features/chat'].isOpen,
- _clientWidth: clientWidth,
- _conference: conference,
- _desktopSharingEnabled: JitsiMeetJS.isDesktopSharingEnabled(),
- _desktopSharingButtonDisabled: isDesktopShareButtonDisabled(state),
- _dialog: Boolean(state['features/base/dialog'].component),
- _disabled: Boolean(iAmRecorder || iAmSipGateway),
- _endConferenceSupported: Boolean(endConferenceSupported),
- _feedbackConfigured: Boolean(callStatsID),
- _fullScreen: fullScreen,
- _gifsEnabled: isGifEnabled(state),
- _isProfileDisabled: Boolean(disableProfile),
- _isIosMobile: isIosMobileBrowser(),
- _isMobile: isMobileBrowser(),
- _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
- _isVpaasMeeting: isVpaasMeeting(state),
- _jwtDisabledButons: getJwtDisabledButtons(state),
- _hasSalesforce: isSalesforceEnabled(state),
- _hangupMenuVisible: hangupMenuVisible,
- _isNarrowLayout: isNarrowLayout,
- _localParticipantID: localParticipant?.id,
- _localVideo: localVideo,
- _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state),
- _overflowMenuVisible: overflowMenuVisible,
- _overflowDrawer: overflowDrawer,
- _participantsPaneOpen: getParticipantsPaneOpen(state),
- _raisedHand: hasRaisedHand(localParticipant),
- _reactionsEnabled: isReactionsEnabled(state),
- _screenSharing: isScreenVideoShared(state),
- _tileViewEnabled: shouldDisplayTileView(state),
- _toolbarButtons: toolbarButtons,
- _virtualSource: state['features/virtual-background'].virtualSource,
- _visible: isToolboxVisible(state),
- _whiteboardEnabled: isWhiteboardButtonVisible(state)
- };
- }
-
- export default translate(connect(_mapStateToProps)(withStyles(styles)(Toolbox)));
|