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

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