Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Toolbox.js 41KB

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