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

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