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

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