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

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