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.web.js 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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 {
  23. beginAddPeople,
  24. InfoDialogButton,
  25. isAddPeopleEnabled,
  26. isDialOutEnabled
  27. } from '../../invite';
  28. import { openKeyboardShortcutsDialog } from '../../keyboard-shortcuts';
  29. import { RECORDING_TYPES, toggleRecording } from '../../recording';
  30. import { toggleSharedVideo } from '../../shared-video';
  31. import { shouldShowOnlyDeviceSelection } from '../../settings';
  32. import { toggleChat, toggleProfile, toggleSettings } from '../../side-panel';
  33. import { SpeakerStats } from '../../speaker-stats';
  34. import {
  35. OverflowMenuVideoQualityItem,
  36. VideoQualityDialog
  37. } from '../../video-quality';
  38. import { setFullScreen, setToolbarHovered } from '../actions';
  39. import OverflowMenuButton from './OverflowMenuButton';
  40. import OverflowMenuItem from './OverflowMenuItem';
  41. import OverflowMenuProfileItem from './OverflowMenuProfileItem';
  42. import ToolbarButton from './ToolbarButton';
  43. import { AudioMuteButton, HangupButton, VideoMuteButton } from './buttons';
  44. type Props = {
  45. /**
  46. * Whether or not the chat feature is currently displayed.
  47. */
  48. _chatOpen: boolean,
  49. /**
  50. * The {@code JitsiConference} for the current conference.
  51. */
  52. _conference: Object,
  53. /**
  54. * Whether or not desktopsharing was explicitly configured to be disabled.
  55. */
  56. _desktopSharingDisabledByConfig: boolean,
  57. /**
  58. * Whether or not screensharing is initialized.
  59. */
  60. _desktopSharingEnabled: boolean,
  61. /**
  62. * Whether or not a dialog is displayed.
  63. */
  64. _dialog: boolean,
  65. /**
  66. * Whether or not the local participant is currently editing a document.
  67. */
  68. _editingDocument: boolean,
  69. /**
  70. * Whether or not collaborative document editing is enabled.
  71. */
  72. _etherpadInitialized: boolean,
  73. /**
  74. * Whether or not call feedback can be sent.
  75. */
  76. _feedbackConfigured: boolean,
  77. /**
  78. * Whether or not the app is currently in full screen.
  79. */
  80. _fullScreen: boolean,
  81. /**
  82. * Whether or not invite should be hidden, regardless of feature
  83. * availability.
  84. */
  85. _hideInviteButton: boolean,
  86. /**
  87. * Whether or not the current user is logged in through a JWT.
  88. */
  89. _isGuest: boolean,
  90. /**
  91. * Whether or not the conference is currently being recorded by the local
  92. * participant.
  93. */
  94. _isRecording: boolean,
  95. /**
  96. * The ID of the local participant.
  97. */
  98. _localParticipantID: String,
  99. /**
  100. * Whether or not the local participant's hand is raised.
  101. */
  102. _raisedHand: boolean,
  103. /**
  104. * Whether or not the recording feature is enabled for use.
  105. */
  106. _recordingEnabled: boolean,
  107. /**
  108. * Whether the recording feature is live streaming (jibri) or is file
  109. * recording (jirecon).
  110. */
  111. _recordingType: String,
  112. /**
  113. * Whether or not the local participant is screensharing.
  114. */
  115. _screensharing: boolean,
  116. /**
  117. * Whether or not the local participant is sharing a YouTube video.
  118. */
  119. _sharingVideo: boolean,
  120. /**
  121. * Flag showing whether toolbar is visible.
  122. */
  123. _visible: boolean,
  124. /**
  125. * Invoked to active other features of the app.
  126. */
  127. dispatch: Function,
  128. /**
  129. * Invoked to obtain translated strings.
  130. */
  131. t: Function
  132. }
  133. type State = {
  134. /**
  135. * Whether or not the overflow menu is visible.
  136. */
  137. showOverflowMenu: boolean
  138. }
  139. declare var APP: Object;
  140. declare var interfaceConfig: Object;
  141. /**
  142. * Implements the conference toolbox on React/Web.
  143. *
  144. * @extends Component
  145. */
  146. class Toolbox extends Component<Props, State> {
  147. _visibleButtons: Object;
  148. state = {
  149. showOverflowMenu: false
  150. }
  151. /**
  152. * Initializes a new {@code Toolbox} instance.
  153. *
  154. * @param {Props} props - The read-only React {@code Component} props with
  155. * which the new instance is to be initialized.
  156. */
  157. constructor(props: Props) {
  158. super(props);
  159. this._visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  160. // Bind event handlers so they are only bound once per instance.
  161. this._onMouseOut = this._onMouseOut.bind(this);
  162. this._onMouseOver = this._onMouseOver.bind(this);
  163. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  164. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  165. this._onShortcutToggleFullScreen
  166. = this._onShortcutToggleFullScreen.bind(this);
  167. this._onShortcutToggleRaiseHand
  168. = this._onShortcutToggleRaiseHand.bind(this);
  169. this._onShortcutToggleScreenshare
  170. = this._onShortcutToggleScreenshare.bind(this);
  171. this._onToolbarOpenFeedback
  172. = this._onToolbarOpenFeedback.bind(this);
  173. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  174. this._onToolbarOpenKeyboardShortcuts
  175. = this._onToolbarOpenKeyboardShortcuts.bind(this);
  176. this._onToolbarOpenSpeakerStats
  177. = this._onToolbarOpenSpeakerStats.bind(this);
  178. this._onToolbarOpenVideoQuality
  179. = this._onToolbarOpenVideoQuality.bind(this);
  180. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  181. this._onToolbarToggleEtherpad
  182. = this._onToolbarToggleEtherpad.bind(this);
  183. this._onToolbarToggleFullScreen
  184. = this._onToolbarToggleFullScreen.bind(this);
  185. this._onToolbarToggleProfile
  186. = this._onToolbarToggleProfile.bind(this);
  187. this._onToolbarToggleRaiseHand
  188. = this._onToolbarToggleRaiseHand.bind(this);
  189. this._onToolbarToggleRecording
  190. = this._onToolbarToggleRecording.bind(this);
  191. this._onToolbarToggleScreenshare
  192. = this._onToolbarToggleScreenshare.bind(this);
  193. this._onToolbarToggleSettings
  194. = this._onToolbarToggleSettings.bind(this);
  195. this._onToolbarToggleSharedVideo
  196. = this._onToolbarToggleSharedVideo.bind(this);
  197. }
  198. /**
  199. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  200. *
  201. * @inheritdoc
  202. * @returns {void}
  203. */
  204. componentDidMount() {
  205. const KEYBOARD_SHORTCUTS = [
  206. this._shouldShowButton('chat') && {
  207. character: 'C',
  208. exec: this._onShortcutToggleChat,
  209. helpDescription: 'keyboardShortcuts.toggleChat'
  210. },
  211. this._shouldShowButton('desktop') && {
  212. character: 'D',
  213. exec: this._onShortcutToggleScreenshare,
  214. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  215. },
  216. this._shouldShowButton('raisehand') && {
  217. character: 'R',
  218. exec: this._onShortcutToggleRaiseHand,
  219. helpDescription: 'keyboardShortcuts.raiseHand'
  220. },
  221. this._shouldShowButton('fullscreen') && {
  222. character: 'S',
  223. exec: this._onShortcutToggleFullScreen,
  224. helpDescription: 'keyboardShortcuts.fullScreen'
  225. }
  226. ];
  227. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  228. if (typeof shortcut === 'object') {
  229. APP.keyboardshortcut.registerShortcut(
  230. shortcut.character,
  231. null,
  232. shortcut.exec,
  233. shortcut.helpDescription);
  234. }
  235. });
  236. }
  237. /**
  238. * Update the visibility of the {@code OverflowMenuButton}.
  239. *
  240. * @inheritdoc
  241. */
  242. componentWillReceiveProps(nextProps) {
  243. // Ensure the dialog is closed when the toolbox becomes hidden.
  244. if (this.state.showOverflowMenu && !nextProps._visible) {
  245. this._onSetOverflowVisible(false);
  246. }
  247. if (this.state.showOverflowMenu
  248. && !this.props._dialog
  249. && nextProps._dialog) {
  250. this._onSetOverflowVisible(false);
  251. this.props.dispatch(setToolbarHovered(false));
  252. }
  253. }
  254. /**
  255. * Removes keyboard shortcuts registered by this component.
  256. *
  257. * @inheritdoc
  258. * @returns {void}
  259. */
  260. componentWillUnmount() {
  261. [ 'C', 'D', 'R', 'S' ].forEach(letter =>
  262. APP.keyboardshortcut.unregisterShortcut(letter));
  263. }
  264. /**
  265. * Implements React's {@link Component#render()}.
  266. *
  267. * @inheritdoc
  268. * @returns {ReactElement}
  269. */
  270. render() {
  271. const {
  272. _chatOpen,
  273. _hideInviteButton,
  274. _raisedHand,
  275. _visible,
  276. t
  277. } = this.props;
  278. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  279. this._visibleButtons.size ? '' : 'no-buttons'}`;
  280. const overflowMenuContent = this._renderOverflowMenuContent();
  281. const overflowHasItems = Boolean(overflowMenuContent.filter(
  282. child => child).length);
  283. return (
  284. <div
  285. className = { rootClassNames }
  286. id = 'new-toolbox'
  287. onMouseOut = { this._onMouseOut }
  288. onMouseOver = { this._onMouseOver }>
  289. <div className = 'button-group-left'>
  290. { this._shouldShowButton('desktop')
  291. && this._renderDesktopSharingButton() }
  292. { this._shouldShowButton('raisehand')
  293. && <ToolbarButton
  294. accessibilityLabel = 'Raised hand'
  295. iconName = { _raisedHand
  296. ? 'icon-raised-hand toggled'
  297. : 'icon-raised-hand' }
  298. onClick = { this._onToolbarToggleRaiseHand }
  299. tooltip = { t('toolbar.raiseHand') } /> }
  300. { this._shouldShowButton('chat')
  301. && <div className = 'toolbar-button-with-badge'>
  302. <ToolbarButton
  303. accessibilityLabel = 'Chat'
  304. iconName = { _chatOpen
  305. ? 'icon-chat toggled'
  306. : 'icon-chat' }
  307. onClick = { this._onToolbarToggleChat }
  308. tooltip = { t('toolbar.chat') } />
  309. <ChatCounter />
  310. </div> }
  311. </div>
  312. <div className = 'button-group-center'>
  313. <AudioMuteButton
  314. visible = { this._shouldShowButton('microphone') } />
  315. <HangupButton
  316. visible = { this._shouldShowButton('hangup') } />
  317. <VideoMuteButton
  318. visible = { this._shouldShowButton('camera') } />
  319. </div>
  320. <div className = 'button-group-right'>
  321. { this._shouldShowButton('invite')
  322. && !_hideInviteButton
  323. && <ToolbarButton
  324. accessibilityLabel = 'Invite'
  325. iconName = 'icon-add'
  326. onClick = { this._onToolbarOpenInvite }
  327. tooltip = { t('toolbar.invite') } /> }
  328. { this._shouldShowButton('info') && <InfoDialogButton /> }
  329. { overflowHasItems
  330. && <OverflowMenuButton
  331. isOpen = { this.state.showOverflowMenu }
  332. onVisibilityChange = { this._onSetOverflowVisible }>
  333. <ul
  334. aria-label = 'Overflow menu'
  335. className = 'overflow-menu'>
  336. { overflowMenuContent }
  337. </ul>
  338. </OverflowMenuButton> }
  339. </div>
  340. </div>
  341. );
  342. }
  343. /**
  344. * Callback invoked to display {@code FeedbackDialog}.
  345. *
  346. * @private
  347. * @returns {void}
  348. */
  349. _doOpenFeedback() {
  350. const { _conference } = this.props;
  351. this.props.dispatch(openFeedbackDialog(_conference));
  352. }
  353. /**
  354. * Dispatches an action to display {@code KeyboardShortcuts}.
  355. *
  356. * @private
  357. * @returns {void}
  358. */
  359. _doOpenKeyboardShorcuts() {
  360. this.props.dispatch(openKeyboardShortcutsDialog());
  361. }
  362. /**
  363. * Callback invoked to display {@code SpeakerStats}.
  364. *
  365. * @private
  366. * @returns {void}
  367. */
  368. _doOpenSpeakerStats() {
  369. this.props.dispatch(openDialog(SpeakerStats, {
  370. conference: this.props._conference
  371. }));
  372. }
  373. /**
  374. * Dispatches an action to toggle the video quality dialog.
  375. *
  376. * @private
  377. * @returns {void}
  378. */
  379. _doOpenVideoQuality() {
  380. this.props.dispatch(openDialog(VideoQualityDialog));
  381. }
  382. /**
  383. * Dispatches an action to toggle the display of chat.
  384. *
  385. * @private
  386. * @returns {void}
  387. */
  388. _doToggleChat() {
  389. this.props.dispatch(toggleChat());
  390. }
  391. /**
  392. * Dispatches an action to show or hide document editing.
  393. *
  394. * @private
  395. * @returns {void}
  396. */
  397. _doToggleEtherpad() {
  398. this.props.dispatch(toggleDocument());
  399. }
  400. /**
  401. * Dispatches an action to toggle screensharing.
  402. *
  403. * @private
  404. * @returns {void}
  405. */
  406. _doToggleFullScreen() {
  407. const fullScreen = !this.props._fullScreen;
  408. this.props.dispatch(setFullScreen(fullScreen));
  409. }
  410. /**
  411. * Dispatches an action to show or hide the profile edit panel.
  412. *
  413. * @private
  414. * @returns {void}
  415. */
  416. _doToggleProfile() {
  417. this.props.dispatch(toggleProfile());
  418. }
  419. /**
  420. * Dispatches an action to toggle the local participant's raised hand state.
  421. *
  422. * @private
  423. * @returns {void}
  424. */
  425. _doToggleRaiseHand() {
  426. const { _localParticipantID, _raisedHand } = this.props;
  427. this.props.dispatch(participantUpdated({
  428. id: _localParticipantID,
  429. local: true,
  430. raisedHand: !_raisedHand
  431. }));
  432. }
  433. /**
  434. * Dispatches an action to toggle recording.
  435. *
  436. * @private
  437. * @returns {void}
  438. */
  439. _doToggleRecording() {
  440. this.props.dispatch(toggleRecording());
  441. }
  442. /**
  443. * Dispatches an action to toggle screensharing.
  444. *
  445. * @private
  446. * @returns {void}
  447. */
  448. _doToggleScreenshare() {
  449. if (this.props._desktopSharingEnabled) {
  450. this.props.dispatch(toggleScreensharing());
  451. }
  452. }
  453. /**
  454. * Dispatches an action to toggle display of settings, be it the settings
  455. * panel or directly to device selection.
  456. *
  457. * @private
  458. * @returns {void}
  459. */
  460. _doToggleSettings() {
  461. if (shouldShowOnlyDeviceSelection()) {
  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.props.dispatch(beginAddPeople());
  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. if (!this.props._desktopSharingEnabled) {
  739. return;
  740. }
  741. sendAnalytics(createShortcutEvent(
  742. 'toggle.screen.sharing',
  743. ACTION_SHORTCUT_TRIGGERED,
  744. { enable: !this.props._screensharing }));
  745. this._doToggleScreenshare();
  746. }
  747. _onToolbarToggleSettings: () => void;
  748. /**
  749. * Creates an analytics toolbar event and dispatches an action for toggling
  750. * settings display.
  751. *
  752. * @private
  753. * @returns {void}
  754. */
  755. _onToolbarToggleSettings() {
  756. sendAnalytics(createToolbarEvent('settings'));
  757. this._doToggleSettings();
  758. }
  759. _onToolbarToggleSharedVideo: () => void;
  760. /**
  761. * Creates an analytics toolbar event and dispatches an action for toggling
  762. * the sharing of a YouTube video.
  763. *
  764. * @private
  765. * @returns {void}
  766. */
  767. _onToolbarToggleSharedVideo() {
  768. sendAnalytics(createToolbarEvent('shared.video.toggled',
  769. {
  770. enable: !this.props._sharingVideo
  771. }));
  772. this._doToggleSharedVideo();
  773. }
  774. /**
  775. * Renders a button for toggleing screen sharing.
  776. *
  777. * @private
  778. * @returns {ReactElement|null}
  779. */
  780. _renderDesktopSharingButton() {
  781. const {
  782. _desktopSharingDisabledByConfig,
  783. _desktopSharingEnabled,
  784. _screensharing,
  785. t
  786. } = this.props;
  787. const disabledTooltipText
  788. = interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP;
  789. const showDisabledTooltip
  790. = disabledTooltipText && _desktopSharingDisabledByConfig;
  791. const visible = _desktopSharingEnabled || showDisabledTooltip;
  792. if (!visible) {
  793. return null;
  794. }
  795. const classNames = `icon-share-desktop ${
  796. _screensharing ? 'toggled' : ''} ${
  797. _desktopSharingEnabled ? '' : 'disabled'}`;
  798. const tooltip = showDisabledTooltip
  799. ? disabledTooltipText
  800. : t('dialog.shareYourScreen');
  801. return (
  802. <ToolbarButton
  803. accessibilityLabel = 'Screenshare'
  804. iconName = { classNames }
  805. onClick = { this._onToolbarToggleScreenshare }
  806. tooltip = { tooltip } />
  807. );
  808. }
  809. /**
  810. * Renders the list elements of the overflow menu.
  811. *
  812. * @private
  813. * @returns {Array<ReactElement>}
  814. */
  815. _renderOverflowMenuContent() {
  816. const {
  817. _editingDocument,
  818. _etherpadInitialized,
  819. _feedbackConfigured,
  820. _fullScreen,
  821. _isGuest,
  822. _sharingVideo,
  823. t
  824. } = this.props;
  825. return [
  826. _isGuest
  827. && this._shouldShowButton('profile')
  828. && <OverflowMenuProfileItem
  829. key = 'profile'
  830. onClick = { this._onToolbarToggleProfile } />,
  831. this._shouldShowButton('videoquality')
  832. && <OverflowMenuVideoQualityItem
  833. key = 'videoquality'
  834. onClick = { this._onToolbarOpenVideoQuality } />,
  835. this._shouldShowButton('fullscreen')
  836. && <OverflowMenuItem
  837. accessibilityLabel = 'Full screen'
  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('sharedvideo')
  848. && <OverflowMenuItem
  849. accessibilityLabel = 'Shared video'
  850. icon = 'icon-shared-video'
  851. key = 'sharedvideo'
  852. onClick = { this._onToolbarToggleSharedVideo }
  853. text = { _sharingVideo
  854. ? t('toolbar.stopSharedVideo')
  855. : t('toolbar.sharedvideo') } />,
  856. this._shouldShowButton('etherpad')
  857. && _etherpadInitialized
  858. && <OverflowMenuItem
  859. accessibilityLabel = 'Etherpad'
  860. icon = 'icon-share-doc'
  861. key = 'etherpad'
  862. onClick = { this._onToolbarToggleEtherpad }
  863. text = { _editingDocument
  864. ? t('toolbar.documentClose')
  865. : t('toolbar.documentOpen') } />,
  866. this._shouldShowButton('settings')
  867. && <OverflowMenuItem
  868. accessibilityLabel = 'Settings'
  869. icon = 'icon-settings'
  870. key = 'settings'
  871. onClick = { this._onToolbarToggleSettings }
  872. text = { t('toolbar.Settings') } />,
  873. this._shouldShowButton('stats')
  874. && <OverflowMenuItem
  875. accessibilityLabel = 'Speaker stats'
  876. icon = 'icon-presentation'
  877. key = 'stats'
  878. onClick = { this._onToolbarOpenSpeakerStats }
  879. text = { t('toolbar.speakerStats') } />,
  880. this._shouldShowButton('feedback')
  881. && _feedbackConfigured
  882. && <OverflowMenuItem
  883. accessibilityLabel = 'Feedback'
  884. icon = 'icon-feedback'
  885. key = 'feedback'
  886. onClick = { this._onToolbarOpenFeedback }
  887. text = { t('toolbar.feedback') } />,
  888. this._shouldShowButton('shortcuts')
  889. && <OverflowMenuItem
  890. accessibilityLabel = 'Shortcuts'
  891. icon = 'icon-open_in_new'
  892. key = 'shortcuts'
  893. onClick = { this._onToolbarOpenKeyboardShortcuts }
  894. text = { t('toolbar.shortcuts') } />
  895. ];
  896. }
  897. /**
  898. * Renders an {@code OverflowMenuItem} depending on the current recording
  899. * state.
  900. *
  901. * @private
  902. * @returns {ReactElement|null}
  903. */
  904. _renderRecordingButton() {
  905. const {
  906. _isRecording,
  907. _recordingEnabled,
  908. _recordingType,
  909. t
  910. } = this.props;
  911. if (!_recordingEnabled || !this._shouldShowButton('recording')) {
  912. return null;
  913. }
  914. let iconClass, translationKey;
  915. if (_recordingType === RECORDING_TYPES.JIBRI) {
  916. iconClass = 'icon-public';
  917. translationKey = _isRecording
  918. ? 'dialog.stopLiveStreaming'
  919. : 'dialog.startLiveStreaming';
  920. } else {
  921. iconClass = 'icon-camera-take-picture';
  922. translationKey = _isRecording
  923. ? 'dialog.stopRecording'
  924. : 'dialog.startRecording';
  925. }
  926. return (
  927. <OverflowMenuItem
  928. accessibilityLabel = 'Record'
  929. icon = { iconClass }
  930. key = 'recording'
  931. onClick = { this._onToolbarToggleRecording }
  932. text = { t(translationKey) } />
  933. );
  934. }
  935. _shouldShowButton: (string) => boolean;
  936. /**
  937. * Returns if a button name has been explicitly configured to be displayed.
  938. *
  939. * @param {string} buttonName - The name of the button, as expected in
  940. * {@link intefaceConfig}.
  941. * @private
  942. * @returns {boolean} True if the button should be displayed.
  943. */
  944. _shouldShowButton(buttonName) {
  945. return this._visibleButtons.has(buttonName);
  946. }
  947. }
  948. /**
  949. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  950. * props.
  951. *
  952. * @param {Object} state - The redux store/state.
  953. * @private
  954. * @returns {{}}
  955. */
  956. function _mapStateToProps(state) {
  957. const {
  958. conference,
  959. desktopSharingEnabled
  960. } = state['features/base/conference'];
  961. const {
  962. callStatsID,
  963. disableDesktopSharing,
  964. enableRecording,
  965. iAmRecorder
  966. } = state['features/base/config'];
  967. const { isRecording, recordingType } = state['features/recording'];
  968. const sharedVideoStatus = state['features/shared-video'].status;
  969. const { current } = state['features/side-panel'];
  970. const {
  971. alwaysVisible,
  972. fullScreen,
  973. timeoutID,
  974. visible
  975. } = state['features/toolbox'];
  976. const localParticipant = getLocalParticipant(state);
  977. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  978. const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
  979. const addPeopleEnabled = isAddPeopleEnabled(state);
  980. const dialOutEnabled = isDialOutEnabled(state);
  981. return {
  982. _chatOpen: current === 'chat_container',
  983. _conference: conference,
  984. _desktopSharingEnabled: desktopSharingEnabled,
  985. _desktopSharingDisabledByConfig: disableDesktopSharing,
  986. _dialog: Boolean(state['features/base/dialog'].component),
  987. _editingDocument: Boolean(state['features/etherpad'].editing),
  988. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  989. _feedbackConfigured: Boolean(callStatsID),
  990. _hideInviteButton:
  991. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  992. _isGuest: state['features/base/jwt'].isGuest,
  993. _isRecording: isRecording,
  994. _fullScreen: fullScreen,
  995. _localParticipantID: localParticipant.id,
  996. _raisedHand: localParticipant.raisedHand,
  997. _recordingEnabled: isModerator && enableRecording
  998. && (conference && conference.isRecordingSupported()),
  999. _recordingType: recordingType,
  1000. _screensharing: localVideo && localVideo.videoType === 'desktop',
  1001. _sharingVideo: sharedVideoStatus === 'playing'
  1002. || sharedVideoStatus === 'start'
  1003. || sharedVideoStatus === 'pause',
  1004. _visible: Boolean(timeoutID || visible || alwaysVisible)
  1005. };
  1006. }
  1007. export default translate(connect(_mapStateToProps)(Toolbox));