Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Toolbox.tsx 50KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633
  1. import { withStyles } from '@mui/styles';
  2. import clsx from 'clsx';
  3. import React, { Component, RefObject } from 'react';
  4. import { WithTranslation } from 'react-i18next';
  5. import { batch, connect } from 'react-redux';
  6. import { isSpeakerStatsDisabled } from '../../../../features/speaker-stats/functions';
  7. import { ACTION_SHORTCUT_TRIGGERED, createShortcutEvent, createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  8. import { sendAnalytics } from '../../../analytics/functions';
  9. import { IReduxState, IStore } from '../../../app/types';
  10. import { IJitsiConference } from '../../../base/conference/reducer';
  11. import { VISITORS_MODE_BUTTONS } from '../../../base/config/constants';
  12. import {
  13. getButtonsWithNotifyClick,
  14. getMultipleVideoSendingSupportFeatureFlag,
  15. getToolbarButtons,
  16. isToolbarButtonEnabled
  17. } from '../../../base/config/functions.web';
  18. import { openDialog, toggleDialog } from '../../../base/dialog/actions';
  19. import { isIosMobileBrowser, isMobileBrowser } from '../../../base/environment/utils';
  20. import { translate } from '../../../base/i18n/functions';
  21. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  22. import {
  23. raiseHand
  24. } from '../../../base/participants/actions';
  25. import {
  26. getLocalParticipant,
  27. hasRaisedHand,
  28. isLocalParticipantModerator
  29. } from '../../../base/participants/functions';
  30. import { getLocalVideoTrack } from '../../../base/tracks/functions.web';
  31. import { ITrack } from '../../../base/tracks/types';
  32. import ContextMenu from '../../../base/ui/components/web/ContextMenu';
  33. import { toggleChat } from '../../../chat/actions.web';
  34. import ChatButton from '../../../chat/components/web/ChatButton';
  35. import EmbedMeetingButton from '../../../embed-meeting/components/EmbedMeetingButton';
  36. import SharedDocumentButton from '../../../etherpad/components/SharedDocumentButton.web';
  37. import FeedbackButton from '../../../feedback/components/FeedbackButton.web';
  38. import { setGifMenuVisibility } from '../../../gifs/actions';
  39. import { isGifEnabled } from '../../../gifs/functions.web';
  40. import InviteButton from '../../../invite/components/add-people-dialog/web/InviteButton';
  41. import { isVpaasMeeting } from '../../../jaas/functions';
  42. import { registerShortcut, unregisterShortcut } from '../../../keyboard-shortcuts/actions';
  43. import KeyboardShortcutsButton from '../../../keyboard-shortcuts/components/web/KeyboardShortcutsButton';
  44. import { areKeyboardShortcutsEnabled } from '../../../keyboard-shortcuts/functions';
  45. import NoiseSuppressionButton from '../../../noise-suppression/components/NoiseSuppressionButton';
  46. import {
  47. close as closeParticipantsPane,
  48. open as openParticipantsPane
  49. } from '../../../participants-pane/actions.web';
  50. import ParticipantsPaneButton from '../../../participants-pane/components/web/ParticipantsPaneButton';
  51. import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
  52. import {
  53. addReactionToBuffer,
  54. toggleReactionsMenuVisibility
  55. } from '../../../reactions/actions.web';
  56. import RaiseHandButton from '../../../reactions/components/web/RaiseHandButton';
  57. import ReactionsMenuButton from '../../../reactions/components/web/ReactionsMenuButton';
  58. import { REACTIONS } from '../../../reactions/constants';
  59. import { isReactionsButtonEnabled, isReactionsEnabled } from '../../../reactions/functions.web';
  60. import LiveStreamButton from '../../../recording/components/LiveStream/web/LiveStreamButton';
  61. import RecordButton from '../../../recording/components/Recording/web/RecordButton';
  62. import { isSalesforceEnabled } from '../../../salesforce/functions';
  63. import {
  64. startScreenShareFlow
  65. } from '../../../screen-share/actions.web';
  66. import ShareAudioButton from '../../../screen-share/components/web/ShareAudioButton';
  67. import {
  68. isScreenAudioSupported,
  69. isScreenVideoShared
  70. } from '../../../screen-share/functions';
  71. import SecurityDialogButton from '../../../security/components/security-dialog/web/SecurityDialogButton';
  72. import SettingsButton from '../../../settings/components/web/SettingsButton';
  73. import SharedVideoButton from '../../../shared-video/components/web/SharedVideoButton';
  74. import SpeakerStats from '../../../speaker-stats/components/web/SpeakerStats';
  75. import SpeakerStatsButton from '../../../speaker-stats/components/web/SpeakerStatsButton';
  76. import ClosedCaptionButton from '../../../subtitles/components/web/ClosedCaptionButton';
  77. import { toggleTileView } from '../../../video-layout/actions.web';
  78. import TileViewButton from '../../../video-layout/components/TileViewButton';
  79. import { shouldDisplayTileView } from '../../../video-layout/functions.web';
  80. import VideoQualityButton from '../../../video-quality/components/VideoQualityButton.web';
  81. import VideoQualityDialog from '../../../video-quality/components/VideoQualityDialog.web';
  82. import VideoBackgroundButton from '../../../virtual-background/components/VideoBackgroundButton';
  83. import { iAmVisitor } from '../../../visitors/functions';
  84. import WhiteboardButton from '../../../whiteboard/components/web/WhiteboardButton';
  85. import { isWhiteboardButtonVisible } from '../../../whiteboard/functions';
  86. import {
  87. setFullScreen,
  88. setHangupMenuVisible,
  89. setOverflowMenuVisible,
  90. setToolbarHovered,
  91. showToolbox
  92. } from '../../actions.web';
  93. import { NOTIFY_CLICK_MODE, NOT_APPLICABLE, THRESHOLDS } from '../../constants';
  94. import {
  95. getJwtDisabledButtons,
  96. isDesktopShareButtonDisabled,
  97. isToolboxVisible
  98. } from '../../functions.web';
  99. import DownloadButton from '../DownloadButton';
  100. import HangupButton from '../HangupButton';
  101. import HelpButton from '../HelpButton';
  102. import AudioSettingsButton from './AudioSettingsButton';
  103. import CustomOptionButton from './CustomOptionButton';
  104. import { EndConferenceButton } from './EndConferenceButton';
  105. import FullscreenButton from './FullscreenButton';
  106. import HangupMenuButton from './HangupMenuButton';
  107. import { LeaveConferenceButton } from './LeaveConferenceButton';
  108. import LinkToSalesforceButton from './LinkToSalesforceButton';
  109. import OverflowMenuButton from './OverflowMenuButton';
  110. import ProfileButton from './ProfileButton';
  111. import Separator from './Separator';
  112. import ShareDesktopButton from './ShareDesktopButton';
  113. import ToggleCameraButton from './ToggleCameraButton';
  114. import VideoSettingsButton from './VideoSettingsButton';
  115. /**
  116. * The type of the React {@code Component} props of {@link Toolbox}.
  117. */
  118. interface IProps extends WithTranslation {
  119. /**
  120. * String showing if the virtual background type is desktop-share.
  121. */
  122. _backgroundType: string;
  123. /**
  124. * Toolbar buttons which have their click exposed through the API.
  125. */
  126. _buttonsWithNotifyClick?: Array<string | {
  127. key: string;
  128. preventExecution: boolean;
  129. }>;
  130. /**
  131. * Whether or not the chat feature is currently displayed.
  132. */
  133. _chatOpen: boolean;
  134. /**
  135. * The width of the client.
  136. */
  137. _clientWidth: number;
  138. /**
  139. * The {@code JitsiConference} for the current conference.
  140. */
  141. _conference?: IJitsiConference;
  142. /**
  143. * Custom Toolbar buttons.
  144. */
  145. _customToolbarButtons?: Array<{ icon: string; id: string; text: string; }>;
  146. /**
  147. * Whether or not screensharing button is disabled.
  148. */
  149. _desktopSharingButtonDisabled: boolean;
  150. /**
  151. * Whether or not screensharing is initialized.
  152. */
  153. _desktopSharingEnabled: boolean;
  154. /**
  155. * Whether or not a dialog is displayed.
  156. */
  157. _dialog: boolean;
  158. /**
  159. * Whether or not the toolbox is disabled. It is for recorders.
  160. */
  161. _disabled: boolean;
  162. /**
  163. * Whether the end conference feature is supported.
  164. */
  165. _endConferenceSupported: boolean;
  166. /**
  167. * Whether or not call feedback can be sent.
  168. */
  169. _feedbackConfigured: boolean;
  170. /**
  171. * Whether or not the app is currently in full screen.
  172. */
  173. _fullScreen?: boolean;
  174. /**
  175. * Whether or not the GIFs feature is enabled.
  176. */
  177. _gifsEnabled: boolean;
  178. /**
  179. * Whether the hangup menu is visible.
  180. */
  181. _hangupMenuVisible: boolean;
  182. /**
  183. * Whether the app has Salesforce integration.
  184. */
  185. _hasSalesforce: boolean;
  186. /**
  187. * Whether or not the app is running in an ios mobile browser.
  188. */
  189. _isIosMobile: boolean;
  190. /**
  191. * Whether or not the app is running in mobile browser.
  192. */
  193. _isMobile: boolean;
  194. /**
  195. * Whether we are in narrow layout mode.
  196. */
  197. _isNarrowLayout: boolean;
  198. /**
  199. * Whether or not the profile is disabled.
  200. */
  201. _isProfileDisabled: boolean;
  202. /**
  203. * Whether or not speaker stats is disable.
  204. */
  205. _isSpeakerStatsDisabled?: boolean;
  206. /**
  207. * Whether or not the current meeting belongs to a JaaS user.
  208. */
  209. _isVpaasMeeting: boolean;
  210. /**
  211. * The array of toolbar buttons disabled through jwt features.
  212. */
  213. _jwtDisabledButons: string[];
  214. /**
  215. * The ID of the local participant.
  216. */
  217. _localParticipantID?: string;
  218. /**
  219. * The JitsiLocalTrack to display.
  220. */
  221. _localVideo?: ITrack;
  222. /**
  223. * Whether or not multi-stream send support is enabled.
  224. */
  225. _multiStreamModeEnabled: boolean;
  226. /**
  227. * Whether or not the overflow menu is displayed in a drawer drawer.
  228. */
  229. _overflowDrawer: boolean;
  230. /**
  231. * Whether or not the overflow menu is visible.
  232. */
  233. _overflowMenuVisible: boolean;
  234. /**
  235. * Whether or not the participants pane is open.
  236. */
  237. _participantsPaneOpen: boolean;
  238. /**
  239. * Whether or not the local participant's hand is raised.
  240. */
  241. _raisedHand: boolean;
  242. /**
  243. * Whether or not to display reactions in separate button.
  244. */
  245. _reactionsButtonEnabled: boolean;
  246. /**
  247. * Whether or not reactions feature is enabled.
  248. */
  249. _reactionsEnabled: boolean;
  250. /**
  251. * Whether or not the local participant is screenSharing.
  252. */
  253. _screenSharing: boolean;
  254. /**
  255. * Whether or not the local participant is sharing a YouTube video.
  256. */
  257. _sharingVideo?: boolean;
  258. /**
  259. * Whether the toolbox should be shifted up or not.
  260. */
  261. _shiftUp: boolean;
  262. /**
  263. * Whether or not the shortcut buttons are enabled.
  264. */
  265. _shortcutsEnabled: boolean;
  266. /**
  267. * Whether or not the tile view is enabled.
  268. */
  269. _tileViewEnabled: boolean;
  270. /**
  271. * The enabled buttons.
  272. */
  273. _toolbarButtons: Array<string>;
  274. /**
  275. * Returns the selected virtual source object.
  276. */
  277. _virtualSource: any;
  278. /**
  279. * Flag showing whether toolbar is visible.
  280. */
  281. _visible: boolean;
  282. /**
  283. * Whether the whiteboard is visible.
  284. */
  285. _whiteboardEnabled: boolean;
  286. /**
  287. * An object containing the CSS classes.
  288. */
  289. classes: any;
  290. /**
  291. * Invoked to active other features of the app.
  292. */
  293. dispatch: IStore['dispatch'];
  294. /**
  295. * Explicitly passed array with the buttons which this Toolbox should display.
  296. */
  297. toolbarButtons: Array<string>;
  298. }
  299. const styles = () => {
  300. return {
  301. contextMenu: {
  302. position: 'relative' as const,
  303. right: 'auto',
  304. margin: 0,
  305. marginBottom: '8px',
  306. maxHeight: 'calc(100vh - 100px)',
  307. minWidth: '240px'
  308. },
  309. hangupMenu: {
  310. position: 'relative' as const,
  311. right: 'auto',
  312. display: 'flex',
  313. flexDirection: 'column' as const,
  314. rowGap: '8px',
  315. margin: 0,
  316. padding: '16px',
  317. marginBottom: '4px'
  318. }
  319. };
  320. };
  321. /**
  322. * Implements the conference toolbox on React/Web.
  323. *
  324. * @augments Component
  325. */
  326. class Toolbox extends Component<IProps> {
  327. _toolboxRef: RefObject<HTMLDivElement>;
  328. /**
  329. * Initializes a new {@code Toolbox} instance.
  330. *
  331. * @param {IProps} props - The read-only React {@code Component} props with
  332. * which the new instance is to be initialized.
  333. */
  334. constructor(props: IProps) {
  335. super(props);
  336. this._toolboxRef = React.createRef();
  337. // Bind event handlers so they are only bound once per instance.
  338. this._onMouseOut = this._onMouseOut.bind(this);
  339. this._onMouseOver = this._onMouseOver.bind(this);
  340. this._onSetHangupVisible = this._onSetHangupVisible.bind(this);
  341. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  342. this._onTabIn = this._onTabIn.bind(this);
  343. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  344. this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
  345. this._onShortcutToggleParticipantsPane = this._onShortcutToggleParticipantsPane.bind(this);
  346. this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
  347. this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
  348. this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
  349. this._onToolbarToggleParticipantsPane = this._onToolbarToggleParticipantsPane.bind(this);
  350. this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
  351. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  352. this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
  353. this._onToolbarToggleRaiseHand = this._onToolbarToggleRaiseHand.bind(this);
  354. this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
  355. this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
  356. this._onShortcutSpeakerStats = this._onShortcutSpeakerStats.bind(this);
  357. this._onEscKey = this._onEscKey.bind(this);
  358. }
  359. /**
  360. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  361. *
  362. * @inheritdoc
  363. * @returns {void}
  364. */
  365. componentDidMount() {
  366. const { _toolbarButtons, t, dispatch, _reactionsEnabled, _gifsEnabled, _isSpeakerStatsDisabled } = this.props;
  367. const KEYBOARD_SHORTCUTS = [
  368. isToolbarButtonEnabled('videoquality', _toolbarButtons) && {
  369. character: 'A',
  370. exec: this._onShortcutToggleVideoQuality,
  371. helpDescription: 'toolbar.callQuality'
  372. },
  373. isToolbarButtonEnabled('chat', _toolbarButtons) && {
  374. character: 'C',
  375. exec: this._onShortcutToggleChat,
  376. helpDescription: 'keyboardShortcuts.toggleChat'
  377. },
  378. isToolbarButtonEnabled('desktop', _toolbarButtons) && {
  379. character: 'D',
  380. exec: this._onShortcutToggleScreenshare,
  381. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  382. },
  383. isToolbarButtonEnabled('participants-pane', _toolbarButtons) && {
  384. character: 'P',
  385. exec: this._onShortcutToggleParticipantsPane,
  386. helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
  387. },
  388. isToolbarButtonEnabled('raisehand', _toolbarButtons) && {
  389. character: 'R',
  390. exec: this._onShortcutToggleRaiseHand,
  391. helpDescription: 'keyboardShortcuts.raiseHand'
  392. },
  393. isToolbarButtonEnabled('fullscreen', _toolbarButtons) && {
  394. character: 'S',
  395. exec: this._onShortcutToggleFullScreen,
  396. helpDescription: 'keyboardShortcuts.fullScreen'
  397. },
  398. isToolbarButtonEnabled('tileview', _toolbarButtons) && {
  399. character: 'W',
  400. exec: this._onShortcutToggleTileView,
  401. helpDescription: 'toolbar.tileViewToggle'
  402. },
  403. !_isSpeakerStatsDisabled && isToolbarButtonEnabled('stats', _toolbarButtons) && {
  404. character: 'T',
  405. exec: this._onShortcutSpeakerStats,
  406. helpDescription: 'keyboardShortcuts.showSpeakerStats'
  407. }
  408. ];
  409. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  410. if (typeof shortcut === 'object') {
  411. dispatch(registerShortcut({
  412. character: shortcut.character,
  413. handler: shortcut.exec,
  414. helpDescription: shortcut.helpDescription
  415. }));
  416. }
  417. });
  418. if (_reactionsEnabled) {
  419. const REACTION_SHORTCUTS = Object.keys(REACTIONS).map(key => {
  420. const onShortcutSendReaction = () => {
  421. dispatch(addReactionToBuffer(key));
  422. sendAnalytics(createShortcutEvent(
  423. `reaction.${key}`
  424. ));
  425. };
  426. return {
  427. character: REACTIONS[key].shortcutChar,
  428. exec: onShortcutSendReaction,
  429. helpDescription: t(`toolbar.reaction${key.charAt(0).toUpperCase()}${key.slice(1)}`),
  430. altKey: true
  431. };
  432. });
  433. REACTION_SHORTCUTS.forEach(shortcut => {
  434. dispatch(registerShortcut({
  435. alt: shortcut.altKey,
  436. character: shortcut.character,
  437. handler: shortcut.exec,
  438. helpDescription: shortcut.helpDescription
  439. }));
  440. });
  441. if (_gifsEnabled) {
  442. const onGifShortcut = () => {
  443. batch(() => {
  444. dispatch(toggleReactionsMenuVisibility());
  445. dispatch(setGifMenuVisibility(true));
  446. });
  447. };
  448. dispatch(registerShortcut({
  449. character: 'G',
  450. handler: onGifShortcut,
  451. helpDescription: 'keyboardShortcuts.giphyMenu'
  452. }));
  453. }
  454. }
  455. }
  456. /**
  457. * Update the visibility of the {@code OverflowMenuButton}.
  458. *
  459. * @inheritdoc
  460. */
  461. componentDidUpdate(prevProps: IProps) {
  462. const { _dialog, _visible, dispatch } = this.props;
  463. if (prevProps._overflowMenuVisible
  464. && !prevProps._dialog
  465. && _dialog) {
  466. this._onSetOverflowVisible(false);
  467. dispatch(setToolbarHovered(false));
  468. }
  469. if (prevProps._hangupMenuVisible
  470. && prevProps._visible
  471. && !_visible) {
  472. this._onSetHangupVisible(false);
  473. dispatch(setToolbarHovered(false));
  474. }
  475. if (!_visible && prevProps._visible !== _visible) {
  476. if (document.activeElement instanceof HTMLElement
  477. && this._toolboxRef.current?.contains(document.activeElement)) {
  478. document.activeElement.blur();
  479. }
  480. }
  481. }
  482. /**
  483. * Removes keyboard shortcuts registered by this component.
  484. *
  485. * @inheritdoc
  486. * @returns {void}
  487. */
  488. componentWillUnmount() {
  489. const { dispatch } = this.props;
  490. [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
  491. dispatch(unregisterShortcut(letter)));
  492. if (this.props._reactionsEnabled) {
  493. Object.keys(REACTIONS).map(key => REACTIONS[key].shortcutChar)
  494. .forEach(letter =>
  495. dispatch(unregisterShortcut(letter, true)));
  496. }
  497. }
  498. /**
  499. * Implements React's {@link Component#render()}.
  500. *
  501. * @inheritdoc
  502. * @returns {ReactElement}
  503. */
  504. render() {
  505. if (this.props._disabled) {
  506. return null;
  507. }
  508. const { _chatOpen, _visible, _toolbarButtons } = this.props;
  509. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  510. _toolbarButtons.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
  511. return (
  512. <div
  513. className = { clsx(rootClassNames, this.props._shiftUp && 'shift-up') }
  514. id = 'new-toolbox'>
  515. { this._renderToolboxContent() }
  516. </div>
  517. );
  518. }
  519. /**
  520. * Key handler for overflow/hangup menus.
  521. *
  522. * @param {KeyboardEvent} e - Esc key click to close the popup.
  523. * @returns {void}
  524. */
  525. _onEscKey(e?: React.KeyboardEvent) {
  526. if (e?.key === 'Escape') {
  527. e?.stopPropagation();
  528. this._closeHangupMenuIfOpen();
  529. this._closeOverflowMenuIfOpen();
  530. }
  531. }
  532. /**
  533. * Closes the hangup menu if opened.
  534. *
  535. * @private
  536. * @returns {void}
  537. */
  538. _closeHangupMenuIfOpen() {
  539. const { dispatch, _hangupMenuVisible } = this.props;
  540. _hangupMenuVisible && dispatch(setHangupMenuVisible(false));
  541. }
  542. /**
  543. * Closes the overflow menu if opened.
  544. *
  545. * @private
  546. * @returns {void}
  547. */
  548. _closeOverflowMenuIfOpen() {
  549. const { dispatch, _overflowMenuVisible } = this.props;
  550. _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
  551. }
  552. /**
  553. * Dispatches an action to open the video quality dialog.
  554. *
  555. * @private
  556. * @returns {void}
  557. */
  558. _doOpenVideoQuality() {
  559. this.props.dispatch(openDialog(VideoQualityDialog));
  560. }
  561. /**
  562. * Dispatches an action to toggle the display of chat.
  563. *
  564. * @private
  565. * @returns {void}
  566. */
  567. _doToggleChat() {
  568. this.props.dispatch(toggleChat());
  569. }
  570. /**
  571. * Dispatches an action to toggle screensharing.
  572. *
  573. * @private
  574. * @returns {void}
  575. */
  576. _doToggleFullScreen() {
  577. const fullScreen = !this.props._fullScreen;
  578. this.props.dispatch(setFullScreen(fullScreen));
  579. }
  580. /**
  581. * Dispatches an action to toggle the local participant's raised hand state.
  582. *
  583. * @private
  584. * @returns {void}
  585. */
  586. _doToggleRaiseHand() {
  587. const { _raisedHand } = this.props;
  588. this.props.dispatch(raiseHand(!_raisedHand));
  589. }
  590. /**
  591. * Dispatches an action to toggle screensharing.
  592. *
  593. * @private
  594. * @param {boolean} enabled - The state to toggle screen sharing to.
  595. * @param {boolean} audioOnly - Only share system audio.
  596. * @returns {void}
  597. */
  598. _doToggleScreenshare() {
  599. const {
  600. _desktopSharingButtonDisabled,
  601. _desktopSharingEnabled,
  602. _screenSharing,
  603. dispatch
  604. } = this.props;
  605. if (_desktopSharingEnabled && !_desktopSharingButtonDisabled) {
  606. dispatch(startScreenShareFlow(!_screenSharing));
  607. }
  608. }
  609. /**
  610. * Dispatches an action to toggle the video quality dialog.
  611. *
  612. * @private
  613. * @returns {void}
  614. */
  615. _doToggleVideoQuality() {
  616. this.props.dispatch(toggleDialog(VideoQualityDialog));
  617. }
  618. /**
  619. * Dispaches an action to toggle tile view.
  620. *
  621. * @private
  622. * @returns {void}
  623. */
  624. _doToggleTileView() {
  625. this.props.dispatch(toggleTileView());
  626. }
  627. /**
  628. * Returns all buttons that could be rendered.
  629. *
  630. * @param {Object} state - The redux state.
  631. * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
  632. */
  633. _getAllButtons() {
  634. const {
  635. _customToolbarButtons,
  636. _feedbackConfigured,
  637. _hasSalesforce,
  638. _isIosMobile,
  639. _isMobile,
  640. _isNarrowLayout,
  641. _isSpeakerStatsDisabled,
  642. _multiStreamModeEnabled,
  643. _reactionsButtonEnabled,
  644. _reactionsEnabled,
  645. _screenSharing,
  646. _shortcutsEnabled,
  647. _whiteboardEnabled
  648. } = this.props;
  649. const microphone = {
  650. key: 'microphone',
  651. Content: AudioSettingsButton,
  652. group: 0
  653. };
  654. const camera = {
  655. key: 'camera',
  656. Content: VideoSettingsButton,
  657. group: 0
  658. };
  659. const profile = this._isProfileVisible() && {
  660. key: 'profile',
  661. Content: ProfileButton,
  662. group: 1
  663. };
  664. const chat = {
  665. key: 'chat',
  666. Content: ChatButton,
  667. handleClick: this._onToolbarToggleChat,
  668. group: 2
  669. };
  670. const desktop = this._showDesktopSharingButton() && {
  671. key: 'desktop',
  672. Content: ShareDesktopButton,
  673. handleClick: this._onToolbarToggleScreenshare,
  674. group: 2
  675. };
  676. // In Narrow layout and mobile web we are using drawer for popups and that is why it is better to include
  677. // all forms of reactions in the overflow menu. Otherwise the toolbox will be hidden and the reactions popup
  678. // misaligned.
  679. const showReactionsAsPartOfRaiseHand
  680. = !_reactionsButtonEnabled && _reactionsEnabled && !_isNarrowLayout && !_isMobile;
  681. const raisehand = {
  682. key: 'raisehand',
  683. Content: showReactionsAsPartOfRaiseHand ? ReactionsMenuButton : RaiseHandButton,
  684. handleClick: this._onToolbarToggleRaiseHand,
  685. group: 2
  686. };
  687. const reactions = _reactionsButtonEnabled && _reactionsEnabled && {
  688. key: 'reactions',
  689. Content: ReactionsMenuButton,
  690. handleClick: this._onToolbarToggleRaiseHand,
  691. group: 2
  692. };
  693. const participants = {
  694. key: 'participants-pane',
  695. Content: ParticipantsPaneButton,
  696. handleClick: this._onToolbarToggleParticipantsPane,
  697. group: 2
  698. };
  699. const invite = {
  700. key: 'invite',
  701. Content: InviteButton,
  702. group: 2
  703. };
  704. const tileview = {
  705. key: 'tileview',
  706. Content: TileViewButton,
  707. group: 2
  708. };
  709. const toggleCamera = {
  710. key: 'toggle-camera',
  711. Content: ToggleCameraButton,
  712. group: 2
  713. };
  714. const videoQuality = {
  715. key: 'videoquality',
  716. Content: VideoQualityButton,
  717. handleClick: this._onToolbarOpenVideoQuality,
  718. group: 2
  719. };
  720. const fullscreen = !_isIosMobile && {
  721. key: 'fullscreen',
  722. Content: FullscreenButton,
  723. handleClick: this._onToolbarToggleFullScreen,
  724. group: 2
  725. };
  726. const security = {
  727. key: 'security',
  728. alias: 'info',
  729. Content: SecurityDialogButton,
  730. group: 2
  731. };
  732. const cc = {
  733. key: 'closedcaptions',
  734. Content: ClosedCaptionButton,
  735. group: 2
  736. };
  737. const recording = {
  738. key: 'recording',
  739. Content: RecordButton,
  740. group: 2
  741. };
  742. const livestreaming = {
  743. key: 'livestreaming',
  744. Content: LiveStreamButton,
  745. group: 2
  746. };
  747. const linkToSalesforce = _hasSalesforce && {
  748. key: 'linktosalesforce',
  749. Content: LinkToSalesforceButton,
  750. group: 2
  751. };
  752. const shareVideo = {
  753. key: 'sharedvideo',
  754. Content: SharedVideoButton,
  755. group: 3
  756. };
  757. const shareAudio = this._showAudioSharingButton() && {
  758. key: 'shareaudio',
  759. Content: ShareAudioButton,
  760. group: 3
  761. };
  762. const noiseSuppression = {
  763. key: 'noisesuppression',
  764. Content: NoiseSuppressionButton,
  765. group: 3
  766. };
  767. const whiteboard = _whiteboardEnabled && {
  768. key: 'whiteboard',
  769. Content: WhiteboardButton,
  770. group: 3
  771. };
  772. const etherpad = {
  773. key: 'etherpad',
  774. Content: SharedDocumentButton,
  775. group: 3
  776. };
  777. const virtualBackground = (_multiStreamModeEnabled || !_screenSharing) && {
  778. key: 'select-background',
  779. Content: VideoBackgroundButton,
  780. group: 3
  781. };
  782. const speakerStats = !_isSpeakerStatsDisabled && {
  783. key: 'stats',
  784. Content: SpeakerStatsButton,
  785. group: 3
  786. };
  787. const settings = {
  788. key: 'settings',
  789. Content: SettingsButton,
  790. group: 4
  791. };
  792. const shortcuts = !_isMobile && _shortcutsEnabled && {
  793. key: 'shortcuts',
  794. Content: KeyboardShortcutsButton,
  795. group: 4
  796. };
  797. const embed = this._isEmbedMeetingVisible() && {
  798. key: 'embedmeeting',
  799. Content: EmbedMeetingButton,
  800. group: 4
  801. };
  802. const feedback = _feedbackConfigured && {
  803. key: 'feedback',
  804. Content: FeedbackButton,
  805. group: 4
  806. };
  807. const download = {
  808. key: 'download',
  809. Content: DownloadButton,
  810. group: 4
  811. };
  812. const help = {
  813. key: 'help',
  814. Content: HelpButton,
  815. group: 4
  816. };
  817. const customButtons = _customToolbarButtons?.reduce((prev, { icon, id, text }) => {
  818. return {
  819. ...prev,
  820. [id]: {
  821. key: id,
  822. Content: CustomOptionButton,
  823. group: 4,
  824. icon,
  825. text
  826. }
  827. };
  828. }, {});
  829. return {
  830. microphone,
  831. camera,
  832. profile,
  833. desktop,
  834. chat,
  835. raisehand,
  836. reactions,
  837. participants,
  838. invite,
  839. tileview,
  840. toggleCamera,
  841. videoQuality,
  842. fullscreen,
  843. security,
  844. cc,
  845. recording,
  846. livestreaming,
  847. linkToSalesforce,
  848. shareVideo,
  849. shareAudio,
  850. noiseSuppression,
  851. whiteboard,
  852. etherpad,
  853. virtualBackground,
  854. speakerStats,
  855. settings,
  856. shortcuts,
  857. embed,
  858. feedback,
  859. download,
  860. help,
  861. ...customButtons
  862. };
  863. }
  864. /**
  865. * Returns the notify mode of the given toolbox button.
  866. *
  867. * @param {string} btnName - The toolbar button's name.
  868. * @returns {string|undefined} - The button's notify mode.
  869. */
  870. _getButtonNotifyMode(btnName: string) {
  871. const notify = this.props._buttonsWithNotifyClick?.find(
  872. btn =>
  873. (typeof btn === 'string' && btn === btnName)
  874. || (typeof btn === 'object' && btn.key === btnName)
  875. );
  876. if (notify) {
  877. return typeof notify === 'string' || notify.preventExecution
  878. ? NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
  879. : NOTIFY_CLICK_MODE.ONLY_NOTIFY;
  880. }
  881. }
  882. /**
  883. * Sets the notify click mode for the buttons.
  884. *
  885. * @param {Object} buttons - The list of toolbar buttons.
  886. * @returns {void}
  887. */
  888. _setButtonsNotifyClickMode(buttons: Object) {
  889. if (typeof APP === 'undefined' || !this.props._buttonsWithNotifyClick?.length) {
  890. return;
  891. }
  892. Object.values(buttons).forEach((button: any) => {
  893. if (typeof button === 'object') {
  894. button.notifyMode = this._getButtonNotifyMode(button.key);
  895. }
  896. });
  897. }
  898. /**
  899. * Returns all buttons that need to be rendered.
  900. *
  901. * @param {Object} state - The redux state.
  902. * @returns {Object} The visible buttons arrays .
  903. */
  904. _getVisibleButtons() {
  905. const {
  906. _clientWidth,
  907. _toolbarButtons,
  908. _jwtDisabledButons
  909. } = this.props;
  910. const buttons = this._getAllButtons();
  911. this._setButtonsNotifyClickMode(buttons);
  912. const isHangupVisible = isToolbarButtonEnabled('hangup', _toolbarButtons);
  913. let { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  914. || THRESHOLDS[THRESHOLDS.length - 1];
  915. const keys = Object.keys(buttons);
  916. const filtered = [
  917. ...order.map(key => buttons[key as keyof typeof buttons]),
  918. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  919. ].filter(Boolean).filter(({ key, alias = NOT_APPLICABLE }) =>
  920. !_jwtDisabledButons.includes(key)
  921. && (isToolbarButtonEnabled(key, _toolbarButtons) || isToolbarButtonEnabled(alias, _toolbarButtons))
  922. );
  923. const filteredKeys = filtered.map(button => button.key);
  924. order = order.filter(key => filteredKeys.includes(buttons[key as keyof typeof buttons].key));
  925. let sliceIndex = order.length + 2;
  926. if (isHangupVisible) {
  927. sliceIndex -= 1;
  928. }
  929. // This implies that the overflow button will be displayed, so save some space for it.
  930. if (sliceIndex < filtered.length) {
  931. sliceIndex -= 1;
  932. }
  933. return {
  934. mainMenuButtons: filtered.slice(0, sliceIndex),
  935. overflowMenuButtons: filtered.slice(sliceIndex)
  936. };
  937. }
  938. /**
  939. * Dispatches an action signaling the toolbar is not being hovered.
  940. *
  941. * @private
  942. * @returns {void}
  943. */
  944. _onMouseOut() {
  945. const { _overflowMenuVisible, dispatch } = this.props;
  946. !_overflowMenuVisible && dispatch(setToolbarHovered(false));
  947. }
  948. /**
  949. * Dispatches an action signaling the toolbar is being hovered.
  950. *
  951. * @private
  952. * @returns {void}
  953. */
  954. _onMouseOver() {
  955. this.props.dispatch(setToolbarHovered(true));
  956. }
  957. /**
  958. * Sets the visibility of the hangup menu.
  959. *
  960. * @param {boolean} visible - Whether or not the hangup menu should be
  961. * displayed.
  962. * @private
  963. * @returns {void}
  964. */
  965. _onSetHangupVisible(visible: boolean) {
  966. this.props.dispatch(setHangupMenuVisible(visible));
  967. this.props.dispatch(setToolbarHovered(visible));
  968. }
  969. /**
  970. * Sets the visibility of the overflow menu.
  971. *
  972. * @param {boolean} visible - Whether or not the overflow menu should be
  973. * displayed.
  974. * @private
  975. * @returns {void}
  976. */
  977. _onSetOverflowVisible(visible: boolean) {
  978. this.props.dispatch(setOverflowMenuVisible(visible));
  979. this.props.dispatch(setToolbarHovered(visible));
  980. }
  981. /**
  982. * Creates an analytics keyboard shortcut event and dispatches an action for
  983. * toggling the display of chat.
  984. *
  985. * @private
  986. * @returns {void}
  987. */
  988. _onShortcutToggleChat() {
  989. sendAnalytics(createShortcutEvent(
  990. 'toggle.chat',
  991. ACTION_SHORTCUT_TRIGGERED,
  992. {
  993. enable: !this.props._chatOpen
  994. }));
  995. // Checks if there was any text selected by the user.
  996. // Used for when we press simultaneously keys for copying
  997. // text messages from the chat board
  998. if (window.getSelection()?.toString() !== '') {
  999. return false;
  1000. }
  1001. this._doToggleChat();
  1002. }
  1003. /**
  1004. * Creates an analytics keyboard shortcut event and dispatches an action for
  1005. * toggling the display of the participants pane.
  1006. *
  1007. * @private
  1008. * @returns {void}
  1009. */
  1010. _onShortcutToggleParticipantsPane() {
  1011. sendAnalytics(createShortcutEvent(
  1012. 'toggle.participants-pane',
  1013. ACTION_SHORTCUT_TRIGGERED,
  1014. {
  1015. enable: !this.props._participantsPaneOpen
  1016. }));
  1017. this._onToolbarToggleParticipantsPane();
  1018. }
  1019. /**
  1020. * Creates an analytics keyboard shortcut event and dispatches an action for
  1021. * toggling the display of Video Quality.
  1022. *
  1023. * @private
  1024. * @returns {void}
  1025. */
  1026. _onShortcutToggleVideoQuality() {
  1027. sendAnalytics(createShortcutEvent('video.quality'));
  1028. this._doToggleVideoQuality();
  1029. }
  1030. /**
  1031. * Dispatches an action for toggling the tile view.
  1032. *
  1033. * @private
  1034. * @returns {void}
  1035. */
  1036. _onShortcutToggleTileView() {
  1037. sendAnalytics(createShortcutEvent(
  1038. 'toggle.tileview',
  1039. ACTION_SHORTCUT_TRIGGERED,
  1040. {
  1041. enable: !this.props._tileViewEnabled
  1042. }));
  1043. this._doToggleTileView();
  1044. }
  1045. /**
  1046. * Creates an analytics keyboard shortcut event and dispatches an action for
  1047. * toggling full screen mode.
  1048. *
  1049. * @private
  1050. * @returns {void}
  1051. */
  1052. _onShortcutToggleFullScreen() {
  1053. sendAnalytics(createShortcutEvent(
  1054. 'toggle.fullscreen',
  1055. ACTION_SHORTCUT_TRIGGERED,
  1056. {
  1057. enable: !this.props._fullScreen
  1058. }));
  1059. this._doToggleFullScreen();
  1060. }
  1061. /**
  1062. * Creates an analytics keyboard shortcut event and dispatches an action for
  1063. * toggling raise hand.
  1064. *
  1065. * @private
  1066. * @returns {void}
  1067. */
  1068. _onShortcutToggleRaiseHand() {
  1069. sendAnalytics(createShortcutEvent(
  1070. 'toggle.raise.hand',
  1071. ACTION_SHORTCUT_TRIGGERED,
  1072. { enable: !this.props._raisedHand }));
  1073. this._doToggleRaiseHand();
  1074. }
  1075. /**
  1076. * Creates an analytics keyboard shortcut event and dispatches an action for
  1077. * toggling screensharing.
  1078. *
  1079. * @private
  1080. * @returns {void}
  1081. */
  1082. _onShortcutToggleScreenshare() {
  1083. // Ignore the shortcut if the button is disabled.
  1084. if (this.props._desktopSharingButtonDisabled) {
  1085. return;
  1086. }
  1087. sendAnalytics(createShortcutEvent(
  1088. 'toggle.screen.sharing',
  1089. ACTION_SHORTCUT_TRIGGERED,
  1090. {
  1091. enable: !this.props._screenSharing
  1092. }));
  1093. this._doToggleScreenshare();
  1094. }
  1095. /**
  1096. * Creates an analytics keyboard shortcut event and dispatches an action for
  1097. * toggling speaker stats.
  1098. *
  1099. * @private
  1100. * @returns {void}
  1101. */
  1102. _onShortcutSpeakerStats() {
  1103. sendAnalytics(createShortcutEvent(
  1104. 'speaker.stats'
  1105. ));
  1106. this._doToggleSpekearStats();
  1107. }
  1108. /**
  1109. * Dispatches an action to toggle speakerStats.
  1110. *
  1111. * @private
  1112. * @returns {void}
  1113. */
  1114. _doToggleSpekearStats() {
  1115. const { dispatch } = this.props;
  1116. dispatch(toggleDialog(SpeakerStats, {
  1117. conference: APP.conference
  1118. }));
  1119. }
  1120. /**
  1121. * Toggle the toolbar visibility when tabbing into it.
  1122. *
  1123. * @returns {void}
  1124. */
  1125. _onTabIn() {
  1126. if (!this.props._visible) {
  1127. this.props.dispatch(showToolbox());
  1128. }
  1129. }
  1130. /**
  1131. * Dispatches an action for toggling the participants pane.
  1132. *
  1133. * @private
  1134. * @returns {void}
  1135. */
  1136. _onToolbarToggleParticipantsPane() {
  1137. const { dispatch, _participantsPaneOpen } = this.props;
  1138. if (_participantsPaneOpen) {
  1139. dispatch(closeParticipantsPane());
  1140. } else {
  1141. dispatch(openParticipantsPane());
  1142. }
  1143. }
  1144. /**
  1145. * Creates an analytics toolbar event and dispatches an action for toggling
  1146. * open the video quality dialog.
  1147. *
  1148. * @private
  1149. * @returns {void}
  1150. */
  1151. _onToolbarOpenVideoQuality() {
  1152. sendAnalytics(createToolbarEvent('video.quality'));
  1153. this._doOpenVideoQuality();
  1154. }
  1155. /**
  1156. * Creates an analytics toolbar event and dispatches an action for toggling
  1157. * the display of chat.
  1158. *
  1159. * @private
  1160. * @returns {void}
  1161. */
  1162. _onToolbarToggleChat() {
  1163. sendAnalytics(createToolbarEvent(
  1164. 'toggle.chat',
  1165. {
  1166. enable: !this.props._chatOpen
  1167. }));
  1168. this._closeOverflowMenuIfOpen();
  1169. this._doToggleChat();
  1170. }
  1171. /**
  1172. * Creates an analytics toolbar event and dispatches an action for toggling
  1173. * full screen mode.
  1174. *
  1175. * @private
  1176. * @returns {void}
  1177. */
  1178. _onToolbarToggleFullScreen() {
  1179. sendAnalytics(createToolbarEvent(
  1180. 'toggle.fullscreen',
  1181. {
  1182. enable: !this.props._fullScreen
  1183. }));
  1184. this._closeOverflowMenuIfOpen();
  1185. this._doToggleFullScreen();
  1186. }
  1187. /**
  1188. * Creates an analytics toolbar event and dispatches an action for toggling
  1189. * raise hand.
  1190. *
  1191. * @private
  1192. * @returns {void}
  1193. */
  1194. _onToolbarToggleRaiseHand() {
  1195. sendAnalytics(createToolbarEvent(
  1196. 'raise.hand',
  1197. { enable: !this.props._raisedHand }));
  1198. this._doToggleRaiseHand();
  1199. }
  1200. /**
  1201. * Creates an analytics toolbar event and dispatches an action for toggling
  1202. * screensharing.
  1203. *
  1204. * @private
  1205. * @returns {void}
  1206. */
  1207. _onToolbarToggleScreenshare() {
  1208. sendAnalytics(createToolbarEvent(
  1209. 'toggle.screen.sharing',
  1210. { enable: !this.props._screenSharing }));
  1211. this._closeOverflowMenuIfOpen();
  1212. this._doToggleScreenshare();
  1213. }
  1214. /**
  1215. * Returns true if the audio sharing button should be visible and
  1216. * false otherwise.
  1217. *
  1218. * @returns {boolean}
  1219. */
  1220. _showAudioSharingButton() {
  1221. const {
  1222. _desktopSharingEnabled
  1223. } = this.props;
  1224. return _desktopSharingEnabled && isScreenAudioSupported();
  1225. }
  1226. /**
  1227. * Returns true if the desktop sharing button should be visible and
  1228. * false otherwise.
  1229. *
  1230. * @returns {boolean}
  1231. */
  1232. _showDesktopSharingButton() {
  1233. return this.props._desktopSharingEnabled;
  1234. }
  1235. /**
  1236. * Returns true if the embed meeting button is visible and false otherwise.
  1237. *
  1238. * @returns {boolean}
  1239. */
  1240. _isEmbedMeetingVisible() {
  1241. return !this.props._isVpaasMeeting
  1242. && !this.props._isMobile;
  1243. }
  1244. /**
  1245. * Returns true if the profile button is visible and false otherwise.
  1246. *
  1247. * @returns {boolean}
  1248. */
  1249. _isProfileVisible() {
  1250. return !this.props._isProfileDisabled;
  1251. }
  1252. /**
  1253. * Renders the toolbox content.
  1254. *
  1255. * @returns {ReactElement}
  1256. */
  1257. _renderToolboxContent() {
  1258. const {
  1259. _endConferenceSupported,
  1260. _hangupMenuVisible,
  1261. _isMobile,
  1262. _isNarrowLayout,
  1263. _overflowDrawer,
  1264. _overflowMenuVisible,
  1265. _reactionsEnabled,
  1266. _reactionsButtonEnabled,
  1267. _toolbarButtons,
  1268. classes,
  1269. t
  1270. } = this.props;
  1271. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  1272. const containerClassName = `toolbox-content${_isMobile || _isNarrowLayout ? ' toolbox-content-mobile' : ''}`;
  1273. const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
  1274. const raiseHandInOverflowMenu = overflowMenuButtons.some(({ key }) => key === 'raisehand');
  1275. const showReactionsInOverflowMenu
  1276. = (_reactionsEnabled && !_reactionsButtonEnabled
  1277. && (raiseHandInOverflowMenu || _isNarrowLayout || _isMobile))
  1278. || overflowMenuButtons.some(({ key }) => key === 'reactions');
  1279. const showRaiseHandInReactionsMenu = showReactionsInOverflowMenu && raiseHandInOverflowMenu;
  1280. return (
  1281. <div className = { containerClassName }>
  1282. <div
  1283. className = 'toolbox-content-wrapper'
  1284. onFocus = { this._onTabIn }
  1285. { ...(_isMobile ? {} : {
  1286. onMouseOut: this._onMouseOut,
  1287. onMouseOver: this._onMouseOver
  1288. }) }>
  1289. <div
  1290. className = 'toolbox-content-items'
  1291. ref = { this._toolboxRef }>
  1292. {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
  1293. <Content
  1294. { ...rest }
  1295. buttonKey = { key }
  1296. key = { key } />))}
  1297. {Boolean(overflowMenuButtons.length) && (
  1298. <OverflowMenuButton
  1299. ariaControls = 'overflow-menu'
  1300. buttons = { overflowMenuButtons.reduce((acc, val) => {
  1301. if (val.key === 'reactions' && showReactionsInOverflowMenu) {
  1302. return acc;
  1303. }
  1304. if (val.key === 'raisehand' && showRaiseHandInReactionsMenu) {
  1305. return acc;
  1306. }
  1307. if (acc.length) {
  1308. const prev = acc[acc.length - 1];
  1309. const group = prev[prev.length - 1].group;
  1310. if (group === val.group) {
  1311. prev.push(val);
  1312. } else {
  1313. acc.push([ val ]);
  1314. }
  1315. } else {
  1316. acc.push([ val ]);
  1317. }
  1318. return acc;
  1319. }, []) }
  1320. isOpen = { _overflowMenuVisible }
  1321. key = 'overflow-menu'
  1322. onToolboxEscKey = { this._onEscKey }
  1323. onVisibilityChange = { this._onSetOverflowVisible }
  1324. showRaiseHandInReactionsMenu = { showRaiseHandInReactionsMenu }
  1325. showReactionsMenu = { showReactionsInOverflowMenu } />
  1326. )}
  1327. { isToolbarButtonEnabled('hangup', _toolbarButtons) && (
  1328. _endConferenceSupported
  1329. ? <HangupMenuButton
  1330. ariaControls = 'hangup-menu'
  1331. isOpen = { _hangupMenuVisible }
  1332. key = 'hangup-menu'
  1333. notifyMode = { this._getButtonNotifyMode('hangup-menu') }
  1334. onVisibilityChange = { this._onSetHangupVisible }>
  1335. <ContextMenu
  1336. accessibilityLabel = { t(toolbarAccLabel) }
  1337. className = { classes.hangupMenu }
  1338. hidden = { false }
  1339. inDrawer = { _overflowDrawer }
  1340. onKeyDown = { this._onEscKey }>
  1341. <EndConferenceButton
  1342. buttonKey = 'end-meeting'
  1343. notifyMode = { this._getButtonNotifyMode('end-meeting') } />
  1344. <LeaveConferenceButton
  1345. buttonKey = 'hangup'
  1346. notifyMode = { this._getButtonNotifyMode('hangup') } />
  1347. </ContextMenu>
  1348. </HangupMenuButton>
  1349. : <HangupButton
  1350. buttonKey = 'hangup'
  1351. customClass = 'hangup-button'
  1352. key = 'hangup-button'
  1353. notifyMode = { this._getButtonNotifyMode('hangup') }
  1354. visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
  1355. )}
  1356. </div>
  1357. </div>
  1358. </div>
  1359. );
  1360. }
  1361. }
  1362. /**
  1363. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1364. * props.
  1365. *
  1366. * @param {Object} state - The redux store/state.
  1367. * @param {Object} ownProps - The props explicitly passed.
  1368. * @private
  1369. * @returns {{}}
  1370. */
  1371. function _mapStateToProps(state: IReduxState, ownProps: any) {
  1372. const { conference } = state['features/base/conference'];
  1373. const { isNarrowLayout } = state['features/base/responsive-ui'];
  1374. const endConferenceSupported = conference?.isEndConferenceSupported() && isLocalParticipantModerator(state);
  1375. const {
  1376. callStatsID,
  1377. customToolbarButtons,
  1378. disableProfile,
  1379. iAmRecorder,
  1380. iAmSipGateway
  1381. } = state['features/base/config'];
  1382. const {
  1383. fullScreen,
  1384. hangupMenuVisible,
  1385. overflowMenuVisible,
  1386. overflowDrawer
  1387. } = state['features/toolbox'];
  1388. const localParticipant = getLocalParticipant(state);
  1389. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1390. const { clientWidth } = state['features/base/responsive-ui'];
  1391. let toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
  1392. const _reactionsEnabled = isReactionsEnabled(state);
  1393. if (iAmVisitor(state)) {
  1394. toolbarButtons = VISITORS_MODE_BUTTONS.filter(e => toolbarButtons.indexOf(e) > -1);
  1395. }
  1396. return {
  1397. _backgroundType: state['features/virtual-background'].backgroundType ?? '',
  1398. _buttonsWithNotifyClick: getButtonsWithNotifyClick(state),
  1399. _chatOpen: state['features/chat'].isOpen,
  1400. _clientWidth: clientWidth,
  1401. _conference: conference,
  1402. _customToolbarButtons: customToolbarButtons,
  1403. _desktopSharingEnabled: JitsiMeetJS.isDesktopSharingEnabled(),
  1404. _desktopSharingButtonDisabled: isDesktopShareButtonDisabled(state),
  1405. _dialog: Boolean(state['features/base/dialog'].component),
  1406. _disabled: Boolean(iAmRecorder || iAmSipGateway),
  1407. _endConferenceSupported: Boolean(endConferenceSupported),
  1408. _feedbackConfigured: Boolean(callStatsID),
  1409. _fullScreen: fullScreen,
  1410. _gifsEnabled: isGifEnabled(state),
  1411. _isProfileDisabled: Boolean(disableProfile),
  1412. _isIosMobile: isIosMobileBrowser(),
  1413. _isMobile: isMobileBrowser(),
  1414. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  1415. _isVpaasMeeting: isVpaasMeeting(state),
  1416. _jwtDisabledButons: getJwtDisabledButtons(state),
  1417. _hasSalesforce: isSalesforceEnabled(state),
  1418. _hangupMenuVisible: hangupMenuVisible,
  1419. _isNarrowLayout: isNarrowLayout,
  1420. _localParticipantID: localParticipant?.id,
  1421. _localVideo: localVideo,
  1422. _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state),
  1423. _overflowMenuVisible: overflowMenuVisible,
  1424. _overflowDrawer: overflowDrawer,
  1425. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1426. _raisedHand: hasRaisedHand(localParticipant),
  1427. _reactionsButtonEnabled: isReactionsButtonEnabled(state),
  1428. _reactionsEnabled,
  1429. _screenSharing: isScreenVideoShared(state),
  1430. _shiftUp: state['features/toolbox'].shiftUp,
  1431. _shortcutsEnabled: areKeyboardShortcutsEnabled(state),
  1432. _tileViewEnabled: shouldDisplayTileView(state),
  1433. _toolbarButtons: toolbarButtons,
  1434. _virtualSource: state['features/virtual-background'].virtualSource,
  1435. _visible: isToolboxVisible(state),
  1436. _whiteboardEnabled: isWhiteboardButtonVisible(state)
  1437. };
  1438. }
  1439. export default translate(connect(_mapStateToProps)(withStyles(styles)(Toolbox)));