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

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