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

Toolbox.tsx 50KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  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. let { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  892. || THRESHOLDS[THRESHOLDS.length - 1];
  893. const keys = Object.keys(buttons);
  894. const filtered = [
  895. ...order.map(key => buttons[key as keyof typeof buttons]),
  896. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  897. ].filter(Boolean).filter(({ key, alias = NOT_APPLICABLE }) =>
  898. !_jwtDisabledButons.includes(key)
  899. && (isToolbarButtonEnabled(key, _toolbarButtons) || isToolbarButtonEnabled(alias, _toolbarButtons))
  900. );
  901. const filteredKeys = filtered.map(button => button.key);
  902. order = order.filter(key => filteredKeys.includes(buttons[key as keyof typeof buttons].key));
  903. let sliceIndex = order.length + 2;
  904. if (isHangupVisible) {
  905. sliceIndex -= 1;
  906. }
  907. // This implies that the overflow button will be displayed, so save some space for it.
  908. if (sliceIndex < filtered.length) {
  909. sliceIndex -= 1;
  910. }
  911. return {
  912. mainMenuButtons: filtered.slice(0, sliceIndex),
  913. overflowMenuButtons: filtered.slice(sliceIndex)
  914. };
  915. }
  916. /**
  917. * Dispatches an action signaling the toolbar is not being hovered.
  918. *
  919. * @private
  920. * @returns {void}
  921. */
  922. _onMouseOut() {
  923. const { _overflowMenuVisible, dispatch } = this.props;
  924. !_overflowMenuVisible && dispatch(setToolbarHovered(false));
  925. }
  926. /**
  927. * Dispatches an action signaling the toolbar is being hovered.
  928. *
  929. * @private
  930. * @returns {void}
  931. */
  932. _onMouseOver() {
  933. this.props.dispatch(setToolbarHovered(true));
  934. }
  935. /**
  936. * Sets the visibility of the hangup menu.
  937. *
  938. * @param {boolean} visible - Whether or not the hangup menu should be
  939. * displayed.
  940. * @private
  941. * @returns {void}
  942. */
  943. _onSetHangupVisible(visible: boolean) {
  944. this.props.dispatch(setHangupMenuVisible(visible));
  945. this.props.dispatch(setToolbarHovered(visible));
  946. }
  947. /**
  948. * Sets the visibility of the overflow menu.
  949. *
  950. * @param {boolean} visible - Whether or not the overflow menu should be
  951. * displayed.
  952. * @private
  953. * @returns {void}
  954. */
  955. _onSetOverflowVisible(visible: boolean) {
  956. this.props.dispatch(setOverflowMenuVisible(visible));
  957. this.props.dispatch(setToolbarHovered(visible));
  958. }
  959. /**
  960. * Creates an analytics keyboard shortcut event and dispatches an action for
  961. * toggling the display of chat.
  962. *
  963. * @private
  964. * @returns {void}
  965. */
  966. _onShortcutToggleChat() {
  967. sendAnalytics(createShortcutEvent(
  968. 'toggle.chat',
  969. ACTION_SHORTCUT_TRIGGERED,
  970. {
  971. enable: !this.props._chatOpen
  972. }));
  973. // Checks if there was any text selected by the user.
  974. // Used for when we press simultaneously keys for copying
  975. // text messages from the chat board
  976. if (window.getSelection()?.toString() !== '') {
  977. return false;
  978. }
  979. this._doToggleChat();
  980. }
  981. /**
  982. * Creates an analytics keyboard shortcut event and dispatches an action for
  983. * toggling the display of the participants pane.
  984. *
  985. * @private
  986. * @returns {void}
  987. */
  988. _onShortcutToggleParticipantsPane() {
  989. sendAnalytics(createShortcutEvent(
  990. 'toggle.participants-pane',
  991. ACTION_SHORTCUT_TRIGGERED,
  992. {
  993. enable: !this.props._participantsPaneOpen
  994. }));
  995. this._onToolbarToggleParticipantsPane();
  996. }
  997. /**
  998. * Creates an analytics keyboard shortcut event and dispatches an action for
  999. * toggling the display of Video Quality.
  1000. *
  1001. * @private
  1002. * @returns {void}
  1003. */
  1004. _onShortcutToggleVideoQuality() {
  1005. sendAnalytics(createShortcutEvent('video.quality'));
  1006. this._doToggleVideoQuality();
  1007. }
  1008. /**
  1009. * Dispatches an action for toggling the tile view.
  1010. *
  1011. * @private
  1012. * @returns {void}
  1013. */
  1014. _onShortcutToggleTileView() {
  1015. sendAnalytics(createShortcutEvent(
  1016. 'toggle.tileview',
  1017. ACTION_SHORTCUT_TRIGGERED,
  1018. {
  1019. enable: !this.props._tileViewEnabled
  1020. }));
  1021. this._doToggleTileView();
  1022. }
  1023. /**
  1024. * Creates an analytics keyboard shortcut event and dispatches an action for
  1025. * toggling full screen mode.
  1026. *
  1027. * @private
  1028. * @returns {void}
  1029. */
  1030. _onShortcutToggleFullScreen() {
  1031. sendAnalytics(createShortcutEvent(
  1032. 'toggle.fullscreen',
  1033. ACTION_SHORTCUT_TRIGGERED,
  1034. {
  1035. enable: !this.props._fullScreen
  1036. }));
  1037. this._doToggleFullScreen();
  1038. }
  1039. /**
  1040. * Creates an analytics keyboard shortcut event and dispatches an action for
  1041. * toggling raise hand.
  1042. *
  1043. * @private
  1044. * @returns {void}
  1045. */
  1046. _onShortcutToggleRaiseHand() {
  1047. sendAnalytics(createShortcutEvent(
  1048. 'toggle.raise.hand',
  1049. ACTION_SHORTCUT_TRIGGERED,
  1050. { enable: !this.props._raisedHand }));
  1051. this._doToggleRaiseHand();
  1052. }
  1053. /**
  1054. * Creates an analytics keyboard shortcut event and dispatches an action for
  1055. * toggling screensharing.
  1056. *
  1057. * @private
  1058. * @returns {void}
  1059. */
  1060. _onShortcutToggleScreenshare() {
  1061. // Ignore the shortcut if the button is disabled.
  1062. if (this.props._desktopSharingButtonDisabled) {
  1063. return;
  1064. }
  1065. sendAnalytics(createShortcutEvent(
  1066. 'toggle.screen.sharing',
  1067. ACTION_SHORTCUT_TRIGGERED,
  1068. {
  1069. enable: !this.props._screenSharing
  1070. }));
  1071. this._doToggleScreenshare();
  1072. }
  1073. /**
  1074. * Creates an analytics keyboard shortcut event and dispatches an action for
  1075. * toggling speaker stats.
  1076. *
  1077. * @private
  1078. * @returns {void}
  1079. */
  1080. _onShortcutSpeakerStats() {
  1081. sendAnalytics(createShortcutEvent(
  1082. 'speaker.stats'
  1083. ));
  1084. this._doToggleSpekearStats();
  1085. }
  1086. /**
  1087. * Dispatches an action to toggle speakerStats.
  1088. *
  1089. * @private
  1090. * @returns {void}
  1091. */
  1092. _doToggleSpekearStats() {
  1093. const { dispatch } = this.props;
  1094. dispatch(toggleDialog(SpeakerStats, {
  1095. conference: APP.conference
  1096. }));
  1097. }
  1098. /**
  1099. * Toggle the toolbar visibility when tabbing into it.
  1100. *
  1101. * @returns {void}
  1102. */
  1103. _onTabIn() {
  1104. if (!this.props._visible) {
  1105. this.props.dispatch(showToolbox());
  1106. }
  1107. }
  1108. /**
  1109. * Dispatches an action for toggling the participants pane.
  1110. *
  1111. * @private
  1112. * @returns {void}
  1113. */
  1114. _onToolbarToggleParticipantsPane() {
  1115. const { dispatch, _participantsPaneOpen } = this.props;
  1116. if (_participantsPaneOpen) {
  1117. dispatch(closeParticipantsPane());
  1118. } else {
  1119. dispatch(openParticipantsPane());
  1120. }
  1121. }
  1122. /**
  1123. * Creates an analytics toolbar event and dispatches an action for toggling
  1124. * open the video quality dialog.
  1125. *
  1126. * @private
  1127. * @returns {void}
  1128. */
  1129. _onToolbarOpenVideoQuality() {
  1130. sendAnalytics(createToolbarEvent('video.quality'));
  1131. this._doOpenVideoQuality();
  1132. }
  1133. /**
  1134. * Creates an analytics toolbar event and dispatches an action for toggling
  1135. * the display of chat.
  1136. *
  1137. * @private
  1138. * @returns {void}
  1139. */
  1140. _onToolbarToggleChat() {
  1141. sendAnalytics(createToolbarEvent(
  1142. 'toggle.chat',
  1143. {
  1144. enable: !this.props._chatOpen
  1145. }));
  1146. this._closeOverflowMenuIfOpen();
  1147. this._doToggleChat();
  1148. }
  1149. /**
  1150. * Creates an analytics toolbar event and dispatches an action for toggling
  1151. * full screen mode.
  1152. *
  1153. * @private
  1154. * @returns {void}
  1155. */
  1156. _onToolbarToggleFullScreen() {
  1157. sendAnalytics(createToolbarEvent(
  1158. 'toggle.fullscreen',
  1159. {
  1160. enable: !this.props._fullScreen
  1161. }));
  1162. this._closeOverflowMenuIfOpen();
  1163. this._doToggleFullScreen();
  1164. }
  1165. /**
  1166. * Creates an analytics toolbar event and dispatches an action for toggling
  1167. * raise hand.
  1168. *
  1169. * @private
  1170. * @returns {void}
  1171. */
  1172. _onToolbarToggleRaiseHand() {
  1173. sendAnalytics(createToolbarEvent(
  1174. 'raise.hand',
  1175. { enable: !this.props._raisedHand }));
  1176. this._doToggleRaiseHand();
  1177. }
  1178. /**
  1179. * Creates an analytics toolbar event and dispatches an action for toggling
  1180. * screensharing.
  1181. *
  1182. * @private
  1183. * @returns {void}
  1184. */
  1185. _onToolbarToggleScreenshare() {
  1186. sendAnalytics(createToolbarEvent(
  1187. 'toggle.screen.sharing',
  1188. { enable: !this.props._screenSharing }));
  1189. this._closeOverflowMenuIfOpen();
  1190. this._doToggleScreenshare();
  1191. }
  1192. /**
  1193. * Returns true if the audio sharing button should be visible and
  1194. * false otherwise.
  1195. *
  1196. * @returns {boolean}
  1197. */
  1198. _showAudioSharingButton() {
  1199. const {
  1200. _desktopSharingEnabled
  1201. } = this.props;
  1202. return _desktopSharingEnabled && isScreenAudioSupported();
  1203. }
  1204. /**
  1205. * Returns true if the desktop sharing button should be visible and
  1206. * false otherwise.
  1207. *
  1208. * @returns {boolean}
  1209. */
  1210. _showDesktopSharingButton() {
  1211. return this.props._desktopSharingEnabled;
  1212. }
  1213. /**
  1214. * Returns true if the embed meeting button is visible and false otherwise.
  1215. *
  1216. * @returns {boolean}
  1217. */
  1218. _isEmbedMeetingVisible() {
  1219. return !this.props._isVpaasMeeting
  1220. && !this.props._isMobile;
  1221. }
  1222. /**
  1223. * Returns true if the profile button is visible and false otherwise.
  1224. *
  1225. * @returns {boolean}
  1226. */
  1227. _isProfileVisible() {
  1228. return !this.props._isProfileDisabled;
  1229. }
  1230. /**
  1231. * Renders the toolbox content.
  1232. *
  1233. * @returns {ReactElement}
  1234. */
  1235. _renderToolboxContent() {
  1236. const {
  1237. _endConferenceSupported,
  1238. _hangupMenuVisible,
  1239. _isMobile,
  1240. _isNarrowLayout,
  1241. _overflowDrawer,
  1242. _overflowMenuVisible,
  1243. _reactionsEnabled,
  1244. _toolbarButtons,
  1245. classes,
  1246. t
  1247. } = this.props;
  1248. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  1249. const containerClassName = `toolbox-content${_isMobile || _isNarrowLayout ? ' toolbox-content-mobile' : ''}`;
  1250. const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
  1251. return (
  1252. <div className = { containerClassName }>
  1253. <div
  1254. className = 'toolbox-content-wrapper'
  1255. onFocus = { this._onTabIn }
  1256. { ...(_isMobile ? {} : {
  1257. onMouseOut: this._onMouseOut,
  1258. onMouseOver: this._onMouseOver
  1259. }) }>
  1260. <div
  1261. className = 'toolbox-content-items'
  1262. ref = { this._toolboxRef }>
  1263. {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
  1264. <Content
  1265. { ...rest }
  1266. buttonKey = { key }
  1267. key = { key } />))}
  1268. {Boolean(overflowMenuButtons.length) && (
  1269. <OverflowMenuButton
  1270. ariaControls = 'overflow-menu'
  1271. isOpen = { _overflowMenuVisible }
  1272. key = 'overflow-menu'
  1273. onVisibilityChange = { this._onSetOverflowVisible }
  1274. showMobileReactions = {
  1275. _reactionsEnabled && (_isMobile || _isNarrowLayout)
  1276. }>
  1277. <ContextMenu
  1278. accessibilityLabel = { t(toolbarAccLabel) }
  1279. className = { classes.contextMenu }
  1280. hidden = { false }
  1281. id = 'overflow-context-menu'
  1282. inDrawer = { _overflowDrawer }
  1283. onKeyDown = { this._onEscKey }>
  1284. {overflowMenuButtons.reduce((acc, val) => {
  1285. if (acc.length) {
  1286. const prev = acc[acc.length - 1];
  1287. const group = prev[prev.length - 1].group;
  1288. if (group === val.group) {
  1289. prev.push(val);
  1290. } else {
  1291. acc.push([ val ]);
  1292. }
  1293. } else {
  1294. acc.push([ val ]);
  1295. }
  1296. return acc;
  1297. }, []).map((buttonGroup: any) => (
  1298. <ContextMenuItemGroup key = { `group-${buttonGroup[0].group}` }>
  1299. {buttonGroup.map(({ key, Content, ...rest }: any) => (
  1300. key !== 'raisehand' || !_reactionsEnabled)
  1301. && <Content
  1302. { ...rest }
  1303. buttonKey = { key }
  1304. contextMenu = { true }
  1305. key = { key }
  1306. showLabel = { true } />)}
  1307. </ContextMenuItemGroup>))}
  1308. </ContextMenu>
  1309. </OverflowMenuButton>
  1310. )}
  1311. { isToolbarButtonEnabled('hangup', _toolbarButtons) && (
  1312. _endConferenceSupported
  1313. ? <HangupMenuButton
  1314. ariaControls = 'hangup-menu'
  1315. isOpen = { _hangupMenuVisible }
  1316. key = 'hangup-menu'
  1317. notifyMode = { this._getButtonNotifyMode('hangup-menu') }
  1318. onVisibilityChange = { this._onSetHangupVisible }>
  1319. <ContextMenu
  1320. accessibilityLabel = { t(toolbarAccLabel) }
  1321. className = { classes.hangupMenu }
  1322. hidden = { false }
  1323. inDrawer = { _overflowDrawer }
  1324. onKeyDown = { this._onEscKey }>
  1325. <EndConferenceButton
  1326. buttonKey = 'end-meeting'
  1327. notifyMode = { this._getButtonNotifyMode('end-meeting') } />
  1328. <LeaveConferenceButton
  1329. buttonKey = 'hangup'
  1330. notifyMode = { this._getButtonNotifyMode('hangup') } />
  1331. </ContextMenu>
  1332. </HangupMenuButton>
  1333. : <HangupButton
  1334. buttonKey = 'hangup'
  1335. customClass = 'hangup-button'
  1336. key = 'hangup-button'
  1337. notifyMode = { this._getButtonNotifyMode('hangup') }
  1338. visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
  1339. )}
  1340. </div>
  1341. </div>
  1342. </div>
  1343. );
  1344. }
  1345. }
  1346. /**
  1347. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1348. * props.
  1349. *
  1350. * @param {Object} state - The redux store/state.
  1351. * @param {Object} ownProps - The props explicitly passed.
  1352. * @private
  1353. * @returns {{}}
  1354. */
  1355. function _mapStateToProps(state: IReduxState, ownProps: any) {
  1356. const { conference } = state['features/base/conference'];
  1357. const { isNarrowLayout } = state['features/base/responsive-ui'];
  1358. const endConferenceSupported = conference?.isEndConferenceSupported() && isLocalParticipantModerator(state);
  1359. const {
  1360. callStatsID,
  1361. customToolbarButtons,
  1362. disableProfile,
  1363. iAmRecorder,
  1364. iAmSipGateway
  1365. } = state['features/base/config'];
  1366. const {
  1367. fullScreen,
  1368. hangupMenuVisible,
  1369. overflowMenuVisible,
  1370. overflowDrawer
  1371. } = state['features/toolbox'];
  1372. const localParticipant = getLocalParticipant(state);
  1373. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1374. const { clientWidth } = state['features/base/responsive-ui'];
  1375. let toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
  1376. if (iAmVisitor(state)) {
  1377. toolbarButtons = VISITORS_MODE_BUTTONS.filter(e => toolbarButtons.indexOf(e) > -1);
  1378. }
  1379. return {
  1380. _backgroundType: state['features/virtual-background'].backgroundType ?? '',
  1381. _buttonsWithNotifyClick: getButtonsWithNotifyClick(state),
  1382. _chatOpen: state['features/chat'].isOpen,
  1383. _clientWidth: clientWidth,
  1384. _conference: conference,
  1385. _customToolbarButtons: customToolbarButtons,
  1386. _desktopSharingEnabled: JitsiMeetJS.isDesktopSharingEnabled(),
  1387. _desktopSharingButtonDisabled: isDesktopShareButtonDisabled(state),
  1388. _dialog: Boolean(state['features/base/dialog'].component),
  1389. _disabled: Boolean(iAmRecorder || iAmSipGateway),
  1390. _endConferenceSupported: Boolean(endConferenceSupported),
  1391. _feedbackConfigured: Boolean(callStatsID),
  1392. _fullScreen: fullScreen,
  1393. _gifsEnabled: isGifEnabled(state),
  1394. _isProfileDisabled: Boolean(disableProfile),
  1395. _isIosMobile: isIosMobileBrowser(),
  1396. _isMobile: isMobileBrowser(),
  1397. _isSpeakerStatsDisabled: isSpeakerStatsDisabled(state),
  1398. _isVpaasMeeting: isVpaasMeeting(state),
  1399. _jwtDisabledButons: getJwtDisabledButtons(state),
  1400. _hasSalesforce: isSalesforceEnabled(state),
  1401. _hangupMenuVisible: hangupMenuVisible,
  1402. _isNarrowLayout: isNarrowLayout,
  1403. _localParticipantID: localParticipant?.id,
  1404. _localVideo: localVideo,
  1405. _multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state),
  1406. _overflowMenuVisible: overflowMenuVisible,
  1407. _overflowDrawer: overflowDrawer,
  1408. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1409. _raisedHand: hasRaisedHand(localParticipant),
  1410. _reactionsEnabled: isReactionsEnabled(state),
  1411. _screenSharing: isScreenVideoShared(state),
  1412. _shortcutsEnabled: areKeyboardShortcutsEnabled(state),
  1413. _tileViewEnabled: shouldDisplayTileView(state),
  1414. _toolbarButtons: toolbarButtons,
  1415. _virtualSource: state['features/virtual-background'].virtualSource,
  1416. _visible: isToolboxVisible(state),
  1417. _whiteboardEnabled: isWhiteboardButtonVisible(state)
  1418. };
  1419. }
  1420. export default translate(connect(_mapStateToProps)(withStyles(styles)(Toolbox)));