Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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