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

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