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

Toolbox.js 38KB

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