Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Toolbox.tsx 49KB

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