12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241 |
- // @flow
-
- import React, { Component } from 'react';
-
- import keyboardShortcut from '../../../../../modules/keyboardshortcut/keyboardshortcut';
- import {
- ACTION_SHORTCUT_TRIGGERED,
- createShortcutEvent,
- createToolbarEvent,
- sendAnalytics
- } from '../../../analytics';
- import { getToolbarButtons } from '../../../base/config';
- import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
- import { openDialog, toggleDialog } from '../../../base/dialog';
- import { isMobileBrowser } from '../../../base/environment/utils';
- import { translate } from '../../../base/i18n';
- import JitsiMeetJS from '../../../base/lib-jitsi-meet';
- import {
- getLocalParticipant,
- getParticipants,
- raiseHand
- } from '../../../base/participants';
- import { connect } from '../../../base/redux';
- import { getLocalVideoTrack } from '../../../base/tracks';
- import { isVpaasMeeting } from '../../../billing-counter/functions';
- import { toggleChat } from '../../../chat';
- import { ChatButton } from '../../../chat/components';
- import { EmbedMeetingButton } from '../../../embed-meeting';
- import { SharedDocumentButton } from '../../../etherpad';
- import { FeedbackButton } from '../../../feedback';
- import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
- import { LocalRecordingButton } from '../../../local-recording';
- import {
- close as closeParticipantsPane,
- open as openParticipantsPane
- } from '../../../participants-pane/actions';
- import ParticipantsPaneButton from '../../../participants-pane/components/ParticipantsPaneButton';
- import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
- import {
- LiveStreamButton,
- RecordButton
- } from '../../../recording';
- import {
- isScreenAudioSupported,
- isScreenVideoShared,
- ShareAudioButton,
- startScreenShareFlow
- } from '../../../screen-share/';
- import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
- import { SettingsButton } from '../../../settings';
- import { SharedVideoButton } from '../../../shared-video/components';
- import { SpeakerStatsButton } from '../../../speaker-stats';
- import {
- ClosedCaptionButton
- } from '../../../subtitles';
- import {
- TileViewButton,
- shouldDisplayTileView,
- toggleTileView
- } from '../../../video-layout';
- import { VideoQualityDialog, VideoQualityButton } from '../../../video-quality/components';
- import { VideoBackgroundButton } from '../../../virtual-background';
- import { toggleBackgroundEffect } from '../../../virtual-background/actions';
- import { VIRTUAL_BACKGROUND_TYPE } from '../../../virtual-background/constants';
- import { checkBlurSupport } from '../../../virtual-background/functions';
- import {
- setFullScreen,
- setOverflowMenuVisible,
- setToolbarHovered,
- showToolbox
- } from '../../actions';
- import { THRESHOLDS } from '../../constants';
- import { isToolboxVisible } from '../../functions';
- import DownloadButton from '../DownloadButton';
- import HangupButton from '../HangupButton';
- import HelpButton from '../HelpButton';
- import MuteEveryoneButton from '../MuteEveryoneButton';
- import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
-
- import AudioSettingsButton from './AudioSettingsButton';
- import FullscreenButton from './FullscreenButton';
- import OverflowMenuButton from './OverflowMenuButton';
- import ProfileButton from './ProfileButton';
- import RaiseHandButton from './RaiseHandButton';
- import Separator from './Separator';
- import ShareDesktopButton from './ShareDesktopButton';
- import VideoSettingsButton from './VideoSettingsButton';
-
- /**
- * The type of the React {@code Component} props of {@link Toolbox}.
- */
- type Props = {
-
- /**
- * String showing if the virtual background type is desktop-share.
- */
- _backgroundType: String,
-
- /**
- * 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: Object,
-
- /**
- * The tooltip key to use when screensharing is disabled. Or undefined
- * if non to be shown and the button to be hidden.
- */
- _desktopSharingDisabledTooltipKey: boolean,
-
- /**
- * Whether or not screensharing is initialized.
- */
- _desktopSharingEnabled: boolean,
-
- /**
- * Whether or not a dialog is displayed.
- */
- _dialog: 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 app is running in mobile browser.
- */
- _isMobile: boolean,
-
- /**
- * Whether or not the profile is disabled.
- */
- _isProfileDisabled: boolean,
-
- /**
- * Whether or not the tile view is enabled.
- */
- _tileViewEnabled: boolean,
-
- /**
- * Whether or not the current meeting belongs to a JaaS user.
- */
- _isVpaasMeeting: boolean,
-
- /**
- * The ID of the local participant.
- */
- _localParticipantID: String,
-
- /**
- * The JitsiLocalTrack to display.
- */
- _localVideo: Object,
-
- /**
- * 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 the local participant is screensharing.
- */
- _screensharing: boolean,
-
- /**
- * Whether or not the local participant is sharing a YouTube video.
- */
- _sharingVideo: boolean,
-
- /**
- * Flag showing whether toolbar is visible.
- */
- _visible: boolean,
-
- /**
- * Array with the buttons which this Toolbox should display.
- */
- _visibleButtons: Array<string>,
-
- /**
- * Handler to check if a button is enabled.
- */
- _shouldShowButton: Function,
-
- /**
- * Returns the selected virtual source object.
- */
- _virtualSource: Object,
-
- /**
- * Invoked to active other features of the app.
- */
- dispatch: Function,
-
- /**
- * Invoked to obtain translated strings.
- */
- t: Function
- };
-
- declare var APP: Object;
-
- /**
- * Implements the conference toolbox on React/Web.
- *
- * @extends Component
- */
- class Toolbox extends Component<Props> {
- /**
- * Initializes a new {@code Toolbox} instance.
- *
- * @param {Props} props - The read-only React {@code Component} props with
- * which the new instance is to be initialized.
- */
- constructor(props: Props) {
- 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._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._onEscKey = this._onEscKey.bind(this);
- }
-
- /**
- * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
- *
- * @inheritdoc
- * @returns {void}
- */
- componentDidMount() {
- const KEYBOARD_SHORTCUTS = [
- this.props._shouldShowButton('videoquality') && {
- character: 'A',
- exec: this._onShortcutToggleVideoQuality,
- helpDescription: 'toolbar.callQuality'
- },
- this.props._shouldShowButton('chat') && {
- character: 'C',
- exec: this._onShortcutToggleChat,
- helpDescription: 'keyboardShortcuts.toggleChat'
- },
- this.props._shouldShowButton('desktop') && {
- character: 'D',
- exec: this._onShortcutToggleScreenshare,
- helpDescription: 'keyboardShortcuts.toggleScreensharing'
- },
- this.props._shouldShowButton('participants-pane') && {
- character: 'P',
- exec: this._onShortcutToggleParticipantsPane,
- helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
- },
- this.props._shouldShowButton('raisehand') && {
- character: 'R',
- exec: this._onShortcutToggleRaiseHand,
- helpDescription: 'keyboardShortcuts.raiseHand'
- },
- this.props._shouldShowButton('fullscreen') && {
- character: 'S',
- exec: this._onShortcutToggleFullScreen,
- helpDescription: 'keyboardShortcuts.fullScreen'
- },
- this.props._shouldShowButton('tileview') && {
- character: 'W',
- exec: this._onShortcutToggleTileView,
- helpDescription: 'toolbar.tileViewToggle'
- }
- ];
-
- KEYBOARD_SHORTCUTS.forEach(shortcut => {
- if (typeof shortcut === 'object') {
- APP.keyboardshortcut.registerShortcut(
- shortcut.character,
- null,
- shortcut.exec,
- shortcut.helpDescription);
- }
- });
- }
-
- /**
- * Update the visibility of the {@code OverflowMenuButton}.
- *
- * @inheritdoc
- */
- componentDidUpdate(prevProps) {
- // Ensure the dialog is closed when the toolbox becomes hidden.
- if (prevProps._overflowMenuVisible && !this.props._visible) {
- this._onSetOverflowVisible(false);
- }
-
- if (prevProps._overflowMenuVisible
- && !prevProps._dialog
- && this.props._dialog) {
- this._onSetOverflowVisible(false);
- this.props.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));
- }
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- const { _chatOpen, _visible, _visibleButtons } = this.props;
- const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
- _visibleButtons.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
-
- return (
- <div
- className = { rootClassNames }
- id = 'new-toolbox'>
- { this._renderToolboxContent() }
- </div>
- );
- }
-
- _onEscKey: (KeyboardEvent) => void;
-
- /**
- * Key handler for overflow menu.
- *
- * @param {KeyboardEvent} e - Esc key click to close the popup.
- * @returns {void}
- */
- _onEscKey(e) {
- if (e.key === 'Escape') {
- e.stopPropagation();
- this._closeOverflowMenuIfOpen();
- }
- }
-
- /**
- * 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 { _localParticipantID, _raisedHand } = this.props;
- const newRaisedStatus = !_raisedHand;
-
- this.props.dispatch(raiseHand(newRaisedStatus));
-
- APP.API.notifyRaiseHandUpdated(_localParticipantID, newRaisedStatus);
- }
-
- /**
- * 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 {
- _backgroundType,
- _desktopSharingEnabled,
- _localVideo,
- _virtualSource,
- dispatch
- } = this.props;
-
- if (_backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
- const noneOptions = {
- enabled: false,
- backgroundType: VIRTUAL_BACKGROUND_TYPE.NONE,
- selectedThumbnail: VIRTUAL_BACKGROUND_TYPE.NONE,
- backgroundEffectEnabled: false
- };
-
- _virtualSource.dispose();
-
- dispatch(toggleBackgroundEffect(noneOptions, _localVideo));
-
- return;
- }
-
- if (_desktopSharingEnabled) {
- dispatch(startScreenShareFlow());
- }
- }
-
- /**
- * 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,
- _isMobile,
- _screensharing
- } = 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 = {
- key: 'raisehand',
- Content: RaiseHandButton,
- handleClick: this._onToolbarToggleRaiseHand,
- group: 2
- };
-
- const participants = {
- key: 'participants-pane',
- Content: ParticipantsPaneButton,
- handleClick: this._onToolbarToggleParticipantsPane,
- group: 2
- };
-
- const tileview = {
- key: 'tileview',
- Content: TileViewButton,
- group: 2
- };
-
- const videoQuality = {
- key: 'videoquality',
- Content: VideoQualityButton,
- handleClick: this._onToolbarOpenVideoQuality,
- group: 2
- };
-
- const fullscreen = !_isMobile && {
- key: 'fullscreen',
- Content: FullscreenButton,
- handleClick: this._onToolbarToggleFullScreen,
- group: 2
- };
-
- const security = {
- key: 'security',
- Content: SecurityDialogButton,
- group: 2
- };
-
- const info = {
- key: 'info',
- Content: SecurityDialogButton,
- group: 2
- };
-
- const cc = {
- key: 'closedcaptions',
- Content: ClosedCaptionButton,
- group: 2
- };
-
- const recording = {
- key: 'recording',
- Content: RecordButton,
- group: 2
- };
-
- const localRecording = {
- key: 'localrecording',
- Content: LocalRecordingButton,
- group: 2
- };
-
- const muteEveryone = {
- key: 'mute-everyone',
- Content: MuteEveryoneButton,
- group: 2
- };
-
- const muteVideoEveryone = {
- key: 'mute-video-everyone',
- Content: MuteEveryonesVideoButton,
- group: 2
- };
-
- const livestreaming = {
- key: 'livestreaming',
- Content: LiveStreamButton,
- group: 2
- };
-
- const shareVideo = {
- key: 'sharedvideo',
- Content: SharedVideoButton,
- group: 3
- };
-
- const shareAudio = this._showAudioSharingButton() && {
- key: 'shareaudio',
- Content: ShareAudioButton,
- group: 3
- };
-
- const etherpad = {
- key: 'etherpad',
- Content: SharedDocumentButton,
- group: 3
- };
-
- const virtualBackground = !_screensharing && checkBlurSupport() && {
- key: 'select-background',
- Content: VideoBackgroundButton,
- group: 3
- };
-
- const speakerStats = {
- 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,
- tileview,
- videoQuality,
- fullscreen,
- security,
- info,
- cc,
- recording,
- localRecording,
- muteEveryone,
- muteVideoEveryone,
- livestreaming,
- shareVideo,
- shareAudio,
- etherpad,
- virtualBackground,
- speakerStats,
- settings,
- shortcuts,
- embed,
- feedback,
- download,
- help
- };
- }
-
- /**
- * Returns all buttons that need to be rendered.
- *
- * @param {Object} state - The redux state.
- * @returns {Object} The visible buttons arrays .
- */
- _getVisibleButtons() {
- const {
- _clientWidth,
- _shouldShowButton
- } = this.props;
-
-
- const buttons = this._getAllButtons();
- const isHangupVisible = _shouldShowButton('hangup');
- 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]),
- ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
- ].filter(Boolean).filter(({ key }) => _shouldShowButton(key));
-
- 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)
- };
- }
-
- _onMouseOut: () => void;
-
- /**
- * Dispatches an action signaling the toolbar is not being hovered.
- *
- * @private
- * @returns {void}
- */
- _onMouseOut() {
- this.props.dispatch(setToolbarHovered(false));
- }
-
- _onMouseOver: () => void;
-
- /**
- * Dispatches an action signaling the toolbar is being hovered.
- *
- * @private
- * @returns {void}
- */
- _onMouseOver() {
- this.props.dispatch(setToolbarHovered(true));
- }
-
-
- _onSetOverflowVisible: (boolean) => void;
-
- /**
- * Sets the visibility of the overflow menu.
- *
- * @param {boolean} visible - Whether or not the overflow menu should be
- * displayed.
- * @private
- * @returns {void}
- */
- _onSetOverflowVisible(visible) {
- this.props.dispatch(setOverflowMenuVisible(visible));
- }
-
- _onShortcutToggleChat: () => void;
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling the display of chat.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleChat() {
- sendAnalytics(createShortcutEvent(
- 'toggle.chat',
- {
- 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();
- }
-
- _onShortcutToggleParticipantsPane: () => void;
-
- /**
- * 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',
- {
- enable: !this.props._participantsPaneOpen
- }));
-
- this._onToolbarToggleParticipantsPane();
- }
-
- _onShortcutToggleVideoQuality: () => void;
-
- /**
- * 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();
- }
-
- _onShortcutToggleTileView: () => void;
-
- /**
- * Dispatches an action for toggling the tile view.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleTileView() {
- sendAnalytics(createShortcutEvent(
- 'toggle.tileview',
- {
- enable: !this.props._tileViewEnabled
- }));
-
- this._doToggleTileView();
- }
-
- _onShortcutToggleFullScreen: () => void;
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling full screen mode.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleFullScreen() {
- sendAnalytics(createShortcutEvent(
- 'toggle.fullscreen',
- {
- enable: !this.props._fullScreen
- }));
-
- this._doToggleFullScreen();
- }
-
- _onShortcutToggleRaiseHand: () => void;
-
- /**
- * 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();
- }
-
- _onShortcutToggleScreenshare: () => void;
-
- /**
- * Creates an analytics keyboard shortcut event and dispatches an action for
- * toggling screensharing.
- *
- * @private
- * @returns {void}
- */
- _onShortcutToggleScreenshare() {
- sendAnalytics(createShortcutEvent(
- 'toggle.screen.sharing',
- ACTION_SHORTCUT_TRIGGERED,
- {
- enable: !this.props._screensharing
- }));
-
- this._doToggleScreenshare();
- }
-
- _onTabIn: () => void;
-
- /**
- * Toggle the toolbar visibility when tabbing into it.
- *
- * @returns {void}
- */
- _onTabIn() {
- if (!this.props._visible) {
- this.props.dispatch(showToolbox());
- }
- }
- _onToolbarToggleParticipantsPane: () => void;
-
- /**
- * Dispatches an action for toggling the participants pane.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleParticipantsPane() {
- const { dispatch, _participantsPaneOpen } = this.props;
-
- if (_participantsPaneOpen) {
- dispatch(closeParticipantsPane());
- } else {
- dispatch(openParticipantsPane());
- }
- }
-
- _onToolbarOpenVideoQuality: () => void;
-
- /**
- * 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();
- }
-
- _onToolbarToggleChat: () => void;
-
- /**
- * 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();
- }
-
- _onToolbarToggleFullScreen: () => void;
-
- /**
- * 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();
- }
-
- _onToolbarToggleRaiseHand: () => void;
-
- /**
- * 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();
- }
-
- _onToolbarToggleScreenshare: () => void;
-
- /**
- * Creates an analytics toolbar event and dispatches an action for toggling
- * screensharing.
- *
- * @private
- * @returns {void}
- */
- _onToolbarToggleScreenshare() {
- sendAnalytics(createToolbarEvent(
- 'toggle.screen.sharing',
- ACTION_SHORTCUT_TRIGGERED,
- { 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() {
- const {
- _desktopSharingEnabled,
- _desktopSharingDisabledTooltipKey
- } = this.props;
-
- return _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
- }
-
- /**
- * 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 {
- _isMobile,
- _overflowMenuVisible,
- t
- } = this.props;
-
- const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
- const containerClassName = `toolbox-content${_isMobile ? ' toolbox-content-mobile' : ''}`;
-
- const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
-
- return (
- <div className = { containerClassName }>
- <div
- className = 'toolbox-content-wrapper'
- onFocus = { this._onTabIn }
- onMouseOut = { this._onMouseOut }
- onMouseOver = { this._onMouseOver }>
- <div className = 'toolbox-content-items'>
- {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
- <Content
- { ...rest }
- key = { key } />))}
-
- {Boolean(overflowMenuButtons.length) && (
- <OverflowMenuButton
- ariaControls = 'overflow-menu'
- isOpen = { _overflowMenuVisible }
- key = 'overflow-menu'
- onVisibilityChange = { this._onSetOverflowVisible }>
- <ul
- aria-label = { t(toolbarAccLabel) }
- className = 'overflow-menu'
- id = 'overflow-menu'
- onKeyDown = { this._onEscKey }
- role = 'menu'>
- {overflowMenuButtons.map(({ group, key, Content, ...rest }, index, arr) => {
- const showSeparator = index > 0 && arr[index - 1].group !== group;
-
- return (
- <>
- {showSeparator && <Separator key = { `hr${group}` } />}
- <Content
- { ...rest }
- key = { key }
- showLabel = { true } />
- </>
- );
- })}
- </ul>
- </OverflowMenuButton>
- )}
-
- <HangupButton
- customClass = 'hangup-button'
- key = 'hangup-button'
- visible = { this.props._shouldShowButton('hangup') } />
- </div>
- </div>
- </div>
- );
- }
- }
-
- /**
- * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
- * props.
- *
- * @param {Object} state - The redux store/state.
- * @private
- * @returns {{}}
- */
- function _mapStateToProps(state) {
- const { conference } = state['features/base/conference'];
- let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
- const {
- callStatsID,
- enableFeaturesBasedOnToken
- } = state['features/base/config'];
- const {
- fullScreen,
- overflowMenuVisible
- } = state['features/toolbox'];
- const localParticipant = getLocalParticipant(state);
- const localVideo = getLocalVideoTrack(state['features/base/tracks']);
- const { clientWidth } = state['features/base/responsive-ui'];
-
- let desktopSharingDisabledTooltipKey;
-
- if (enableFeaturesBasedOnToken) {
- // we enable desktop sharing if any participant already have this
- // feature enabled
- desktopSharingEnabled = getParticipants(state)
- .find(({ features = {} }) =>
- String(features['screen-sharing']) === 'true') !== undefined;
- desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
- }
-
- return {
- _chatOpen: state['features/chat'].isOpen,
- _clientWidth: clientWidth,
- _conference: conference,
- _desktopSharingEnabled: desktopSharingEnabled,
- _backgroundType: state['features/virtual-background'].backgroundType,
- _virtualSource: state['features/virtual-background'].virtualSource,
- _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
- _dialog: Boolean(state['features/base/dialog'].component),
- _feedbackConfigured: Boolean(callStatsID),
- _isProfileDisabled: Boolean(state['features/base/config'].disableProfile),
- _isMobile: isMobileBrowser(),
- _isVpaasMeeting: isVpaasMeeting(state),
- _fullScreen: fullScreen,
- _tileViewEnabled: shouldDisplayTileView(state),
- _localParticipantID: localParticipant.id,
- _localVideo: localVideo,
- _overflowMenuVisible: overflowMenuVisible,
- _participantsPaneOpen: getParticipantsPaneOpen(state),
- _raisedHand: localParticipant.raisedHand,
- _screensharing: isScreenVideoShared(state),
- _shouldShowButton: buttonName => isToolbarButtonEnabled(buttonName)(state),
- _visible: isToolboxVisible(state),
- _visibleButtons: getToolbarButtons(state)
- };
- }
-
- export default translate(connect(_mapStateToProps)(Toolbox));
|