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 41KB

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