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.

ToolboxV2.web.js 33KB

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