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

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