您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Toolbox.js 32KB

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