您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ToolboxV2.web.js 32KB

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