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 37KB

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