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

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