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

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