You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Toolbox.js 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  1. // @flow
  2. import React, { Component } from 'react';
  3. import keyboardShortcut from '../../../../../modules/keyboardshortcut/keyboardshortcut';
  4. import {
  5. ACTION_SHORTCUT_TRIGGERED,
  6. createShortcutEvent,
  7. createToolbarEvent,
  8. sendAnalytics
  9. } from '../../../analytics';
  10. import { getToolbarButtons } from '../../../base/config';
  11. import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
  12. import { openDialog, toggleDialog } from '../../../base/dialog';
  13. import { isMobileBrowser } from '../../../base/environment/utils';
  14. import { translate } from '../../../base/i18n';
  15. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  16. import {
  17. getLocalParticipant,
  18. haveParticipantWithScreenSharingFeature,
  19. raiseHand
  20. } from '../../../base/participants';
  21. import { connect } from '../../../base/redux';
  22. import { getLocalVideoTrack } from '../../../base/tracks';
  23. import { isVpaasMeeting } from '../../../billing-counter/functions';
  24. import { toggleChat } from '../../../chat';
  25. import { ChatButton } from '../../../chat/components';
  26. import { EmbedMeetingButton } from '../../../embed-meeting';
  27. import { SharedDocumentButton } from '../../../etherpad';
  28. import { FeedbackButton } from '../../../feedback';
  29. import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
  30. import { LocalRecordingButton } from '../../../local-recording';
  31. import {
  32. close as closeParticipantsPane,
  33. open as openParticipantsPane
  34. } from '../../../participants-pane/actions';
  35. import ParticipantsPaneButton from '../../../participants-pane/components/ParticipantsPaneButton';
  36. import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
  37. import { ReactionsMenuButton } from '../../../reactions/components';
  38. import {
  39. LiveStreamButton,
  40. RecordButton
  41. } from '../../../recording';
  42. import {
  43. isScreenAudioSupported,
  44. isScreenVideoShared,
  45. ShareAudioButton,
  46. startScreenShareFlow
  47. } from '../../../screen-share/';
  48. import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
  49. import { SettingsButton } from '../../../settings';
  50. import { SharedVideoButton } from '../../../shared-video/components';
  51. import { SpeakerStatsButton } from '../../../speaker-stats';
  52. import {
  53. ClosedCaptionButton
  54. } from '../../../subtitles';
  55. import {
  56. TileViewButton,
  57. shouldDisplayTileView,
  58. toggleTileView
  59. } from '../../../video-layout';
  60. import { VideoQualityDialog, VideoQualityButton } from '../../../video-quality/components';
  61. import { VideoBackgroundButton } from '../../../virtual-background';
  62. import { toggleBackgroundEffect } from '../../../virtual-background/actions';
  63. import { VIRTUAL_BACKGROUND_TYPE } from '../../../virtual-background/constants';
  64. import { checkBlurSupport } from '../../../virtual-background/functions';
  65. import {
  66. setFullScreen,
  67. setOverflowMenuVisible,
  68. setToolbarHovered,
  69. showToolbox
  70. } from '../../actions';
  71. import { THRESHOLDS } from '../../constants';
  72. import { isToolboxVisible } from '../../functions';
  73. import DownloadButton from '../DownloadButton';
  74. import HangupButton from '../HangupButton';
  75. import HelpButton from '../HelpButton';
  76. import MuteEveryoneButton from '../MuteEveryoneButton';
  77. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  78. import AudioSettingsButton from './AudioSettingsButton';
  79. import FullscreenButton from './FullscreenButton';
  80. import OverflowMenuButton from './OverflowMenuButton';
  81. import ProfileButton from './ProfileButton';
  82. import Separator from './Separator';
  83. import ShareDesktopButton from './ShareDesktopButton';
  84. import VideoSettingsButton from './VideoSettingsButton';
  85. /**
  86. * The type of the React {@code Component} props of {@link Toolbox}.
  87. */
  88. type Props = {
  89. /**
  90. * String showing if the virtual background type is desktop-share.
  91. */
  92. _backgroundType: String,
  93. /**
  94. * Whether or not the chat feature is currently displayed.
  95. */
  96. _chatOpen: boolean,
  97. /**
  98. * The width of the client.
  99. */
  100. _clientWidth: number,
  101. /**
  102. * The {@code JitsiConference} for the current conference.
  103. */
  104. _conference: Object,
  105. /**
  106. * The tooltip key to use when screensharing is disabled. Or undefined
  107. * if non to be shown and the button to be hidden.
  108. */
  109. _desktopSharingDisabledTooltipKey: boolean,
  110. /**
  111. * Whether or not screensharing is initialized.
  112. */
  113. _desktopSharingEnabled: boolean,
  114. /**
  115. * Whether or not a dialog is displayed.
  116. */
  117. _dialog: boolean,
  118. /**
  119. * Whether or not call feedback can be sent.
  120. */
  121. _feedbackConfigured: boolean,
  122. /**
  123. * Whether or not the app is currently in full screen.
  124. */
  125. _fullScreen: boolean,
  126. /**
  127. * Whether or not the app is running in mobile browser.
  128. */
  129. _isMobile: boolean,
  130. /**
  131. * Whether or not the profile is disabled.
  132. */
  133. _isProfileDisabled: boolean,
  134. /**
  135. * Whether or not the tile view is enabled.
  136. */
  137. _tileViewEnabled: boolean,
  138. /**
  139. * Whether or not the current meeting belongs to a JaaS user.
  140. */
  141. _isVpaasMeeting: boolean,
  142. /**
  143. * The ID of the local participant.
  144. */
  145. _localParticipantID: String,
  146. /**
  147. * The JitsiLocalTrack to display.
  148. */
  149. _localVideo: Object,
  150. /**
  151. * Whether or not the overflow menu is visible.
  152. */
  153. _overflowMenuVisible: boolean,
  154. /**
  155. * Whether or not the participants pane is open.
  156. */
  157. _participantsPaneOpen: boolean,
  158. /**
  159. * Whether or not the local participant's hand is raised.
  160. */
  161. _raisedHand: boolean,
  162. /**
  163. * Whether or not the local participant is screenSharing.
  164. */
  165. _screenSharing: boolean,
  166. /**
  167. * Whether or not the local participant is sharing a YouTube video.
  168. */
  169. _sharingVideo: boolean,
  170. /**
  171. * The enabled buttons.
  172. */
  173. _toolbarButtons: Array<string>,
  174. /**
  175. * Flag showing whether toolbar is visible.
  176. */
  177. _visible: boolean,
  178. /**
  179. * Array with the buttons which this Toolbox should display.
  180. */
  181. _visibleButtons: Array<string>,
  182. /**
  183. * Returns the selected virtual source object.
  184. */
  185. _virtualSource: Object,
  186. /**
  187. * Invoked to active other features of the app.
  188. */
  189. dispatch: Function,
  190. /**
  191. * Invoked to obtain translated strings.
  192. */
  193. t: Function
  194. };
  195. declare var APP: Object;
  196. /**
  197. * Implements the conference toolbox on React/Web.
  198. *
  199. * @extends Component
  200. */
  201. class Toolbox extends Component<Props> {
  202. /**
  203. * Initializes a new {@code Toolbox} instance.
  204. *
  205. * @param {Props} props - The read-only React {@code Component} props with
  206. * which the new instance is to be initialized.
  207. */
  208. constructor(props: Props) {
  209. super(props);
  210. // Bind event handlers so they are only bound once per instance.
  211. this._onMouseOut = this._onMouseOut.bind(this);
  212. this._onMouseOver = this._onMouseOver.bind(this);
  213. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  214. this._onTabIn = this._onTabIn.bind(this);
  215. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  216. this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
  217. this._onShortcutToggleParticipantsPane = this._onShortcutToggleParticipantsPane.bind(this);
  218. this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
  219. this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
  220. this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
  221. this._onToolbarToggleParticipantsPane = this._onToolbarToggleParticipantsPane.bind(this);
  222. this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
  223. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  224. this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
  225. this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
  226. this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
  227. this._onEscKey = this._onEscKey.bind(this);
  228. }
  229. /**
  230. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  231. *
  232. * @inheritdoc
  233. * @returns {void}
  234. */
  235. componentDidMount() {
  236. const { _toolbarButtons } = this.props;
  237. const KEYBOARD_SHORTCUTS = [
  238. isToolbarButtonEnabled('videoquality', _toolbarButtons) && {
  239. character: 'A',
  240. exec: this._onShortcutToggleVideoQuality,
  241. helpDescription: 'toolbar.callQuality'
  242. },
  243. isToolbarButtonEnabled('chat', _toolbarButtons) && {
  244. character: 'C',
  245. exec: this._onShortcutToggleChat,
  246. helpDescription: 'keyboardShortcuts.toggleChat'
  247. },
  248. isToolbarButtonEnabled('desktop', _toolbarButtons) && {
  249. character: 'D',
  250. exec: this._onShortcutToggleScreenshare,
  251. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  252. },
  253. isToolbarButtonEnabled('participants-pane', _toolbarButtons) && {
  254. character: 'P',
  255. exec: this._onShortcutToggleParticipantsPane,
  256. helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
  257. },
  258. isToolbarButtonEnabled('raisehand', _toolbarButtons) && {
  259. character: 'R',
  260. exec: this._onShortcutToggleRaiseHand,
  261. helpDescription: 'keyboardShortcuts.raiseHand'
  262. },
  263. isToolbarButtonEnabled('fullscreen', _toolbarButtons) && {
  264. character: 'S',
  265. exec: this._onShortcutToggleFullScreen,
  266. helpDescription: 'keyboardShortcuts.fullScreen'
  267. },
  268. isToolbarButtonEnabled('tileview', _toolbarButtons) && {
  269. character: 'W',
  270. exec: this._onShortcutToggleTileView,
  271. helpDescription: 'toolbar.tileViewToggle'
  272. }
  273. ];
  274. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  275. if (typeof shortcut === 'object') {
  276. APP.keyboardshortcut.registerShortcut(
  277. shortcut.character,
  278. null,
  279. shortcut.exec,
  280. shortcut.helpDescription);
  281. }
  282. });
  283. }
  284. /**
  285. * Update the visibility of the {@code OverflowMenuButton}.
  286. *
  287. * @inheritdoc
  288. */
  289. componentDidUpdate(prevProps) {
  290. // Ensure the dialog is closed when the toolbox becomes hidden.
  291. if (prevProps._overflowMenuVisible && !this.props._visible) {
  292. this._onSetOverflowVisible(false);
  293. }
  294. if (prevProps._overflowMenuVisible
  295. && !prevProps._dialog
  296. && this.props._dialog) {
  297. this._onSetOverflowVisible(false);
  298. this.props.dispatch(setToolbarHovered(false));
  299. }
  300. }
  301. /**
  302. * Removes keyboard shortcuts registered by this component.
  303. *
  304. * @inheritdoc
  305. * @returns {void}
  306. */
  307. componentWillUnmount() {
  308. [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
  309. APP.keyboardshortcut.unregisterShortcut(letter));
  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.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
  321. return (
  322. <div
  323. className = { rootClassNames }
  324. id = 'new-toolbox'>
  325. { this._renderToolboxContent() }
  326. </div>
  327. );
  328. }
  329. _onEscKey: (KeyboardEvent) => void;
  330. /**
  331. * Key handler for overflow menu.
  332. *
  333. * @param {KeyboardEvent} e - Esc key click to close the popup.
  334. * @returns {void}
  335. */
  336. _onEscKey(e) {
  337. if (e.key === 'Escape') {
  338. e.stopPropagation();
  339. this._closeOverflowMenuIfOpen();
  340. }
  341. }
  342. /**
  343. * Closes the overflow menu if opened.
  344. *
  345. * @private
  346. * @returns {void}
  347. */
  348. _closeOverflowMenuIfOpen() {
  349. const { dispatch, _overflowMenuVisible } = this.props;
  350. _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
  351. }
  352. /**
  353. * Dispatches an action to open the video quality dialog.
  354. *
  355. * @private
  356. * @returns {void}
  357. */
  358. _doOpenVideoQuality() {
  359. this.props.dispatch(openDialog(VideoQualityDialog));
  360. }
  361. /**
  362. * Dispatches an action to toggle the display of chat.
  363. *
  364. * @private
  365. * @returns {void}
  366. */
  367. _doToggleChat() {
  368. this.props.dispatch(toggleChat());
  369. }
  370. /**
  371. * Dispatches an action to toggle screensharing.
  372. *
  373. * @private
  374. * @returns {void}
  375. */
  376. _doToggleFullScreen() {
  377. const fullScreen = !this.props._fullScreen;
  378. this.props.dispatch(setFullScreen(fullScreen));
  379. }
  380. /**
  381. * Dispatches an action to toggle the local participant's raised hand state.
  382. *
  383. * @private
  384. * @returns {void}
  385. */
  386. _doToggleRaiseHand() {
  387. const { _localParticipantID, _raisedHand } = this.props;
  388. const newRaisedStatus = !_raisedHand;
  389. this.props.dispatch(raiseHand(newRaisedStatus));
  390. APP.API.notifyRaiseHandUpdated(_localParticipantID, newRaisedStatus);
  391. }
  392. /**
  393. * Dispatches an action to toggle screensharing.
  394. *
  395. * @private
  396. * @param {boolean} enabled - The state to toggle screen sharing to.
  397. * @param {boolean} audioOnly - Only share system audio.
  398. * @returns {void}
  399. */
  400. _doToggleScreenshare() {
  401. const {
  402. _backgroundType,
  403. _desktopSharingEnabled,
  404. _localVideo,
  405. _virtualSource,
  406. dispatch
  407. } = this.props;
  408. if (_backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
  409. const noneOptions = {
  410. enabled: false,
  411. backgroundType: VIRTUAL_BACKGROUND_TYPE.NONE,
  412. selectedThumbnail: VIRTUAL_BACKGROUND_TYPE.NONE,
  413. backgroundEffectEnabled: false
  414. };
  415. _virtualSource.dispose();
  416. dispatch(toggleBackgroundEffect(noneOptions, _localVideo));
  417. return;
  418. }
  419. if (_desktopSharingEnabled) {
  420. dispatch(startScreenShareFlow());
  421. }
  422. }
  423. /**
  424. * Dispatches an action to toggle the video quality dialog.
  425. *
  426. * @private
  427. * @returns {void}
  428. */
  429. _doToggleVideoQuality() {
  430. this.props.dispatch(toggleDialog(VideoQualityDialog));
  431. }
  432. /**
  433. * Dispaches an action to toggle tile view.
  434. *
  435. * @private
  436. * @returns {void}
  437. */
  438. _doToggleTileView() {
  439. this.props.dispatch(toggleTileView());
  440. }
  441. /**
  442. * Returns all buttons that could be rendered.
  443. *
  444. * @param {Object} state - The redux state.
  445. * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
  446. */
  447. _getAllButtons() {
  448. const {
  449. _feedbackConfigured,
  450. _isMobile,
  451. _screenSharing
  452. } = this.props;
  453. const microphone = {
  454. key: 'microphone',
  455. Content: AudioSettingsButton,
  456. group: 0
  457. };
  458. const camera = {
  459. key: 'camera',
  460. Content: VideoSettingsButton,
  461. group: 0
  462. };
  463. const profile = this._isProfileVisible() && {
  464. key: 'profile',
  465. Content: ProfileButton,
  466. group: 1
  467. };
  468. const chat = {
  469. key: 'chat',
  470. Content: ChatButton,
  471. handleClick: this._onToolbarToggleChat,
  472. group: 2
  473. };
  474. const desktop = this._showDesktopSharingButton() && {
  475. key: 'desktop',
  476. Content: ShareDesktopButton,
  477. handleClick: this._onToolbarToggleScreenshare,
  478. group: 2
  479. };
  480. const raisehand = {
  481. key: 'raisehand',
  482. Content: ReactionsMenuButton,
  483. group: 2
  484. };
  485. const participants = {
  486. key: 'participants-pane',
  487. Content: ParticipantsPaneButton,
  488. handleClick: this._onToolbarToggleParticipantsPane,
  489. group: 2
  490. };
  491. const tileview = {
  492. key: 'tileview',
  493. Content: TileViewButton,
  494. group: 2
  495. };
  496. const videoQuality = {
  497. key: 'videoquality',
  498. Content: VideoQualityButton,
  499. handleClick: this._onToolbarOpenVideoQuality,
  500. group: 2
  501. };
  502. const fullscreen = !_isMobile && {
  503. key: 'fullscreen',
  504. Content: FullscreenButton,
  505. handleClick: this._onToolbarToggleFullScreen,
  506. group: 2
  507. };
  508. const security = {
  509. key: 'security',
  510. Content: SecurityDialogButton,
  511. group: 2
  512. };
  513. const info = {
  514. key: 'info',
  515. Content: SecurityDialogButton,
  516. group: 2
  517. };
  518. const cc = {
  519. key: 'closedcaptions',
  520. Content: ClosedCaptionButton,
  521. group: 2
  522. };
  523. const recording = {
  524. key: 'recording',
  525. Content: RecordButton,
  526. group: 2
  527. };
  528. const localRecording = {
  529. key: 'localrecording',
  530. Content: LocalRecordingButton,
  531. group: 2
  532. };
  533. const muteEveryone = {
  534. key: 'mute-everyone',
  535. Content: MuteEveryoneButton,
  536. group: 2
  537. };
  538. const muteVideoEveryone = {
  539. key: 'mute-video-everyone',
  540. Content: MuteEveryonesVideoButton,
  541. group: 2
  542. };
  543. const livestreaming = {
  544. key: 'livestreaming',
  545. Content: LiveStreamButton,
  546. group: 2
  547. };
  548. const shareVideo = {
  549. key: 'sharedvideo',
  550. Content: SharedVideoButton,
  551. group: 3
  552. };
  553. const shareAudio = this._showAudioSharingButton() && {
  554. key: 'shareaudio',
  555. Content: ShareAudioButton,
  556. group: 3
  557. };
  558. const etherpad = {
  559. key: 'etherpad',
  560. Content: SharedDocumentButton,
  561. group: 3
  562. };
  563. const virtualBackground = !_screenSharing && checkBlurSupport() && {
  564. key: 'select-background',
  565. Content: VideoBackgroundButton,
  566. group: 3
  567. };
  568. const speakerStats = {
  569. key: 'stats',
  570. Content: SpeakerStatsButton,
  571. group: 3
  572. };
  573. const settings = {
  574. key: 'settings',
  575. Content: SettingsButton,
  576. group: 4
  577. };
  578. const shortcuts = !_isMobile && keyboardShortcut.getEnabled() && {
  579. key: 'shortcuts',
  580. Content: KeyboardShortcutsButton,
  581. group: 4
  582. };
  583. const embed = this._isEmbedMeetingVisible() && {
  584. key: 'embedmeeting',
  585. Content: EmbedMeetingButton,
  586. group: 4
  587. };
  588. const feedback = _feedbackConfigured && {
  589. key: 'feedback',
  590. Content: FeedbackButton,
  591. group: 4
  592. };
  593. const download = {
  594. key: 'download',
  595. Content: DownloadButton,
  596. group: 4
  597. };
  598. const help = {
  599. key: 'help',
  600. Content: HelpButton,
  601. group: 4
  602. };
  603. return {
  604. microphone,
  605. camera,
  606. profile,
  607. desktop,
  608. chat,
  609. raisehand,
  610. participants,
  611. tileview,
  612. videoQuality,
  613. fullscreen,
  614. security,
  615. info,
  616. cc,
  617. recording,
  618. localRecording,
  619. muteEveryone,
  620. muteVideoEveryone,
  621. livestreaming,
  622. shareVideo,
  623. shareAudio,
  624. etherpad,
  625. virtualBackground,
  626. speakerStats,
  627. settings,
  628. shortcuts,
  629. embed,
  630. feedback,
  631. download,
  632. help
  633. };
  634. }
  635. /**
  636. * Returns all buttons that need to be rendered.
  637. *
  638. * @param {Object} state - The redux state.
  639. * @returns {Object} The visible buttons arrays .
  640. */
  641. _getVisibleButtons() {
  642. const {
  643. _clientWidth,
  644. _toolbarButtons
  645. } = this.props;
  646. const buttons = this._getAllButtons();
  647. const isHangupVisible = isToolbarButtonEnabled('hangup', _toolbarButtons);
  648. const { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  649. || THRESHOLDS[THRESHOLDS.length - 1];
  650. let sliceIndex = order.length + 2;
  651. const keys = Object.keys(buttons);
  652. const filtered = [
  653. ...order.map(key => buttons[key]),
  654. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  655. ].filter(Boolean).filter(({ key }) => isToolbarButtonEnabled(key, _toolbarButtons));
  656. if (isHangupVisible) {
  657. sliceIndex -= 1;
  658. }
  659. // This implies that the overflow button will be displayed, so save some space for it.
  660. if (sliceIndex < filtered.length) {
  661. sliceIndex -= 1;
  662. }
  663. return {
  664. mainMenuButtons: filtered.slice(0, sliceIndex),
  665. overflowMenuButtons: filtered.slice(sliceIndex)
  666. };
  667. }
  668. _onMouseOut: () => void;
  669. /**
  670. * Dispatches an action signaling the toolbar is not being hovered.
  671. *
  672. * @private
  673. * @returns {void}
  674. */
  675. _onMouseOut() {
  676. this.props.dispatch(setToolbarHovered(false));
  677. }
  678. _onMouseOver: () => void;
  679. /**
  680. * Dispatches an action signaling the toolbar is being hovered.
  681. *
  682. * @private
  683. * @returns {void}
  684. */
  685. _onMouseOver() {
  686. this.props.dispatch(setToolbarHovered(true));
  687. }
  688. _onSetOverflowVisible: (boolean) => void;
  689. /**
  690. * Sets the visibility of the overflow menu.
  691. *
  692. * @param {boolean} visible - Whether or not the overflow menu should be
  693. * displayed.
  694. * @private
  695. * @returns {void}
  696. */
  697. _onSetOverflowVisible(visible) {
  698. this.props.dispatch(setOverflowMenuVisible(visible));
  699. }
  700. _onShortcutToggleChat: () => void;
  701. /**
  702. * Creates an analytics keyboard shortcut event and dispatches an action for
  703. * toggling the display of chat.
  704. *
  705. * @private
  706. * @returns {void}
  707. */
  708. _onShortcutToggleChat() {
  709. sendAnalytics(createShortcutEvent(
  710. 'toggle.chat',
  711. {
  712. enable: !this.props._chatOpen
  713. }));
  714. // Checks if there was any text selected by the user.
  715. // Used for when we press simultaneously keys for copying
  716. // text messages from the chat board
  717. if (window.getSelection().toString() !== '') {
  718. return false;
  719. }
  720. this._doToggleChat();
  721. }
  722. _onShortcutToggleParticipantsPane: () => void;
  723. /**
  724. * Creates an analytics keyboard shortcut event and dispatches an action for
  725. * toggling the display of the participants pane.
  726. *
  727. * @private
  728. * @returns {void}
  729. */
  730. _onShortcutToggleParticipantsPane() {
  731. sendAnalytics(createShortcutEvent(
  732. 'toggle.participants-pane',
  733. {
  734. enable: !this.props._participantsPaneOpen
  735. }));
  736. this._onToolbarToggleParticipantsPane();
  737. }
  738. _onShortcutToggleVideoQuality: () => void;
  739. /**
  740. * Creates an analytics keyboard shortcut event and dispatches an action for
  741. * toggling the display of Video Quality.
  742. *
  743. * @private
  744. * @returns {void}
  745. */
  746. _onShortcutToggleVideoQuality() {
  747. sendAnalytics(createShortcutEvent('video.quality'));
  748. this._doToggleVideoQuality();
  749. }
  750. _onShortcutToggleTileView: () => void;
  751. /**
  752. * Dispatches an action for toggling the tile view.
  753. *
  754. * @private
  755. * @returns {void}
  756. */
  757. _onShortcutToggleTileView() {
  758. sendAnalytics(createShortcutEvent(
  759. 'toggle.tileview',
  760. {
  761. enable: !this.props._tileViewEnabled
  762. }));
  763. this._doToggleTileView();
  764. }
  765. _onShortcutToggleFullScreen: () => void;
  766. /**
  767. * Creates an analytics keyboard shortcut event and dispatches an action for
  768. * toggling full screen mode.
  769. *
  770. * @private
  771. * @returns {void}
  772. */
  773. _onShortcutToggleFullScreen() {
  774. sendAnalytics(createShortcutEvent(
  775. 'toggle.fullscreen',
  776. {
  777. enable: !this.props._fullScreen
  778. }));
  779. this._doToggleFullScreen();
  780. }
  781. _onShortcutToggleRaiseHand: () => void;
  782. /**
  783. * Creates an analytics keyboard shortcut event and dispatches an action for
  784. * toggling raise hand.
  785. *
  786. * @private
  787. * @returns {void}
  788. */
  789. _onShortcutToggleRaiseHand() {
  790. sendAnalytics(createShortcutEvent(
  791. 'toggle.raise.hand',
  792. ACTION_SHORTCUT_TRIGGERED,
  793. { enable: !this.props._raisedHand }));
  794. this._doToggleRaiseHand();
  795. }
  796. _onShortcutToggleScreenshare: () => void;
  797. /**
  798. * Creates an analytics keyboard shortcut event and dispatches an action for
  799. * toggling screensharing.
  800. *
  801. * @private
  802. * @returns {void}
  803. */
  804. _onShortcutToggleScreenshare() {
  805. sendAnalytics(createShortcutEvent(
  806. 'toggle.screen.sharing',
  807. ACTION_SHORTCUT_TRIGGERED,
  808. {
  809. enable: !this.props._screenSharing
  810. }));
  811. this._doToggleScreenshare();
  812. }
  813. _onTabIn: () => void;
  814. /**
  815. * Toggle the toolbar visibility when tabbing into it.
  816. *
  817. * @returns {void}
  818. */
  819. _onTabIn() {
  820. if (!this.props._visible) {
  821. this.props.dispatch(showToolbox());
  822. }
  823. }
  824. _onToolbarToggleParticipantsPane: () => void;
  825. /**
  826. * Dispatches an action for toggling the participants pane.
  827. *
  828. * @private
  829. * @returns {void}
  830. */
  831. _onToolbarToggleParticipantsPane() {
  832. const { dispatch, _participantsPaneOpen } = this.props;
  833. if (_participantsPaneOpen) {
  834. dispatch(closeParticipantsPane());
  835. } else {
  836. dispatch(openParticipantsPane());
  837. }
  838. }
  839. _onToolbarOpenVideoQuality: () => void;
  840. /**
  841. * Creates an analytics toolbar event and dispatches an action for toggling
  842. * open the video quality dialog.
  843. *
  844. * @private
  845. * @returns {void}
  846. */
  847. _onToolbarOpenVideoQuality() {
  848. sendAnalytics(createToolbarEvent('video.quality'));
  849. this._doOpenVideoQuality();
  850. }
  851. _onToolbarToggleChat: () => void;
  852. /**
  853. * Creates an analytics toolbar event and dispatches an action for toggling
  854. * the display of chat.
  855. *
  856. * @private
  857. * @returns {void}
  858. */
  859. _onToolbarToggleChat() {
  860. sendAnalytics(createToolbarEvent(
  861. 'toggle.chat',
  862. {
  863. enable: !this.props._chatOpen
  864. }));
  865. this._closeOverflowMenuIfOpen();
  866. this._doToggleChat();
  867. }
  868. _onToolbarToggleFullScreen: () => void;
  869. /**
  870. * Creates an analytics toolbar event and dispatches an action for toggling
  871. * full screen mode.
  872. *
  873. * @private
  874. * @returns {void}
  875. */
  876. _onToolbarToggleFullScreen() {
  877. sendAnalytics(createToolbarEvent(
  878. 'toggle.fullscreen',
  879. {
  880. enable: !this.props._fullScreen
  881. }));
  882. this._closeOverflowMenuIfOpen();
  883. this._doToggleFullScreen();
  884. }
  885. _onToolbarToggleScreenshare: () => void;
  886. /**
  887. * Creates an analytics toolbar event and dispatches an action for toggling
  888. * screensharing.
  889. *
  890. * @private
  891. * @returns {void}
  892. */
  893. _onToolbarToggleScreenshare() {
  894. sendAnalytics(createToolbarEvent(
  895. 'toggle.screen.sharing',
  896. ACTION_SHORTCUT_TRIGGERED,
  897. { enable: !this.props._screenSharing }));
  898. this._closeOverflowMenuIfOpen();
  899. this._doToggleScreenshare();
  900. }
  901. /**
  902. * Returns true if the audio sharing button should be visible and
  903. * false otherwise.
  904. *
  905. * @returns {boolean}
  906. */
  907. _showAudioSharingButton() {
  908. const {
  909. _desktopSharingEnabled
  910. } = this.props;
  911. return _desktopSharingEnabled && isScreenAudioSupported();
  912. }
  913. /**
  914. * Returns true if the desktop sharing button should be visible and
  915. * false otherwise.
  916. *
  917. * @returns {boolean}
  918. */
  919. _showDesktopSharingButton() {
  920. const {
  921. _desktopSharingEnabled,
  922. _desktopSharingDisabledTooltipKey
  923. } = this.props;
  924. return _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  925. }
  926. /**
  927. * Returns true if the embed meeting button is visible and false otherwise.
  928. *
  929. * @returns {boolean}
  930. */
  931. _isEmbedMeetingVisible() {
  932. return !this.props._isVpaasMeeting
  933. && !this.props._isMobile;
  934. }
  935. /**
  936. * Returns true if the profile button is visible and false otherwise.
  937. *
  938. * @returns {boolean}
  939. */
  940. _isProfileVisible() {
  941. return !this.props._isProfileDisabled;
  942. }
  943. /**
  944. * Renders the toolbox content.
  945. *
  946. * @returns {ReactElement}
  947. */
  948. _renderToolboxContent() {
  949. const {
  950. _isMobile,
  951. _overflowMenuVisible,
  952. _toolbarButtons,
  953. t
  954. } = this.props;
  955. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  956. const containerClassName = `toolbox-content${_isMobile ? ' toolbox-content-mobile' : ''}`;
  957. const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
  958. return (
  959. <div className = { containerClassName }>
  960. <div
  961. className = 'toolbox-content-wrapper'
  962. onFocus = { this._onTabIn }
  963. onMouseOut = { this._onMouseOut }
  964. onMouseOver = { this._onMouseOver }>
  965. <div className = 'toolbox-content-items'>
  966. {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
  967. <Content
  968. { ...rest }
  969. key = { key } />))}
  970. {Boolean(overflowMenuButtons.length) && (
  971. <OverflowMenuButton
  972. ariaControls = 'overflow-menu'
  973. isOpen = { _overflowMenuVisible }
  974. key = 'overflow-menu'
  975. onVisibilityChange = { this._onSetOverflowVisible }
  976. showMobileReactions = {
  977. overflowMenuButtons.find(({ key }) => key === 'raisehand')
  978. }>
  979. <ul
  980. aria-label = { t(toolbarAccLabel) }
  981. className = 'overflow-menu'
  982. id = 'overflow-menu'
  983. onKeyDown = { this._onEscKey }
  984. role = 'menu'>
  985. {overflowMenuButtons.map(({ group, key, Content, ...rest }, index, arr) => {
  986. const showSeparator = index > 0 && arr[index - 1].group !== group;
  987. return key !== 'raisehand'
  988. && <>
  989. {showSeparator && <Separator key = { `hr${group}` } />}
  990. <Content
  991. { ...rest }
  992. key = { key }
  993. showLabel = { true } />
  994. </>
  995. ;
  996. })}
  997. </ul>
  998. </OverflowMenuButton>
  999. )}
  1000. <HangupButton
  1001. customClass = 'hangup-button'
  1002. key = 'hangup-button'
  1003. visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
  1004. </div>
  1005. </div>
  1006. </div>
  1007. );
  1008. }
  1009. }
  1010. /**
  1011. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1012. * props.
  1013. *
  1014. * @param {Object} state - The redux store/state.
  1015. * @private
  1016. * @returns {{}}
  1017. */
  1018. function _mapStateToProps(state) {
  1019. const { conference } = state['features/base/conference'];
  1020. let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
  1021. const {
  1022. callStatsID,
  1023. enableFeaturesBasedOnToken
  1024. } = state['features/base/config'];
  1025. const {
  1026. fullScreen,
  1027. overflowMenuVisible
  1028. } = state['features/toolbox'];
  1029. const localParticipant = getLocalParticipant(state);
  1030. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1031. const { clientWidth } = state['features/base/responsive-ui'];
  1032. let desktopSharingDisabledTooltipKey;
  1033. if (enableFeaturesBasedOnToken) {
  1034. if (desktopSharingEnabled) {
  1035. // we enable desktop sharing if any participant already have this
  1036. // feature enabled and if the user supports it.
  1037. desktopSharingEnabled = haveParticipantWithScreenSharingFeature(state);
  1038. desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
  1039. }
  1040. }
  1041. return {
  1042. _chatOpen: state['features/chat'].isOpen,
  1043. _clientWidth: clientWidth,
  1044. _conference: conference,
  1045. _desktopSharingEnabled: desktopSharingEnabled,
  1046. _backgroundType: state['features/virtual-background'].backgroundType,
  1047. _virtualSource: state['features/virtual-background'].virtualSource,
  1048. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  1049. _dialog: Boolean(state['features/base/dialog'].component),
  1050. _feedbackConfigured: Boolean(callStatsID),
  1051. _isProfileDisabled: Boolean(state['features/base/config'].disableProfile),
  1052. _isMobile: isMobileBrowser(),
  1053. _isVpaasMeeting: isVpaasMeeting(state),
  1054. _fullScreen: fullScreen,
  1055. _tileViewEnabled: shouldDisplayTileView(state),
  1056. _localParticipantID: localParticipant?.id,
  1057. _localVideo: localVideo,
  1058. _overflowMenuVisible: overflowMenuVisible,
  1059. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1060. _raisedHand: localParticipant?.raisedHand,
  1061. _screenSharing: isScreenVideoShared(state),
  1062. _toolbarButtons: getToolbarButtons(state),
  1063. _visible: isToolboxVisible(state),
  1064. _visibleButtons: getToolbarButtons(state)
  1065. };
  1066. }
  1067. export default translate(connect(_mapStateToProps)(Toolbox));