You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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