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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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. * The subsection of Redux state for local recording
  120. */
  121. _localRecState: Object,
  122. /**
  123. * Whether or not the overflow menu is visible.
  124. */
  125. _overflowMenuVisible: boolean,
  126. /**
  127. * Whether or not the local participant's hand is raised.
  128. */
  129. _raisedHand: boolean,
  130. /**
  131. * Whether or not the local participant is screensharing.
  132. */
  133. _screensharing: boolean,
  134. /**
  135. * Whether or not the local participant is sharing a YouTube video.
  136. */
  137. _sharingVideo: boolean,
  138. /**
  139. * Whether or not transcribing is enabled.
  140. */
  141. _transcribingEnabled: boolean,
  142. /**
  143. * Flag showing whether toolbar is visible.
  144. */
  145. _visible: boolean,
  146. /**
  147. * Set with the buttons which this Toolbox should display.
  148. */
  149. _visibleButtons: Set<string>,
  150. /**
  151. * Invoked to active other features of the app.
  152. */
  153. dispatch: Function,
  154. /**
  155. * Invoked to obtain translated strings.
  156. */
  157. t: Function
  158. };
  159. declare var APP: Object;
  160. declare var interfaceConfig: Object;
  161. /**
  162. * Implements the conference toolbox on React/Web.
  163. *
  164. * @extends Component
  165. */
  166. class Toolbox extends Component<Props> {
  167. /**
  168. * Initializes a new {@code Toolbox} instance.
  169. *
  170. * @param {Props} props - The read-only React {@code Component} props with
  171. * which the new instance is to be initialized.
  172. */
  173. constructor(props: Props) {
  174. super(props);
  175. // Bind event handlers so they are only bound once per instance.
  176. this._onMouseOut = this._onMouseOut.bind(this);
  177. this._onMouseOver = this._onMouseOver.bind(this);
  178. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  179. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  180. this._onShortcutToggleFullScreen
  181. = this._onShortcutToggleFullScreen.bind(this);
  182. this._onShortcutToggleRaiseHand
  183. = this._onShortcutToggleRaiseHand.bind(this);
  184. this._onShortcutToggleScreenshare
  185. = this._onShortcutToggleScreenshare.bind(this);
  186. this._onToolbarOpenFeedback
  187. = this._onToolbarOpenFeedback.bind(this);
  188. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  189. this._onToolbarOpenKeyboardShortcuts
  190. = this._onToolbarOpenKeyboardShortcuts.bind(this);
  191. this._onToolbarOpenSpeakerStats
  192. = this._onToolbarOpenSpeakerStats.bind(this);
  193. this._onToolbarOpenVideoQuality
  194. = this._onToolbarOpenVideoQuality.bind(this);
  195. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  196. this._onToolbarToggleEtherpad
  197. = this._onToolbarToggleEtherpad.bind(this);
  198. this._onToolbarToggleFullScreen
  199. = this._onToolbarToggleFullScreen.bind(this);
  200. this._onToolbarToggleProfile
  201. = this._onToolbarToggleProfile.bind(this);
  202. this._onToolbarToggleRaiseHand
  203. = this._onToolbarToggleRaiseHand.bind(this);
  204. this._onToolbarToggleScreenshare
  205. = this._onToolbarToggleScreenshare.bind(this);
  206. this._onToolbarToggleSharedVideo
  207. = this._onToolbarToggleSharedVideo.bind(this);
  208. this._onToolbarToggleLocalRecordingInfoDialog
  209. = this._onToolbarToggleLocalRecordingInfoDialog.bind(this);
  210. }
  211. /**
  212. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  213. *
  214. * @inheritdoc
  215. * @returns {void}
  216. */
  217. componentDidMount() {
  218. const KEYBOARD_SHORTCUTS = [
  219. this._shouldShowButton('chat') && {
  220. character: 'C',
  221. exec: this._onShortcutToggleChat,
  222. helpDescription: 'keyboardShortcuts.toggleChat'
  223. },
  224. this._shouldShowButton('desktop') && {
  225. character: 'D',
  226. exec: this._onShortcutToggleScreenshare,
  227. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  228. },
  229. this._shouldShowButton('raisehand') && {
  230. character: 'R',
  231. exec: this._onShortcutToggleRaiseHand,
  232. helpDescription: 'keyboardShortcuts.raiseHand'
  233. },
  234. this._shouldShowButton('fullscreen') && {
  235. character: 'S',
  236. exec: this._onShortcutToggleFullScreen,
  237. helpDescription: 'keyboardShortcuts.fullScreen'
  238. }
  239. ];
  240. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  241. if (typeof shortcut === 'object') {
  242. APP.keyboardshortcut.registerShortcut(
  243. shortcut.character,
  244. null,
  245. shortcut.exec,
  246. shortcut.helpDescription);
  247. }
  248. });
  249. }
  250. /**
  251. * Update the visibility of the {@code OverflowMenuButton}.
  252. *
  253. * @inheritdoc
  254. */
  255. componentWillReceiveProps(nextProps) {
  256. // Ensure the dialog is closed when the toolbox becomes hidden.
  257. if (this.props._overflowMenuVisible && !nextProps._visible) {
  258. this._onSetOverflowVisible(false);
  259. }
  260. if (this.props._overflowMenuVisible
  261. && !this.props._dialog
  262. && nextProps._dialog) {
  263. this._onSetOverflowVisible(false);
  264. this.props.dispatch(setToolbarHovered(false));
  265. }
  266. }
  267. /**
  268. * Removes keyboard shortcuts registered by this component.
  269. *
  270. * @inheritdoc
  271. * @returns {void}
  272. */
  273. componentWillUnmount() {
  274. [ 'C', 'D', 'R', 'S' ].forEach(letter =>
  275. APP.keyboardshortcut.unregisterShortcut(letter));
  276. }
  277. /**
  278. * Implements React's {@link Component#render()}.
  279. *
  280. * @inheritdoc
  281. * @returns {ReactElement}
  282. */
  283. render() {
  284. const {
  285. _chatOpen,
  286. _hideInviteButton,
  287. _overflowMenuVisible,
  288. _transcribingEnabled,
  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. {
  331. _transcribingEnabled
  332. && this._shouldShowButton('closedcaptions')
  333. && <ClosedCaptionButton />
  334. }
  335. </div>
  336. <div className = 'button-group-center'>
  337. <AudioMuteButton
  338. visible = { this._shouldShowButton('microphone') } />
  339. <HangupButton
  340. visible = { this._shouldShowButton('hangup') } />
  341. <VideoMuteButton
  342. visible = { this._shouldShowButton('camera') } />
  343. </div>
  344. <div className = 'button-group-right'>
  345. { this._shouldShowButton('localrecording')
  346. && <LocalRecordingButton
  347. isDialogShown =
  348. { this.props._localRecState.showDialog }
  349. onClick = {
  350. this._onToolbarToggleLocalRecordingInfoDialog
  351. } />
  352. }
  353. { this._shouldShowButton('invite')
  354. && !_hideInviteButton
  355. && <ToolbarButton
  356. accessibilityLabel =
  357. { t('toolbar.accessibilityLabel.invite') }
  358. iconName = 'icon-add'
  359. onClick = { this._onToolbarOpenInvite }
  360. tooltip = { t('toolbar.invite') } /> }
  361. { this._shouldShowButton('info') && <InfoDialogButton /> }
  362. { overflowHasItems
  363. && <OverflowMenuButton
  364. isOpen = { _overflowMenuVisible }
  365. onVisibilityChange = { this._onSetOverflowVisible }>
  366. <ul
  367. aria-label = { t(toolbarAccLabel) }
  368. className = 'overflow-menu'>
  369. { overflowMenuContent }
  370. </ul>
  371. </OverflowMenuButton> }
  372. </div>
  373. </div>
  374. );
  375. }
  376. /**
  377. * Callback invoked to display {@code FeedbackDialog}.
  378. *
  379. * @private
  380. * @returns {void}
  381. */
  382. _doOpenFeedback() {
  383. const { _conference } = this.props;
  384. this.props.dispatch(openFeedbackDialog(_conference));
  385. }
  386. /**
  387. * Dispatches an action to display {@code KeyboardShortcuts}.
  388. *
  389. * @private
  390. * @returns {void}
  391. */
  392. _doOpenKeyboardShorcuts() {
  393. this.props.dispatch(openKeyboardShortcutsDialog());
  394. }
  395. /**
  396. * Callback invoked to display {@code SpeakerStats}.
  397. *
  398. * @private
  399. * @returns {void}
  400. */
  401. _doOpenSpeakerStats() {
  402. this.props.dispatch(openDialog(SpeakerStats, {
  403. conference: this.props._conference
  404. }));
  405. }
  406. /**
  407. * Dispatches an action to toggle the video quality dialog.
  408. *
  409. * @private
  410. * @returns {void}
  411. */
  412. _doOpenVideoQuality() {
  413. this.props.dispatch(openDialog(VideoQualityDialog));
  414. }
  415. /**
  416. * Dispatches an action to toggle the display of chat.
  417. *
  418. * @private
  419. * @returns {void}
  420. */
  421. _doToggleChat() {
  422. this.props.dispatch(toggleChat());
  423. }
  424. /**
  425. * Dispatches an action to show or hide document editing.
  426. *
  427. * @private
  428. * @returns {void}
  429. */
  430. _doToggleEtherpad() {
  431. this.props.dispatch(toggleDocument());
  432. }
  433. /**
  434. * Dispatches an action to toggle screensharing.
  435. *
  436. * @private
  437. * @returns {void}
  438. */
  439. _doToggleFullScreen() {
  440. const fullScreen = !this.props._fullScreen;
  441. this.props.dispatch(setFullScreen(fullScreen));
  442. }
  443. /**
  444. * Dispatches an action to show or hide the profile edit panel.
  445. *
  446. * @private
  447. * @returns {void}
  448. */
  449. _doToggleProfile() {
  450. this.props.dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE));
  451. }
  452. /**
  453. * Dispatches an action to toggle the local participant's raised hand state.
  454. *
  455. * @private
  456. * @returns {void}
  457. */
  458. _doToggleRaiseHand() {
  459. const { _localParticipantID, _raisedHand } = this.props;
  460. this.props.dispatch(participantUpdated({
  461. // XXX Only the local participant is allowed to update without
  462. // stating the JitsiConference instance (i.e. participant property
  463. // `conference` for a remote participant) because the local
  464. // participant is uniquely identified by the very fact that there is
  465. // only one local participant.
  466. id: _localParticipantID,
  467. local: true,
  468. raisedHand: !_raisedHand
  469. }));
  470. }
  471. /**
  472. * Dispatches an action to toggle screensharing.
  473. *
  474. * @private
  475. * @returns {void}
  476. */
  477. _doToggleScreenshare() {
  478. if (this.props._desktopSharingEnabled) {
  479. this.props.dispatch(toggleScreensharing());
  480. }
  481. }
  482. /**
  483. * Dispatches an action to toggle YouTube video sharing.
  484. *
  485. * @private
  486. * @returns {void}
  487. */
  488. _doToggleSharedVideo() {
  489. this.props.dispatch(toggleSharedVideo());
  490. }
  491. _onMouseOut: () => void;
  492. /**
  493. * Dispatches an action signaling the toolbar is not being hovered.
  494. *
  495. * @private
  496. * @returns {void}
  497. */
  498. _onMouseOut() {
  499. this.props.dispatch(setToolbarHovered(false));
  500. }
  501. _onMouseOver: () => void;
  502. /**
  503. * Dispatches an action signaling the toolbar is being hovered.
  504. *
  505. * @private
  506. * @returns {void}
  507. */
  508. _onMouseOver() {
  509. this.props.dispatch(setToolbarHovered(true));
  510. }
  511. _onSetOverflowVisible: (boolean) => void;
  512. /**
  513. * Sets the visibility of the overflow menu.
  514. *
  515. * @param {boolean} visible - Whether or not the overflow menu should be
  516. * displayed.
  517. * @private
  518. * @returns {void}
  519. */
  520. _onSetOverflowVisible(visible) {
  521. this.props.dispatch(setOverflowMenuVisible(visible));
  522. }
  523. _onShortcutToggleChat: () => void;
  524. /**
  525. * Creates an analytics keyboard shortcut event and dispatches an action for
  526. * toggling the display of chat.
  527. *
  528. * @private
  529. * @returns {void}
  530. */
  531. _onShortcutToggleChat() {
  532. sendAnalytics(createShortcutEvent(
  533. 'toggle.chat',
  534. {
  535. enable: !this.props._chatOpen
  536. }));
  537. this._doToggleChat();
  538. }
  539. _onShortcutToggleFullScreen: () => void;
  540. /**
  541. * Creates an analytics keyboard shortcut event and dispatches an action for
  542. * toggling full screen mode.
  543. *
  544. * @private
  545. * @returns {void}
  546. */
  547. _onShortcutToggleFullScreen() {
  548. sendAnalytics(createShortcutEvent(
  549. 'toggle.fullscreen',
  550. {
  551. enable: !this.props._fullScreen
  552. }));
  553. this._doToggleFullScreen();
  554. }
  555. _onShortcutToggleRaiseHand: () => void;
  556. /**
  557. * Creates an analytics keyboard shortcut event and dispatches an action for
  558. * toggling raise hand.
  559. *
  560. * @private
  561. * @returns {void}
  562. */
  563. _onShortcutToggleRaiseHand() {
  564. sendAnalytics(createShortcutEvent(
  565. 'toggle.raise.hand',
  566. ACTION_SHORTCUT_TRIGGERED,
  567. { enable: !this.props._raisedHand }));
  568. this._doToggleRaiseHand();
  569. }
  570. _onShortcutToggleScreenshare: () => void;
  571. /**
  572. * Creates an analytics keyboard shortcut event and dispatches an action for
  573. * toggling screensharing.
  574. *
  575. * @private
  576. * @returns {void}
  577. */
  578. _onShortcutToggleScreenshare() {
  579. sendAnalytics(createToolbarEvent(
  580. 'screen.sharing',
  581. {
  582. enable: !this.props._screensharing
  583. }));
  584. this._doToggleScreenshare();
  585. }
  586. _onToolbarOpenFeedback: () => void;
  587. /**
  588. * Creates an analytics toolbar event and dispatches an action for toggling
  589. * display of feedback.
  590. *
  591. * @private
  592. * @returns {void}
  593. */
  594. _onToolbarOpenFeedback() {
  595. sendAnalytics(createToolbarEvent('feedback'));
  596. this._doOpenFeedback();
  597. }
  598. _onToolbarOpenInvite: () => void;
  599. /**
  600. * Creates an analytics toolbar event and dispatches an action for opening
  601. * the modal for inviting people directly into the conference.
  602. *
  603. * @private
  604. * @returns {void}
  605. */
  606. _onToolbarOpenInvite() {
  607. sendAnalytics(createToolbarEvent('invite'));
  608. this.props.dispatch(beginAddPeople());
  609. }
  610. _onToolbarOpenKeyboardShortcuts: () => void;
  611. /**
  612. * Creates an analytics toolbar event and dispatches an action for opening
  613. * the modal for showing available keyboard shortcuts.
  614. *
  615. * @private
  616. * @returns {void}
  617. */
  618. _onToolbarOpenKeyboardShortcuts() {
  619. sendAnalytics(createToolbarEvent('shortcuts'));
  620. this._doOpenKeyboardShorcuts();
  621. }
  622. _onToolbarOpenSpeakerStats: () => void;
  623. /**
  624. * Creates an analytics toolbar event and dispatches an action for opening
  625. * the speaker stats modal.
  626. *
  627. * @private
  628. * @returns {void}
  629. */
  630. _onToolbarOpenSpeakerStats() {
  631. sendAnalytics(createToolbarEvent('speaker.stats'));
  632. this._doOpenSpeakerStats();
  633. }
  634. _onToolbarOpenVideoQuality: () => void;
  635. /**
  636. * Creates an analytics toolbar event and dispatches an action for toggling
  637. * open the video quality dialog.
  638. *
  639. * @private
  640. * @returns {void}
  641. */
  642. _onToolbarOpenVideoQuality() {
  643. sendAnalytics(createToolbarEvent('video.quality'));
  644. this._doOpenVideoQuality();
  645. }
  646. _onToolbarToggleChat: () => void;
  647. /**
  648. * Creates an analytics toolbar event and dispatches an action for toggling
  649. * the display of chat.
  650. *
  651. * @private
  652. * @returns {void}
  653. */
  654. _onToolbarToggleChat() {
  655. sendAnalytics(createToolbarEvent(
  656. 'toggle.chat',
  657. {
  658. enable: !this.props._chatOpen
  659. }));
  660. this._doToggleChat();
  661. }
  662. _onToolbarToggleEtherpad: () => void;
  663. /**
  664. * Creates an analytics toolbar event and dispatches an action for toggling
  665. * the display of document editing.
  666. *
  667. * @private
  668. * @returns {void}
  669. */
  670. _onToolbarToggleEtherpad() {
  671. sendAnalytics(createToolbarEvent(
  672. 'toggle.etherpad',
  673. {
  674. enable: !this.props._editingDocument
  675. }));
  676. this._doToggleEtherpad();
  677. }
  678. _onToolbarToggleFullScreen: () => void;
  679. /**
  680. * Creates an analytics toolbar event and dispatches an action for toggling
  681. * full screen mode.
  682. *
  683. * @private
  684. * @returns {void}
  685. */
  686. _onToolbarToggleFullScreen() {
  687. sendAnalytics(createToolbarEvent(
  688. 'toggle.fullscreen',
  689. {
  690. enable: !this.props._fullScreen
  691. }));
  692. this._doToggleFullScreen();
  693. }
  694. _onToolbarToggleProfile: () => void;
  695. /**
  696. * Creates an analytics toolbar event and dispatches an action for showing
  697. * or hiding the profile edit panel.
  698. *
  699. * @private
  700. * @returns {void}
  701. */
  702. _onToolbarToggleProfile() {
  703. sendAnalytics(createToolbarEvent('profile'));
  704. this._doToggleProfile();
  705. }
  706. _onToolbarToggleRaiseHand: () => void;
  707. /**
  708. * Creates an analytics toolbar event and dispatches an action for toggling
  709. * raise hand.
  710. *
  711. * @private
  712. * @returns {void}
  713. */
  714. _onToolbarToggleRaiseHand() {
  715. sendAnalytics(createToolbarEvent(
  716. 'raise.hand',
  717. { enable: !this.props._raisedHand }));
  718. this._doToggleRaiseHand();
  719. }
  720. _onToolbarToggleScreenshare: () => void;
  721. /**
  722. * Creates an analytics toolbar event and dispatches an action for toggling
  723. * screensharing.
  724. *
  725. * @private
  726. * @returns {void}
  727. */
  728. _onToolbarToggleScreenshare() {
  729. if (!this.props._desktopSharingEnabled) {
  730. return;
  731. }
  732. sendAnalytics(createShortcutEvent(
  733. 'toggle.screen.sharing',
  734. ACTION_SHORTCUT_TRIGGERED,
  735. { enable: !this.props._screensharing }));
  736. this._doToggleScreenshare();
  737. }
  738. _onToolbarToggleSharedVideo: () => void;
  739. /**
  740. * Creates an analytics toolbar event and dispatches an action for toggling
  741. * the sharing of a YouTube video.
  742. *
  743. * @private
  744. * @returns {void}
  745. */
  746. _onToolbarToggleSharedVideo() {
  747. sendAnalytics(createToolbarEvent('shared.video.toggled',
  748. {
  749. enable: !this.props._sharingVideo
  750. }));
  751. this._doToggleSharedVideo();
  752. }
  753. _onToolbarToggleLocalRecordingInfoDialog: () => void;
  754. /**
  755. * Switches local recording on or off.
  756. *
  757. * @private
  758. * @returns {void}
  759. */
  760. _onToolbarToggleLocalRecordingInfoDialog() {
  761. this.props.dispatch(toggleLocalRecordingInfoDialog());
  762. }
  763. /**
  764. * Renders a button for toggleing screen sharing.
  765. *
  766. * @private
  767. * @returns {ReactElement|null}
  768. */
  769. _renderDesktopSharingButton() {
  770. const {
  771. _desktopSharingEnabled,
  772. _desktopSharingDisabledTooltipKey,
  773. _screensharing,
  774. t
  775. } = this.props;
  776. const visible
  777. = _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  778. if (!visible) {
  779. return null;
  780. }
  781. const classNames = `icon-share-desktop ${
  782. _screensharing ? 'toggled' : ''} ${
  783. _desktopSharingEnabled ? '' : 'disabled'}`;
  784. const tooltip = t(
  785. _desktopSharingEnabled
  786. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey);
  787. return (
  788. <ToolbarButton
  789. accessibilityLabel
  790. = { t('toolbar.accessibilityLabel.shareYourScreen') }
  791. iconName = { classNames }
  792. onClick = { this._onToolbarToggleScreenshare }
  793. tooltip = { tooltip } />
  794. );
  795. }
  796. /**
  797. * Renders the list elements of the overflow menu.
  798. *
  799. * @private
  800. * @returns {Array<ReactElement>}
  801. */
  802. _renderOverflowMenuContent() {
  803. const {
  804. _editingDocument,
  805. _etherpadInitialized,
  806. _feedbackConfigured,
  807. _fullScreen,
  808. _isGuest,
  809. _sharingVideo,
  810. t
  811. } = this.props;
  812. return [
  813. _isGuest
  814. && this._shouldShowButton('profile')
  815. && <OverflowMenuProfileItem
  816. key = 'profile'
  817. onClick = { this._onToolbarToggleProfile } />,
  818. this._shouldShowButton('videoquality')
  819. && <OverflowMenuVideoQualityItem
  820. key = 'videoquality'
  821. onClick = { this._onToolbarOpenVideoQuality } />,
  822. this._shouldShowButton('fullscreen')
  823. && <OverflowMenuItem
  824. accessibilityLabel =
  825. { t('toolbar.accessibilityLabel.fullScreen') }
  826. icon = { _fullScreen
  827. ? 'icon-exit-full-screen'
  828. : 'icon-full-screen' }
  829. key = 'fullscreen'
  830. onClick = { this._onToolbarToggleFullScreen }
  831. text = { _fullScreen
  832. ? t('toolbar.exitFullScreen')
  833. : t('toolbar.enterFullScreen') } />,
  834. <LiveStreamButton
  835. key = 'livestreaming'
  836. showLabel = { true } />,
  837. <RecordButton
  838. key = 'record'
  839. showLabel = { true } />,
  840. this._shouldShowButton('sharedvideo')
  841. && <OverflowMenuItem
  842. accessibilityLabel =
  843. { t('toolbar.accessibilityLabel.sharedvideo') }
  844. icon = 'icon-shared-video'
  845. key = 'sharedvideo'
  846. onClick = { this._onToolbarToggleSharedVideo }
  847. text = { _sharingVideo
  848. ? t('toolbar.stopSharedVideo')
  849. : t('toolbar.sharedvideo') } />,
  850. this._shouldShowButton('etherpad')
  851. && _etherpadInitialized
  852. && <OverflowMenuItem
  853. accessibilityLabel =
  854. { t('toolbar.accessibilityLabel.document') }
  855. icon = 'icon-share-doc'
  856. key = 'etherpad'
  857. onClick = { this._onToolbarToggleEtherpad }
  858. text = { _editingDocument
  859. ? t('toolbar.documentClose')
  860. : t('toolbar.documentOpen') } />,
  861. <SettingsButton
  862. key = 'settings'
  863. showLabel = { true }
  864. visible = { this._shouldShowButton('settings') } />,
  865. this._shouldShowButton('stats')
  866. && <OverflowMenuItem
  867. accessibilityLabel =
  868. { t('toolbar.accessibilityLabel.speakerStats') }
  869. icon = 'icon-presentation'
  870. key = 'stats'
  871. onClick = { this._onToolbarOpenSpeakerStats }
  872. text = { t('toolbar.speakerStats') } />,
  873. this._shouldShowButton('feedback')
  874. && _feedbackConfigured
  875. && <OverflowMenuItem
  876. accessibilityLabel =
  877. { t('toolbar.accessibilityLabel.feedback') }
  878. icon = 'icon-feedback'
  879. key = 'feedback'
  880. onClick = { this._onToolbarOpenFeedback }
  881. text = { t('toolbar.feedback') } />,
  882. this._shouldShowButton('shortcuts')
  883. && <OverflowMenuItem
  884. accessibilityLabel =
  885. { t('toolbar.accessibilityLabel.shortcuts') }
  886. icon = 'icon-open_in_new'
  887. key = 'shortcuts'
  888. onClick = { this._onToolbarOpenKeyboardShortcuts }
  889. text = { t('toolbar.shortcuts') } />
  890. ];
  891. }
  892. _shouldShowButton: (string) => boolean;
  893. /**
  894. * Returns if a button name has been explicitly configured to be displayed.
  895. *
  896. * @param {string} buttonName - The name of the button, as expected in
  897. * {@link intefaceConfig}.
  898. * @private
  899. * @returns {boolean} True if the button should be displayed.
  900. */
  901. _shouldShowButton(buttonName) {
  902. return this.props._visibleButtons.has(buttonName);
  903. }
  904. }
  905. /**
  906. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  907. * props.
  908. *
  909. * @param {Object} state - The redux store/state.
  910. * @private
  911. * @returns {{}}
  912. */
  913. function _mapStateToProps(state) {
  914. const { conference } = state['features/base/conference'];
  915. let { desktopSharingEnabled } = state['features/base/conference'];
  916. const {
  917. callStatsID,
  918. iAmRecorder
  919. } = state['features/base/config'];
  920. let {
  921. transcribingEnabled
  922. } = state['features/base/config'];
  923. const sharedVideoStatus = state['features/shared-video'].status;
  924. const { current } = state['features/side-panel'];
  925. const {
  926. alwaysVisible,
  927. fullScreen,
  928. overflowMenuVisible,
  929. timeoutID,
  930. visible
  931. } = state['features/toolbox'];
  932. const localParticipant = getLocalParticipant(state);
  933. const localRecordingStates = state['features/local-recording'];
  934. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  935. const addPeopleEnabled = isAddPeopleEnabled(state);
  936. const dialOutEnabled = isDialOutEnabled(state);
  937. let desktopSharingDisabledTooltipKey;
  938. transcribingEnabled
  939. = isLocalParticipantModerator(state) && transcribingEnabled;
  940. if (state['features/base/config'].enableFeaturesBasedOnToken) {
  941. // we enable desktop sharing if any participant already have this
  942. // feature enabled
  943. desktopSharingEnabled = getParticipants(state)
  944. .find(({ features = {} }) =>
  945. String(features['screen-sharing']) === 'true') !== undefined;
  946. // we want to show button and tooltip
  947. if (state['features/base/jwt'].isGuest) {
  948. desktopSharingDisabledTooltipKey
  949. = 'dialog.shareYourScreenDisabledForGuest';
  950. } else {
  951. desktopSharingDisabledTooltipKey
  952. = 'dialog.shareYourScreenDisabled';
  953. }
  954. }
  955. return {
  956. _chatOpen: current === 'chat_container',
  957. _conference: conference,
  958. _desktopSharingEnabled: desktopSharingEnabled,
  959. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  960. _dialog: Boolean(state['features/base/dialog'].component),
  961. _editingDocument: Boolean(state['features/etherpad'].editing),
  962. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  963. _feedbackConfigured: Boolean(callStatsID),
  964. _hideInviteButton:
  965. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  966. _isGuest: state['features/base/jwt'].isGuest,
  967. _fullScreen: fullScreen,
  968. _localParticipantID: localParticipant.id,
  969. _localRecState: localRecordingStates,
  970. _overflowMenuVisible: overflowMenuVisible,
  971. _raisedHand: localParticipant.raisedHand,
  972. _screensharing: localVideo && localVideo.videoType === 'desktop',
  973. _transcribingEnabled: transcribingEnabled,
  974. _sharingVideo: sharedVideoStatus === 'playing'
  975. || sharedVideoStatus === 'start'
  976. || sharedVideoStatus === 'pause',
  977. _visible: Boolean(timeoutID || visible || alwaysVisible),
  978. // XXX: We are not currently using state here, but in the future, when
  979. // interfaceConfig is part of redux we will.
  980. _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
  981. };
  982. }
  983. export default translate(connect(_mapStateToProps)(Toolbox));