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

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