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.

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