Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Toolbox.tsx 49KB

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