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

Toolbox.tsx 48KB

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