您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Toolbox.tsx 48KB

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