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

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