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

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