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.

ToolboxV2.web.js 32KB

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