Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Toolbox.tsx 46KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565
  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-ignore
  7. import keyboardShortcut from '../../../../../modules/keyboardshortcut/keyboardshortcut';
  8. import { ACTION_SHORTCUT_TRIGGERED, createShortcutEvent, createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  9. import { sendAnalytics } from '../../../analytics/functions';
  10. import { IState } from '../../../app/types';
  11. import ContextMenu from '../../../base/components/context-menu/ContextMenu';
  12. import ContextMenuItemGroup from '../../../base/components/context-menu/ContextMenuItemGroup';
  13. // @ts-ignore
  14. import { getMultipleVideoSendingSupportFeatureFlag, getToolbarButtons } from '../../../base/config';
  15. // @ts-ignore
  16. import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
  17. // @ts-ignore
  18. import { openDialog, toggleDialog } from '../../../base/dialog';
  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. // @ts-ignore
  31. import { getLocalVideoTrack } from '../../../base/tracks';
  32. // @ts-ignore
  33. import { toggleChat } from '../../../chat';
  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. // @ts-ignore
  43. import { setGifMenuVisibility } from '../../../gifs/actions';
  44. // @ts-ignore
  45. import { isGifEnabled } from '../../../gifs/functions';
  46. // @ts-ignore
  47. import { InviteButton } from '../../../invite/components/add-people-dialog';
  48. // @ts-ignore
  49. import { isVpaasMeeting } from '../../../jaas/functions';
  50. // @ts-ignore
  51. import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
  52. import { NoiseSuppressionButton } from '../../../noise-suppression/components';
  53. import {
  54. close as closeParticipantsPane,
  55. open as openParticipantsPane
  56. // @ts-ignore
  57. } from '../../../participants-pane/actions';
  58. // @ts-ignore
  59. import { ParticipantsPaneButton } from '../../../participants-pane/components/web';
  60. // @ts-ignore
  61. import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
  62. import { addReactionToBuffer } from '../../../reactions/actions.any';
  63. import { toggleReactionsMenuVisibility } from '../../../reactions/actions.web';
  64. import ReactionsMenuButton from '../../../reactions/components/web/ReactionsMenuButton';
  65. import { REACTIONS } from '../../../reactions/constants';
  66. import { isReactionsEnabled } from '../../../reactions/functions.any';
  67. import {
  68. LiveStreamButton,
  69. RecordButton
  70. // @ts-ignore
  71. } from '../../../recording';
  72. // @ts-ignore
  73. import { isSalesforceEnabled } from '../../../salesforce/functions';
  74. import {
  75. ShareAudioButton,
  76. isScreenAudioSupported,
  77. isScreenVideoShared,
  78. startScreenShareFlow
  79. // @ts-ignore
  80. } from '../../../screen-share';
  81. // @ts-ignore
  82. import SecurityDialogButton from '../../../security/components/security-dialog/web/SecurityDialogButton';
  83. // @ts-ignore
  84. import { SettingsButton } from '../../../settings';
  85. // @ts-ignore
  86. import { SharedVideoButton } from '../../../shared-video/components';
  87. // @ts-ignore
  88. import { SpeakerStatsButton } from '../../../speaker-stats/components/web';
  89. import {
  90. ClosedCaptionButton
  91. // @ts-ignore
  92. } from '../../../subtitles';
  93. import {
  94. TileViewButton,
  95. shouldDisplayTileView,
  96. toggleTileView
  97. // @ts-ignore
  98. } from '../../../video-layout';
  99. // @ts-ignore
  100. import { VideoQualityButton, VideoQualityDialog } from '../../../video-quality/components';
  101. // @ts-ignore
  102. import { VideoBackgroundButton, toggleBackgroundEffect } from '../../../virtual-background';
  103. import { VIRTUAL_BACKGROUND_TYPE } from '../../../virtual-background/constants';
  104. import WhiteboardButton from '../../../whiteboard/components/web/WhiteboardButton';
  105. import { isWhiteboardEnabled } from '../../../whiteboard/functions';
  106. import {
  107. setFullScreen,
  108. setHangupMenuVisible,
  109. setOverflowMenuVisible,
  110. setToolbarHovered,
  111. showToolbox
  112. // @ts-ignore
  113. } from '../../actions';
  114. import { NOTIFY_CLICK_MODE, NOT_APPLICABLE, THRESHOLDS } from '../../constants';
  115. // @ts-ignore
  116. import { isDesktopShareButtonDisabled, isToolboxVisible } from '../../functions';
  117. import { getJwtDisabledButtons } from '../../functions.any';
  118. // @ts-ignore
  119. import DownloadButton from '../DownloadButton';
  120. // @ts-ignore
  121. import HangupButton from '../HangupButton';
  122. // @ts-ignore
  123. import HelpButton from '../HelpButton';
  124. // @ts-ignore
  125. import AudioSettingsButton from './AudioSettingsButton';
  126. // @ts-ignore
  127. import DockIframeButton from './DockIframeButton';
  128. import { EndConferenceButton } from './EndConferenceButton';
  129. // @ts-ignore
  130. import FullscreenButton from './FullscreenButton';
  131. import HangupMenuButton from './HangupMenuButton';
  132. import { LeaveConferenceButton } from './LeaveConferenceButton';
  133. // @ts-ignore
  134. import LinkToSalesforceButton from './LinkToSalesforceButton';
  135. // @ts-ignore
  136. import OverflowMenuButton from './OverflowMenuButton';
  137. // @ts-ignore
  138. import ProfileButton from './ProfileButton';
  139. // @ts-ignore
  140. import Separator from './Separator';
  141. // @ts-ignore
  142. import ShareDesktopButton from './ShareDesktopButton';
  143. // @ts-ignore
  144. import ToggleCameraButton from './ToggleCameraButton';
  145. // @ts-ignore
  146. import UndockIframeButton from './UndockIframeButton';
  147. // @ts-ignore
  148. import VideoSettingsButton from './VideoSettingsButton';
  149. /**
  150. * The type of the React {@code Component} props of {@link Toolbox}.
  151. */
  152. interface Props extends WithTranslation {
  153. /**
  154. * String showing if the virtual background type is desktop-share.
  155. */
  156. _backgroundType: String;
  157. /**
  158. * Toolbar buttons which have their click exposed through the API.
  159. */
  160. _buttonsWithNotifyClick: Array<string | {
  161. key: string;
  162. preventExecution: boolean;
  163. }>;
  164. /**
  165. * Whether or not the chat feature is currently displayed.
  166. */
  167. _chatOpen: boolean;
  168. /**
  169. * The width of the client.
  170. */
  171. _clientWidth: number;
  172. /**
  173. * The {@code JitsiConference} for the current conference.
  174. */
  175. _conference: Object;
  176. /**
  177. * Whether or not screensharing button is disabled.
  178. */
  179. _desktopSharingButtonDisabled: boolean;
  180. /**
  181. * Whether or not screensharing is initialized.
  182. */
  183. _desktopSharingEnabled: boolean;
  184. /**
  185. * Whether or not a dialog is displayed.
  186. */
  187. _dialog: boolean;
  188. /**
  189. * Whether or not the toolbox is disabled. It is for recorders.
  190. */
  191. _disabled: boolean;
  192. /**
  193. * Whether the end conference feature is supported.
  194. */
  195. _endConferenceSupported: boolean;
  196. /**
  197. * Whether or not call feedback can be sent.
  198. */
  199. _feedbackConfigured: boolean;
  200. /**
  201. * Whether or not the app is currently in full screen.
  202. */
  203. _fullScreen: boolean;
  204. /**
  205. * Whether or not the GIFs feature is enabled.
  206. */
  207. _gifsEnabled: boolean;
  208. /**
  209. * Whether the hangup menu is visible.
  210. */
  211. _hangupMenuVisible: boolean;
  212. /**
  213. * Whether the app has Salesforce integration.
  214. */
  215. _hasSalesforce: boolean;
  216. /**
  217. * Whether or not the app is running in an ios mobile browser.
  218. */
  219. _isIosMobile: boolean;
  220. /**
  221. * Whether or not the app is running in mobile browser.
  222. */
  223. _isMobile: boolean;
  224. /**
  225. * Whether or not the profile is disabled.
  226. */
  227. _isProfileDisabled: boolean;
  228. /**
  229. * Whether or not the current meeting belongs to a JaaS user.
  230. */
  231. _isVpaasMeeting: boolean;
  232. /**
  233. * The array of toolbar buttons disabled through jwt features.
  234. */
  235. _jwtDisabledButons: string[];
  236. /**
  237. * The ID of the local participant.
  238. */
  239. _localParticipantID: String;
  240. /**
  241. * The JitsiLocalTrack to display.
  242. */
  243. _localVideo: Object;
  244. /**
  245. * Whether or not multi-stream send support is enabled.
  246. */
  247. _multiStreamModeEnabled: boolean;
  248. /**
  249. * Whether or not the overflow menu is displayed in a drawer drawer.
  250. */
  251. _overflowDrawer: boolean;
  252. /**
  253. * Whether or not the overflow menu is visible.
  254. */
  255. _overflowMenuVisible: boolean;
  256. /**
  257. * Whether or not the participants pane is open.
  258. */
  259. _participantsPaneOpen: boolean;
  260. /**
  261. * Whether or not the local participant's hand is raised.
  262. */
  263. _raisedHand: boolean;
  264. /**
  265. * Whether or not reactions feature is enabled.
  266. */
  267. _reactionsEnabled: boolean;
  268. /**
  269. * Whether or not the local participant is screenSharing.
  270. */
  271. _screenSharing: boolean;
  272. /**
  273. * Whether or not the local participant is sharing a YouTube video.
  274. */
  275. _sharingVideo: boolean;
  276. /**
  277. * Whether or not the tile view is enabled.
  278. */
  279. _tileViewEnabled: boolean;
  280. /**
  281. * The enabled buttons.
  282. */
  283. _toolbarButtons: Array<string>;
  284. /**
  285. * Returns the selected virtual source object.
  286. */
  287. _virtualSource: any;
  288. /**
  289. * Flag showing whether toolbar is visible.
  290. */
  291. _visible: boolean;
  292. /**
  293. * Whether the whiteboard is visible.
  294. */
  295. _whiteboardEnabled: boolean;
  296. /**
  297. * An object containing the CSS classes.
  298. */
  299. classes: any;
  300. /**
  301. * Invoked to active other features of the app.
  302. */
  303. dispatch: Function;
  304. /**
  305. * Explicitly passed array with the buttons which this Toolbox should display.
  306. */
  307. toolbarButtons: Array<string>;
  308. }
  309. declare let APP: any;
  310. const styles = () => {
  311. return {
  312. contextMenu: {
  313. position: 'relative' as const,
  314. right: 'auto',
  315. maxHeight: 'inherit',
  316. margin: 0
  317. },
  318. hangupMenu: {
  319. position: 'relative' as const,
  320. right: 'auto',
  321. display: 'flex',
  322. flexDirection: 'column' as const,
  323. rowGap: '8px',
  324. margin: 0,
  325. padding: '16px'
  326. }
  327. };
  328. };
  329. /**
  330. * Implements the conference toolbox on React/Web.
  331. *
  332. * @augments Component
  333. */
  334. class Toolbox extends Component<Props> {
  335. /**
  336. * Initializes a new {@code Toolbox} instance.
  337. *
  338. * @param {Props} props - The read-only React {@code Component} props with
  339. * which the new instance is to be initialized.
  340. */
  341. constructor(props: Props) {
  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._onEscKey = this._onEscKey.bind(this);
  363. }
  364. /**
  365. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  366. *
  367. * @inheritdoc
  368. * @returns {void}
  369. */
  370. componentDidMount() {
  371. const { _toolbarButtons, t, dispatch, _reactionsEnabled, _gifsEnabled } = this.props;
  372. const KEYBOARD_SHORTCUTS = [
  373. isToolbarButtonEnabled('videoquality', _toolbarButtons) && {
  374. character: 'A',
  375. exec: this._onShortcutToggleVideoQuality,
  376. helpDescription: 'toolbar.callQuality'
  377. },
  378. isToolbarButtonEnabled('chat', _toolbarButtons) && {
  379. character: 'C',
  380. exec: this._onShortcutToggleChat,
  381. helpDescription: 'keyboardShortcuts.toggleChat'
  382. },
  383. isToolbarButtonEnabled('desktop', _toolbarButtons) && {
  384. character: 'D',
  385. exec: this._onShortcutToggleScreenshare,
  386. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  387. },
  388. isToolbarButtonEnabled('participants-pane', _toolbarButtons) && {
  389. character: 'P',
  390. exec: this._onShortcutToggleParticipantsPane,
  391. helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
  392. },
  393. isToolbarButtonEnabled('raisehand', _toolbarButtons) && {
  394. character: 'R',
  395. exec: this._onShortcutToggleRaiseHand,
  396. helpDescription: 'keyboardShortcuts.raiseHand'
  397. },
  398. isToolbarButtonEnabled('fullscreen', _toolbarButtons) && {
  399. character: 'S',
  400. exec: this._onShortcutToggleFullScreen,
  401. helpDescription: 'keyboardShortcuts.fullScreen'
  402. },
  403. isToolbarButtonEnabled('tileview', _toolbarButtons) && {
  404. character: 'W',
  405. exec: this._onShortcutToggleTileView,
  406. helpDescription: 'toolbar.tileViewToggle'
  407. }
  408. ];
  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: Props) {
  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. _backgroundType,
  595. _desktopSharingButtonDisabled,
  596. _desktopSharingEnabled,
  597. _localVideo,
  598. _screenSharing,
  599. _virtualSource,
  600. dispatch
  601. } = this.props;
  602. if (_backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
  603. const noneOptions = {
  604. enabled: false,
  605. backgroundType: VIRTUAL_BACKGROUND_TYPE.NONE,
  606. selectedThumbnail: VIRTUAL_BACKGROUND_TYPE.NONE,
  607. backgroundEffectEnabled: false
  608. };
  609. _virtualSource.dispose();
  610. dispatch(toggleBackgroundEffect(noneOptions, _localVideo));
  611. return;
  612. }
  613. if (_desktopSharingEnabled && !_desktopSharingButtonDisabled) {
  614. dispatch(startScreenShareFlow(!_screenSharing));
  615. }
  616. }
  617. /**
  618. * Dispatches an action to toggle the video quality dialog.
  619. *
  620. * @private
  621. * @returns {void}
  622. */
  623. _doToggleVideoQuality() {
  624. this.props.dispatch(toggleDialog(VideoQualityDialog));
  625. }
  626. /**
  627. * Dispaches an action to toggle tile view.
  628. *
  629. * @private
  630. * @returns {void}
  631. */
  632. _doToggleTileView() {
  633. this.props.dispatch(toggleTileView());
  634. }
  635. /**
  636. * Returns all buttons that could be rendered.
  637. *
  638. * @param {Object} state - The redux state.
  639. * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
  640. */
  641. _getAllButtons() {
  642. const {
  643. _feedbackConfigured,
  644. _isIosMobile,
  645. _isMobile,
  646. _hasSalesforce,
  647. _multiStreamModeEnabled,
  648. _screenSharing,
  649. _whiteboardEnabled
  650. } = this.props;
  651. const microphone = {
  652. key: 'microphone',
  653. Content: AudioSettingsButton,
  654. group: 0
  655. };
  656. const camera = {
  657. key: 'camera',
  658. Content: VideoSettingsButton,
  659. group: 0
  660. };
  661. const profile = this._isProfileVisible() && {
  662. key: 'profile',
  663. Content: ProfileButton,
  664. group: 1
  665. };
  666. const chat = {
  667. key: 'chat',
  668. Content: ChatButton,
  669. handleClick: this._onToolbarToggleChat,
  670. group: 2
  671. };
  672. const desktop = this._showDesktopSharingButton() && {
  673. key: 'desktop',
  674. Content: ShareDesktopButton,
  675. handleClick: this._onToolbarToggleScreenshare,
  676. group: 2
  677. };
  678. const raisehand = {
  679. key: 'raisehand',
  680. Content: ReactionsMenuButton,
  681. handleClick: this._onToolbarToggleRaiseHand,
  682. group: 2
  683. };
  684. const participants = {
  685. key: 'participants-pane',
  686. Content: ParticipantsPaneButton,
  687. handleClick: this._onToolbarToggleParticipantsPane,
  688. group: 2
  689. };
  690. const invite = {
  691. key: 'invite',
  692. Content: InviteButton,
  693. group: 2
  694. };
  695. const tileview = {
  696. key: 'tileview',
  697. Content: TileViewButton,
  698. group: 2
  699. };
  700. const toggleCamera = {
  701. key: 'toggle-camera',
  702. Content: ToggleCameraButton,
  703. group: 2
  704. };
  705. const videoQuality = {
  706. key: 'videoquality',
  707. Content: VideoQualityButton,
  708. handleClick: this._onToolbarOpenVideoQuality,
  709. group: 2
  710. };
  711. const fullscreen = !_isIosMobile && {
  712. key: 'fullscreen',
  713. Content: FullscreenButton,
  714. handleClick: this._onToolbarToggleFullScreen,
  715. group: 2
  716. };
  717. const security = {
  718. key: 'security',
  719. alias: 'info',
  720. Content: SecurityDialogButton,
  721. group: 2
  722. };
  723. const cc = {
  724. key: 'closedcaptions',
  725. Content: ClosedCaptionButton,
  726. group: 2
  727. };
  728. const recording = {
  729. key: 'recording',
  730. Content: RecordButton,
  731. group: 2
  732. };
  733. const livestreaming = {
  734. key: 'livestreaming',
  735. Content: LiveStreamButton,
  736. group: 2
  737. };
  738. const linkToSalesforce = _hasSalesforce && {
  739. key: 'linktosalesforce',
  740. Content: LinkToSalesforceButton,
  741. group: 2
  742. };
  743. const shareVideo = {
  744. key: 'sharedvideo',
  745. Content: SharedVideoButton,
  746. group: 3
  747. };
  748. const shareAudio = this._showAudioSharingButton() && {
  749. key: 'shareaudio',
  750. Content: ShareAudioButton,
  751. group: 3
  752. };
  753. const noiseSuppression = {
  754. key: 'noisesuppression',
  755. Content: NoiseSuppressionButton,
  756. group: 3
  757. };
  758. const whiteboard = _whiteboardEnabled && {
  759. key: 'whiteboard',
  760. Content: WhiteboardButton,
  761. group: 3
  762. };
  763. const etherpad = {
  764. key: 'etherpad',
  765. Content: SharedDocumentButton,
  766. group: 3
  767. };
  768. const virtualBackground = (_multiStreamModeEnabled || !_screenSharing) && {
  769. key: 'select-background',
  770. Content: VideoBackgroundButton,
  771. group: 3
  772. };
  773. const dockIframe = {
  774. key: 'dock-iframe',
  775. Content: DockIframeButton,
  776. group: 3
  777. };
  778. const undockIframe = {
  779. key: 'undock-iframe',
  780. Content: UndockIframeButton,
  781. group: 3
  782. };
  783. const speakerStats = {
  784. key: 'stats',
  785. Content: SpeakerStatsButton,
  786. group: 3
  787. };
  788. const settings = {
  789. key: 'settings',
  790. Content: SettingsButton,
  791. group: 4
  792. };
  793. const shortcuts = !_isMobile && keyboardShortcut.getEnabled() && {
  794. key: 'shortcuts',
  795. Content: KeyboardShortcutsButton,
  796. group: 4
  797. };
  798. const embed = this._isEmbedMeetingVisible() && {
  799. key: 'embedmeeting',
  800. Content: EmbedMeetingButton,
  801. group: 4
  802. };
  803. const feedback = _feedbackConfigured && {
  804. key: 'feedback',
  805. Content: FeedbackButton,
  806. group: 4
  807. };
  808. const download = {
  809. key: 'download',
  810. Content: DownloadButton,
  811. group: 4
  812. };
  813. const help = {
  814. key: 'help',
  815. Content: HelpButton,
  816. group: 4
  817. };
  818. return {
  819. microphone,
  820. camera,
  821. profile,
  822. desktop,
  823. chat,
  824. raisehand,
  825. participants,
  826. invite,
  827. tileview,
  828. toggleCamera,
  829. videoQuality,
  830. fullscreen,
  831. security,
  832. cc,
  833. recording,
  834. livestreaming,
  835. linkToSalesforce,
  836. shareVideo,
  837. shareAudio,
  838. noiseSuppression,
  839. whiteboard,
  840. etherpad,
  841. virtualBackground,
  842. dockIframe,
  843. undockIframe,
  844. speakerStats,
  845. settings,
  846. shortcuts,
  847. embed,
  848. feedback,
  849. download,
  850. help
  851. };
  852. }
  853. /**
  854. * Returns the notify mode of the given toolbox button.
  855. *
  856. * @param {string} btnName - The toolbar button's name.
  857. * @returns {string|undefined} - The button's notify mode.
  858. */
  859. _getButtonNotifyMode(btnName: string) {
  860. const notify = this.props._buttonsWithNotifyClick?.find(
  861. btn =>
  862. (typeof btn === 'string' && btn === btnName)
  863. || (typeof btn === 'object' && btn.key === btnName)
  864. );
  865. if (notify) {
  866. return typeof notify === 'string' || notify.preventExecution
  867. ? NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
  868. : NOTIFY_CLICK_MODE.ONLY_NOTIFY;
  869. }
  870. }
  871. /**
  872. * Sets the notify click mode for the buttons.
  873. *
  874. * @param {Object} buttons - The list of toolbar buttons.
  875. * @returns {void}
  876. */
  877. _setButtonsNotifyClickMode(buttons: Object) {
  878. if (typeof APP === 'undefined' || !this.props._buttonsWithNotifyClick?.length) {
  879. return;
  880. }
  881. Object.values(buttons).forEach((button: any) => {
  882. if (typeof button === 'object') {
  883. button.notifyMode = this._getButtonNotifyMode(button.key);
  884. }
  885. });
  886. }
  887. /**
  888. * Returns all buttons that need to be rendered.
  889. *
  890. * @param {Object} state - The redux state.
  891. * @returns {Object} The visible buttons arrays .
  892. */
  893. _getVisibleButtons() {
  894. const {
  895. _clientWidth,
  896. _toolbarButtons,
  897. _jwtDisabledButons
  898. } = this.props;
  899. const buttons = this._getAllButtons();
  900. this._setButtonsNotifyClickMode(buttons);
  901. const isHangupVisible = isToolbarButtonEnabled('hangup', _toolbarButtons);
  902. const { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  903. || THRESHOLDS[THRESHOLDS.length - 1];
  904. let sliceIndex = order.length + 2;
  905. const keys = Object.keys(buttons);
  906. const filtered = [
  907. ...order.map(key => buttons[key as keyof typeof buttons]),
  908. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  909. ].filter(Boolean).filter(({ key, alias = NOT_APPLICABLE }) =>
  910. !_jwtDisabledButons.includes(key)
  911. && (isToolbarButtonEnabled(key, _toolbarButtons) || isToolbarButtonEnabled(alias, _toolbarButtons))
  912. );
  913. if (isHangupVisible) {
  914. sliceIndex -= 1;
  915. }
  916. // This implies that the overflow button will be displayed, so save some space for it.
  917. if (sliceIndex < filtered.length) {
  918. sliceIndex -= 1;
  919. }
  920. return {
  921. mainMenuButtons: filtered.slice(0, sliceIndex),
  922. overflowMenuButtons: filtered.slice(sliceIndex)
  923. };
  924. }
  925. /**
  926. * Dispatches an action signaling the toolbar is not being hovered.
  927. *
  928. * @private
  929. * @returns {void}
  930. */
  931. _onMouseOut() {
  932. const { _overflowMenuVisible, dispatch } = this.props;
  933. !_overflowMenuVisible && dispatch(setToolbarHovered(false));
  934. }
  935. /**
  936. * Dispatches an action signaling the toolbar is being hovered.
  937. *
  938. * @private
  939. * @returns {void}
  940. */
  941. _onMouseOver() {
  942. this.props.dispatch(setToolbarHovered(true));
  943. }
  944. /**
  945. * Sets the visibility of the hangup menu.
  946. *
  947. * @param {boolean} visible - Whether or not the hangup menu should be
  948. * displayed.
  949. * @private
  950. * @returns {void}
  951. */
  952. _onSetHangupVisible(visible: boolean) {
  953. this.props.dispatch(setHangupMenuVisible(visible));
  954. this.props.dispatch(setToolbarHovered(visible));
  955. }
  956. /**
  957. * Sets the visibility of the overflow menu.
  958. *
  959. * @param {boolean} visible - Whether or not the overflow menu should be
  960. * displayed.
  961. * @private
  962. * @returns {void}
  963. */
  964. _onSetOverflowVisible(visible: boolean) {
  965. this.props.dispatch(setOverflowMenuVisible(visible));
  966. this.props.dispatch(setToolbarHovered(visible));
  967. }
  968. /**
  969. * Creates an analytics keyboard shortcut event and dispatches an action for
  970. * toggling the display of chat.
  971. *
  972. * @private
  973. * @returns {void}
  974. */
  975. _onShortcutToggleChat() {
  976. sendAnalytics(createShortcutEvent(
  977. 'toggle.chat',
  978. ACTION_SHORTCUT_TRIGGERED,
  979. {
  980. enable: !this.props._chatOpen
  981. }));
  982. // Checks if there was any text selected by the user.
  983. // Used for when we press simultaneously keys for copying
  984. // text messages from the chat board
  985. if (window.getSelection()?.toString() !== '') {
  986. return false;
  987. }
  988. this._doToggleChat();
  989. }
  990. /**
  991. * Creates an analytics keyboard shortcut event and dispatches an action for
  992. * toggling the display of the participants pane.
  993. *
  994. * @private
  995. * @returns {void}
  996. */
  997. _onShortcutToggleParticipantsPane() {
  998. sendAnalytics(createShortcutEvent(
  999. 'toggle.participants-pane',
  1000. ACTION_SHORTCUT_TRIGGERED,
  1001. {
  1002. enable: !this.props._participantsPaneOpen
  1003. }));
  1004. this._onToolbarToggleParticipantsPane();
  1005. }
  1006. /**
  1007. * Creates an analytics keyboard shortcut event and dispatches an action for
  1008. * toggling the display of Video Quality.
  1009. *
  1010. * @private
  1011. * @returns {void}
  1012. */
  1013. _onShortcutToggleVideoQuality() {
  1014. sendAnalytics(createShortcutEvent('video.quality'));
  1015. this._doToggleVideoQuality();
  1016. }
  1017. /**
  1018. * Dispatches an action for toggling the tile view.
  1019. *
  1020. * @private
  1021. * @returns {void}
  1022. */
  1023. _onShortcutToggleTileView() {
  1024. sendAnalytics(createShortcutEvent(
  1025. 'toggle.tileview',
  1026. ACTION_SHORTCUT_TRIGGERED,
  1027. {
  1028. enable: !this.props._tileViewEnabled
  1029. }));
  1030. this._doToggleTileView();
  1031. }
  1032. /**
  1033. * Creates an analytics keyboard shortcut event and dispatches an action for
  1034. * toggling full screen mode.
  1035. *
  1036. * @private
  1037. * @returns {void}
  1038. */
  1039. _onShortcutToggleFullScreen() {
  1040. sendAnalytics(createShortcutEvent(
  1041. 'toggle.fullscreen',
  1042. ACTION_SHORTCUT_TRIGGERED,
  1043. {
  1044. enable: !this.props._fullScreen
  1045. }));
  1046. this._doToggleFullScreen();
  1047. }
  1048. /**
  1049. * Creates an analytics keyboard shortcut event and dispatches an action for
  1050. * toggling raise hand.
  1051. *
  1052. * @private
  1053. * @returns {void}
  1054. */
  1055. _onShortcutToggleRaiseHand() {
  1056. sendAnalytics(createShortcutEvent(
  1057. 'toggle.raise.hand',
  1058. ACTION_SHORTCUT_TRIGGERED,
  1059. { enable: !this.props._raisedHand }));
  1060. this._doToggleRaiseHand();
  1061. }
  1062. /**
  1063. * Creates an analytics keyboard shortcut event and dispatches an action for
  1064. * toggling screensharing.
  1065. *
  1066. * @private
  1067. * @returns {void}
  1068. */
  1069. _onShortcutToggleScreenshare() {
  1070. // Ignore the shortcut if the button is disabled.
  1071. if (this.props._desktopSharingButtonDisabled) {
  1072. return;
  1073. }
  1074. sendAnalytics(createShortcutEvent(
  1075. 'toggle.screen.sharing',
  1076. ACTION_SHORTCUT_TRIGGERED,
  1077. {
  1078. enable: !this.props._screenSharing
  1079. }));
  1080. this._doToggleScreenshare();
  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. onVisibilityChange = { this._onSetHangupVisible }>
  1298. <ContextMenu
  1299. accessibilityLabel = { t(toolbarAccLabel) }
  1300. className = { classes.hangupMenu }
  1301. hidden = { false }
  1302. inDrawer = { _overflowDrawer }
  1303. onKeyDown = { this._onEscKey }>
  1304. <EndConferenceButton />
  1305. <LeaveConferenceButton />
  1306. </ContextMenu>
  1307. </HangupMenuButton>
  1308. : <HangupButton
  1309. buttonKey = 'hangup'
  1310. customClass = 'hangup-button'
  1311. key = 'hangup-button'
  1312. notifyMode = { this._getButtonNotifyMode('hangup') }
  1313. visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
  1314. )}
  1315. </div>
  1316. </div>
  1317. </div>
  1318. );
  1319. }
  1320. }
  1321. /**
  1322. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1323. * props.
  1324. *
  1325. * @param {Object} state - The redux store/state.
  1326. * @param {Object} ownProps - The props explicitly passed.
  1327. * @private
  1328. * @returns {{}}
  1329. */
  1330. function _mapStateToProps(state: IState, ownProps: Partial<Props>) {
  1331. const { conference } = state['features/base/conference'];
  1332. const endConferenceSupported = conference?.isEndConferenceSupported();
  1333. const {
  1334. buttonsWithNotifyClick,
  1335. callStatsID,
  1336. disableProfile,
  1337. iAmRecorder,
  1338. iAmSipGateway
  1339. } = state['features/base/config'];
  1340. const {
  1341. fullScreen,
  1342. hangupMenuVisible,
  1343. overflowMenuVisible,
  1344. overflowDrawer
  1345. } = state['features/toolbox'];
  1346. const localParticipant = getLocalParticipant(state);
  1347. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1348. const { clientWidth } = state['features/base/responsive-ui'];
  1349. const toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
  1350. return {
  1351. _backgroundType: state['features/virtual-background'].backgroundType,
  1352. _buttonsWithNotifyClick: buttonsWithNotifyClick,
  1353. _chatOpen: state['features/chat'].isOpen,
  1354. _clientWidth: clientWidth,
  1355. _conference: conference,
  1356. _desktopSharingEnabled: JitsiMeetJS.isDesktopSharingEnabled(),
  1357. _desktopSharingButtonDisabled: isDesktopShareButtonDisabled(state),
  1358. _dialog: Boolean(state['features/base/dialog'].component),
  1359. _disabled: Boolean(iAmRecorder || iAmSipGateway),
  1360. _endConferenceSupported: Boolean(endConferenceSupported),
  1361. _feedbackConfigured: Boolean(callStatsID),
  1362. _fullScreen: fullScreen,
  1363. _gifsEnabled: isGifEnabled(state),
  1364. _isProfileDisabled: Boolean(disableProfile),
  1365. _isIosMobile: isIosMobileBrowser(),
  1366. _isMobile: isMobileBrowser(),
  1367. _isVpaasMeeting: isVpaasMeeting(state),
  1368. _jwtDisabledButons: getJwtDisabledButtons(state),
  1369. _hasSalesforce: isSalesforceEnabled(state),
  1370. _hangupMenuVisible: hangupMenuVisible,
  1371. _localParticipantID: localParticipant?.id,
  1372. _localVideo: localVideo,
  1373. _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state),
  1374. _overflowMenuVisible: overflowMenuVisible,
  1375. _overflowDrawer: overflowDrawer,
  1376. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1377. _raisedHand: hasRaisedHand(localParticipant),
  1378. _reactionsEnabled: isReactionsEnabled(state),
  1379. _screenSharing: isScreenVideoShared(state),
  1380. _tileViewEnabled: shouldDisplayTileView(state),
  1381. _toolbarButtons: toolbarButtons,
  1382. _virtualSource: state['features/virtual-background'].virtualSource,
  1383. _visible: isToolboxVisible(state),
  1384. _whiteboardEnabled: isWhiteboardEnabled(state)
  1385. };
  1386. }
  1387. export default translate(connect(_mapStateToProps)(withStyles(styles)(Toolbox)));