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

Toolbox.js 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  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. getLocalParticipant,
  14. getParticipants,
  15. participantUpdated
  16. } from '../../../base/participants';
  17. import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
  18. import { ChatCounter, toggleChat } 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 {
  29. LocalRecordingButton,
  30. LocalRecordingInfoDialog
  31. } from '../../../local-recording';
  32. import {
  33. LiveStreamButton,
  34. RecordButton
  35. } from '../../../recording';
  36. import {
  37. SETTINGS_TABS,
  38. SettingsButton,
  39. openSettingsDialog
  40. } from '../../../settings';
  41. import { toggleSharedVideo } from '../../../shared-video';
  42. import { SpeakerStats } from '../../../speaker-stats';
  43. import { TileViewButton } from '../../../video-layout';
  44. import {
  45. OverflowMenuVideoQualityItem,
  46. VideoQualityDialog
  47. } from '../../../video-quality';
  48. import {
  49. setFullScreen,
  50. setOverflowMenuVisible,
  51. setToolbarHovered
  52. } from '../../actions';
  53. import AudioMuteButton from '../AudioMuteButton';
  54. import HangupButton from '../HangupButton';
  55. import OverflowMenuButton from './OverflowMenuButton';
  56. import OverflowMenuItem from './OverflowMenuItem';
  57. import OverflowMenuProfileItem from './OverflowMenuProfileItem';
  58. import ToolbarButton from './ToolbarButton';
  59. import VideoMuteButton from '../VideoMuteButton';
  60. import {
  61. ClosedCaptionButton
  62. } from '../../../subtitles';
  63. /**
  64. * The type of the React {@code Component} props of {@link Toolbox}.
  65. */
  66. type Props = {
  67. /**
  68. * Whether or not the chat feature is currently displayed.
  69. */
  70. _chatOpen: boolean,
  71. /**
  72. * The {@code JitsiConference} for the current conference.
  73. */
  74. _conference: Object,
  75. /**
  76. * The tooltip key to use when screensharing is disabled. Or undefined
  77. * if non to be shown and the button to be hidden.
  78. */
  79. _desktopSharingDisabledTooltipKey: boolean,
  80. /**
  81. * Whether or not screensharing is initialized.
  82. */
  83. _desktopSharingEnabled: boolean,
  84. /**
  85. * Whether or not a dialog is displayed.
  86. */
  87. _dialog: boolean,
  88. /**
  89. * Whether or not the local participant is currently editing a document.
  90. */
  91. _editingDocument: boolean,
  92. /**
  93. * Whether or not collaborative document editing is enabled.
  94. */
  95. _etherpadInitialized: boolean,
  96. /**
  97. * Whether or not call feedback can be sent.
  98. */
  99. _feedbackConfigured: boolean,
  100. /**
  101. * Whether or not the app is currently in full screen.
  102. */
  103. _fullScreen: boolean,
  104. /**
  105. * Whether or not invite should be hidden, regardless of feature
  106. * availability.
  107. */
  108. _hideInviteButton: boolean,
  109. /**
  110. * Whether or not the current user is logged in through a JWT.
  111. */
  112. _isGuest: boolean,
  113. /**
  114. * The ID of the local participant.
  115. */
  116. _localParticipantID: String,
  117. /**
  118. * The subsection of Redux state for local recording
  119. */
  120. _localRecState: Object,
  121. /**
  122. * Whether or not the overflow menu is visible.
  123. */
  124. _overflowMenuVisible: boolean,
  125. /**
  126. * Whether or not the local participant's hand is raised.
  127. */
  128. _raisedHand: boolean,
  129. /**
  130. * Whether or not the local participant is screensharing.
  131. */
  132. _screensharing: boolean,
  133. /**
  134. * Whether or not the local participant is sharing a YouTube video.
  135. */
  136. _sharingVideo: boolean,
  137. /**
  138. * Flag showing whether toolbar is visible.
  139. */
  140. _visible: boolean,
  141. /**
  142. * Set with the buttons which this Toolbox should display.
  143. */
  144. _visibleButtons: Set<string>,
  145. /**
  146. * Invoked to active other features of the app.
  147. */
  148. dispatch: Function,
  149. /**
  150. * Invoked to obtain translated strings.
  151. */
  152. t: Function
  153. };
  154. declare var APP: Object;
  155. declare var interfaceConfig: Object;
  156. /**
  157. * Implements the conference toolbox on React/Web.
  158. *
  159. * @extends Component
  160. */
  161. class Toolbox extends Component<Props> {
  162. /**
  163. * Initializes a new {@code Toolbox} instance.
  164. *
  165. * @param {Props} props - The read-only React {@code Component} props with
  166. * which the new instance is to be initialized.
  167. */
  168. constructor(props: Props) {
  169. super(props);
  170. // Bind event handlers so they are only bound once per instance.
  171. this._onMouseOut = this._onMouseOut.bind(this);
  172. this._onMouseOver = this._onMouseOver.bind(this);
  173. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  174. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  175. this._onShortcutToggleFullScreen
  176. = this._onShortcutToggleFullScreen.bind(this);
  177. this._onShortcutToggleRaiseHand
  178. = this._onShortcutToggleRaiseHand.bind(this);
  179. this._onShortcutToggleScreenshare
  180. = this._onShortcutToggleScreenshare.bind(this);
  181. this._onToolbarOpenFeedback
  182. = this._onToolbarOpenFeedback.bind(this);
  183. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  184. this._onToolbarOpenKeyboardShortcuts
  185. = this._onToolbarOpenKeyboardShortcuts.bind(this);
  186. this._onToolbarOpenSpeakerStats
  187. = this._onToolbarOpenSpeakerStats.bind(this);
  188. this._onToolbarOpenVideoQuality
  189. = this._onToolbarOpenVideoQuality.bind(this);
  190. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  191. this._onToolbarToggleEtherpad
  192. = this._onToolbarToggleEtherpad.bind(this);
  193. this._onToolbarToggleFullScreen
  194. = this._onToolbarToggleFullScreen.bind(this);
  195. this._onToolbarToggleProfile
  196. = this._onToolbarToggleProfile.bind(this);
  197. this._onToolbarToggleRaiseHand
  198. = this._onToolbarToggleRaiseHand.bind(this);
  199. this._onToolbarToggleScreenshare
  200. = this._onToolbarToggleScreenshare.bind(this);
  201. this._onToolbarToggleSharedVideo
  202. = this._onToolbarToggleSharedVideo.bind(this);
  203. this._onToolbarOpenLocalRecordingInfoDialog
  204. = this._onToolbarOpenLocalRecordingInfoDialog.bind(this);
  205. }
  206. /**
  207. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  208. *
  209. * @inheritdoc
  210. * @returns {void}
  211. */
  212. componentDidMount() {
  213. const KEYBOARD_SHORTCUTS = [
  214. this._shouldShowButton('chat') && {
  215. character: 'C',
  216. exec: this._onShortcutToggleChat,
  217. helpDescription: 'keyboardShortcuts.toggleChat'
  218. },
  219. this._shouldShowButton('desktop') && {
  220. character: 'D',
  221. exec: this._onShortcutToggleScreenshare,
  222. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  223. },
  224. this._shouldShowButton('raisehand') && {
  225. character: 'R',
  226. exec: this._onShortcutToggleRaiseHand,
  227. helpDescription: 'keyboardShortcuts.raiseHand'
  228. },
  229. this._shouldShowButton('fullscreen') && {
  230. character: 'S',
  231. exec: this._onShortcutToggleFullScreen,
  232. helpDescription: 'keyboardShortcuts.fullScreen'
  233. }
  234. ];
  235. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  236. if (typeof shortcut === 'object') {
  237. APP.keyboardshortcut.registerShortcut(
  238. shortcut.character,
  239. null,
  240. shortcut.exec,
  241. shortcut.helpDescription);
  242. }
  243. });
  244. }
  245. /**
  246. * Update the visibility of the {@code OverflowMenuButton}.
  247. *
  248. * @inheritdoc
  249. */
  250. componentDidUpdate(prevProps) {
  251. // Ensure the dialog is closed when the toolbox becomes hidden.
  252. if (prevProps._overflowMenuVisible && !this.props._visible) {
  253. this._onSetOverflowVisible(false);
  254. }
  255. if (prevProps._overflowMenuVisible
  256. && !prevProps._dialog
  257. && this.props._dialog) {
  258. this._onSetOverflowVisible(false);
  259. this.props.dispatch(setToolbarHovered(false));
  260. }
  261. }
  262. /**
  263. * Removes keyboard shortcuts registered by this component.
  264. *
  265. * @inheritdoc
  266. * @returns {void}
  267. */
  268. componentWillUnmount() {
  269. [ 'C', 'D', 'R', 'S' ].forEach(letter =>
  270. APP.keyboardshortcut.unregisterShortcut(letter));
  271. }
  272. /**
  273. * Implements React's {@link Component#render()}.
  274. *
  275. * @inheritdoc
  276. * @returns {ReactElement}
  277. */
  278. render() {
  279. const {
  280. _chatOpen,
  281. _hideInviteButton,
  282. _overflowMenuVisible,
  283. _raisedHand,
  284. _visible,
  285. _visibleButtons,
  286. t
  287. } = this.props;
  288. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  289. _visibleButtons.size ? '' : 'no-buttons'}`;
  290. const overflowMenuContent = this._renderOverflowMenuContent();
  291. const overflowHasItems = Boolean(overflowMenuContent.filter(
  292. child => child).length);
  293. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  294. return (
  295. <div
  296. className = { rootClassNames }
  297. id = 'new-toolbox'
  298. onMouseOut = { this._onMouseOut }
  299. onMouseOver = { this._onMouseOver }>
  300. <div className = 'button-group-left'>
  301. { this._shouldShowButton('desktop')
  302. && this._renderDesktopSharingButton() }
  303. { this._shouldShowButton('raisehand')
  304. && <ToolbarButton
  305. accessibilityLabel =
  306. { t('toolbar.accessibilityLabel.raiseHand') }
  307. iconName = { _raisedHand
  308. ? 'icon-raised-hand toggled'
  309. : 'icon-raised-hand' }
  310. onClick = { this._onToolbarToggleRaiseHand }
  311. tooltip = { t('toolbar.raiseHand') } /> }
  312. { this._shouldShowButton('chat')
  313. && <div className = 'toolbar-button-with-badge'>
  314. <ToolbarButton
  315. accessibilityLabel =
  316. { t('toolbar.accessibilityLabel.chat') }
  317. iconName = { _chatOpen
  318. ? 'icon-chat toggled'
  319. : 'icon-chat' }
  320. onClick = { this._onToolbarToggleChat }
  321. tooltip = { t('toolbar.chat') } />
  322. <ChatCounter />
  323. </div> }
  324. {
  325. this._shouldShowButton('closedcaptions')
  326. && <ClosedCaptionButton />
  327. }
  328. </div>
  329. <div className = 'button-group-center'>
  330. <AudioMuteButton
  331. visible = { this._shouldShowButton('microphone') } />
  332. <HangupButton
  333. visible = { this._shouldShowButton('hangup') } />
  334. <VideoMuteButton
  335. visible = { this._shouldShowButton('camera') } />
  336. </div>
  337. <div className = 'button-group-right'>
  338. { this._shouldShowButton('localrecording')
  339. && <LocalRecordingButton
  340. onClick = {
  341. this._onToolbarOpenLocalRecordingInfoDialog
  342. } />
  343. }
  344. { this._shouldShowButton('tileview')
  345. && <TileViewButton /> }
  346. { this._shouldShowButton('invite')
  347. && !_hideInviteButton
  348. && <ToolbarButton
  349. accessibilityLabel =
  350. { t('toolbar.accessibilityLabel.invite') }
  351. iconName = 'icon-add'
  352. onClick = { this._onToolbarOpenInvite }
  353. tooltip = { t('toolbar.invite') } /> }
  354. { this._shouldShowButton('info') && <InfoDialogButton /> }
  355. { overflowHasItems
  356. && <OverflowMenuButton
  357. isOpen = { _overflowMenuVisible }
  358. onVisibilityChange = { this._onSetOverflowVisible }>
  359. <ul
  360. aria-label = { t(toolbarAccLabel) }
  361. className = 'overflow-menu'>
  362. { overflowMenuContent }
  363. </ul>
  364. </OverflowMenuButton> }
  365. </div>
  366. </div>
  367. );
  368. }
  369. /**
  370. * Callback invoked to display {@code FeedbackDialog}.
  371. *
  372. * @private
  373. * @returns {void}
  374. */
  375. _doOpenFeedback() {
  376. const { _conference } = this.props;
  377. this.props.dispatch(openFeedbackDialog(_conference));
  378. }
  379. /**
  380. * Dispatches an action to display {@code KeyboardShortcuts}.
  381. *
  382. * @private
  383. * @returns {void}
  384. */
  385. _doOpenKeyboardShorcuts() {
  386. this.props.dispatch(openKeyboardShortcutsDialog());
  387. }
  388. /**
  389. * Callback invoked to display {@code SpeakerStats}.
  390. *
  391. * @private
  392. * @returns {void}
  393. */
  394. _doOpenSpeakerStats() {
  395. this.props.dispatch(openDialog(SpeakerStats, {
  396. conference: this.props._conference
  397. }));
  398. }
  399. /**
  400. * Dispatches an action to toggle the video quality dialog.
  401. *
  402. * @private
  403. * @returns {void}
  404. */
  405. _doOpenVideoQuality() {
  406. this.props.dispatch(openDialog(VideoQualityDialog));
  407. }
  408. /**
  409. * Dispatches an action to toggle the display of chat.
  410. *
  411. * @private
  412. * @returns {void}
  413. */
  414. _doToggleChat() {
  415. this.props.dispatch(toggleChat());
  416. }
  417. /**
  418. * Dispatches an action to show or hide document editing.
  419. *
  420. * @private
  421. * @returns {void}
  422. */
  423. _doToggleEtherpad() {
  424. this.props.dispatch(toggleDocument());
  425. }
  426. /**
  427. * Dispatches an action to toggle screensharing.
  428. *
  429. * @private
  430. * @returns {void}
  431. */
  432. _doToggleFullScreen() {
  433. const fullScreen = !this.props._fullScreen;
  434. this.props.dispatch(setFullScreen(fullScreen));
  435. }
  436. /**
  437. * Dispatches an action to show or hide the profile edit panel.
  438. *
  439. * @private
  440. * @returns {void}
  441. */
  442. _doToggleProfile() {
  443. this.props.dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE));
  444. }
  445. /**
  446. * Dispatches an action to toggle the local participant's raised hand state.
  447. *
  448. * @private
  449. * @returns {void}
  450. */
  451. _doToggleRaiseHand() {
  452. const { _localParticipantID, _raisedHand } = this.props;
  453. this.props.dispatch(participantUpdated({
  454. // XXX Only the local participant is allowed to update without
  455. // stating the JitsiConference instance (i.e. participant property
  456. // `conference` for a remote participant) because the local
  457. // participant is uniquely identified by the very fact that there is
  458. // only one local participant.
  459. id: _localParticipantID,
  460. local: true,
  461. raisedHand: !_raisedHand
  462. }));
  463. }
  464. /**
  465. * Dispatches an action to toggle screensharing.
  466. *
  467. * @private
  468. * @returns {void}
  469. */
  470. _doToggleScreenshare() {
  471. if (this.props._desktopSharingEnabled) {
  472. this.props.dispatch(toggleScreensharing());
  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.props.dispatch(setOverflowMenuVisible(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.props.dispatch(beginAddPeople());
  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. _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. _onToolbarToggleScreenshare: () => void;
  714. /**
  715. * Creates an analytics toolbar event and dispatches an action for toggling
  716. * screensharing.
  717. *
  718. * @private
  719. * @returns {void}
  720. */
  721. _onToolbarToggleScreenshare() {
  722. if (!this.props._desktopSharingEnabled) {
  723. return;
  724. }
  725. sendAnalytics(createShortcutEvent(
  726. 'toggle.screen.sharing',
  727. ACTION_SHORTCUT_TRIGGERED,
  728. { enable: !this.props._screensharing }));
  729. this._doToggleScreenshare();
  730. }
  731. _onToolbarToggleSharedVideo: () => void;
  732. /**
  733. * Creates an analytics toolbar event and dispatches an action for toggling
  734. * the sharing of a YouTube video.
  735. *
  736. * @private
  737. * @returns {void}
  738. */
  739. _onToolbarToggleSharedVideo() {
  740. sendAnalytics(createToolbarEvent('shared.video.toggled',
  741. {
  742. enable: !this.props._sharingVideo
  743. }));
  744. this._doToggleSharedVideo();
  745. }
  746. _onToolbarOpenLocalRecordingInfoDialog: () => void;
  747. /**
  748. * Opens the {@code LocalRecordingInfoDialog}.
  749. *
  750. * @private
  751. * @returns {void}
  752. */
  753. _onToolbarOpenLocalRecordingInfoDialog() {
  754. sendAnalytics(createToolbarEvent('local.recording'));
  755. this.props.dispatch(openDialog(LocalRecordingInfoDialog));
  756. }
  757. /**
  758. * Renders a button for toggleing screen sharing.
  759. *
  760. * @private
  761. * @returns {ReactElement|null}
  762. */
  763. _renderDesktopSharingButton() {
  764. const {
  765. _desktopSharingEnabled,
  766. _desktopSharingDisabledTooltipKey,
  767. _screensharing,
  768. t
  769. } = this.props;
  770. const visible
  771. = _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  772. if (!visible) {
  773. return null;
  774. }
  775. const classNames = `icon-share-desktop ${
  776. _screensharing ? 'toggled' : ''} ${
  777. _desktopSharingEnabled ? '' : 'disabled'}`;
  778. const tooltip = t(
  779. _desktopSharingEnabled
  780. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey);
  781. return (
  782. <ToolbarButton
  783. accessibilityLabel
  784. = { t('toolbar.accessibilityLabel.shareYourScreen') }
  785. iconName = { classNames }
  786. onClick = { this._onToolbarToggleScreenshare }
  787. tooltip = { tooltip } />
  788. );
  789. }
  790. /**
  791. * Renders the list elements of the overflow menu.
  792. *
  793. * @private
  794. * @returns {Array<ReactElement>}
  795. */
  796. _renderOverflowMenuContent() {
  797. const {
  798. _editingDocument,
  799. _etherpadInitialized,
  800. _feedbackConfigured,
  801. _fullScreen,
  802. _isGuest,
  803. _sharingVideo,
  804. t
  805. } = this.props;
  806. return [
  807. _isGuest
  808. && this._shouldShowButton('profile')
  809. && <OverflowMenuProfileItem
  810. key = 'profile'
  811. onClick = { this._onToolbarToggleProfile } />,
  812. this._shouldShowButton('videoquality')
  813. && <OverflowMenuVideoQualityItem
  814. key = 'videoquality'
  815. onClick = { this._onToolbarOpenVideoQuality } />,
  816. this._shouldShowButton('fullscreen')
  817. && <OverflowMenuItem
  818. accessibilityLabel =
  819. { t('toolbar.accessibilityLabel.fullScreen') }
  820. icon = { _fullScreen
  821. ? 'icon-exit-full-screen'
  822. : 'icon-full-screen' }
  823. key = 'fullscreen'
  824. onClick = { this._onToolbarToggleFullScreen }
  825. text = { _fullScreen
  826. ? t('toolbar.exitFullScreen')
  827. : t('toolbar.enterFullScreen') } />,
  828. <LiveStreamButton
  829. key = 'livestreaming'
  830. showLabel = { true } />,
  831. <RecordButton
  832. key = 'record'
  833. showLabel = { true } />,
  834. this._shouldShowButton('sharedvideo')
  835. && <OverflowMenuItem
  836. accessibilityLabel =
  837. { t('toolbar.accessibilityLabel.sharedvideo') }
  838. icon = 'icon-shared-video'
  839. key = 'sharedvideo'
  840. onClick = { this._onToolbarToggleSharedVideo }
  841. text = { _sharingVideo
  842. ? t('toolbar.stopSharedVideo')
  843. : t('toolbar.sharedvideo') } />,
  844. this._shouldShowButton('etherpad')
  845. && _etherpadInitialized
  846. && <OverflowMenuItem
  847. accessibilityLabel =
  848. { t('toolbar.accessibilityLabel.document') }
  849. icon = 'icon-share-doc'
  850. key = 'etherpad'
  851. onClick = { this._onToolbarToggleEtherpad }
  852. text = { _editingDocument
  853. ? t('toolbar.documentClose')
  854. : t('toolbar.documentOpen') } />,
  855. <SettingsButton
  856. key = 'settings'
  857. showLabel = { true }
  858. visible = { this._shouldShowButton('settings') } />,
  859. this._shouldShowButton('stats')
  860. && <OverflowMenuItem
  861. accessibilityLabel =
  862. { t('toolbar.accessibilityLabel.speakerStats') }
  863. icon = 'icon-presentation'
  864. key = 'stats'
  865. onClick = { this._onToolbarOpenSpeakerStats }
  866. text = { t('toolbar.speakerStats') } />,
  867. this._shouldShowButton('feedback')
  868. && _feedbackConfigured
  869. && <OverflowMenuItem
  870. accessibilityLabel =
  871. { t('toolbar.accessibilityLabel.feedback') }
  872. icon = 'icon-feedback'
  873. key = 'feedback'
  874. onClick = { this._onToolbarOpenFeedback }
  875. text = { t('toolbar.feedback') } />,
  876. this._shouldShowButton('shortcuts')
  877. && <OverflowMenuItem
  878. accessibilityLabel =
  879. { t('toolbar.accessibilityLabel.shortcuts') }
  880. icon = 'icon-open_in_new'
  881. key = 'shortcuts'
  882. onClick = { this._onToolbarOpenKeyboardShortcuts }
  883. text = { t('toolbar.shortcuts') } />
  884. ];
  885. }
  886. _shouldShowButton: (string) => boolean;
  887. /**
  888. * Returns if a button name has been explicitly configured to be displayed.
  889. *
  890. * @param {string} buttonName - The name of the button, as expected in
  891. * {@link interfaceConfig}.
  892. * @private
  893. * @returns {boolean} True if the button should be displayed.
  894. */
  895. _shouldShowButton(buttonName) {
  896. return this.props._visibleButtons.has(buttonName);
  897. }
  898. }
  899. /**
  900. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  901. * props.
  902. *
  903. * @param {Object} state - The redux store/state.
  904. * @private
  905. * @returns {{}}
  906. */
  907. function _mapStateToProps(state) {
  908. const { conference } = state['features/base/conference'];
  909. let { desktopSharingEnabled } = state['features/base/conference'];
  910. const {
  911. callStatsID,
  912. iAmRecorder
  913. } = state['features/base/config'];
  914. const sharedVideoStatus = state['features/shared-video'].status;
  915. const {
  916. alwaysVisible,
  917. fullScreen,
  918. overflowMenuVisible,
  919. timeoutID,
  920. visible
  921. } = state['features/toolbox'];
  922. const localParticipant = getLocalParticipant(state);
  923. const localRecordingStates = state['features/local-recording'];
  924. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  925. const addPeopleEnabled = isAddPeopleEnabled(state);
  926. const dialOutEnabled = isDialOutEnabled(state);
  927. let desktopSharingDisabledTooltipKey;
  928. if (state['features/base/config'].enableFeaturesBasedOnToken) {
  929. // we enable desktop sharing if any participant already have this
  930. // feature enabled
  931. desktopSharingEnabled = getParticipants(state)
  932. .find(({ features = {} }) =>
  933. String(features['screen-sharing']) === 'true') !== undefined;
  934. // we want to show button and tooltip
  935. if (state['features/base/jwt'].isGuest) {
  936. desktopSharingDisabledTooltipKey
  937. = 'dialog.shareYourScreenDisabledForGuest';
  938. } else {
  939. desktopSharingDisabledTooltipKey
  940. = 'dialog.shareYourScreenDisabled';
  941. }
  942. }
  943. return {
  944. _chatOpen: state['features/chat'].isOpen,
  945. _conference: conference,
  946. _desktopSharingEnabled: desktopSharingEnabled,
  947. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  948. _dialog: Boolean(state['features/base/dialog'].component),
  949. _editingDocument: Boolean(state['features/etherpad'].editing),
  950. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  951. _feedbackConfigured: Boolean(callStatsID),
  952. _hideInviteButton:
  953. iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
  954. _isGuest: state['features/base/jwt'].isGuest,
  955. _fullScreen: fullScreen,
  956. _localParticipantID: localParticipant.id,
  957. _localRecState: localRecordingStates,
  958. _overflowMenuVisible: overflowMenuVisible,
  959. _raisedHand: localParticipant.raisedHand,
  960. _screensharing: localVideo && localVideo.videoType === 'desktop',
  961. _sharingVideo: sharedVideoStatus === 'playing'
  962. || sharedVideoStatus === 'start'
  963. || sharedVideoStatus === 'pause',
  964. _visible: Boolean(timeoutID || visible || alwaysVisible),
  965. // XXX: We are not currently using state here, but in the future, when
  966. // interfaceConfig is part of redux we will.
  967. _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS)
  968. };
  969. }
  970. export default translate(connect(_mapStateToProps)(Toolbox));