Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Toolbox.tsx 48KB

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