You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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