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.web.js 32KB

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