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

Toolbox.js 35KB

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