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. LocalRecordingButton,
  31. LocalRecordingInfoDialog
  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._onToolbarOpenLocalRecordingInfoDialog
  209. = this._onToolbarOpenLocalRecordingInfoDialog.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. onClick = {
  348. this._onToolbarOpenLocalRecordingInfoDialog
  349. } />
  350. }
  351. { this._shouldShowButton('invite')
  352. && !_hideInviteButton
  353. && <ToolbarButton
  354. accessibilityLabel =
  355. { t('toolbar.accessibilityLabel.invite') }
  356. iconName = 'icon-add'
  357. onClick = { this._onToolbarOpenInvite }
  358. tooltip = { t('toolbar.invite') } /> }
  359. { this._shouldShowButton('info') && <InfoDialogButton /> }
  360. { overflowHasItems
  361. && <OverflowMenuButton
  362. isOpen = { _overflowMenuVisible }
  363. onVisibilityChange = { this._onSetOverflowVisible }>
  364. <ul
  365. aria-label = { t(toolbarAccLabel) }
  366. className = 'overflow-menu'>
  367. { overflowMenuContent }
  368. </ul>
  369. </OverflowMenuButton> }
  370. </div>
  371. </div>
  372. );
  373. }
  374. /**
  375. * Callback invoked to display {@code FeedbackDialog}.
  376. *
  377. * @private
  378. * @returns {void}
  379. */
  380. _doOpenFeedback() {
  381. const { _conference } = this.props;
  382. this.props.dispatch(openFeedbackDialog(_conference));
  383. }
  384. /**
  385. * Dispatches an action to display {@code KeyboardShortcuts}.
  386. *
  387. * @private
  388. * @returns {void}
  389. */
  390. _doOpenKeyboardShorcuts() {
  391. this.props.dispatch(openKeyboardShortcutsDialog());
  392. }
  393. /**
  394. * Callback invoked to display {@code SpeakerStats}.
  395. *
  396. * @private
  397. * @returns {void}
  398. */
  399. _doOpenSpeakerStats() {
  400. this.props.dispatch(openDialog(SpeakerStats, {
  401. conference: this.props._conference
  402. }));
  403. }
  404. /**
  405. * Dispatches an action to toggle the video quality dialog.
  406. *
  407. * @private
  408. * @returns {void}
  409. */
  410. _doOpenVideoQuality() {
  411. this.props.dispatch(openDialog(VideoQualityDialog));
  412. }
  413. /**
  414. * Dispatches an action to toggle the display of chat.
  415. *
  416. * @private
  417. * @returns {void}
  418. */
  419. _doToggleChat() {
  420. this.props.dispatch(toggleChat());
  421. }
  422. /**
  423. * Dispatches an action to show or hide document editing.
  424. *
  425. * @private
  426. * @returns {void}
  427. */
  428. _doToggleEtherpad() {
  429. this.props.dispatch(toggleDocument());
  430. }
  431. /**
  432. * Dispatches an action to toggle screensharing.
  433. *
  434. * @private
  435. * @returns {void}
  436. */
  437. _doToggleFullScreen() {
  438. const fullScreen = !this.props._fullScreen;
  439. this.props.dispatch(setFullScreen(fullScreen));
  440. }
  441. /**
  442. * Dispatches an action to show or hide the profile edit panel.
  443. *
  444. * @private
  445. * @returns {void}
  446. */
  447. _doToggleProfile() {
  448. this.props.dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE));
  449. }
  450. /**
  451. * Dispatches an action to toggle the local participant's raised hand state.
  452. *
  453. * @private
  454. * @returns {void}
  455. */
  456. _doToggleRaiseHand() {
  457. const { _localParticipantID, _raisedHand } = this.props;
  458. this.props.dispatch(participantUpdated({
  459. // XXX Only the local participant is allowed to update without
  460. // stating the JitsiConference instance (i.e. participant property
  461. // `conference` for a remote participant) because the local
  462. // participant is uniquely identified by the very fact that there is
  463. // only one local participant.
  464. id: _localParticipantID,
  465. local: true,
  466. raisedHand: !_raisedHand
  467. }));
  468. }
  469. /**
  470. * Dispatches an action to toggle screensharing.
  471. *
  472. * @private
  473. * @returns {void}
  474. */
  475. _doToggleScreenshare() {
  476. if (this.props._desktopSharingEnabled) {
  477. this.props.dispatch(toggleScreensharing());
  478. }
  479. }
  480. /**
  481. * Dispatches an action to toggle YouTube video sharing.
  482. *
  483. * @private
  484. * @returns {void}
  485. */
  486. _doToggleSharedVideo() {
  487. this.props.dispatch(toggleSharedVideo());
  488. }
  489. _onMouseOut: () => void;
  490. /**
  491. * Dispatches an action signaling the toolbar is not being hovered.
  492. *
  493. * @private
  494. * @returns {void}
  495. */
  496. _onMouseOut() {
  497. this.props.dispatch(setToolbarHovered(false));
  498. }
  499. _onMouseOver: () => void;
  500. /**
  501. * Dispatches an action signaling the toolbar is being hovered.
  502. *
  503. * @private
  504. * @returns {void}
  505. */
  506. _onMouseOver() {
  507. this.props.dispatch(setToolbarHovered(true));
  508. }
  509. _onSetOverflowVisible: (boolean) => void;
  510. /**
  511. * Sets the visibility of the overflow menu.
  512. *
  513. * @param {boolean} visible - Whether or not the overflow menu should be
  514. * displayed.
  515. * @private
  516. * @returns {void}
  517. */
  518. _onSetOverflowVisible(visible) {
  519. this.props.dispatch(setOverflowMenuVisible(visible));
  520. }
  521. _onShortcutToggleChat: () => void;
  522. /**
  523. * Creates an analytics keyboard shortcut event and dispatches an action for
  524. * toggling the display of chat.
  525. *
  526. * @private
  527. * @returns {void}
  528. */
  529. _onShortcutToggleChat() {
  530. sendAnalytics(createShortcutEvent(
  531. 'toggle.chat',
  532. {
  533. enable: !this.props._chatOpen
  534. }));
  535. this._doToggleChat();
  536. }
  537. _onShortcutToggleFullScreen: () => void;
  538. /**
  539. * Creates an analytics keyboard shortcut event and dispatches an action for
  540. * toggling full screen mode.
  541. *
  542. * @private
  543. * @returns {void}
  544. */
  545. _onShortcutToggleFullScreen() {
  546. sendAnalytics(createShortcutEvent(
  547. 'toggle.fullscreen',
  548. {
  549. enable: !this.props._fullScreen
  550. }));
  551. this._doToggleFullScreen();
  552. }
  553. _onShortcutToggleRaiseHand: () => void;
  554. /**
  555. * Creates an analytics keyboard shortcut event and dispatches an action for
  556. * toggling raise hand.
  557. *
  558. * @private
  559. * @returns {void}
  560. */
  561. _onShortcutToggleRaiseHand() {
  562. sendAnalytics(createShortcutEvent(
  563. 'toggle.raise.hand',
  564. ACTION_SHORTCUT_TRIGGERED,
  565. { enable: !this.props._raisedHand }));
  566. this._doToggleRaiseHand();
  567. }
  568. _onShortcutToggleScreenshare: () => void;
  569. /**
  570. * Creates an analytics keyboard shortcut event and dispatches an action for
  571. * toggling screensharing.
  572. *
  573. * @private
  574. * @returns {void}
  575. */
  576. _onShortcutToggleScreenshare() {
  577. sendAnalytics(createToolbarEvent(
  578. 'screen.sharing',
  579. {
  580. enable: !this.props._screensharing
  581. }));
  582. this._doToggleScreenshare();
  583. }
  584. _onToolbarOpenFeedback: () => void;
  585. /**
  586. * Creates an analytics toolbar event and dispatches an action for toggling
  587. * display of feedback.
  588. *
  589. * @private
  590. * @returns {void}
  591. */
  592. _onToolbarOpenFeedback() {
  593. sendAnalytics(createToolbarEvent('feedback'));
  594. this._doOpenFeedback();
  595. }
  596. _onToolbarOpenInvite: () => void;
  597. /**
  598. * Creates an analytics toolbar event and dispatches an action for opening
  599. * the modal for inviting people directly into the conference.
  600. *
  601. * @private
  602. * @returns {void}
  603. */
  604. _onToolbarOpenInvite() {
  605. sendAnalytics(createToolbarEvent('invite'));
  606. this.props.dispatch(beginAddPeople());
  607. }
  608. _onToolbarOpenKeyboardShortcuts: () => void;
  609. /**
  610. * Creates an analytics toolbar event and dispatches an action for opening
  611. * the modal for showing available keyboard shortcuts.
  612. *
  613. * @private
  614. * @returns {void}
  615. */
  616. _onToolbarOpenKeyboardShortcuts() {
  617. sendAnalytics(createToolbarEvent('shortcuts'));
  618. this._doOpenKeyboardShorcuts();
  619. }
  620. _onToolbarOpenSpeakerStats: () => void;
  621. /**
  622. * Creates an analytics toolbar event and dispatches an action for opening
  623. * the speaker stats modal.
  624. *
  625. * @private
  626. * @returns {void}
  627. */
  628. _onToolbarOpenSpeakerStats() {
  629. sendAnalytics(createToolbarEvent('speaker.stats'));
  630. this._doOpenSpeakerStats();
  631. }
  632. _onToolbarOpenVideoQuality: () => void;
  633. /**
  634. * Creates an analytics toolbar event and dispatches an action for toggling
  635. * open the video quality dialog.
  636. *
  637. * @private
  638. * @returns {void}
  639. */
  640. _onToolbarOpenVideoQuality() {
  641. sendAnalytics(createToolbarEvent('video.quality'));
  642. this._doOpenVideoQuality();
  643. }
  644. _onToolbarToggleChat: () => void;
  645. /**
  646. * Creates an analytics toolbar event and dispatches an action for toggling
  647. * the display of chat.
  648. *
  649. * @private
  650. * @returns {void}
  651. */
  652. _onToolbarToggleChat() {
  653. sendAnalytics(createToolbarEvent(
  654. 'toggle.chat',
  655. {
  656. enable: !this.props._chatOpen
  657. }));
  658. this._doToggleChat();
  659. }
  660. _onToolbarToggleEtherpad: () => void;
  661. /**
  662. * Creates an analytics toolbar event and dispatches an action for toggling
  663. * the display of document editing.
  664. *
  665. * @private
  666. * @returns {void}
  667. */
  668. _onToolbarToggleEtherpad() {
  669. sendAnalytics(createToolbarEvent(
  670. 'toggle.etherpad',
  671. {
  672. enable: !this.props._editingDocument
  673. }));
  674. this._doToggleEtherpad();
  675. }
  676. _onToolbarToggleFullScreen: () => void;
  677. /**
  678. * Creates an analytics toolbar event and dispatches an action for toggling
  679. * full screen mode.
  680. *
  681. * @private
  682. * @returns {void}
  683. */
  684. _onToolbarToggleFullScreen() {
  685. sendAnalytics(createToolbarEvent(
  686. 'toggle.fullscreen',
  687. {
  688. enable: !this.props._fullScreen
  689. }));
  690. this._doToggleFullScreen();
  691. }
  692. _onToolbarToggleProfile: () => void;
  693. /**
  694. * Creates an analytics toolbar event and dispatches an action for showing
  695. * or hiding the profile edit panel.
  696. *
  697. * @private
  698. * @returns {void}
  699. */
  700. _onToolbarToggleProfile() {
  701. sendAnalytics(createToolbarEvent('profile'));
  702. this._doToggleProfile();
  703. }
  704. _onToolbarToggleRaiseHand: () => void;
  705. /**
  706. * Creates an analytics toolbar event and dispatches an action for toggling
  707. * raise hand.
  708. *
  709. * @private
  710. * @returns {void}
  711. */
  712. _onToolbarToggleRaiseHand() {
  713. sendAnalytics(createToolbarEvent(
  714. 'raise.hand',
  715. { enable: !this.props._raisedHand }));
  716. this._doToggleRaiseHand();
  717. }
  718. _onToolbarToggleScreenshare: () => void;
  719. /**
  720. * Creates an analytics toolbar event and dispatches an action for toggling
  721. * screensharing.
  722. *
  723. * @private
  724. * @returns {void}
  725. */
  726. _onToolbarToggleScreenshare() {
  727. if (!this.props._desktopSharingEnabled) {
  728. return;
  729. }
  730. sendAnalytics(createShortcutEvent(
  731. 'toggle.screen.sharing',
  732. ACTION_SHORTCUT_TRIGGERED,
  733. { enable: !this.props._screensharing }));
  734. this._doToggleScreenshare();
  735. }
  736. _onToolbarToggleSharedVideo: () => void;
  737. /**
  738. * Creates an analytics toolbar event and dispatches an action for toggling
  739. * the sharing of a YouTube video.
  740. *
  741. * @private
  742. * @returns {void}
  743. */
  744. _onToolbarToggleSharedVideo() {
  745. sendAnalytics(createToolbarEvent('shared.video.toggled',
  746. {
  747. enable: !this.props._sharingVideo
  748. }));
  749. this._doToggleSharedVideo();
  750. }
  751. _onToolbarOpenLocalRecordingInfoDialog: () => void;
  752. /**
  753. * Opens the {@code LocalRecordingInfoDialog}.
  754. *
  755. * @private
  756. * @returns {void}
  757. */
  758. _onToolbarOpenLocalRecordingInfoDialog() {
  759. sendAnalytics(createToolbarEvent('local.recording'));
  760. this.props.dispatch(openDialog(LocalRecordingInfoDialog));
  761. }
  762. /**
  763. * Renders a button for toggleing screen sharing.
  764. *
  765. * @private
  766. * @returns {ReactElement|null}
  767. */
  768. _renderDesktopSharingButton() {
  769. const {
  770. _desktopSharingEnabled,
  771. _desktopSharingDisabledTooltipKey,
  772. _screensharing,
  773. t
  774. } = this.props;
  775. const visible
  776. = _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  777. if (!visible) {
  778. return null;
  779. }
  780. const classNames = `icon-share-desktop ${
  781. _screensharing ? 'toggled' : ''} ${
  782. _desktopSharingEnabled ? '' : 'disabled'}`;
  783. const tooltip = t(
  784. _desktopSharingEnabled
  785. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey);
  786. return (
  787. <ToolbarButton
  788. accessibilityLabel
  789. = { t('toolbar.accessibilityLabel.shareYourScreen') }
  790. iconName = { classNames }
  791. onClick = { this._onToolbarToggleScreenshare }
  792. tooltip = { tooltip } />
  793. );
  794. }
  795. /**
  796. * Renders the list elements of the overflow menu.
  797. *
  798. * @private
  799. * @returns {Array<ReactElement>}
  800. */
  801. _renderOverflowMenuContent() {
  802. const {
  803. _editingDocument,
  804. _etherpadInitialized,
  805. _feedbackConfigured,
  806. _fullScreen,
  807. _isGuest,
  808. _sharingVideo,
  809. t
  810. } = this.props;
  811. return [
  812. _isGuest
  813. && this._shouldShowButton('profile')
  814. && <OverflowMenuProfileItem
  815. key = 'profile'
  816. onClick = { this._onToolbarToggleProfile } />,
  817. this._shouldShowButton('videoquality')
  818. && <OverflowMenuVideoQualityItem
  819. key = 'videoquality'
  820. onClick = { this._onToolbarOpenVideoQuality } />,
  821. this._shouldShowButton('fullscreen')
  822. && <OverflowMenuItem
  823. accessibilityLabel =
  824. { t('toolbar.accessibilityLabel.fullScreen') }
  825. icon = { _fullScreen
  826. ? 'icon-exit-full-screen'
  827. : 'icon-full-screen' }
  828. key = 'fullscreen'
  829. onClick = { this._onToolbarToggleFullScreen }
  830. text = { _fullScreen
  831. ? t('toolbar.exitFullScreen')
  832. : t('toolbar.enterFullScreen') } />,
  833. <LiveStreamButton
  834. key = 'livestreaming'
  835. showLabel = { true } />,
  836. <RecordButton
  837. key = 'record'
  838. showLabel = { true } />,
  839. this._shouldShowButton('sharedvideo')
  840. && <OverflowMenuItem
  841. accessibilityLabel =
  842. { t('toolbar.accessibilityLabel.sharedvideo') }
  843. icon = 'icon-shared-video'
  844. key = 'sharedvideo'
  845. onClick = { this._onToolbarToggleSharedVideo }
  846. text = { _sharingVideo
  847. ? t('toolbar.stopSharedVideo')
  848. : t('toolbar.sharedvideo') } />,
  849. this._shouldShowButton('etherpad')
  850. && _etherpadInitialized
  851. && <OverflowMenuItem
  852. accessibilityLabel =
  853. { t('toolbar.accessibilityLabel.document') }
  854. icon = 'icon-share-doc'
  855. key = 'etherpad'
  856. onClick = { this._onToolbarToggleEtherpad }
  857. text = { _editingDocument
  858. ? t('toolbar.documentClose')
  859. : t('toolbar.documentOpen') } />,
  860. <SettingsButton
  861. key = 'settings'
  862. showLabel = { true }
  863. visible = { this._shouldShowButton('settings') } />,
  864. this._shouldShowButton('stats')
  865. && <OverflowMenuItem
  866. accessibilityLabel =
  867. { t('toolbar.accessibilityLabel.speakerStats') }
  868. icon = 'icon-presentation'
  869. key = 'stats'
  870. onClick = { this._onToolbarOpenSpeakerStats }
  871. text = { t('toolbar.speakerStats') } />,
  872. this._shouldShowButton('feedback')
  873. && _feedbackConfigured
  874. && <OverflowMenuItem
  875. accessibilityLabel =
  876. { t('toolbar.accessibilityLabel.feedback') }
  877. icon = 'icon-feedback'
  878. key = 'feedback'
  879. onClick = { this._onToolbarOpenFeedback }
  880. text = { t('toolbar.feedback') } />,
  881. this._shouldShowButton('shortcuts')
  882. && <OverflowMenuItem
  883. accessibilityLabel =
  884. { t('toolbar.accessibilityLabel.shortcuts') }
  885. icon = 'icon-open_in_new'
  886. key = 'shortcuts'
  887. onClick = { this._onToolbarOpenKeyboardShortcuts }
  888. text = { t('toolbar.shortcuts') } />
  889. ];
  890. }
  891. _shouldShowButton: (string) => boolean;
  892. /**
  893. * Returns if a button name has been explicitly configured to be displayed.
  894. *
  895. * @param {string} buttonName - The name of the button, as expected in
  896. * {@link intefaceConfig}.
  897. * @private
  898. * @returns {boolean} True if the button should be displayed.
  899. */
  900. _shouldShowButton(buttonName) {
  901. return this.props._visibleButtons.has(buttonName);
  902. }
  903. }
  904. /**
  905. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  906. * props.
  907. *
  908. * @param {Object} state - The redux store/state.
  909. * @private
  910. * @returns {{}}
  911. */
  912. function _mapStateToProps(state) {
  913. const { conference } = state['features/base/conference'];
  914. let { desktopSharingEnabled } = state['features/base/conference'];
  915. const {
  916. callStatsID,
  917. iAmRecorder
  918. } = state['features/base/config'];
  919. let {
  920. transcribingEnabled
  921. } = state['features/base/config'];
  922. const sharedVideoStatus = state['features/shared-video'].status;
  923. const { current } = state['features/side-panel'];
  924. const {
  925. alwaysVisible,
  926. fullScreen,
  927. overflowMenuVisible,
  928. timeoutID,
  929. visible
  930. } = state['features/toolbox'];
  931. const localParticipant = getLocalParticipant(state);
  932. const localRecordingStates = state['features/local-recording'];
  933. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  934. const addPeopleEnabled = isAddPeopleEnabled(state);
  935. const dialOutEnabled = isDialOutEnabled(state);
  936. let desktopSharingDisabledTooltipKey;
  937. transcribingEnabled
  938. = isLocalParticipantModerator(state) && transcribingEnabled;
  939. if (state['features/base/config'].enableFeaturesBasedOnToken) {
  940. // we enable desktop sharing if any participant already have this
  941. // feature enabled
  942. desktopSharingEnabled = getParticipants(state)
  943. .find(({ features = {} }) =>
  944. String(features['screen-sharing']) === 'true') !== undefined;
  945. // we want to show button and tooltip
  946. if (state['features/base/jwt'].isGuest) {
  947. desktopSharingDisabledTooltipKey
  948. = 'dialog.shareYourScreenDisabledForGuest';
  949. } else {
  950. desktopSharingDisabledTooltipKey
  951. = 'dialog.shareYourScreenDisabled';
  952. }
  953. }
  954. return {
  955. _chatOpen: current === 'chat_container',
  956. _conference: conference,
  957. _desktopSharingEnabled: desktopSharingEnabled,
  958. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  959. _dialog: Boolean(state['features/base/dialog'].component),
  960. _editingDocument: Boolean(state['features/etherpad'].editing),
  961. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  962. _feedbackConfigured: Boolean(callStatsID),
  963. _hideInviteButton:
  964. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  965. _isGuest: state['features/base/jwt'].isGuest,
  966. _fullScreen: fullScreen,
  967. _localParticipantID: localParticipant.id,
  968. _localRecState: localRecordingStates,
  969. _overflowMenuVisible: overflowMenuVisible,
  970. _raisedHand: localParticipant.raisedHand,
  971. _screensharing: localVideo && localVideo.videoType === 'desktop',
  972. _transcribingEnabled: transcribingEnabled,
  973. _sharingVideo: sharedVideoStatus === 'playing'
  974. || sharedVideoStatus === 'start'
  975. || sharedVideoStatus === 'pause',
  976. _visible: Boolean(timeoutID || visible || alwaysVisible),
  977. // XXX: We are not currently using state here, but in the future, when
  978. // interfaceConfig is part of redux we will.
  979. _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
  980. };
  981. }
  982. export default translate(connect(_mapStateToProps)(Toolbox));