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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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. // XXX Only the local participant is allowed to update without
  456. // stating the JitsiConference instance (i.e. participant property
  457. // `conference` for a remote participant) because the local
  458. // participant is uniquely identified by the very fact that there is
  459. // only one local participant.
  460. id: _localParticipantID,
  461. local: true,
  462. raisedHand: !_raisedHand
  463. }));
  464. }
  465. /**
  466. * Dispatches an action to toggle recording.
  467. *
  468. * @private
  469. * @returns {void}
  470. */
  471. _doToggleRecording() {
  472. const { _fileRecordingSession } = this.props;
  473. const dialog = _fileRecordingSession
  474. ? StopRecordingDialog : StartRecordingDialog;
  475. this.props.dispatch(
  476. openDialog(dialog, { session: _fileRecordingSession }));
  477. }
  478. /**
  479. * Dispatches an action to toggle screensharing.
  480. *
  481. * @private
  482. * @returns {void}
  483. */
  484. _doToggleScreenshare() {
  485. if (this.props._desktopSharingEnabled) {
  486. this.props.dispatch(toggleScreensharing());
  487. }
  488. }
  489. /**
  490. * Dispatches an action to toggle YouTube video sharing.
  491. *
  492. * @private
  493. * @returns {void}
  494. */
  495. _doToggleSharedVideo() {
  496. this.props.dispatch(toggleSharedVideo());
  497. }
  498. _onMouseOut: () => void;
  499. /**
  500. * Dispatches an action signaling the toolbar is not being hovered.
  501. *
  502. * @private
  503. * @returns {void}
  504. */
  505. _onMouseOut() {
  506. this.props.dispatch(setToolbarHovered(false));
  507. }
  508. _onMouseOver: () => void;
  509. /**
  510. * Dispatches an action signaling the toolbar is being hovered.
  511. *
  512. * @private
  513. * @returns {void}
  514. */
  515. _onMouseOver() {
  516. this.props.dispatch(setToolbarHovered(true));
  517. }
  518. _onSetOverflowVisible: (boolean) => void;
  519. /**
  520. * Sets the visibility of the overflow menu.
  521. *
  522. * @param {boolean} visible - Whether or not the overflow menu should be
  523. * displayed.
  524. * @private
  525. * @returns {void}
  526. */
  527. _onSetOverflowVisible(visible) {
  528. this.props.dispatch(setOverflowMenuVisible(visible));
  529. }
  530. _onShortcutToggleChat: () => void;
  531. /**
  532. * Creates an analytics keyboard shortcut event and dispatches an action for
  533. * toggling the display of chat.
  534. *
  535. * @private
  536. * @returns {void}
  537. */
  538. _onShortcutToggleChat() {
  539. sendAnalytics(createShortcutEvent(
  540. 'toggle.chat',
  541. {
  542. enable: !this.props._chatOpen
  543. }));
  544. this._doToggleChat();
  545. }
  546. _onShortcutToggleFullScreen: () => void;
  547. /**
  548. * Creates an analytics keyboard shortcut event and dispatches an action for
  549. * toggling full screen mode.
  550. *
  551. * @private
  552. * @returns {void}
  553. */
  554. _onShortcutToggleFullScreen() {
  555. sendAnalytics(createShortcutEvent(
  556. 'toggle.fullscreen',
  557. {
  558. enable: !this.props._fullScreen
  559. }));
  560. this._doToggleFullScreen();
  561. }
  562. _onShortcutToggleRaiseHand: () => void;
  563. /**
  564. * Creates an analytics keyboard shortcut event and dispatches an action for
  565. * toggling raise hand.
  566. *
  567. * @private
  568. * @returns {void}
  569. */
  570. _onShortcutToggleRaiseHand() {
  571. sendAnalytics(createShortcutEvent(
  572. 'toggle.raise.hand',
  573. ACTION_SHORTCUT_TRIGGERED,
  574. { enable: !this.props._raisedHand }));
  575. this._doToggleRaiseHand();
  576. }
  577. _onShortcutToggleScreenshare: () => void;
  578. /**
  579. * Creates an analytics keyboard shortcut event and dispatches an action for
  580. * toggling screensharing.
  581. *
  582. * @private
  583. * @returns {void}
  584. */
  585. _onShortcutToggleScreenshare() {
  586. sendAnalytics(createToolbarEvent(
  587. 'screen.sharing',
  588. {
  589. enable: !this.props._screensharing
  590. }));
  591. this._doToggleScreenshare();
  592. }
  593. _onToolbarOpenFeedback: () => void;
  594. /**
  595. * Creates an analytics toolbar event and dispatches an action for toggling
  596. * display of feedback.
  597. *
  598. * @private
  599. * @returns {void}
  600. */
  601. _onToolbarOpenFeedback() {
  602. sendAnalytics(createToolbarEvent('feedback'));
  603. this._doOpenFeedback();
  604. }
  605. _onToolbarOpenInvite: () => void;
  606. /**
  607. * Creates an analytics toolbar event and dispatches an action for opening
  608. * the modal for inviting people directly into the conference.
  609. *
  610. * @private
  611. * @returns {void}
  612. */
  613. _onToolbarOpenInvite() {
  614. sendAnalytics(createToolbarEvent('invite'));
  615. this.props.dispatch(beginAddPeople());
  616. }
  617. _onToolbarOpenKeyboardShortcuts: () => void;
  618. /**
  619. * Creates an analytics toolbar event and dispatches an action for opening
  620. * the modal for showing available keyboard shortcuts.
  621. *
  622. * @private
  623. * @returns {void}
  624. */
  625. _onToolbarOpenKeyboardShortcuts() {
  626. sendAnalytics(createToolbarEvent('shortcuts'));
  627. this._doOpenKeyboardShorcuts();
  628. }
  629. _onToolbarOpenSpeakerStats: () => void;
  630. /**
  631. * Creates an analytics toolbar event and dispatches an action for opening
  632. * the speaker stats modal.
  633. *
  634. * @private
  635. * @returns {void}
  636. */
  637. _onToolbarOpenSpeakerStats() {
  638. sendAnalytics(createToolbarEvent('speaker.stats'));
  639. this._doOpenSpeakerStats();
  640. }
  641. _onToolbarOpenVideoQuality: () => void;
  642. /**
  643. * Creates an analytics toolbar event and dispatches an action for toggling
  644. * open the video quality dialog.
  645. *
  646. * @private
  647. * @returns {void}
  648. */
  649. _onToolbarOpenVideoQuality() {
  650. sendAnalytics(createToolbarEvent('video.quality'));
  651. this._doOpenVideoQuality();
  652. }
  653. _onToolbarToggleChat: () => void;
  654. /**
  655. * Creates an analytics toolbar event and dispatches an action for toggling
  656. * the display of chat.
  657. *
  658. * @private
  659. * @returns {void}
  660. */
  661. _onToolbarToggleChat() {
  662. sendAnalytics(createToolbarEvent(
  663. 'toggle.chat',
  664. {
  665. enable: !this.props._chatOpen
  666. }));
  667. this._doToggleChat();
  668. }
  669. _onToolbarToggleEtherpad: () => void;
  670. /**
  671. * Creates an analytics toolbar event and dispatches an action for toggling
  672. * the display of document editing.
  673. *
  674. * @private
  675. * @returns {void}
  676. */
  677. _onToolbarToggleEtherpad() {
  678. sendAnalytics(createToolbarEvent(
  679. 'toggle.etherpad',
  680. {
  681. enable: !this.props._editingDocument
  682. }));
  683. this._doToggleEtherpad();
  684. }
  685. _onToolbarToggleFullScreen: () => void;
  686. /**
  687. * Creates an analytics toolbar event and dispatches an action for toggling
  688. * full screen mode.
  689. *
  690. * @private
  691. * @returns {void}
  692. */
  693. _onToolbarToggleFullScreen() {
  694. sendAnalytics(createToolbarEvent(
  695. 'toggle.fullscreen',
  696. {
  697. enable: !this.props._fullScreen
  698. }));
  699. this._doToggleFullScreen();
  700. }
  701. _onToolbarToggleLiveStreaming: () => void;
  702. /**
  703. * Starts the process for enabling or disabling live streaming.
  704. *
  705. * @private
  706. * @returns {void}
  707. */
  708. _onToolbarToggleLiveStreaming() {
  709. sendAnalytics(createToolbarEvent(
  710. 'livestreaming.button',
  711. {
  712. 'is_streaming': Boolean(this.props._liveStreamingSession),
  713. type: JitsiRecordingConstants.mode.STREAM
  714. }));
  715. this._doToggleLiveStreaming();
  716. }
  717. _onToolbarToggleProfile: () => void;
  718. /**
  719. * Creates an analytics toolbar event and dispatches an action for showing
  720. * or hiding the profile edit panel.
  721. *
  722. * @private
  723. * @returns {void}
  724. */
  725. _onToolbarToggleProfile() {
  726. sendAnalytics(createToolbarEvent('profile'));
  727. this._doToggleProfile();
  728. }
  729. _onToolbarToggleRaiseHand: () => void;
  730. /**
  731. * Creates an analytics toolbar event and dispatches an action for toggling
  732. * raise hand.
  733. *
  734. * @private
  735. * @returns {void}
  736. */
  737. _onToolbarToggleRaiseHand() {
  738. sendAnalytics(createToolbarEvent(
  739. 'raise.hand',
  740. { enable: !this.props._raisedHand }));
  741. this._doToggleRaiseHand();
  742. }
  743. _onToolbarToggleRecording: () => void;
  744. /**
  745. * Dispatches an action to toggle recording.
  746. *
  747. * @private
  748. * @returns {void}
  749. */
  750. _onToolbarToggleRecording() {
  751. sendAnalytics(createToolbarEvent(
  752. 'recording.button',
  753. {
  754. 'is_recording': Boolean(this.props._fileRecordingSession),
  755. type: JitsiRecordingConstants.mode.FILE
  756. }));
  757. this._doToggleRecording();
  758. }
  759. _onToolbarToggleScreenshare: () => void;
  760. /**
  761. * Creates an analytics toolbar event and dispatches an action for toggling
  762. * screensharing.
  763. *
  764. * @private
  765. * @returns {void}
  766. */
  767. _onToolbarToggleScreenshare() {
  768. if (!this.props._desktopSharingEnabled) {
  769. return;
  770. }
  771. sendAnalytics(createShortcutEvent(
  772. 'toggle.screen.sharing',
  773. ACTION_SHORTCUT_TRIGGERED,
  774. { enable: !this.props._screensharing }));
  775. this._doToggleScreenshare();
  776. }
  777. _onToolbarToggleSharedVideo: () => void;
  778. /**
  779. * Creates an analytics toolbar event and dispatches an action for toggling
  780. * the sharing of a YouTube video.
  781. *
  782. * @private
  783. * @returns {void}
  784. */
  785. _onToolbarToggleSharedVideo() {
  786. sendAnalytics(createToolbarEvent('shared.video.toggled',
  787. {
  788. enable: !this.props._sharingVideo
  789. }));
  790. this._doToggleSharedVideo();
  791. }
  792. /**
  793. * Renders a button for toggleing screen sharing.
  794. *
  795. * @private
  796. * @returns {ReactElement|null}
  797. */
  798. _renderDesktopSharingButton() {
  799. const {
  800. _desktopSharingDisabledByConfig,
  801. _desktopSharingEnabled,
  802. _screensharing,
  803. t
  804. } = this.props;
  805. const disabledTooltipText
  806. = interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP;
  807. const showDisabledTooltip
  808. = disabledTooltipText && _desktopSharingDisabledByConfig;
  809. const visible = _desktopSharingEnabled || showDisabledTooltip;
  810. if (!visible) {
  811. return null;
  812. }
  813. const classNames = `icon-share-desktop ${
  814. _screensharing ? 'toggled' : ''} ${
  815. _desktopSharingEnabled ? '' : 'disabled'}`;
  816. const tooltip = showDisabledTooltip
  817. ? disabledTooltipText
  818. : t('dialog.shareYourScreen');
  819. return (
  820. <ToolbarButton
  821. accessibilityLabel = 'Screenshare'
  822. iconName = { classNames }
  823. onClick = { this._onToolbarToggleScreenshare }
  824. tooltip = { tooltip } />
  825. );
  826. }
  827. /**
  828. * Renders the list elements of the overflow menu.
  829. *
  830. * @private
  831. * @returns {Array<ReactElement>}
  832. */
  833. _renderOverflowMenuContent() {
  834. const {
  835. _editingDocument,
  836. _etherpadInitialized,
  837. _feedbackConfigured,
  838. _fullScreen,
  839. _isGuest,
  840. _liveStreamingSession,
  841. _recordingEnabled,
  842. _sharingVideo,
  843. t
  844. } = this.props;
  845. return [
  846. _isGuest
  847. && this._shouldShowButton('profile')
  848. && <OverflowMenuProfileItem
  849. key = 'profile'
  850. onClick = { this._onToolbarToggleProfile } />,
  851. this._shouldShowButton('videoquality')
  852. && <OverflowMenuVideoQualityItem
  853. key = 'videoquality'
  854. onClick = { this._onToolbarOpenVideoQuality } />,
  855. this._shouldShowButton('fullscreen')
  856. && <OverflowMenuItem
  857. accessibilityLabel = 'Full screen'
  858. icon = { _fullScreen
  859. ? 'icon-exit-full-screen'
  860. : 'icon-full-screen' }
  861. key = 'fullscreen'
  862. onClick = { this._onToolbarToggleFullScreen }
  863. text = { _fullScreen
  864. ? t('toolbar.exitFullScreen')
  865. : t('toolbar.enterFullScreen') } />,
  866. _recordingEnabled
  867. && this._shouldShowButton('livestreaming')
  868. && <OverflowMenuLiveStreamingItem
  869. key = 'livestreaming'
  870. onClick = { this._onToolbarToggleLiveStreaming }
  871. session = { _liveStreamingSession } />,
  872. _recordingEnabled
  873. && this._shouldShowButton('recording')
  874. && this._renderRecordingButton(),
  875. this._shouldShowButton('sharedvideo')
  876. && <OverflowMenuItem
  877. accessibilityLabel = 'Shared video'
  878. icon = 'icon-shared-video'
  879. key = 'sharedvideo'
  880. onClick = { this._onToolbarToggleSharedVideo }
  881. text = { _sharingVideo
  882. ? t('toolbar.stopSharedVideo')
  883. : t('toolbar.sharedvideo') } />,
  884. this._shouldShowButton('etherpad')
  885. && _etherpadInitialized
  886. && <OverflowMenuItem
  887. accessibilityLabel = 'Etherpad'
  888. icon = 'icon-share-doc'
  889. key = 'etherpad'
  890. onClick = { this._onToolbarToggleEtherpad }
  891. text = { _editingDocument
  892. ? t('toolbar.documentClose')
  893. : t('toolbar.documentOpen') } />,
  894. <SettingsButton
  895. key = 'settings'
  896. showLabel = { true }
  897. visible = { this._shouldShowButton('settings') } />,
  898. this._shouldShowButton('stats')
  899. && <OverflowMenuItem
  900. accessibilityLabel = 'Speaker stats'
  901. icon = 'icon-presentation'
  902. key = 'stats'
  903. onClick = { this._onToolbarOpenSpeakerStats }
  904. text = { t('toolbar.speakerStats') } />,
  905. this._shouldShowButton('feedback')
  906. && _feedbackConfigured
  907. && <OverflowMenuItem
  908. accessibilityLabel = 'Feedback'
  909. icon = 'icon-feedback'
  910. key = 'feedback'
  911. onClick = { this._onToolbarOpenFeedback }
  912. text = { t('toolbar.feedback') } />,
  913. this._shouldShowButton('shortcuts')
  914. && <OverflowMenuItem
  915. accessibilityLabel = 'Shortcuts'
  916. icon = 'icon-open_in_new'
  917. key = 'shortcuts'
  918. onClick = { this._onToolbarOpenKeyboardShortcuts }
  919. text = { t('toolbar.shortcuts') } />
  920. ];
  921. }
  922. /**
  923. * Renders an {@code OverflowMenuItem} to start or stop recording of the
  924. * current conference.
  925. *
  926. * @private
  927. * @returns {ReactElement|null}
  928. */
  929. _renderRecordingButton() {
  930. const { _fileRecordingSession, t } = this.props;
  931. const translationKey = _fileRecordingSession
  932. ? 'dialog.stopRecording'
  933. : 'dialog.startRecording';
  934. return (
  935. <OverflowMenuItem
  936. accessibilityLabel = 'Record'
  937. icon = 'icon-camera-take-picture'
  938. key = 'recording'
  939. onClick = { this._onToolbarToggleRecording }
  940. text = { t(translationKey) } />
  941. );
  942. }
  943. _shouldShowButton: (string) => boolean;
  944. /**
  945. * Returns if a button name has been explicitly configured to be displayed.
  946. *
  947. * @param {string} buttonName - The name of the button, as expected in
  948. * {@link intefaceConfig}.
  949. * @private
  950. * @returns {boolean} True if the button should be displayed.
  951. */
  952. _shouldShowButton(buttonName) {
  953. return this.props._visibleButtons.has(buttonName);
  954. }
  955. }
  956. /**
  957. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  958. * props.
  959. *
  960. * @param {Object} state - The redux store/state.
  961. * @private
  962. * @returns {{}}
  963. */
  964. function _mapStateToProps(state) {
  965. const {
  966. conference,
  967. desktopSharingEnabled
  968. } = state['features/base/conference'];
  969. const {
  970. callStatsID,
  971. disableDesktopSharing,
  972. enableRecording,
  973. iAmRecorder
  974. } = state['features/base/config'];
  975. const sharedVideoStatus = state['features/shared-video'].status;
  976. const { current } = state['features/side-panel'];
  977. const {
  978. alwaysVisible,
  979. fullScreen,
  980. overflowMenuVisible,
  981. timeoutID,
  982. visible
  983. } = state['features/toolbox'];
  984. const localParticipant = getLocalParticipant(state);
  985. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  986. const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
  987. const addPeopleEnabled = isAddPeopleEnabled(state);
  988. const dialOutEnabled = isDialOutEnabled(state);
  989. return {
  990. _chatOpen: current === 'chat_container',
  991. _conference: conference,
  992. _desktopSharingEnabled: desktopSharingEnabled,
  993. _desktopSharingDisabledByConfig: disableDesktopSharing,
  994. _dialog: Boolean(state['features/base/dialog'].component),
  995. _editingDocument: Boolean(state['features/etherpad'].editing),
  996. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  997. _feedbackConfigured: Boolean(callStatsID),
  998. _hideInviteButton:
  999. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  1000. _isGuest: state['features/base/jwt'].isGuest,
  1001. _fileRecordingSession:
  1002. getActiveSession(state, JitsiRecordingConstants.mode.FILE),
  1003. _fullScreen: fullScreen,
  1004. _liveStreamingSession:
  1005. getActiveSession(state, JitsiRecordingConstants.mode.STREAM),
  1006. _localParticipantID: localParticipant.id,
  1007. _overflowMenuVisible: overflowMenuVisible,
  1008. _raisedHand: localParticipant.raisedHand,
  1009. _recordingEnabled: isModerator && enableRecording,
  1010. _screensharing: localVideo && localVideo.videoType === 'desktop',
  1011. _sharingVideo: sharedVideoStatus === 'playing'
  1012. || sharedVideoStatus === 'start'
  1013. || sharedVideoStatus === 'pause',
  1014. _visible: Boolean(timeoutID || visible || alwaysVisible),
  1015. // XXX: We are not currently using state here, but in the future, when
  1016. // interfaceConfig is part of redux we will.
  1017. _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
  1018. };
  1019. }
  1020. export default translate(connect(_mapStateToProps)(Toolbox));