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

Toolbox.js 42KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. // @flow
  2. import React, { Component } from 'react';
  3. import {
  4. ACTION_SHORTCUT_TRIGGERED,
  5. createShortcutEvent,
  6. createToolbarEvent,
  7. sendAnalytics
  8. } from '../../../analytics';
  9. import { getToolbarButtons } from '../../../base/config';
  10. import { openDialog, toggleDialog } from '../../../base/dialog';
  11. import { isMobileBrowser } from '../../../base/environment/utils';
  12. import { translate } from '../../../base/i18n';
  13. import {
  14. IconChat,
  15. IconCodeBlock,
  16. IconDeviceDocument,
  17. IconExitFullScreen,
  18. IconFeedback,
  19. IconFullScreen,
  20. IconInviteMore,
  21. IconPresentation,
  22. IconRaisedHand,
  23. IconRec,
  24. IconShareAudio,
  25. IconShareDesktop
  26. } from '../../../base/icons';
  27. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  28. import {
  29. getLocalParticipant,
  30. getParticipants,
  31. participantUpdated
  32. } from '../../../base/participants';
  33. import { connect } from '../../../base/redux';
  34. import { OverflowMenuItem } from '../../../base/toolbox/components';
  35. import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
  36. import { isVpaasMeeting } from '../../../billing-counter/functions';
  37. import { ChatCounter, toggleChat } from '../../../chat';
  38. import { InviteMore } from '../../../conference';
  39. import { EmbedMeetingDialog } from '../../../embed-meeting';
  40. import { SharedDocumentButton } from '../../../etherpad';
  41. import { openFeedbackDialog } from '../../../feedback';
  42. import { beginAddPeople } from '../../../invite';
  43. import { openKeyboardShortcutsDialog } from '../../../keyboard-shortcuts';
  44. import { LocalRecordingInfoDialog } from '../../../local-recording';
  45. import {
  46. LiveStreamButton,
  47. RecordButton
  48. } from '../../../recording';
  49. import { isScreenAudioShared, isScreenAudioSupported } from '../../../screen-share/';
  50. import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
  51. import {
  52. SETTINGS_TABS,
  53. SettingsButton,
  54. openSettingsDialog
  55. } from '../../../settings';
  56. import { SharedVideoButton } from '../../../shared-video/components';
  57. import { SpeakerStats } from '../../../speaker-stats';
  58. import {
  59. ClosedCaptionButton
  60. } from '../../../subtitles';
  61. import {
  62. TileViewButton,
  63. shouldDisplayTileView,
  64. toggleTileView
  65. } from '../../../video-layout';
  66. import {
  67. OverflowMenuVideoQualityItem,
  68. VideoQualityDialog
  69. } from '../../../video-quality';
  70. import { VideoBackgroundButton } from '../../../virtual-background';
  71. import { checkBlurSupport } from '../../../virtual-background/functions';
  72. import {
  73. setFullScreen,
  74. setOverflowMenuVisible,
  75. setToolbarHovered,
  76. showToolbox
  77. } from '../../actions';
  78. import { getToolbarAdditionalButtons, isToolboxVisible } from '../../functions';
  79. import DownloadButton from '../DownloadButton';
  80. import HangupButton from '../HangupButton';
  81. import HelpButton from '../HelpButton';
  82. import MuteEveryoneButton from '../MuteEveryoneButton';
  83. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  84. import AudioSettingsButton from './AudioSettingsButton';
  85. import OverflowMenuButton from './OverflowMenuButton';
  86. import OverflowMenuProfileItem from './OverflowMenuProfileItem';
  87. import ToggleCameraButton from './ToggleCameraButton';
  88. import ToolbarButton from './ToolbarButton';
  89. import VideoSettingsButton from './VideoSettingsButton';
  90. /**
  91. * The type of the React {@code Component} props of {@link Toolbox}.
  92. */
  93. type Props = {
  94. /**
  95. * Whether or not the chat feature is currently displayed.
  96. */
  97. _chatOpen: boolean,
  98. /**
  99. * The width of the client.
  100. */
  101. _clientWidth: number,
  102. /**
  103. * The {@code JitsiConference} for the current conference.
  104. */
  105. _conference: Object,
  106. /**
  107. * The tooltip key to use when screensharing is disabled. Or undefined
  108. * if non to be shown and the button to be hidden.
  109. */
  110. _desktopSharingDisabledTooltipKey: boolean,
  111. /**
  112. * Whether or not screensharing is initialized.
  113. */
  114. _desktopSharingEnabled: boolean,
  115. /**
  116. * Whether or not a dialog is displayed.
  117. */
  118. _dialog: boolean,
  119. /**
  120. * Whether or not call feedback can be sent.
  121. */
  122. _feedbackConfigured: boolean,
  123. /**
  124. * Whether or not the app is currently in full screen.
  125. */
  126. _fullScreen: boolean,
  127. /**
  128. * Whether or not the app is running in mobile browser.
  129. */
  130. _isMobile: boolean,
  131. /**
  132. * Whether or not the profile is disabled.
  133. */
  134. _isProfileDisabled: boolean,
  135. /**
  136. * Whether or not the tile view is enabled.
  137. */
  138. _tileViewEnabled: boolean,
  139. /**
  140. * Whether or not the current meeting belongs to a JaaS user.
  141. */
  142. _isVpaasMeeting: boolean,
  143. /**
  144. * The ID of the local participant.
  145. */
  146. _localParticipantID: String,
  147. /**
  148. * The subsection of Redux state for local recording
  149. */
  150. _localRecState: Object,
  151. /**
  152. * The value for how the conference is locked (or undefined if not locked)
  153. * as defined by room-lock constants.
  154. */
  155. _locked: boolean,
  156. /**
  157. * Whether or not the overflow menu is visible.
  158. */
  159. _overflowMenuVisible: boolean,
  160. /**
  161. * Whether or not the local participant's hand is raised.
  162. */
  163. _raisedHand: boolean,
  164. /**
  165. * Whether or not the local participant is screensharing.
  166. */
  167. _screensharing: boolean,
  168. /**
  169. * Whether or not the local participant is sharing a YouTube video.
  170. */
  171. _sharingVideo: boolean,
  172. /**
  173. * Flag showing whether toolbar is visible.
  174. */
  175. _visible: boolean,
  176. /**
  177. * Array with the buttons which this Toolbox should display.
  178. */
  179. _visibleButtons: Array<string>,
  180. /**
  181. * Invoked to active other features of the app.
  182. */
  183. dispatch: Function,
  184. /**
  185. * Invoked to obtain translated strings.
  186. */
  187. t: Function
  188. };
  189. declare var APP: Object;
  190. /**
  191. * Implements the conference toolbox on React/Web.
  192. *
  193. * @extends Component
  194. */
  195. class Toolbox extends Component<Props> {
  196. /**
  197. * Initializes a new {@code Toolbox} instance.
  198. *
  199. * @param {Props} props - The read-only React {@code Component} props with
  200. * which the new instance is to be initialized.
  201. */
  202. constructor(props: Props) {
  203. super(props);
  204. // Bind event handlers so they are only bound once per instance.
  205. this._onMouseOut = this._onMouseOut.bind(this);
  206. this._onMouseOver = this._onMouseOver.bind(this);
  207. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  208. this._onTabIn = this._onTabIn.bind(this);
  209. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  210. this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
  211. this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
  212. this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
  213. this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
  214. this._onToolbarOpenFeedback = this._onToolbarOpenFeedback.bind(this);
  215. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  216. this._onToolbarOpenKeyboardShortcuts = this._onToolbarOpenKeyboardShortcuts.bind(this);
  217. this._onToolbarOpenSpeakerStats = this._onToolbarOpenSpeakerStats.bind(this);
  218. this._onToolbarOpenEmbedMeeting = this._onToolbarOpenEmbedMeeting.bind(this);
  219. this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
  220. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  221. this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
  222. this._onToolbarToggleProfile = this._onToolbarToggleProfile.bind(this);
  223. this._onToolbarToggleRaiseHand = this._onToolbarToggleRaiseHand.bind(this);
  224. this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
  225. this._onToolbarToggleShareAudio = this._onToolbarToggleShareAudio.bind(this);
  226. this._onToolbarOpenLocalRecordingInfoDialog = this._onToolbarOpenLocalRecordingInfoDialog.bind(this);
  227. this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
  228. }
  229. /**
  230. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  231. *
  232. * @inheritdoc
  233. * @returns {void}
  234. */
  235. componentDidMount() {
  236. const KEYBOARD_SHORTCUTS = [
  237. this._shouldShowButton('videoquality') && {
  238. character: 'A',
  239. exec: this._onShortcutToggleVideoQuality,
  240. helpDescription: 'toolbar.callQuality'
  241. },
  242. this._shouldShowButton('chat') && {
  243. character: 'C',
  244. exec: this._onShortcutToggleChat,
  245. helpDescription: 'keyboardShortcuts.toggleChat'
  246. },
  247. this._shouldShowButton('desktop') && {
  248. character: 'D',
  249. exec: this._onShortcutToggleScreenshare,
  250. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  251. },
  252. this._shouldShowButton('raisehand') && {
  253. character: 'R',
  254. exec: this._onShortcutToggleRaiseHand,
  255. helpDescription: 'keyboardShortcuts.raiseHand'
  256. },
  257. this._shouldShowButton('fullscreen') && {
  258. character: 'S',
  259. exec: this._onShortcutToggleFullScreen,
  260. helpDescription: 'keyboardShortcuts.fullScreen'
  261. },
  262. this._shouldShowButton('tileview') && {
  263. character: 'W',
  264. exec: this._onShortcutToggleTileView,
  265. helpDescription: 'toolbar.tileViewToggle'
  266. }
  267. ];
  268. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  269. if (typeof shortcut === 'object') {
  270. APP.keyboardshortcut.registerShortcut(
  271. shortcut.character,
  272. null,
  273. shortcut.exec,
  274. shortcut.helpDescription);
  275. }
  276. });
  277. }
  278. /**
  279. * Update the visibility of the {@code OverflowMenuButton}.
  280. *
  281. * @inheritdoc
  282. */
  283. componentDidUpdate(prevProps) {
  284. // Ensure the dialog is closed when the toolbox becomes hidden.
  285. if (prevProps._overflowMenuVisible && !this.props._visible) {
  286. this._onSetOverflowVisible(false);
  287. }
  288. if (prevProps._overflowMenuVisible
  289. && !prevProps._dialog
  290. && this.props._dialog) {
  291. this._onSetOverflowVisible(false);
  292. this.props.dispatch(setToolbarHovered(false));
  293. }
  294. }
  295. /**
  296. * Removes keyboard shortcuts registered by this component.
  297. *
  298. * @inheritdoc
  299. * @returns {void}
  300. */
  301. componentWillUnmount() {
  302. [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
  303. APP.keyboardshortcut.unregisterShortcut(letter));
  304. }
  305. /**
  306. * Implements React's {@link Component#render()}.
  307. *
  308. * @inheritdoc
  309. * @returns {ReactElement}
  310. */
  311. render() {
  312. const { _chatOpen, _visible, _visibleButtons } = this.props;
  313. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  314. _visibleButtons.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
  315. return (
  316. <div
  317. className = { rootClassNames }
  318. id = 'new-toolbox'
  319. onFocus = { this._onTabIn }
  320. onMouseOut = { this._onMouseOut }
  321. onMouseOver = { this._onMouseOver }>
  322. { this._renderToolboxContent() }
  323. </div>
  324. );
  325. }
  326. /**
  327. * Closes the overflow menu if opened.
  328. *
  329. * @private
  330. * @returns {void}
  331. */
  332. _closeOverflowMenuIfOpen() {
  333. const { dispatch, _overflowMenuVisible } = this.props;
  334. _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
  335. }
  336. /**
  337. * Callback invoked to display {@code FeedbackDialog}.
  338. *
  339. * @private
  340. * @returns {void}
  341. */
  342. _doOpenFeedback() {
  343. const { _conference } = this.props;
  344. this.props.dispatch(openFeedbackDialog(_conference));
  345. }
  346. /**
  347. * Callback invoked to display {@code FeedbackDialog}.
  348. *
  349. * @private
  350. * @returns {void}
  351. */
  352. _doOpenEmbedMeeting() {
  353. this.props.dispatch(openDialog(EmbedMeetingDialog));
  354. }
  355. /**
  356. * Dispatches an action to display {@code KeyboardShortcuts}.
  357. *
  358. * @private
  359. * @returns {void}
  360. */
  361. _doOpenKeyboardShorcuts() {
  362. this.props.dispatch(openKeyboardShortcutsDialog());
  363. }
  364. /**
  365. * Callback invoked to display {@code SpeakerStats}.
  366. *
  367. * @private
  368. * @returns {void}
  369. */
  370. _doOpenSpeakerStats() {
  371. this.props.dispatch(openDialog(SpeakerStats, {
  372. conference: this.props._conference
  373. }));
  374. }
  375. /**
  376. * Dispatches an action to open the video quality dialog.
  377. *
  378. * @private
  379. * @returns {void}
  380. */
  381. _doOpenVideoQuality() {
  382. this.props.dispatch(openDialog(VideoQualityDialog));
  383. }
  384. /**
  385. * Dispatches an action to toggle the display of chat.
  386. *
  387. * @private
  388. * @returns {void}
  389. */
  390. _doToggleChat() {
  391. this.props.dispatch(toggleChat());
  392. }
  393. /**
  394. * Dispatches an action to toggle screensharing.
  395. *
  396. * @private
  397. * @returns {void}
  398. */
  399. _doToggleFullScreen() {
  400. const fullScreen = !this.props._fullScreen;
  401. this.props.dispatch(setFullScreen(fullScreen));
  402. }
  403. /**
  404. * Dispatches an action to show or hide the profile edit panel.
  405. *
  406. * @private
  407. * @returns {void}
  408. */
  409. _doToggleProfile() {
  410. this.props.dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE));
  411. }
  412. /**
  413. * Dispatches an action to toggle the local participant's raised hand state.
  414. *
  415. * @private
  416. * @returns {void}
  417. */
  418. _doToggleRaiseHand() {
  419. const { _localParticipantID, _raisedHand } = this.props;
  420. const newRaisedStatus = !_raisedHand;
  421. this.props.dispatch(participantUpdated({
  422. // XXX Only the local participant is allowed to update without
  423. // stating the JitsiConference instance (i.e. participant property
  424. // `conference` for a remote participant) because the local
  425. // participant is uniquely identified by the very fact that there is
  426. // only one local participant.
  427. id: _localParticipantID,
  428. local: true,
  429. raisedHand: newRaisedStatus
  430. }));
  431. APP.API.notifyRaiseHandUpdated(_localParticipantID, newRaisedStatus);
  432. }
  433. /**
  434. * Dispatches an action to toggle screensharing.
  435. *
  436. * @private
  437. * @param {boolean} audioOnly - Only share system audio.
  438. * @returns {void}
  439. */
  440. _doToggleScreenshare(audioOnly = false) {
  441. if (this.props._desktopSharingEnabled) {
  442. this.props.dispatch(toggleScreensharing(audioOnly));
  443. }
  444. }
  445. /**
  446. * Dispatches an action to toggle the video quality dialog.
  447. *
  448. * @private
  449. * @returns {void}
  450. */
  451. _doToggleVideoQuality() {
  452. this.props.dispatch(toggleDialog(VideoQualityDialog));
  453. }
  454. /**
  455. * Dispaches an action to toggle tile view.
  456. *
  457. * @private
  458. * @returns {void}
  459. */
  460. _doToggleTileView() {
  461. this.props.dispatch(toggleTileView());
  462. }
  463. _onMouseOut: () => void;
  464. /**
  465. * Dispatches an action signaling the toolbar is not being hovered.
  466. *
  467. * @private
  468. * @returns {void}
  469. */
  470. _onMouseOut() {
  471. this.props.dispatch(setToolbarHovered(false));
  472. }
  473. _onMouseOver: () => void;
  474. /**
  475. * Dispatches an action signaling the toolbar is being hovered.
  476. *
  477. * @private
  478. * @returns {void}
  479. */
  480. _onMouseOver() {
  481. this.props.dispatch(setToolbarHovered(true));
  482. }
  483. _onSetOverflowVisible: (boolean) => void;
  484. /**
  485. * Sets the visibility of the overflow menu.
  486. *
  487. * @param {boolean} visible - Whether or not the overflow menu should be
  488. * displayed.
  489. * @private
  490. * @returns {void}
  491. */
  492. _onSetOverflowVisible(visible) {
  493. this.props.dispatch(setOverflowMenuVisible(visible));
  494. }
  495. _onShortcutToggleChat: () => void;
  496. /**
  497. * Creates an analytics keyboard shortcut event and dispatches an action for
  498. * toggling the display of chat.
  499. *
  500. * @private
  501. * @returns {void}
  502. */
  503. _onShortcutToggleChat() {
  504. sendAnalytics(createShortcutEvent(
  505. 'toggle.chat',
  506. {
  507. enable: !this.props._chatOpen
  508. }));
  509. this._doToggleChat();
  510. }
  511. _onShortcutToggleVideoQuality: () => void;
  512. /**
  513. * Creates an analytics keyboard shortcut event and dispatches an action for
  514. * toggling the display of Video Quality.
  515. *
  516. * @private
  517. * @returns {void}
  518. */
  519. _onShortcutToggleVideoQuality() {
  520. sendAnalytics(createShortcutEvent('video.quality'));
  521. this._doToggleVideoQuality();
  522. }
  523. _onShortcutToggleTileView: () => void;
  524. /**
  525. * Dispatches an action for toggling the tile view.
  526. *
  527. * @private
  528. * @returns {void}
  529. */
  530. _onShortcutToggleTileView() {
  531. sendAnalytics(createShortcutEvent(
  532. 'toggle.tileview',
  533. {
  534. enable: !this.props._tileViewEnabled
  535. }));
  536. this._doToggleTileView();
  537. }
  538. _onShortcutToggleFullScreen: () => void;
  539. /**
  540. * Creates an analytics keyboard shortcut event and dispatches an action for
  541. * toggling full screen mode.
  542. *
  543. * @private
  544. * @returns {void}
  545. */
  546. _onShortcutToggleFullScreen() {
  547. sendAnalytics(createShortcutEvent(
  548. 'toggle.fullscreen',
  549. {
  550. enable: !this.props._fullScreen
  551. }));
  552. this._doToggleFullScreen();
  553. }
  554. _onShortcutToggleRaiseHand: () => void;
  555. /**
  556. * Creates an analytics keyboard shortcut event and dispatches an action for
  557. * toggling raise hand.
  558. *
  559. * @private
  560. * @returns {void}
  561. */
  562. _onShortcutToggleRaiseHand() {
  563. sendAnalytics(createShortcutEvent(
  564. 'toggle.raise.hand',
  565. ACTION_SHORTCUT_TRIGGERED,
  566. { enable: !this.props._raisedHand }));
  567. this._doToggleRaiseHand();
  568. }
  569. _onShortcutToggleScreenshare: () => void;
  570. /**
  571. * Creates an analytics keyboard shortcut event and dispatches an action for
  572. * toggling screensharing.
  573. *
  574. * @private
  575. * @returns {void}
  576. */
  577. _onShortcutToggleScreenshare() {
  578. sendAnalytics(createToolbarEvent(
  579. 'screen.sharing',
  580. {
  581. enable: !this.props._screensharing
  582. }));
  583. this._doToggleScreenshare();
  584. }
  585. _onTabIn: () => void;
  586. /**
  587. * Toggle the toolbar visibility when tabbing into it.
  588. *
  589. * @returns {void}
  590. */
  591. _onTabIn() {
  592. if (!this.props._visible) {
  593. this.props.dispatch(showToolbox());
  594. }
  595. }
  596. _onToolbarOpenFeedback: () => void;
  597. /**
  598. * Creates an analytics toolbar event and dispatches an action for toggling
  599. * display of feedback.
  600. *
  601. * @private
  602. * @returns {void}
  603. */
  604. _onToolbarOpenFeedback() {
  605. sendAnalytics(createToolbarEvent('feedback'));
  606. this._doOpenFeedback();
  607. }
  608. _onToolbarOpenInvite: () => void;
  609. /**
  610. * Creates an analytics toolbar event and dispatches an action for opening
  611. * the modal for inviting people directly into the conference.
  612. *
  613. * @private
  614. * @returns {void}
  615. */
  616. _onToolbarOpenInvite() {
  617. sendAnalytics(createToolbarEvent('invite'));
  618. this.props.dispatch(beginAddPeople());
  619. }
  620. _onToolbarOpenKeyboardShortcuts: () => void;
  621. /**
  622. * Creates an analytics toolbar event and dispatches an action for opening
  623. * the modal for showing available keyboard shortcuts.
  624. *
  625. * @private
  626. * @returns {void}
  627. */
  628. _onToolbarOpenKeyboardShortcuts() {
  629. sendAnalytics(createToolbarEvent('shortcuts'));
  630. this._doOpenKeyboardShorcuts();
  631. }
  632. _onToolbarOpenEmbedMeeting: () => void;
  633. /**
  634. * Creates an analytics toolbar event and dispatches an action for opening
  635. * the embed meeting modal.
  636. *
  637. * @private
  638. * @returns {void}
  639. */
  640. _onToolbarOpenEmbedMeeting() {
  641. sendAnalytics(createToolbarEvent('embed.meeting'));
  642. this._doOpenEmbedMeeting();
  643. }
  644. _onToolbarOpenSpeakerStats: () => void;
  645. /**
  646. * Creates an analytics toolbar event and dispatches an action for opening
  647. * the speaker stats modal.
  648. *
  649. * @private
  650. * @returns {void}
  651. */
  652. _onToolbarOpenSpeakerStats() {
  653. sendAnalytics(createToolbarEvent('speaker.stats'));
  654. this._doOpenSpeakerStats();
  655. }
  656. _onToolbarOpenVideoQuality: () => void;
  657. /**
  658. * Creates an analytics toolbar event and dispatches an action for toggling
  659. * open the video quality dialog.
  660. *
  661. * @private
  662. * @returns {void}
  663. */
  664. _onToolbarOpenVideoQuality() {
  665. sendAnalytics(createToolbarEvent('video.quality'));
  666. this._doOpenVideoQuality();
  667. }
  668. _onToolbarToggleChat: () => void;
  669. /**
  670. * Creates an analytics toolbar event and dispatches an action for toggling
  671. * the display of chat.
  672. *
  673. * @private
  674. * @returns {void}
  675. */
  676. _onToolbarToggleChat() {
  677. sendAnalytics(createToolbarEvent(
  678. 'toggle.chat',
  679. {
  680. enable: !this.props._chatOpen
  681. }));
  682. this._closeOverflowMenuIfOpen();
  683. this._doToggleChat();
  684. }
  685. _onToolbarToggleFullScreen: () => void;
  686. /**
  687. * Creates an analytics toolbar event and dispatches an action for toggling
  688. * full screen mode.
  689. *
  690. * @private
  691. * @returns {void}
  692. */
  693. _onToolbarToggleFullScreen() {
  694. sendAnalytics(createToolbarEvent(
  695. 'toggle.fullscreen',
  696. {
  697. enable: !this.props._fullScreen
  698. }));
  699. this._closeOverflowMenuIfOpen();
  700. this._doToggleFullScreen();
  701. }
  702. _onToolbarToggleProfile: () => void;
  703. /**
  704. * Creates an analytics toolbar event and dispatches an action for showing
  705. * or hiding the profile edit panel.
  706. *
  707. * @private
  708. * @returns {void}
  709. */
  710. _onToolbarToggleProfile() {
  711. sendAnalytics(createToolbarEvent('profile'));
  712. this._doToggleProfile();
  713. }
  714. _onToolbarToggleRaiseHand: () => void;
  715. /**
  716. * Creates an analytics toolbar event and dispatches an action for toggling
  717. * raise hand.
  718. *
  719. * @private
  720. * @returns {void}
  721. */
  722. _onToolbarToggleRaiseHand() {
  723. sendAnalytics(createToolbarEvent(
  724. 'raise.hand',
  725. { enable: !this.props._raisedHand }));
  726. this._doToggleRaiseHand();
  727. }
  728. _onToolbarToggleScreenshare: () => void;
  729. /**
  730. * Creates an analytics toolbar event and dispatches an action for toggling
  731. * screensharing.
  732. *
  733. * @private
  734. * @returns {void}
  735. */
  736. _onToolbarToggleScreenshare() {
  737. if (!this.props._desktopSharingEnabled) {
  738. return;
  739. }
  740. sendAnalytics(createShortcutEvent(
  741. 'toggle.screen.sharing',
  742. ACTION_SHORTCUT_TRIGGERED,
  743. { enable: !this.props._screensharing }));
  744. this._closeOverflowMenuIfOpen();
  745. this._doToggleScreenshare();
  746. }
  747. _onToolbarToggleShareAudio: () => void;
  748. /**
  749. * Handles toggle share audio action.
  750. *
  751. * @returns {void}
  752. */
  753. _onToolbarToggleShareAudio() {
  754. this._closeOverflowMenuIfOpen();
  755. this._doToggleScreenshare(true);
  756. }
  757. _onToolbarOpenLocalRecordingInfoDialog: () => void;
  758. /**
  759. * Opens the {@code LocalRecordingInfoDialog}.
  760. *
  761. * @private
  762. * @returns {void}
  763. */
  764. _onToolbarOpenLocalRecordingInfoDialog() {
  765. sendAnalytics(createToolbarEvent('local.recording'));
  766. this.props.dispatch(openDialog(LocalRecordingInfoDialog));
  767. }
  768. /**
  769. * Returns true if the desktop sharing button should be visible and
  770. * false otherwise.
  771. *
  772. * @returns {boolean}
  773. */
  774. _showDesktopSharingButton() {
  775. const {
  776. _desktopSharingEnabled,
  777. _desktopSharingDisabledTooltipKey
  778. } = this.props;
  779. return (
  780. (_desktopSharingEnabled
  781. || _desktopSharingDisabledTooltipKey)
  782. && this._shouldShowButton('desktop')
  783. );
  784. }
  785. /**
  786. * Returns true if the embed meeting button is visible and false otherwise.
  787. *
  788. * @returns {boolean}
  789. */
  790. _isEmbedMeetingVisible() {
  791. return !this.props._isVpaasMeeting
  792. && !this.props._isMobile
  793. && this._shouldShowButton('embedmeeting');
  794. }
  795. /**
  796. * Returns true if the profile button is visible and false otherwise.
  797. *
  798. * @returns {boolean}
  799. */
  800. _isProfileVisible() {
  801. return !this.props._isProfileDisabled && this._shouldShowButton('profile');
  802. }
  803. /**
  804. * Renders the list elements of the overflow menu.
  805. *
  806. * @private
  807. * @param {Array<React$Element>} additionalButtons - Additional buttons to be displayed.
  808. * @returns {Array<React$Element>}
  809. */
  810. _renderOverflowMenuContent(additionalButtons: Array<React$Element<any>>) {
  811. const {
  812. _feedbackConfigured,
  813. _fullScreen,
  814. _isMobile,
  815. _screensharing,
  816. t
  817. } = this.props;
  818. const group1 = [
  819. ...additionalButtons,
  820. this._shouldShowButton('toggle-camera')
  821. && <ToggleCameraButton
  822. key = 'toggle-camera'
  823. showLabel = { true } />,
  824. this._shouldShowButton('videoquality')
  825. && <OverflowMenuVideoQualityItem
  826. key = 'videoquality'
  827. onClick = { this._onToolbarOpenVideoQuality } />,
  828. this._shouldShowButton('fullscreen')
  829. && !_isMobile
  830. && <OverflowMenuItem
  831. accessibilityLabel = { t('toolbar.accessibilityLabel.fullScreen') }
  832. icon = { _fullScreen ? IconExitFullScreen : IconFullScreen }
  833. key = 'fullscreen'
  834. onClick = { this._onToolbarToggleFullScreen }
  835. text = { _fullScreen ? t('toolbar.exitFullScreen') : t('toolbar.enterFullScreen') } />,
  836. (this._shouldShowButton('security') || this._shouldShowButton('info'))
  837. && <SecurityDialogButton
  838. key = 'security'
  839. showLabel = { true } />,
  840. this._shouldShowButton('closedcaptions')
  841. && <ClosedCaptionButton
  842. key = 'closed-captions'
  843. showLabel = { true } />,
  844. this._shouldShowButton('recording')
  845. && <RecordButton
  846. key = 'record'
  847. showLabel = { true } />,
  848. this._shouldShowButton('localrecording')
  849. && <OverflowMenuItem
  850. accessibilityLabel = { t('toolbar.accessibilityLabel.localRecording') }
  851. icon = { IconRec }
  852. key = 'localrecording'
  853. onClick = { this._onToolbarOpenLocalRecordingInfoDialog }
  854. text = { t('localRecording.dialogTitle') } />,
  855. this._shouldShowButton('mute-everyone')
  856. && <MuteEveryoneButton
  857. key = 'mute-everyone'
  858. showLabel = { true } />,
  859. this._shouldShowButton('mute-video-everyone')
  860. && <MuteEveryonesVideoButton
  861. key = 'mute-everyones-video'
  862. showLabel = { true } />,
  863. this._shouldShowButton('livestreaming')
  864. && <LiveStreamButton
  865. key = 'livestreaming'
  866. showLabel = { true } />
  867. ];
  868. const group2 = [
  869. this._shouldShowButton('sharedvideo')
  870. && <SharedVideoButton
  871. key = 'sharedvideo'
  872. showLabel = { true } />,
  873. this._shouldShowButton('shareaudio') && isScreenAudioSupported()
  874. && <OverflowMenuItem
  875. accessibilityLabel = { t('toolbar.accessibilityLabel.shareaudio') }
  876. icon = { IconShareAudio }
  877. key = 'shareaudio'
  878. onClick = { this._onToolbarToggleShareAudio }
  879. text = { t('toolbar.shareaudio') } />,
  880. this._shouldShowButton('etherpad')
  881. && <SharedDocumentButton
  882. key = 'etherpad'
  883. showLabel = { true } />,
  884. (this._shouldShowButton('select-background') || this._shouldShowButton('videobackgroundblur'))
  885. && <VideoBackgroundButton
  886. key = { 'select-background' }
  887. showLabel = { true }
  888. visible = { !_screensharing && checkBlurSupport() } />,
  889. this._shouldShowButton('stats')
  890. && <OverflowMenuItem
  891. accessibilityLabel = { t('toolbar.accessibilityLabel.speakerStats') }
  892. icon = { IconPresentation }
  893. key = 'stats'
  894. onClick = { this._onToolbarOpenSpeakerStats }
  895. text = { t('toolbar.speakerStats') } />
  896. ];
  897. return [
  898. this._isProfileVisible()
  899. && <OverflowMenuProfileItem
  900. key = 'profile'
  901. onClick = { this._onToolbarToggleProfile } />,
  902. this._isProfileVisible()
  903. && <hr
  904. className = 'overflow-menu-hr'
  905. key = 'hr1' />,
  906. ...group1,
  907. group1.some(Boolean)
  908. && <hr
  909. className = 'overflow-menu-hr'
  910. key = 'hr2' />,
  911. ...group2,
  912. group2.some(Boolean)
  913. && <hr
  914. className = 'overflow-menu-hr'
  915. key = 'hr3' />,
  916. this._shouldShowButton('settings')
  917. && <SettingsButton
  918. key = 'settings'
  919. showLabel = { true } />,
  920. this._shouldShowButton('shortcuts')
  921. && !_isMobile
  922. && <OverflowMenuItem
  923. accessibilityLabel = { t('toolbar.accessibilityLabel.shortcuts') }
  924. icon = { IconDeviceDocument }
  925. key = 'shortcuts'
  926. onClick = { this._onToolbarOpenKeyboardShortcuts }
  927. text = { t('toolbar.shortcuts') } />,
  928. this._isEmbedMeetingVisible()
  929. && <OverflowMenuItem
  930. accessibilityLabel = { t('toolbar.accessibilityLabel.embedMeeting') }
  931. icon = { IconCodeBlock }
  932. key = 'embed'
  933. onClick = { this._onToolbarOpenEmbedMeeting }
  934. text = { t('toolbar.embedMeeting') } />,
  935. this._shouldShowButton('feedback')
  936. && _feedbackConfigured
  937. && <OverflowMenuItem
  938. accessibilityLabel = { t('toolbar.accessibilityLabel.feedback') }
  939. icon = { IconFeedback }
  940. key = 'feedback'
  941. onClick = { this._onToolbarOpenFeedback }
  942. text = { t('toolbar.feedback') } />,
  943. this._shouldShowButton('download')
  944. && <DownloadButton
  945. key = 'download'
  946. showLabel = { true } />,
  947. this._shouldShowButton('help')
  948. && <HelpButton
  949. key = 'help'
  950. showLabel = { true } />
  951. ];
  952. }
  953. /**
  954. * Returns the buttons to be displayed in main or the overflow menu.
  955. *
  956. * @param {Set} buttons - A set containing the buttons to be displayed
  957. * in the toolbar beside the main audio/video & hanugup.
  958. * @returns {Object}
  959. */
  960. _getAdditionalButtons(buttons) {
  961. const {
  962. _chatOpen,
  963. _desktopSharingEnabled,
  964. _desktopSharingDisabledTooltipKey,
  965. _raisedHand,
  966. _screensharing,
  967. t
  968. } = this.props;
  969. const overflowMenuAdditionalButtons = [];
  970. const mainMenuAdditionalButtons = [];
  971. if (this._showDesktopSharingButton()) {
  972. buttons.has('desktop')
  973. ? mainMenuAdditionalButtons.push(<ToolbarButton
  974. accessibilityLabel = { t('toolbar.accessibilityLabel.shareYourScreen') }
  975. disabled = { !_desktopSharingEnabled }
  976. icon = { IconShareDesktop }
  977. key = 'desktop'
  978. onClick = { this._onToolbarToggleScreenshare }
  979. toggled = { _screensharing }
  980. tooltip = { t(_desktopSharingEnabled
  981. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey) } />)
  982. : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  983. accessibilityLabel = { t('toolbar.accessibilityLabel.shareYourScreen') }
  984. icon = { IconShareDesktop }
  985. iconId = 'share-desktop'
  986. key = 'desktop'
  987. onClick = { this._onToolbarToggleScreenshare }
  988. text = { t(`toolbar.${_screensharing ? 'stopScreenSharing' : 'startScreenSharing'}`) } />);
  989. }
  990. if (this._shouldShowButton('chat')) {
  991. buttons.has('chat')
  992. ? mainMenuAdditionalButtons.push(<div
  993. className = 'toolbar-button-with-badge'
  994. key = 'chatcontainer'>
  995. <ToolbarButton
  996. accessibilityLabel = { t('toolbar.accessibilityLabel.chat') }
  997. icon = { IconChat }
  998. key = 'chat'
  999. onClick = { this._onToolbarToggleChat }
  1000. toggled = { _chatOpen }
  1001. tooltip = { t('toolbar.chat') } />
  1002. <ChatCounter />
  1003. </div>) : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  1004. accessibilityLabel = { t('toolbar.accessibilityLabel.chat') }
  1005. icon = { IconChat }
  1006. key = 'chat'
  1007. onClick = { this._onToolbarToggleChat }
  1008. text = { t(`toolbar.${_chatOpen ? 'closeChat' : 'openChat'}`) } />);
  1009. }
  1010. if (this._shouldShowButton('raisehand')) {
  1011. buttons.has('raisehand')
  1012. ? mainMenuAdditionalButtons.push(<ToolbarButton
  1013. accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
  1014. icon = { IconRaisedHand }
  1015. key = 'raisehand'
  1016. onClick = { this._onToolbarToggleRaiseHand }
  1017. toggled = { _raisedHand }
  1018. tooltip = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />)
  1019. : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  1020. accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
  1021. icon = { IconRaisedHand }
  1022. key = 'raisehand'
  1023. onClick = { this._onToolbarToggleRaiseHand }
  1024. text = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />);
  1025. }
  1026. if (this._shouldShowButton('tileview')) {
  1027. buttons.has('tileview')
  1028. ? mainMenuAdditionalButtons.push(
  1029. <TileViewButton
  1030. key = 'tileview'
  1031. showLabel = { false } />)
  1032. : overflowMenuAdditionalButtons.push(
  1033. <TileViewButton
  1034. key = 'tileview'
  1035. showLabel = { true } />);
  1036. }
  1037. if (this._shouldShowButton('invite')) {
  1038. buttons.has('invite')
  1039. ? mainMenuAdditionalButtons.push(
  1040. <ToolbarButton
  1041. accessibilityLabel = { t('toolbar.accessibilityLabel.invite') }
  1042. icon = { IconInviteMore }
  1043. key = 'invite'
  1044. onClick = { this._onToolbarOpenInvite }
  1045. tooltip = { t('toolbar.invite') } />)
  1046. : overflowMenuAdditionalButtons.push(
  1047. <OverflowMenuItem
  1048. accessibilityLabel = { t('toolbar.accessibilityLabel.invite') }
  1049. icon = { IconInviteMore }
  1050. key = 'invite'
  1051. onClick = { this._onToolbarOpenInvite }
  1052. text = { t('toolbar.invite') } />
  1053. );
  1054. }
  1055. return {
  1056. mainMenuAdditionalButtons,
  1057. overflowMenuAdditionalButtons
  1058. };
  1059. }
  1060. /**
  1061. * Renders the Audio controlling button.
  1062. *
  1063. * @returns {ReactElement}
  1064. */
  1065. _renderAudioButton() {
  1066. return this._shouldShowButton('microphone')
  1067. ? <AudioSettingsButton
  1068. key = 'asb'
  1069. visible = { true } />
  1070. : null;
  1071. }
  1072. /**
  1073. * Renders the Video controlling button.
  1074. *
  1075. * @returns {ReactElement}
  1076. */
  1077. _renderVideoButton() {
  1078. return this._shouldShowButton('camera')
  1079. ? <VideoSettingsButton
  1080. key = 'vsb'
  1081. visible = { true } />
  1082. : null;
  1083. }
  1084. /**
  1085. * Renders the toolbox content.
  1086. *
  1087. * @returns {ReactElement}
  1088. */
  1089. _renderToolboxContent() {
  1090. const {
  1091. _clientWidth,
  1092. _isMobile,
  1093. _overflowMenuVisible,
  1094. t
  1095. } = this.props;
  1096. const buttonSet = getToolbarAdditionalButtons(_clientWidth, _isMobile);
  1097. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  1098. const showOverflowMenuButton = buttonSet.has('overflow');
  1099. const containerClassName = `toolbox-content${_isMobile ? ' toolbox-content-mobile' : ''}`;
  1100. let overflowMenuAdditionalButtons = [];
  1101. let mainMenuAdditionalButtons = [];
  1102. if (showOverflowMenuButton) {
  1103. ({ overflowMenuAdditionalButtons, mainMenuAdditionalButtons } = this._getAdditionalButtons(buttonSet));
  1104. }
  1105. return (
  1106. <div className = { containerClassName }>
  1107. <div className = 'toolbox-content-wrapper'>
  1108. <InviteMore />
  1109. <div className = 'toolbox-content-items'>
  1110. { this._renderAudioButton() }
  1111. { this._renderVideoButton() }
  1112. { mainMenuAdditionalButtons }
  1113. { showOverflowMenuButton && <OverflowMenuButton
  1114. isOpen = { _overflowMenuVisible }
  1115. onVisibilityChange = { this._onSetOverflowVisible }>
  1116. <ul
  1117. aria-label = { t(toolbarAccLabel) }
  1118. className = 'overflow-menu'>
  1119. { this._renderOverflowMenuContent(overflowMenuAdditionalButtons) }
  1120. </ul>
  1121. </OverflowMenuButton>}
  1122. <HangupButton
  1123. customClass = 'hangup-button'
  1124. visible = { this._shouldShowButton('hangup') } />
  1125. </div>
  1126. </div>
  1127. </div>
  1128. );
  1129. }
  1130. _shouldShowButton: (string) => boolean;
  1131. /**
  1132. * Returns if a button name has been explicitly configured to be displayed.
  1133. *
  1134. * @param {string} buttonName - The name of the button, as expected in
  1135. * {@link interfaceConfig}.
  1136. * @private
  1137. * @returns {boolean} True if the button should be displayed.
  1138. */
  1139. _shouldShowButton(buttonName) {
  1140. return this.props._visibleButtons.includes(buttonName);
  1141. }
  1142. }
  1143. /**
  1144. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1145. * props.
  1146. *
  1147. * @param {Object} state - The redux store/state.
  1148. * @private
  1149. * @returns {{}}
  1150. */
  1151. function _mapStateToProps(state) {
  1152. const { conference, locked } = state['features/base/conference'];
  1153. let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
  1154. const {
  1155. callStatsID,
  1156. enableFeaturesBasedOnToken
  1157. } = state['features/base/config'];
  1158. const {
  1159. fullScreen,
  1160. overflowMenuVisible
  1161. } = state['features/toolbox'];
  1162. const localParticipant = getLocalParticipant(state);
  1163. const localRecordingStates = state['features/local-recording'];
  1164. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1165. const { clientWidth } = state['features/base/responsive-ui'];
  1166. let desktopSharingDisabledTooltipKey;
  1167. if (enableFeaturesBasedOnToken) {
  1168. // we enable desktop sharing if any participant already have this
  1169. // feature enabled
  1170. desktopSharingEnabled = getParticipants(state)
  1171. .find(({ features = {} }) =>
  1172. String(features['screen-sharing']) === 'true') !== undefined;
  1173. desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
  1174. }
  1175. return {
  1176. _chatOpen: state['features/chat'].isOpen,
  1177. _clientWidth: clientWidth,
  1178. _conference: conference,
  1179. _desktopSharingEnabled: desktopSharingEnabled,
  1180. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  1181. _dialog: Boolean(state['features/base/dialog'].component),
  1182. _feedbackConfigured: Boolean(callStatsID),
  1183. _isProfileDisabled: Boolean(state['features/base/config'].disableProfile),
  1184. _isMobile: isMobileBrowser(),
  1185. _isVpaasMeeting: isVpaasMeeting(state),
  1186. _fullScreen: fullScreen,
  1187. _tileViewEnabled: shouldDisplayTileView(state),
  1188. _localParticipantID: localParticipant.id,
  1189. _localRecState: localRecordingStates,
  1190. _locked: locked,
  1191. _overflowMenuVisible: overflowMenuVisible,
  1192. _raisedHand: localParticipant.raisedHand,
  1193. _screensharing: (localVideo && localVideo.videoType === 'desktop') || isScreenAudioShared(state),
  1194. _visible: isToolboxVisible(state),
  1195. _visibleButtons: getToolbarButtons(state)
  1196. };
  1197. }
  1198. export default translate(connect(_mapStateToProps)(Toolbox));