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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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. * 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._onToolbarToggleProfile
  197. = this._onToolbarToggleProfile.bind(this);
  198. this._onToolbarToggleRaiseHand
  199. = this._onToolbarToggleRaiseHand.bind(this);
  200. this._onToolbarToggleScreenshare
  201. = this._onToolbarToggleScreenshare.bind(this);
  202. this._onToolbarToggleSharedVideo
  203. = this._onToolbarToggleSharedVideo.bind(this);
  204. this._onToolbarOpenLocalRecordingInfoDialog
  205. = this._onToolbarOpenLocalRecordingInfoDialog.bind(this);
  206. }
  207. /**
  208. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  209. *
  210. * @inheritdoc
  211. * @returns {void}
  212. */
  213. componentDidMount() {
  214. const KEYBOARD_SHORTCUTS = [
  215. this._shouldShowButton('chat') && {
  216. character: 'C',
  217. exec: this._onShortcutToggleChat,
  218. helpDescription: 'keyboardShortcuts.toggleChat'
  219. },
  220. this._shouldShowButton('desktop') && {
  221. character: 'D',
  222. exec: this._onShortcutToggleScreenshare,
  223. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  224. },
  225. this._shouldShowButton('raisehand') && {
  226. character: 'R',
  227. exec: this._onShortcutToggleRaiseHand,
  228. helpDescription: 'keyboardShortcuts.raiseHand'
  229. },
  230. this._shouldShowButton('fullscreen') && {
  231. character: 'S',
  232. exec: this._onShortcutToggleFullScreen,
  233. helpDescription: 'keyboardShortcuts.fullScreen'
  234. }
  235. ];
  236. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  237. if (typeof shortcut === 'object') {
  238. APP.keyboardshortcut.registerShortcut(
  239. shortcut.character,
  240. null,
  241. shortcut.exec,
  242. shortcut.helpDescription);
  243. }
  244. });
  245. }
  246. /**
  247. * Update the visibility of the {@code OverflowMenuButton}.
  248. *
  249. * @inheritdoc
  250. */
  251. componentWillReceiveProps(nextProps) {
  252. // Ensure the dialog is closed when the toolbox becomes hidden.
  253. if (this.props._overflowMenuVisible && !nextProps._visible) {
  254. this._onSetOverflowVisible(false);
  255. }
  256. if (this.props._overflowMenuVisible
  257. && !this.props._dialog
  258. && nextProps._dialog) {
  259. this._onSetOverflowVisible(false);
  260. this.props.dispatch(setToolbarHovered(false));
  261. }
  262. }
  263. /**
  264. * Removes keyboard shortcuts registered by this component.
  265. *
  266. * @inheritdoc
  267. * @returns {void}
  268. */
  269. componentWillUnmount() {
  270. [ 'C', 'D', 'R', 'S' ].forEach(letter =>
  271. APP.keyboardshortcut.unregisterShortcut(letter));
  272. }
  273. /**
  274. * Implements React's {@link Component#render()}.
  275. *
  276. * @inheritdoc
  277. * @returns {ReactElement}
  278. */
  279. render() {
  280. const {
  281. _chatOpen,
  282. _hideInviteButton,
  283. _overflowMenuVisible,
  284. _raisedHand,
  285. _visible,
  286. _visibleButtons,
  287. t
  288. } = this.props;
  289. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  290. _visibleButtons.size ? '' : 'no-buttons'}`;
  291. const overflowMenuContent = this._renderOverflowMenuContent();
  292. const overflowHasItems = Boolean(overflowMenuContent.filter(
  293. child => child).length);
  294. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  295. return (
  296. <div
  297. className = { rootClassNames }
  298. id = 'new-toolbox'
  299. onMouseOut = { this._onMouseOut }
  300. onMouseOver = { this._onMouseOver }>
  301. <div className = 'button-group-left'>
  302. { this._shouldShowButton('desktop')
  303. && this._renderDesktopSharingButton() }
  304. { this._shouldShowButton('raisehand')
  305. && <ToolbarButton
  306. accessibilityLabel =
  307. { t('toolbar.accessibilityLabel.raiseHand') }
  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 =
  317. { t('toolbar.accessibilityLabel.chat') }
  318. iconName = { _chatOpen
  319. ? 'icon-chat toggled'
  320. : 'icon-chat' }
  321. onClick = { this._onToolbarToggleChat }
  322. tooltip = { t('toolbar.chat') } />
  323. <ChatCounter />
  324. </div> }
  325. {
  326. this._shouldShowButton('closedcaptions')
  327. && <ClosedCaptionButton />
  328. }
  329. </div>
  330. <div className = 'button-group-center'>
  331. <AudioMuteButton
  332. visible = { this._shouldShowButton('microphone') } />
  333. <HangupButton
  334. visible = { this._shouldShowButton('hangup') } />
  335. <VideoMuteButton
  336. visible = { this._shouldShowButton('camera') } />
  337. </div>
  338. <div className = 'button-group-right'>
  339. { this._shouldShowButton('localrecording')
  340. && <LocalRecordingButton
  341. onClick = {
  342. this._onToolbarOpenLocalRecordingInfoDialog
  343. } />
  344. }
  345. { this._shouldShowButton('tileview')
  346. && <TileViewButton /> }
  347. { this._shouldShowButton('invite')
  348. && !_hideInviteButton
  349. && <ToolbarButton
  350. accessibilityLabel =
  351. { t('toolbar.accessibilityLabel.invite') }
  352. iconName = 'icon-add'
  353. onClick = { this._onToolbarOpenInvite }
  354. tooltip = { t('toolbar.invite') } /> }
  355. { this._shouldShowButton('info') && <InfoDialogButton /> }
  356. { overflowHasItems
  357. && <OverflowMenuButton
  358. isOpen = { _overflowMenuVisible }
  359. onVisibilityChange = { this._onSetOverflowVisible }>
  360. <ul
  361. aria-label = { t(toolbarAccLabel) }
  362. className = 'overflow-menu'>
  363. { overflowMenuContent }
  364. </ul>
  365. </OverflowMenuButton> }
  366. </div>
  367. </div>
  368. );
  369. }
  370. /**
  371. * Callback invoked to display {@code FeedbackDialog}.
  372. *
  373. * @private
  374. * @returns {void}
  375. */
  376. _doOpenFeedback() {
  377. const { _conference } = this.props;
  378. this.props.dispatch(openFeedbackDialog(_conference));
  379. }
  380. /**
  381. * Dispatches an action to display {@code KeyboardShortcuts}.
  382. *
  383. * @private
  384. * @returns {void}
  385. */
  386. _doOpenKeyboardShorcuts() {
  387. this.props.dispatch(openKeyboardShortcutsDialog());
  388. }
  389. /**
  390. * Callback invoked to display {@code SpeakerStats}.
  391. *
  392. * @private
  393. * @returns {void}
  394. */
  395. _doOpenSpeakerStats() {
  396. this.props.dispatch(openDialog(SpeakerStats, {
  397. conference: this.props._conference
  398. }));
  399. }
  400. /**
  401. * Dispatches an action to toggle the video quality dialog.
  402. *
  403. * @private
  404. * @returns {void}
  405. */
  406. _doOpenVideoQuality() {
  407. this.props.dispatch(openDialog(VideoQualityDialog));
  408. }
  409. /**
  410. * Dispatches an action to toggle the display of chat.
  411. *
  412. * @private
  413. * @returns {void}
  414. */
  415. _doToggleChat() {
  416. this.props.dispatch(toggleChat());
  417. }
  418. /**
  419. * Dispatches an action to show or hide document editing.
  420. *
  421. * @private
  422. * @returns {void}
  423. */
  424. _doToggleEtherpad() {
  425. this.props.dispatch(toggleDocument());
  426. }
  427. /**
  428. * Dispatches an action to toggle screensharing.
  429. *
  430. * @private
  431. * @returns {void}
  432. */
  433. _doToggleFullScreen() {
  434. const fullScreen = !this.props._fullScreen;
  435. this.props.dispatch(setFullScreen(fullScreen));
  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(openSettingsDialog(SETTINGS_TABS.PROFILE));
  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 screensharing.
  467. *
  468. * @private
  469. * @returns {void}
  470. */
  471. _doToggleScreenshare() {
  472. if (this.props._desktopSharingEnabled) {
  473. this.props.dispatch(toggleScreensharing());
  474. }
  475. }
  476. /**
  477. * Dispatches an action to toggle YouTube video sharing.
  478. *
  479. * @private
  480. * @returns {void}
  481. */
  482. _doToggleSharedVideo() {
  483. this.props.dispatch(toggleSharedVideo());
  484. }
  485. _onMouseOut: () => void;
  486. /**
  487. * Dispatches an action signaling the toolbar is not being hovered.
  488. *
  489. * @private
  490. * @returns {void}
  491. */
  492. _onMouseOut() {
  493. this.props.dispatch(setToolbarHovered(false));
  494. }
  495. _onMouseOver: () => void;
  496. /**
  497. * Dispatches an action signaling the toolbar is being hovered.
  498. *
  499. * @private
  500. * @returns {void}
  501. */
  502. _onMouseOver() {
  503. this.props.dispatch(setToolbarHovered(true));
  504. }
  505. _onSetOverflowVisible: (boolean) => void;
  506. /**
  507. * Sets the visibility of the overflow menu.
  508. *
  509. * @param {boolean} visible - Whether or not the overflow menu should be
  510. * displayed.
  511. * @private
  512. * @returns {void}
  513. */
  514. _onSetOverflowVisible(visible) {
  515. this.props.dispatch(setOverflowMenuVisible(visible));
  516. }
  517. _onShortcutToggleChat: () => void;
  518. /**
  519. * Creates an analytics keyboard shortcut event and dispatches an action for
  520. * toggling the display of chat.
  521. *
  522. * @private
  523. * @returns {void}
  524. */
  525. _onShortcutToggleChat() {
  526. sendAnalytics(createShortcutEvent(
  527. 'toggle.chat',
  528. {
  529. enable: !this.props._chatOpen
  530. }));
  531. this._doToggleChat();
  532. }
  533. _onShortcutToggleFullScreen: () => void;
  534. /**
  535. * Creates an analytics keyboard shortcut event and dispatches an action for
  536. * toggling full screen mode.
  537. *
  538. * @private
  539. * @returns {void}
  540. */
  541. _onShortcutToggleFullScreen() {
  542. sendAnalytics(createShortcutEvent(
  543. 'toggle.fullscreen',
  544. {
  545. enable: !this.props._fullScreen
  546. }));
  547. this._doToggleFullScreen();
  548. }
  549. _onShortcutToggleRaiseHand: () => void;
  550. /**
  551. * Creates an analytics keyboard shortcut event and dispatches an action for
  552. * toggling raise hand.
  553. *
  554. * @private
  555. * @returns {void}
  556. */
  557. _onShortcutToggleRaiseHand() {
  558. sendAnalytics(createShortcutEvent(
  559. 'toggle.raise.hand',
  560. ACTION_SHORTCUT_TRIGGERED,
  561. { enable: !this.props._raisedHand }));
  562. this._doToggleRaiseHand();
  563. }
  564. _onShortcutToggleScreenshare: () => void;
  565. /**
  566. * Creates an analytics keyboard shortcut event and dispatches an action for
  567. * toggling screensharing.
  568. *
  569. * @private
  570. * @returns {void}
  571. */
  572. _onShortcutToggleScreenshare() {
  573. sendAnalytics(createToolbarEvent(
  574. 'screen.sharing',
  575. {
  576. enable: !this.props._screensharing
  577. }));
  578. this._doToggleScreenshare();
  579. }
  580. _onToolbarOpenFeedback: () => void;
  581. /**
  582. * Creates an analytics toolbar event and dispatches an action for toggling
  583. * display of feedback.
  584. *
  585. * @private
  586. * @returns {void}
  587. */
  588. _onToolbarOpenFeedback() {
  589. sendAnalytics(createToolbarEvent('feedback'));
  590. this._doOpenFeedback();
  591. }
  592. _onToolbarOpenInvite: () => void;
  593. /**
  594. * Creates an analytics toolbar event and dispatches an action for opening
  595. * the modal for inviting people directly into the conference.
  596. *
  597. * @private
  598. * @returns {void}
  599. */
  600. _onToolbarOpenInvite() {
  601. sendAnalytics(createToolbarEvent('invite'));
  602. this.props.dispatch(beginAddPeople());
  603. }
  604. _onToolbarOpenKeyboardShortcuts: () => void;
  605. /**
  606. * Creates an analytics toolbar event and dispatches an action for opening
  607. * the modal for showing available keyboard shortcuts.
  608. *
  609. * @private
  610. * @returns {void}
  611. */
  612. _onToolbarOpenKeyboardShortcuts() {
  613. sendAnalytics(createToolbarEvent('shortcuts'));
  614. this._doOpenKeyboardShorcuts();
  615. }
  616. _onToolbarOpenSpeakerStats: () => void;
  617. /**
  618. * Creates an analytics toolbar event and dispatches an action for opening
  619. * the speaker stats modal.
  620. *
  621. * @private
  622. * @returns {void}
  623. */
  624. _onToolbarOpenSpeakerStats() {
  625. sendAnalytics(createToolbarEvent('speaker.stats'));
  626. this._doOpenSpeakerStats();
  627. }
  628. _onToolbarOpenVideoQuality: () => void;
  629. /**
  630. * Creates an analytics toolbar event and dispatches an action for toggling
  631. * open the video quality dialog.
  632. *
  633. * @private
  634. * @returns {void}
  635. */
  636. _onToolbarOpenVideoQuality() {
  637. sendAnalytics(createToolbarEvent('video.quality'));
  638. this._doOpenVideoQuality();
  639. }
  640. _onToolbarToggleChat: () => void;
  641. /**
  642. * Creates an analytics toolbar event and dispatches an action for toggling
  643. * the display of chat.
  644. *
  645. * @private
  646. * @returns {void}
  647. */
  648. _onToolbarToggleChat() {
  649. sendAnalytics(createToolbarEvent(
  650. 'toggle.chat',
  651. {
  652. enable: !this.props._chatOpen
  653. }));
  654. this._doToggleChat();
  655. }
  656. _onToolbarToggleEtherpad: () => void;
  657. /**
  658. * Creates an analytics toolbar event and dispatches an action for toggling
  659. * the display of document editing.
  660. *
  661. * @private
  662. * @returns {void}
  663. */
  664. _onToolbarToggleEtherpad() {
  665. sendAnalytics(createToolbarEvent(
  666. 'toggle.etherpad',
  667. {
  668. enable: !this.props._editingDocument
  669. }));
  670. this._doToggleEtherpad();
  671. }
  672. _onToolbarToggleFullScreen: () => void;
  673. /**
  674. * Creates an analytics toolbar event and dispatches an action for toggling
  675. * full screen mode.
  676. *
  677. * @private
  678. * @returns {void}
  679. */
  680. _onToolbarToggleFullScreen() {
  681. sendAnalytics(createToolbarEvent(
  682. 'toggle.fullscreen',
  683. {
  684. enable: !this.props._fullScreen
  685. }));
  686. this._doToggleFullScreen();
  687. }
  688. _onToolbarToggleProfile: () => void;
  689. /**
  690. * Creates an analytics toolbar event and dispatches an action for showing
  691. * or hiding the profile edit panel.
  692. *
  693. * @private
  694. * @returns {void}
  695. */
  696. _onToolbarToggleProfile() {
  697. sendAnalytics(createToolbarEvent('profile'));
  698. this._doToggleProfile();
  699. }
  700. _onToolbarToggleRaiseHand: () => void;
  701. /**
  702. * Creates an analytics toolbar event and dispatches an action for toggling
  703. * raise hand.
  704. *
  705. * @private
  706. * @returns {void}
  707. */
  708. _onToolbarToggleRaiseHand() {
  709. sendAnalytics(createToolbarEvent(
  710. 'raise.hand',
  711. { enable: !this.props._raisedHand }));
  712. this._doToggleRaiseHand();
  713. }
  714. _onToolbarToggleScreenshare: () => void;
  715. /**
  716. * Creates an analytics toolbar event and dispatches an action for toggling
  717. * screensharing.
  718. *
  719. * @private
  720. * @returns {void}
  721. */
  722. _onToolbarToggleScreenshare() {
  723. if (!this.props._desktopSharingEnabled) {
  724. return;
  725. }
  726. sendAnalytics(createShortcutEvent(
  727. 'toggle.screen.sharing',
  728. ACTION_SHORTCUT_TRIGGERED,
  729. { enable: !this.props._screensharing }));
  730. this._doToggleScreenshare();
  731. }
  732. _onToolbarToggleSharedVideo: () => void;
  733. /**
  734. * Creates an analytics toolbar event and dispatches an action for toggling
  735. * the sharing of a YouTube video.
  736. *
  737. * @private
  738. * @returns {void}
  739. */
  740. _onToolbarToggleSharedVideo() {
  741. sendAnalytics(createToolbarEvent('shared.video.toggled',
  742. {
  743. enable: !this.props._sharingVideo
  744. }));
  745. this._doToggleSharedVideo();
  746. }
  747. _onToolbarOpenLocalRecordingInfoDialog: () => void;
  748. /**
  749. * Opens the {@code LocalRecordingInfoDialog}.
  750. *
  751. * @private
  752. * @returns {void}
  753. */
  754. _onToolbarOpenLocalRecordingInfoDialog() {
  755. sendAnalytics(createToolbarEvent('local.recording'));
  756. this.props.dispatch(openDialog(LocalRecordingInfoDialog));
  757. }
  758. /**
  759. * Renders a button for toggleing screen sharing.
  760. *
  761. * @private
  762. * @returns {ReactElement|null}
  763. */
  764. _renderDesktopSharingButton() {
  765. const {
  766. _desktopSharingEnabled,
  767. _desktopSharingDisabledTooltipKey,
  768. _screensharing,
  769. t
  770. } = this.props;
  771. const visible
  772. = _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  773. if (!visible) {
  774. return null;
  775. }
  776. const classNames = `icon-share-desktop ${
  777. _screensharing ? 'toggled' : ''} ${
  778. _desktopSharingEnabled ? '' : 'disabled'}`;
  779. const tooltip = t(
  780. _desktopSharingEnabled
  781. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey);
  782. return (
  783. <ToolbarButton
  784. accessibilityLabel
  785. = { t('toolbar.accessibilityLabel.shareYourScreen') }
  786. iconName = { classNames }
  787. onClick = { this._onToolbarToggleScreenshare }
  788. tooltip = { tooltip } />
  789. );
  790. }
  791. /**
  792. * Renders the list elements of the overflow menu.
  793. *
  794. * @private
  795. * @returns {Array<ReactElement>}
  796. */
  797. _renderOverflowMenuContent() {
  798. const {
  799. _editingDocument,
  800. _etherpadInitialized,
  801. _feedbackConfigured,
  802. _fullScreen,
  803. _isGuest,
  804. _sharingVideo,
  805. t
  806. } = this.props;
  807. return [
  808. _isGuest
  809. && this._shouldShowButton('profile')
  810. && <OverflowMenuProfileItem
  811. key = 'profile'
  812. onClick = { this._onToolbarToggleProfile } />,
  813. this._shouldShowButton('videoquality')
  814. && <OverflowMenuVideoQualityItem
  815. key = 'videoquality'
  816. onClick = { this._onToolbarOpenVideoQuality } />,
  817. this._shouldShowButton('fullscreen')
  818. && <OverflowMenuItem
  819. accessibilityLabel =
  820. { t('toolbar.accessibilityLabel.fullScreen') }
  821. icon = { _fullScreen
  822. ? 'icon-exit-full-screen'
  823. : 'icon-full-screen' }
  824. key = 'fullscreen'
  825. onClick = { this._onToolbarToggleFullScreen }
  826. text = { _fullScreen
  827. ? t('toolbar.exitFullScreen')
  828. : t('toolbar.enterFullScreen') } />,
  829. <LiveStreamButton
  830. key = 'livestreaming'
  831. showLabel = { true } />,
  832. <RecordButton
  833. key = 'record'
  834. showLabel = { true } />,
  835. this._shouldShowButton('sharedvideo')
  836. && <OverflowMenuItem
  837. accessibilityLabel =
  838. { t('toolbar.accessibilityLabel.sharedvideo') }
  839. icon = 'icon-shared-video'
  840. key = 'sharedvideo'
  841. onClick = { this._onToolbarToggleSharedVideo }
  842. text = { _sharingVideo
  843. ? t('toolbar.stopSharedVideo')
  844. : t('toolbar.sharedvideo') } />,
  845. this._shouldShowButton('etherpad')
  846. && _etherpadInitialized
  847. && <OverflowMenuItem
  848. accessibilityLabel =
  849. { t('toolbar.accessibilityLabel.document') }
  850. icon = 'icon-share-doc'
  851. key = 'etherpad'
  852. onClick = { this._onToolbarToggleEtherpad }
  853. text = { _editingDocument
  854. ? t('toolbar.documentClose')
  855. : t('toolbar.documentOpen') } />,
  856. <SettingsButton
  857. key = 'settings'
  858. showLabel = { true }
  859. visible = { this._shouldShowButton('settings') } />,
  860. this._shouldShowButton('stats')
  861. && <OverflowMenuItem
  862. accessibilityLabel =
  863. { t('toolbar.accessibilityLabel.speakerStats') }
  864. icon = 'icon-presentation'
  865. key = 'stats'
  866. onClick = { this._onToolbarOpenSpeakerStats }
  867. text = { t('toolbar.speakerStats') } />,
  868. this._shouldShowButton('feedback')
  869. && _feedbackConfigured
  870. && <OverflowMenuItem
  871. accessibilityLabel =
  872. { t('toolbar.accessibilityLabel.feedback') }
  873. icon = 'icon-feedback'
  874. key = 'feedback'
  875. onClick = { this._onToolbarOpenFeedback }
  876. text = { t('toolbar.feedback') } />,
  877. this._shouldShowButton('shortcuts')
  878. && <OverflowMenuItem
  879. accessibilityLabel =
  880. { t('toolbar.accessibilityLabel.shortcuts') }
  881. icon = 'icon-open_in_new'
  882. key = 'shortcuts'
  883. onClick = { this._onToolbarOpenKeyboardShortcuts }
  884. text = { t('toolbar.shortcuts') } />
  885. ];
  886. }
  887. _shouldShowButton: (string) => boolean;
  888. /**
  889. * Returns if a button name has been explicitly configured to be displayed.
  890. *
  891. * @param {string} buttonName - The name of the button, as expected in
  892. * {@link interfaceConfig}.
  893. * @private
  894. * @returns {boolean} True if the button should be displayed.
  895. */
  896. _shouldShowButton(buttonName) {
  897. return this.props._visibleButtons.has(buttonName);
  898. }
  899. }
  900. /**
  901. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  902. * props.
  903. *
  904. * @param {Object} state - The redux store/state.
  905. * @private
  906. * @returns {{}}
  907. */
  908. function _mapStateToProps(state) {
  909. const { conference } = state['features/base/conference'];
  910. let { desktopSharingEnabled } = state['features/base/conference'];
  911. const {
  912. callStatsID,
  913. iAmRecorder
  914. } = state['features/base/config'];
  915. const sharedVideoStatus = state['features/shared-video'].status;
  916. const { current } = state['features/side-panel'];
  917. const {
  918. alwaysVisible,
  919. fullScreen,
  920. overflowMenuVisible,
  921. timeoutID,
  922. visible
  923. } = state['features/toolbox'];
  924. const localParticipant = getLocalParticipant(state);
  925. const localRecordingStates = state['features/local-recording'];
  926. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  927. const addPeopleEnabled = isAddPeopleEnabled(state);
  928. const dialOutEnabled = isDialOutEnabled(state);
  929. let desktopSharingDisabledTooltipKey;
  930. if (state['features/base/config'].enableFeaturesBasedOnToken) {
  931. // we enable desktop sharing if any participant already have this
  932. // feature enabled
  933. desktopSharingEnabled = getParticipants(state)
  934. .find(({ features = {} }) =>
  935. String(features['screen-sharing']) === 'true') !== undefined;
  936. // we want to show button and tooltip
  937. if (state['features/base/jwt'].isGuest) {
  938. desktopSharingDisabledTooltipKey
  939. = 'dialog.shareYourScreenDisabledForGuest';
  940. } else {
  941. desktopSharingDisabledTooltipKey
  942. = 'dialog.shareYourScreenDisabled';
  943. }
  944. }
  945. return {
  946. _chatOpen: current === 'chat_container',
  947. _conference: conference,
  948. _desktopSharingEnabled: desktopSharingEnabled,
  949. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  950. _dialog: Boolean(state['features/base/dialog'].component),
  951. _editingDocument: Boolean(state['features/etherpad'].editing),
  952. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  953. _feedbackConfigured: Boolean(callStatsID),
  954. _hideInviteButton:
  955. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  956. _isGuest: state['features/base/jwt'].isGuest,
  957. _fullScreen: fullScreen,
  958. _localParticipantID: localParticipant.id,
  959. _localRecState: localRecordingStates,
  960. _overflowMenuVisible: overflowMenuVisible,
  961. _raisedHand: localParticipant.raisedHand,
  962. _screensharing: localVideo && localVideo.videoType === 'desktop',
  963. _sharingVideo: sharedVideoStatus === 'playing'
  964. || sharedVideoStatus === 'start'
  965. || sharedVideoStatus === 'pause',
  966. _visible: Boolean(timeoutID || visible || alwaysVisible),
  967. // XXX: We are not currently using state here, but in the future, when
  968. // interfaceConfig is part of redux we will.
  969. _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
  970. };
  971. }
  972. export default translate(connect(_mapStateToProps)(Toolbox));