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

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