Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  1. // @flow
  2. import React, { Component } from 'react';
  3. import {
  4. ACTION_SHORTCUT_TRIGGERED,
  5. createShortcutEvent,
  6. createToolbarEvent,
  7. sendAnalytics
  8. } from '../../../analytics';
  9. import { openDialog, toggleDialog } from '../../../base/dialog';
  10. import { translate } from '../../../base/i18n';
  11. import {
  12. IconChat,
  13. IconCodeBlock,
  14. IconDeviceDocument,
  15. IconExitFullScreen,
  16. IconFeedback,
  17. IconFullScreen,
  18. IconInviteMore,
  19. IconPresentation,
  20. IconRaisedHand,
  21. IconRec,
  22. IconShareDesktop
  23. } from '../../../base/icons';
  24. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  25. import {
  26. getLocalParticipant,
  27. getParticipants,
  28. participantUpdated
  29. } from '../../../base/participants';
  30. import { connect, equals } from '../../../base/redux';
  31. import { OverflowMenuItem } from '../../../base/toolbox/components';
  32. import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
  33. import { isVpaasMeeting } from '../../../billing-counter/functions';
  34. import { VideoBlurButton } from '../../../blur';
  35. import { checkBlurSupport } from '../../../blur/functions';
  36. import { CHAT_SIZE, ChatCounter, toggleChat } from '../../../chat';
  37. import { EmbedMeetingDialog } from '../../../embed-meeting';
  38. import { SharedDocumentButton } from '../../../etherpad';
  39. import { openFeedbackDialog } from '../../../feedback';
  40. import { beginAddPeople } from '../../../invite';
  41. import { openKeyboardShortcutsDialog } from '../../../keyboard-shortcuts';
  42. import { LocalRecordingInfoDialog } from '../../../local-recording';
  43. import {
  44. LiveStreamButton,
  45. RecordButton
  46. } from '../../../recording';
  47. import { SecurityDialogButton } from '../../../security';
  48. import {
  49. SETTINGS_TABS,
  50. SettingsButton,
  51. openSettingsDialog
  52. } from '../../../settings';
  53. import { SharedVideoButton } from '../../../shared-video/components';
  54. import { SpeakerStats } from '../../../speaker-stats';
  55. import {
  56. ClosedCaptionButton
  57. } from '../../../subtitles';
  58. import {
  59. TileViewButton,
  60. shouldDisplayTileView,
  61. toggleTileView
  62. } from '../../../video-layout';
  63. import {
  64. OverflowMenuVideoQualityItem,
  65. VideoQualityDialog
  66. } from '../../../video-quality';
  67. import {
  68. setFullScreen,
  69. setOverflowMenuVisible,
  70. setToolbarHovered,
  71. setToolboxVisible
  72. } from '../../actions';
  73. import { getToolbarAdditionalButtons, isToolboxVisible } from '../../functions';
  74. import DownloadButton from '../DownloadButton';
  75. import HangupButton from '../HangupButton';
  76. import HelpButton from '../HelpButton';
  77. import MuteEveryoneButton from '../MuteEveryoneButton';
  78. import AudioSettingsButton from './AudioSettingsButton';
  79. import OverflowMenuButton from './OverflowMenuButton';
  80. import OverflowMenuProfileItem from './OverflowMenuProfileItem';
  81. import ToolbarButton from './ToolbarButton';
  82. import VideoSettingsButton from './VideoSettingsButton';
  83. /**
  84. * The type of the React {@code Component} props of {@link Toolbox}.
  85. */
  86. type Props = {
  87. /**
  88. * Whether or not the chat feature is currently displayed.
  89. */
  90. _chatOpen: boolean,
  91. /**
  92. * The {@code JitsiConference} for the current conference.
  93. */
  94. _conference: Object,
  95. /**
  96. * The tooltip key to use when screensharing is disabled. Or undefined
  97. * if non to be shown and the button to be hidden.
  98. */
  99. _desktopSharingDisabledTooltipKey: boolean,
  100. /**
  101. * Whether or not screensharing is initialized.
  102. */
  103. _desktopSharingEnabled: boolean,
  104. /**
  105. * Whether or not a dialog is displayed.
  106. */
  107. _dialog: boolean,
  108. /**
  109. * Whether or not call feedback can be sent.
  110. */
  111. _feedbackConfigured: boolean,
  112. /**
  113. * Whether or not the app is currently in full screen.
  114. */
  115. _fullScreen: boolean,
  116. /**
  117. * Whether or not the profile is disabled.
  118. */
  119. _isProfileDisabled: boolean,
  120. /**
  121. * Whether or not the tile view is enabled.
  122. */
  123. _tileViewEnabled: boolean,
  124. /**
  125. * Whether or not the current meeting belongs to a JaaS user.
  126. */
  127. _isVpaasMeeting: boolean,
  128. /**
  129. * The ID of the local participant.
  130. */
  131. _localParticipantID: String,
  132. /**
  133. * The subsection of Redux state for local recording
  134. */
  135. _localRecState: Object,
  136. /**
  137. * The value for how the conference is locked (or undefined if not locked)
  138. * as defined by room-lock constants.
  139. */
  140. _locked: boolean,
  141. /**
  142. * Whether or not the overflow menu is visible.
  143. */
  144. _overflowMenuVisible: boolean,
  145. /**
  146. * Whether or not the local participant's hand is raised.
  147. */
  148. _raisedHand: boolean,
  149. /**
  150. * Whether or not the local participant is screensharing.
  151. */
  152. _screensharing: boolean,
  153. /**
  154. * Whether or not the local participant is sharing a YouTube video.
  155. */
  156. _sharingVideo: boolean,
  157. /**
  158. * Flag showing whether toolbar is visible.
  159. */
  160. _visible: boolean,
  161. /**
  162. * Set with the buttons which this Toolbox should display.
  163. */
  164. _visibleButtons: Set<string>,
  165. /**
  166. * Invoked to active other features of the app.
  167. */
  168. dispatch: Function,
  169. /**
  170. * Invoked to obtain translated strings.
  171. */
  172. t: Function
  173. };
  174. /**
  175. * The type of the React {@code Component} state of {@link Toolbox}.
  176. */
  177. type State = {
  178. /**
  179. * The width of the browser's window.
  180. */
  181. windowWidth: number
  182. };
  183. declare var APP: Object;
  184. declare var interfaceConfig: Object;
  185. // XXX: We are not currently using state here, but in the future, when
  186. // interfaceConfig is part of redux we will. This will have to be retrieved from the store.
  187. const visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  188. /**
  189. * Implements the conference toolbox on React/Web.
  190. *
  191. * @extends Component
  192. */
  193. class Toolbox extends Component<Props, State> {
  194. /**
  195. * Initializes a new {@code Toolbox} instance.
  196. *
  197. * @param {Props} props - The read-only React {@code Component} props with
  198. * which the new instance is to be initialized.
  199. */
  200. constructor(props: Props) {
  201. super(props);
  202. // Bind event handlers so they are only bound once per instance.
  203. this._onMouseOut = this._onMouseOut.bind(this);
  204. this._onMouseOver = this._onMouseOver.bind(this);
  205. this._onResize = this._onResize.bind(this);
  206. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  207. this._onTabIn = this._onTabIn.bind(this);
  208. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  209. this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
  210. this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
  211. this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
  212. this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
  213. this._onToolbarOpenFeedback = this._onToolbarOpenFeedback.bind(this);
  214. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  215. this._onToolbarOpenKeyboardShortcuts = this._onToolbarOpenKeyboardShortcuts.bind(this);
  216. this._onToolbarOpenSpeakerStats = this._onToolbarOpenSpeakerStats.bind(this);
  217. this._onToolbarOpenEmbedMeeting = this._onToolbarOpenEmbedMeeting.bind(this);
  218. this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
  219. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  220. this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
  221. this._onToolbarToggleProfile = this._onToolbarToggleProfile.bind(this);
  222. this._onToolbarToggleRaiseHand = this._onToolbarToggleRaiseHand.bind(this);
  223. this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
  224. this._onToolbarOpenLocalRecordingInfoDialog = this._onToolbarOpenLocalRecordingInfoDialog.bind(this);
  225. this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
  226. this.state = {
  227. windowWidth: window.innerWidth
  228. };
  229. }
  230. /**
  231. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  232. *
  233. * @inheritdoc
  234. * @returns {void}
  235. */
  236. componentDidMount() {
  237. const KEYBOARD_SHORTCUTS = [
  238. this._shouldShowButton('videoquality') && {
  239. character: 'A',
  240. exec: this._onShortcutToggleVideoQuality,
  241. helpDescription: 'toolbar.callQuality'
  242. },
  243. this._shouldShowButton('chat') && {
  244. character: 'C',
  245. exec: this._onShortcutToggleChat,
  246. helpDescription: 'keyboardShortcuts.toggleChat'
  247. },
  248. this._shouldShowButton('desktop') && {
  249. character: 'D',
  250. exec: this._onShortcutToggleScreenshare,
  251. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  252. },
  253. this._shouldShowButton('raisehand') && {
  254. character: 'R',
  255. exec: this._onShortcutToggleRaiseHand,
  256. helpDescription: 'keyboardShortcuts.raiseHand'
  257. },
  258. this._shouldShowButton('fullscreen') && {
  259. character: 'S',
  260. exec: this._onShortcutToggleFullScreen,
  261. helpDescription: 'keyboardShortcuts.fullScreen'
  262. },
  263. this._shouldShowButton('tileview') && {
  264. character: 'W',
  265. exec: this._onShortcutToggleTileView,
  266. helpDescription: 'toolbar.tileViewToggle'
  267. }
  268. ];
  269. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  270. if (typeof shortcut === 'object') {
  271. APP.keyboardshortcut.registerShortcut(
  272. shortcut.character,
  273. null,
  274. shortcut.exec,
  275. shortcut.helpDescription);
  276. }
  277. });
  278. window.addEventListener('resize', this._onResize);
  279. }
  280. /**
  281. * Update the visibility of the {@code OverflowMenuButton}.
  282. *
  283. * @inheritdoc
  284. */
  285. componentDidUpdate(prevProps) {
  286. // Ensure the dialog is closed when the toolbox becomes hidden.
  287. if (prevProps._overflowMenuVisible && !this.props._visible) {
  288. this._onSetOverflowVisible(false);
  289. }
  290. if (prevProps._overflowMenuVisible
  291. && !prevProps._dialog
  292. && this.props._dialog) {
  293. this._onSetOverflowVisible(false);
  294. this.props.dispatch(setToolbarHovered(false));
  295. }
  296. if (this.props._chatOpen !== prevProps._chatOpen) {
  297. this._onResize();
  298. }
  299. }
  300. /**
  301. * Removes keyboard shortcuts registered by this component.
  302. *
  303. * @inheritdoc
  304. * @returns {void}
  305. */
  306. componentWillUnmount() {
  307. [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
  308. APP.keyboardshortcut.unregisterShortcut(letter));
  309. window.removeEventListener('resize', this._onResize);
  310. }
  311. /**
  312. * Implements React's {@link Component#render()}.
  313. *
  314. * @inheritdoc
  315. * @returns {ReactElement}
  316. */
  317. render() {
  318. const { _chatOpen, _visible, _visibleButtons } = this.props;
  319. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  320. _visibleButtons.size ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
  321. return (
  322. <div
  323. className = { rootClassNames }
  324. id = 'new-toolbox'
  325. onFocus = { this._onTabIn }
  326. onMouseOut = { this._onMouseOut }
  327. onMouseOver = { this._onMouseOver }>
  328. { this._renderToolboxContent() }
  329. </div>
  330. );
  331. }
  332. /**
  333. * Closes the overflow menu if opened.
  334. *
  335. * @private
  336. * @returns {void}
  337. */
  338. _closeOverflowMenuIfOpen() {
  339. const { dispatch, _overflowMenuVisible } = this.props;
  340. _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
  341. }
  342. /**
  343. * Callback invoked to display {@code FeedbackDialog}.
  344. *
  345. * @private
  346. * @returns {void}
  347. */
  348. _doOpenFeedback() {
  349. const { _conference } = this.props;
  350. this.props.dispatch(openFeedbackDialog(_conference));
  351. }
  352. /**
  353. * Callback invoked to display {@code FeedbackDialog}.
  354. *
  355. * @private
  356. * @returns {void}
  357. */
  358. _doOpenEmbedMeeting() {
  359. this.props.dispatch(openDialog(EmbedMeetingDialog));
  360. }
  361. /**
  362. * Dispatches an action to display {@code KeyboardShortcuts}.
  363. *
  364. * @private
  365. * @returns {void}
  366. */
  367. _doOpenKeyboardShorcuts() {
  368. this.props.dispatch(openKeyboardShortcutsDialog());
  369. }
  370. /**
  371. * Callback invoked to display {@code SpeakerStats}.
  372. *
  373. * @private
  374. * @returns {void}
  375. */
  376. _doOpenSpeakerStats() {
  377. this.props.dispatch(openDialog(SpeakerStats, {
  378. conference: this.props._conference
  379. }));
  380. }
  381. /**
  382. * Dispatches an action to open the video quality dialog.
  383. *
  384. * @private
  385. * @returns {void}
  386. */
  387. _doOpenVideoQuality() {
  388. this.props.dispatch(openDialog(VideoQualityDialog));
  389. }
  390. /**
  391. * Dispatches an action to toggle the display of chat.
  392. *
  393. * @private
  394. * @returns {void}
  395. */
  396. _doToggleChat() {
  397. this.props.dispatch(toggleChat());
  398. }
  399. /**
  400. * Dispatches an action to toggle screensharing.
  401. *
  402. * @private
  403. * @returns {void}
  404. */
  405. _doToggleFullScreen() {
  406. const fullScreen = !this.props._fullScreen;
  407. this.props.dispatch(setFullScreen(fullScreen));
  408. }
  409. /**
  410. * Dispatches an action to show or hide the profile edit panel.
  411. *
  412. * @private
  413. * @returns {void}
  414. */
  415. _doToggleProfile() {
  416. this.props.dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE));
  417. }
  418. /**
  419. * Dispatches an action to toggle the local participant's raised hand state.
  420. *
  421. * @private
  422. * @returns {void}
  423. */
  424. _doToggleRaiseHand() {
  425. const { _localParticipantID, _raisedHand } = this.props;
  426. const newRaisedStatus = !_raisedHand;
  427. this.props.dispatch(participantUpdated({
  428. // XXX Only the local participant is allowed to update without
  429. // stating the JitsiConference instance (i.e. participant property
  430. // `conference` for a remote participant) because the local
  431. // participant is uniquely identified by the very fact that there is
  432. // only one local participant.
  433. id: _localParticipantID,
  434. local: true,
  435. raisedHand: newRaisedStatus
  436. }));
  437. APP.API.notifyRaiseHandUpdated(_localParticipantID, newRaisedStatus);
  438. }
  439. /**
  440. * Dispatches an action to toggle screensharing.
  441. *
  442. * @private
  443. * @returns {void}
  444. */
  445. _doToggleScreenshare() {
  446. if (this.props._desktopSharingEnabled) {
  447. this.props.dispatch(toggleScreensharing());
  448. }
  449. }
  450. /**
  451. * Dispatches an action to toggle the video quality dialog.
  452. *
  453. * @private
  454. * @returns {void}
  455. */
  456. _doToggleVideoQuality() {
  457. this.props.dispatch(toggleDialog(VideoQualityDialog));
  458. }
  459. /**
  460. * Dispaches an action to toggle tile view.
  461. *
  462. * @private
  463. * @returns {void}
  464. */
  465. _doToggleTileView() {
  466. this.props.dispatch(toggleTileView());
  467. }
  468. _onMouseOut: () => void;
  469. /**
  470. * Dispatches an action signaling the toolbar is not being hovered.
  471. *
  472. * @private
  473. * @returns {void}
  474. */
  475. _onMouseOut() {
  476. this.props.dispatch(setToolbarHovered(false));
  477. }
  478. _onMouseOver: () => void;
  479. /**
  480. * Dispatches an action signaling the toolbar is being hovered.
  481. *
  482. * @private
  483. * @returns {void}
  484. */
  485. _onMouseOver() {
  486. this.props.dispatch(setToolbarHovered(true));
  487. }
  488. _onResize: () => void;
  489. /**
  490. * A window resize handler used to calculate the number of buttons we can
  491. * fit in the toolbar.
  492. *
  493. * @private
  494. * @returns {void}
  495. */
  496. _onResize() {
  497. let widthToUse = window.innerWidth;
  498. // Take chat size into account when resizing toolbox.
  499. if (this.props._chatOpen) {
  500. widthToUse -= CHAT_SIZE;
  501. }
  502. if (this.state.windowWidth !== widthToUse) {
  503. this.setState({ windowWidth: widthToUse });
  504. }
  505. }
  506. _onSetOverflowVisible: (boolean) => void;
  507. /**
  508. * Sets the visibility of the overflow menu.
  509. *
  510. * @param {boolean} visible - Whether or not the overflow menu should be
  511. * displayed.
  512. * @private
  513. * @returns {void}
  514. */
  515. _onSetOverflowVisible(visible) {
  516. this.props.dispatch(setOverflowMenuVisible(visible));
  517. }
  518. _onShortcutToggleChat: () => void;
  519. /**
  520. * Creates an analytics keyboard shortcut event and dispatches an action for
  521. * toggling the display of chat.
  522. *
  523. * @private
  524. * @returns {void}
  525. */
  526. _onShortcutToggleChat() {
  527. sendAnalytics(createShortcutEvent(
  528. 'toggle.chat',
  529. {
  530. enable: !this.props._chatOpen
  531. }));
  532. this._doToggleChat();
  533. }
  534. _onShortcutToggleVideoQuality: () => void;
  535. /**
  536. * Creates an analytics keyboard shortcut event and dispatches an action for
  537. * toggling the display of Video Quality.
  538. *
  539. * @private
  540. * @returns {void}
  541. */
  542. _onShortcutToggleVideoQuality() {
  543. sendAnalytics(createShortcutEvent('video.quality'));
  544. this._doToggleVideoQuality();
  545. }
  546. _onShortcutToggleTileView: () => void;
  547. /**
  548. * Dispatches an action for toggling the tile view.
  549. *
  550. * @private
  551. * @returns {void}
  552. */
  553. _onShortcutToggleTileView() {
  554. sendAnalytics(createShortcutEvent(
  555. 'toggle.tileview',
  556. {
  557. enable: !this.props._tileViewEnabled
  558. }));
  559. this._doToggleTileView();
  560. }
  561. _onShortcutToggleFullScreen: () => void;
  562. /**
  563. * Creates an analytics keyboard shortcut event and dispatches an action for
  564. * toggling full screen mode.
  565. *
  566. * @private
  567. * @returns {void}
  568. */
  569. _onShortcutToggleFullScreen() {
  570. sendAnalytics(createShortcutEvent(
  571. 'toggle.fullscreen',
  572. {
  573. enable: !this.props._fullScreen
  574. }));
  575. this._doToggleFullScreen();
  576. }
  577. _onShortcutToggleRaiseHand: () => void;
  578. /**
  579. * Creates an analytics keyboard shortcut event and dispatches an action for
  580. * toggling raise hand.
  581. *
  582. * @private
  583. * @returns {void}
  584. */
  585. _onShortcutToggleRaiseHand() {
  586. sendAnalytics(createShortcutEvent(
  587. 'toggle.raise.hand',
  588. ACTION_SHORTCUT_TRIGGERED,
  589. { enable: !this.props._raisedHand }));
  590. this._doToggleRaiseHand();
  591. }
  592. _onShortcutToggleScreenshare: () => void;
  593. /**
  594. * Creates an analytics keyboard shortcut event and dispatches an action for
  595. * toggling screensharing.
  596. *
  597. * @private
  598. * @returns {void}
  599. */
  600. _onShortcutToggleScreenshare() {
  601. sendAnalytics(createToolbarEvent(
  602. 'screen.sharing',
  603. {
  604. enable: !this.props._screensharing
  605. }));
  606. this._doToggleScreenshare();
  607. }
  608. _onTabIn: () => void;
  609. /**
  610. * Toggle the toolbar visibility when tabbing into it.
  611. *
  612. * @returns {void}
  613. */
  614. _onTabIn() {
  615. if (!this.props._visible) {
  616. this.props.dispatch(setToolboxVisible(true));
  617. }
  618. }
  619. _onToolbarOpenFeedback: () => void;
  620. /**
  621. * Creates an analytics toolbar event and dispatches an action for toggling
  622. * display of feedback.
  623. *
  624. * @private
  625. * @returns {void}
  626. */
  627. _onToolbarOpenFeedback() {
  628. sendAnalytics(createToolbarEvent('feedback'));
  629. this._doOpenFeedback();
  630. }
  631. _onToolbarOpenInvite: () => void;
  632. /**
  633. * Creates an analytics toolbar event and dispatches an action for opening
  634. * the modal for inviting people directly into the conference.
  635. *
  636. * @private
  637. * @returns {void}
  638. */
  639. _onToolbarOpenInvite() {
  640. sendAnalytics(createToolbarEvent('invite'));
  641. this.props.dispatch(beginAddPeople());
  642. }
  643. _onToolbarOpenKeyboardShortcuts: () => void;
  644. /**
  645. * Creates an analytics toolbar event and dispatches an action for opening
  646. * the modal for showing available keyboard shortcuts.
  647. *
  648. * @private
  649. * @returns {void}
  650. */
  651. _onToolbarOpenKeyboardShortcuts() {
  652. sendAnalytics(createToolbarEvent('shortcuts'));
  653. this._doOpenKeyboardShorcuts();
  654. }
  655. _onToolbarOpenEmbedMeeting: () => void;
  656. /**
  657. * Creates an analytics toolbar event and dispatches an action for opening
  658. * the embed meeting modal.
  659. *
  660. * @private
  661. * @returns {void}
  662. */
  663. _onToolbarOpenEmbedMeeting() {
  664. sendAnalytics(createToolbarEvent('embed.meeting'));
  665. this._doOpenEmbedMeeting();
  666. }
  667. _onToolbarOpenSpeakerStats: () => void;
  668. /**
  669. * Creates an analytics toolbar event and dispatches an action for opening
  670. * the speaker stats modal.
  671. *
  672. * @private
  673. * @returns {void}
  674. */
  675. _onToolbarOpenSpeakerStats() {
  676. sendAnalytics(createToolbarEvent('speaker.stats'));
  677. this._doOpenSpeakerStats();
  678. }
  679. _onToolbarOpenVideoQuality: () => void;
  680. /**
  681. * Creates an analytics toolbar event and dispatches an action for toggling
  682. * open the video quality dialog.
  683. *
  684. * @private
  685. * @returns {void}
  686. */
  687. _onToolbarOpenVideoQuality() {
  688. sendAnalytics(createToolbarEvent('video.quality'));
  689. this._doOpenVideoQuality();
  690. }
  691. _onToolbarToggleChat: () => void;
  692. /**
  693. * Creates an analytics toolbar event and dispatches an action for toggling
  694. * the display of chat.
  695. *
  696. * @private
  697. * @returns {void}
  698. */
  699. _onToolbarToggleChat() {
  700. sendAnalytics(createToolbarEvent(
  701. 'toggle.chat',
  702. {
  703. enable: !this.props._chatOpen
  704. }));
  705. this._closeOverflowMenuIfOpen();
  706. this._doToggleChat();
  707. }
  708. _onToolbarToggleFullScreen: () => void;
  709. /**
  710. * Creates an analytics toolbar event and dispatches an action for toggling
  711. * full screen mode.
  712. *
  713. * @private
  714. * @returns {void}
  715. */
  716. _onToolbarToggleFullScreen() {
  717. sendAnalytics(createToolbarEvent(
  718. 'toggle.fullscreen',
  719. {
  720. enable: !this.props._fullScreen
  721. }));
  722. this._closeOverflowMenuIfOpen();
  723. this._doToggleFullScreen();
  724. }
  725. _onToolbarToggleProfile: () => void;
  726. /**
  727. * Creates an analytics toolbar event and dispatches an action for showing
  728. * or hiding the profile edit panel.
  729. *
  730. * @private
  731. * @returns {void}
  732. */
  733. _onToolbarToggleProfile() {
  734. sendAnalytics(createToolbarEvent('profile'));
  735. this._doToggleProfile();
  736. }
  737. _onToolbarToggleRaiseHand: () => void;
  738. /**
  739. * Creates an analytics toolbar event and dispatches an action for toggling
  740. * raise hand.
  741. *
  742. * @private
  743. * @returns {void}
  744. */
  745. _onToolbarToggleRaiseHand() {
  746. sendAnalytics(createToolbarEvent(
  747. 'raise.hand',
  748. { enable: !this.props._raisedHand }));
  749. this._doToggleRaiseHand();
  750. }
  751. _onToolbarToggleScreenshare: () => void;
  752. /**
  753. * Creates an analytics toolbar event and dispatches an action for toggling
  754. * screensharing.
  755. *
  756. * @private
  757. * @returns {void}
  758. */
  759. _onToolbarToggleScreenshare() {
  760. if (!this.props._desktopSharingEnabled) {
  761. return;
  762. }
  763. sendAnalytics(createShortcutEvent(
  764. 'toggle.screen.sharing',
  765. ACTION_SHORTCUT_TRIGGERED,
  766. { enable: !this.props._screensharing }));
  767. this._closeOverflowMenuIfOpen();
  768. this._doToggleScreenshare();
  769. }
  770. _onToolbarOpenLocalRecordingInfoDialog: () => void;
  771. /**
  772. * Opens the {@code LocalRecordingInfoDialog}.
  773. *
  774. * @private
  775. * @returns {void}
  776. */
  777. _onToolbarOpenLocalRecordingInfoDialog() {
  778. sendAnalytics(createToolbarEvent('local.recording'));
  779. this.props.dispatch(openDialog(LocalRecordingInfoDialog));
  780. }
  781. /**
  782. * Returns true if the desktop sharing button should be visible and
  783. * false otherwise.
  784. *
  785. * @returns {boolean}
  786. */
  787. _showDesktopSharingButton() {
  788. const {
  789. _desktopSharingEnabled,
  790. _desktopSharingDisabledTooltipKey
  791. } = this.props;
  792. return (
  793. (_desktopSharingEnabled
  794. || _desktopSharingDisabledTooltipKey)
  795. && this._shouldShowButton('desktop')
  796. );
  797. }
  798. /**
  799. * Returns true if the profile button is visible and false otherwise.
  800. *
  801. * @returns {boolean}
  802. */
  803. _isEmbedMeetingVisible() {
  804. return !this.props._isVpaasMeeting && this._shouldShowButton('embedmeeting');
  805. }
  806. /**
  807. * Returns true if the profile button is visible and false otherwise.
  808. *
  809. * @returns {boolean}
  810. */
  811. _isProfileVisible() {
  812. return !this.props._isProfileDisabled && this._shouldShowButton('profile');
  813. }
  814. /**
  815. * Renders the list elements of the overflow menu.
  816. *
  817. * @private
  818. * @param {Array<React$Element>} additionalButtons - Additional buttons to be displayed.
  819. * @returns {Array<React$Element>}
  820. */
  821. _renderOverflowMenuContent(additionalButtons: Array<React$Element<any>>) {
  822. const {
  823. _feedbackConfigured,
  824. _fullScreen,
  825. _screensharing,
  826. t
  827. } = this.props;
  828. const group1 = [
  829. ...additionalButtons,
  830. this._shouldShowButton('videoquality')
  831. && <OverflowMenuVideoQualityItem
  832. key = 'videoquality'
  833. onClick = { this._onToolbarOpenVideoQuality } />,
  834. this._shouldShowButton('fullscreen')
  835. && <OverflowMenuItem
  836. accessibilityLabel = { t('toolbar.accessibilityLabel.fullScreen') }
  837. icon = { _fullScreen ? IconExitFullScreen : IconFullScreen }
  838. key = 'fullscreen'
  839. onClick = { this._onToolbarToggleFullScreen }
  840. text = { _fullScreen ? t('toolbar.exitFullScreen') : t('toolbar.enterFullScreen') } />,
  841. this._shouldShowButton('security')
  842. && <SecurityDialogButton
  843. key = 'security'
  844. showLabel = { true } />,
  845. this._shouldShowButton('closedcaptions')
  846. && <ClosedCaptionButton
  847. key = 'closed-captions'
  848. showLabel = { true } />,
  849. this._shouldShowButton('recording')
  850. && <RecordButton
  851. key = 'record'
  852. showLabel = { true } />,
  853. this._shouldShowButton('localrecording')
  854. && <OverflowMenuItem
  855. accessibilityLabel = { t('toolbar.accessibilityLabel.localRecording') }
  856. icon = { IconRec }
  857. key = 'localrecording'
  858. onClick = { this._onToolbarOpenLocalRecordingInfoDialog }
  859. text = { t('localRecording.dialogTitle') } />,
  860. this._shouldShowButton('mute-everyone')
  861. && <MuteEveryoneButton
  862. key = 'mute-everyone'
  863. showLabel = { true } />,
  864. this._shouldShowButton('livestreaming')
  865. && <LiveStreamButton
  866. key = 'livestreaming'
  867. showLabel = { true } />
  868. ];
  869. const group2 = [
  870. this._shouldShowButton('sharedvideo')
  871. && <SharedVideoButton
  872. key = 'sharedvideo'
  873. showLabel = { true } />,
  874. this._shouldShowButton('etherpad')
  875. && <SharedDocumentButton
  876. key = 'etherpad'
  877. showLabel = { true } />,
  878. this._shouldShowButton('videobackgroundblur')
  879. && <VideoBlurButton
  880. key = 'videobackgroundblur'
  881. showLabel = { true }
  882. visible = { !_screensharing && checkBlurSupport() } />,
  883. this._shouldShowButton('stats')
  884. && <OverflowMenuItem
  885. accessibilityLabel = { t('toolbar.accessibilityLabel.speakerStats') }
  886. icon = { IconPresentation }
  887. key = 'stats'
  888. onClick = { this._onToolbarOpenSpeakerStats }
  889. text = { t('toolbar.speakerStats') } />
  890. ];
  891. return [
  892. this._isProfileVisible()
  893. && <OverflowMenuProfileItem
  894. key = 'profile'
  895. onClick = { this._onToolbarToggleProfile } />,
  896. this._isProfileVisible()
  897. && <hr
  898. className = 'overflow-menu-hr'
  899. key = 'hr1' />,
  900. ...group1,
  901. group1.some(Boolean)
  902. && <hr
  903. className = 'overflow-menu-hr'
  904. key = 'hr2' />,
  905. ...group2,
  906. group2.some(Boolean)
  907. && <hr
  908. className = 'overflow-menu-hr'
  909. key = 'hr3' />,
  910. this._shouldShowButton('settings')
  911. && <SettingsButton
  912. key = 'settings'
  913. showLabel = { true } />,
  914. this._shouldShowButton('shortcuts')
  915. && <OverflowMenuItem
  916. accessibilityLabel = { t('toolbar.accessibilityLabel.shortcuts') }
  917. icon = { IconDeviceDocument }
  918. key = 'shortcuts'
  919. onClick = { this._onToolbarOpenKeyboardShortcuts }
  920. text = { t('toolbar.shortcuts') } />,
  921. this._isEmbedMeetingVisible()
  922. && <OverflowMenuItem
  923. accessibilityLabel = { t('toolbar.accessibilityLabel.embedMeeting') }
  924. icon = { IconCodeBlock }
  925. key = 'embed'
  926. onClick = { this._onToolbarOpenEmbedMeeting }
  927. text = { t('toolbar.embedMeeting') } />,
  928. this._shouldShowButton('feedback')
  929. && _feedbackConfigured
  930. && <OverflowMenuItem
  931. accessibilityLabel = { t('toolbar.accessibilityLabel.feedback') }
  932. icon = { IconFeedback }
  933. key = 'feedback'
  934. onClick = { this._onToolbarOpenFeedback }
  935. text = { t('toolbar.feedback') } />,
  936. this._shouldShowButton('download')
  937. && <DownloadButton
  938. key = 'download'
  939. showLabel = { true } />,
  940. this._shouldShowButton('help')
  941. && <HelpButton
  942. key = 'help'
  943. showLabel = { true } />
  944. ];
  945. }
  946. /**
  947. * Returns the buttons to be displayed in main or the oveflow menu.
  948. *
  949. * @param {Set} buttons - A set containing the buttons to be displayed
  950. * in the toolbar beside the main audio/video & hanugup.
  951. * @returns {Object}
  952. */
  953. _getAdditionalButtons(buttons) {
  954. const {
  955. _chatOpen,
  956. _desktopSharingEnabled,
  957. _desktopSharingDisabledTooltipKey,
  958. _raisedHand,
  959. _screensharing,
  960. t
  961. } = this.props;
  962. const overflowMenuAdditionalButtons = [];
  963. const mainMenuAdditionalButtons = [];
  964. if (this._showDesktopSharingButton()) {
  965. buttons.has('desktop')
  966. ? mainMenuAdditionalButtons.push(<ToolbarButton
  967. accessibilityLabel = { t('toolbar.accessibilityLabel.shareYourScreen') }
  968. disabled = { !_desktopSharingEnabled }
  969. icon = { IconShareDesktop }
  970. key = 'desktop'
  971. onClick = { this._onToolbarToggleScreenshare }
  972. toggled = { _screensharing }
  973. tooltip = { t(_desktopSharingEnabled
  974. ? 'dialog.shareYourScreen' : _desktopSharingDisabledTooltipKey) } />)
  975. : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  976. accessibilityLabel = { t('toolbar.accessibilityLabel.shareYourScreen') }
  977. icon = { IconShareDesktop }
  978. iconId = 'share-desktop'
  979. key = 'desktop'
  980. onClick = { this._onToolbarToggleScreenshare }
  981. text = { t(`toolbar.${_screensharing ? 'stopScreenSharing' : 'startScreenSharing'}`) } />);
  982. }
  983. if (this._shouldShowButton('chat')) {
  984. buttons.has('chat')
  985. ? mainMenuAdditionalButtons.push(<div className = 'toolbar-button-with-badge'>
  986. <ToolbarButton
  987. accessibilityLabel = { t('toolbar.accessibilityLabel.chat') }
  988. icon = { IconChat }
  989. key = 'chat'
  990. onClick = { this._onToolbarToggleChat }
  991. toggled = { _chatOpen }
  992. tooltip = { t('toolbar.chat') } />
  993. <ChatCounter />
  994. </div>) : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  995. accessibilityLabel = { t('toolbar.accessibilityLabel.chat') }
  996. icon = { IconChat }
  997. key = 'chat'
  998. onClick = { this._onToolbarToggleChat }
  999. text = { t(`toolbar.${_chatOpen ? 'closeChat' : 'openChat'}`) } />);
  1000. }
  1001. if (this._shouldShowButton('raisehand')) {
  1002. buttons.has('raisehand')
  1003. ? mainMenuAdditionalButtons.push(<ToolbarButton
  1004. accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
  1005. icon = { IconRaisedHand }
  1006. key = 'raisehand'
  1007. onClick = { this._onToolbarToggleRaiseHand }
  1008. toggled = { _raisedHand }
  1009. tooltip = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />)
  1010. : overflowMenuAdditionalButtons.push(<OverflowMenuItem
  1011. accessibilityLabel = { t('toolbar.accessibilityLabel.raiseHand') }
  1012. icon = { IconRaisedHand }
  1013. key = 'raisehand'
  1014. onClick = { this._onToolbarToggleRaiseHand }
  1015. text = { t(`toolbar.${_raisedHand ? 'lowerYourHand' : 'raiseYourHand'}`) } />);
  1016. }
  1017. if (this._shouldShowButton('tileview')) {
  1018. buttons.has('tileview')
  1019. ? mainMenuAdditionalButtons.push(
  1020. <TileViewButton
  1021. key = 'tileview'
  1022. showLabel = { false }
  1023. visible = { true } />)
  1024. : overflowMenuAdditionalButtons.push(
  1025. <TileViewButton
  1026. key = 'tileview'
  1027. showLabel = { true } />);
  1028. }
  1029. if (this._shouldShowButton('invite')) {
  1030. buttons.has('invite')
  1031. ? mainMenuAdditionalButtons.push(
  1032. <ToolbarButton
  1033. accessibilityLabel = { t('toolbar.accessibilityLabel.invite') }
  1034. icon = { IconInviteMore }
  1035. key = 'invite'
  1036. onClick = { this._onToolbarOpenInvite }
  1037. tooltip = { t('toolbar.invite') } />)
  1038. : overflowMenuAdditionalButtons.push(
  1039. <OverflowMenuItem
  1040. accessibilityLabel = { t('toolbar.accessibilityLabel.invite') }
  1041. icon = { IconInviteMore }
  1042. key = 'invite'
  1043. onClick = { this._onToolbarOpenInvite }
  1044. text = { t('toolbar.invite') } />
  1045. );
  1046. }
  1047. return {
  1048. mainMenuAdditionalButtons,
  1049. overflowMenuAdditionalButtons
  1050. };
  1051. }
  1052. /**
  1053. * Renders the Audio controlling button.
  1054. *
  1055. * @returns {ReactElement}
  1056. */
  1057. _renderAudioButton() {
  1058. return this._shouldShowButton('microphone')
  1059. ? <AudioSettingsButton
  1060. key = 'asb'
  1061. visible = { true } />
  1062. : null;
  1063. }
  1064. /**
  1065. * Renders the Video controlling button.
  1066. *
  1067. * @returns {ReactElement}
  1068. */
  1069. _renderVideoButton() {
  1070. return this._shouldShowButton('camera')
  1071. ? <VideoSettingsButton
  1072. key = 'vsb'
  1073. visible = { true } />
  1074. : null;
  1075. }
  1076. /**
  1077. * Renders the toolbox content.
  1078. *
  1079. * @returns {ReactElement}
  1080. */
  1081. _renderToolboxContent() {
  1082. const {
  1083. _overflowMenuVisible,
  1084. t
  1085. } = this.props;
  1086. const buttonSet = getToolbarAdditionalButtons(this.state.windowWidth);
  1087. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  1088. const showOverflowMenuButton = buttonSet.has('overflow');
  1089. let overflowMenuAdditionalButtons = [];
  1090. let mainMenuAdditionalButtons = [];
  1091. if (showOverflowMenuButton) {
  1092. ({ overflowMenuAdditionalButtons, mainMenuAdditionalButtons } = this._getAdditionalButtons(buttonSet));
  1093. }
  1094. return (
  1095. <div className = 'toolbox-content'>
  1096. <div className = 'toolbox-content-items'>
  1097. { this._renderAudioButton() }
  1098. { this._renderVideoButton() }
  1099. { mainMenuAdditionalButtons }
  1100. { showOverflowMenuButton && <OverflowMenuButton
  1101. isOpen = { _overflowMenuVisible }
  1102. onVisibilityChange = { this._onSetOverflowVisible }>
  1103. <ul
  1104. aria-label = { t(toolbarAccLabel) }
  1105. className = 'overflow-menu'>
  1106. { this._renderOverflowMenuContent(overflowMenuAdditionalButtons) }
  1107. </ul>
  1108. </OverflowMenuButton>}
  1109. <HangupButton
  1110. customClass = 'hangup-button'
  1111. visible = { this._shouldShowButton('hangup') } />
  1112. </div>
  1113. </div>
  1114. );
  1115. }
  1116. _shouldShowButton: (string) => boolean;
  1117. /**
  1118. * Returns if a button name has been explicitly configured to be displayed.
  1119. *
  1120. * @param {string} buttonName - The name of the button, as expected in
  1121. * {@link interfaceConfig}.
  1122. * @private
  1123. * @returns {boolean} True if the button should be displayed.
  1124. */
  1125. _shouldShowButton(buttonName) {
  1126. return this.props._visibleButtons.has(buttonName);
  1127. }
  1128. }
  1129. /**
  1130. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1131. * props.
  1132. *
  1133. * @param {Object} state - The redux store/state.
  1134. * @private
  1135. * @returns {{}}
  1136. */
  1137. function _mapStateToProps(state) {
  1138. const { conference, locked } = state['features/base/conference'];
  1139. let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
  1140. const {
  1141. callStatsID,
  1142. enableFeaturesBasedOnToken
  1143. } = state['features/base/config'];
  1144. const {
  1145. fullScreen,
  1146. overflowMenuVisible
  1147. } = state['features/toolbox'];
  1148. const localParticipant = getLocalParticipant(state);
  1149. const localRecordingStates = state['features/local-recording'];
  1150. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1151. let desktopSharingDisabledTooltipKey;
  1152. if (enableFeaturesBasedOnToken) {
  1153. // we enable desktop sharing if any participant already have this
  1154. // feature enabled
  1155. desktopSharingEnabled = getParticipants(state)
  1156. .find(({ features = {} }) =>
  1157. String(features['screen-sharing']) === 'true') !== undefined;
  1158. desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
  1159. }
  1160. // NB: We compute the buttons again here because if URL parameters were used to
  1161. // override them we'd miss it.
  1162. const buttons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  1163. return {
  1164. _chatOpen: state['features/chat'].isOpen,
  1165. _conference: conference,
  1166. _desktopSharingEnabled: desktopSharingEnabled,
  1167. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  1168. _dialog: Boolean(state['features/base/dialog'].component),
  1169. _feedbackConfigured: Boolean(callStatsID),
  1170. _isProfileDisabled: Boolean(state['features/base/config'].disableProfile),
  1171. _isVpaasMeeting: isVpaasMeeting(state),
  1172. _fullScreen: fullScreen,
  1173. _tileViewEnabled: shouldDisplayTileView(state),
  1174. _localParticipantID: localParticipant.id,
  1175. _localRecState: localRecordingStates,
  1176. _locked: locked,
  1177. _overflowMenuVisible: overflowMenuVisible,
  1178. _raisedHand: localParticipant.raisedHand,
  1179. _screensharing: localVideo && localVideo.videoType === 'desktop',
  1180. _visible: isToolboxVisible(state),
  1181. _visibleButtons: equals(visibleButtons, buttons) ? visibleButtons : buttons
  1182. };
  1183. }
  1184. export default translate(connect(_mapStateToProps)(Toolbox));