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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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. getParticipants,
  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. * Flag showing whether toolbar is visible.
  172. */
  173. _visible: boolean,
  174. /**
  175. * Array with the buttons which this Toolbox should display.
  176. */
  177. _visibleButtons: Array<string>,
  178. /**
  179. * Handler to check if a button is enabled.
  180. */
  181. _shouldShowButton: Function,
  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 KEYBOARD_SHORTCUTS = [
  238. this.props._shouldShowButton('videoquality') && {
  239. character: 'A',
  240. exec: this._onShortcutToggleVideoQuality,
  241. helpDescription: 'toolbar.callQuality'
  242. },
  243. this.props._shouldShowButton('chat') && {
  244. character: 'C',
  245. exec: this._onShortcutToggleChat,
  246. helpDescription: 'keyboardShortcuts.toggleChat'
  247. },
  248. this.props._shouldShowButton('desktop') && {
  249. character: 'D',
  250. exec: this._onShortcutToggleScreenshare,
  251. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  252. },
  253. this.props._shouldShowButton('participants-pane') && {
  254. character: 'P',
  255. exec: this._onShortcutToggleParticipantsPane,
  256. helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
  257. },
  258. this.props._shouldShowButton('raisehand') && {
  259. character: 'R',
  260. exec: this._onShortcutToggleRaiseHand,
  261. helpDescription: 'keyboardShortcuts.raiseHand'
  262. },
  263. this.props._shouldShowButton('fullscreen') && {
  264. character: 'S',
  265. exec: this._onShortcutToggleFullScreen,
  266. helpDescription: 'keyboardShortcuts.fullScreen'
  267. },
  268. this.props._shouldShowButton('tileview') && {
  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: RaiseHandButton,
  483. handleClick: this._onToolbarToggleRaiseHand,
  484. group: 2
  485. };
  486. const participants = {
  487. key: 'participants-pane',
  488. Content: ParticipantsPaneButton,
  489. handleClick: this._onToolbarToggleParticipantsPane,
  490. group: 2
  491. };
  492. const tileview = {
  493. key: 'tileview',
  494. Content: TileViewButton,
  495. group: 2
  496. };
  497. const videoQuality = {
  498. key: 'videoquality',
  499. Content: VideoQualityButton,
  500. handleClick: this._onToolbarOpenVideoQuality,
  501. group: 2
  502. };
  503. const fullscreen = !_isMobile && {
  504. key: 'fullscreen',
  505. Content: FullscreenButton,
  506. handleClick: this._onToolbarToggleFullScreen,
  507. group: 2
  508. };
  509. const security = {
  510. key: 'security',
  511. Content: SecurityDialogButton,
  512. group: 2
  513. };
  514. const info = {
  515. key: 'info',
  516. Content: SecurityDialogButton,
  517. group: 2
  518. };
  519. const cc = {
  520. key: 'closedcaptions',
  521. Content: ClosedCaptionButton,
  522. group: 2
  523. };
  524. const recording = {
  525. key: 'recording',
  526. Content: RecordButton,
  527. group: 2
  528. };
  529. const localRecording = {
  530. key: 'localrecording',
  531. Content: LocalRecordingButton,
  532. group: 2
  533. };
  534. const muteEveryone = {
  535. key: 'mute-everyone',
  536. Content: MuteEveryoneButton,
  537. group: 2
  538. };
  539. const muteVideoEveryone = {
  540. key: 'mute-video-everyone',
  541. Content: MuteEveryonesVideoButton,
  542. group: 2
  543. };
  544. const livestreaming = {
  545. key: 'livestreaming',
  546. Content: LiveStreamButton,
  547. group: 2
  548. };
  549. const shareVideo = {
  550. key: 'sharedvideo',
  551. Content: SharedVideoButton,
  552. group: 3
  553. };
  554. const shareAudio = this._showAudioSharingButton() && {
  555. key: 'shareaudio',
  556. Content: ShareAudioButton,
  557. group: 3
  558. };
  559. const etherpad = {
  560. key: 'etherpad',
  561. Content: SharedDocumentButton,
  562. group: 3
  563. };
  564. const virtualBackground = !_screensharing && checkBlurSupport() && {
  565. key: 'select-background',
  566. Content: VideoBackgroundButton,
  567. group: 3
  568. };
  569. const speakerStats = {
  570. key: 'stats',
  571. Content: SpeakerStatsButton,
  572. group: 3
  573. };
  574. const settings = {
  575. key: 'settings',
  576. Content: SettingsButton,
  577. group: 4
  578. };
  579. const shortcuts = !_isMobile && keyboardShortcut.getEnabled() && {
  580. key: 'shortcuts',
  581. Content: KeyboardShortcutsButton,
  582. group: 4
  583. };
  584. const embed = this._isEmbedMeetingVisible() && {
  585. key: 'embedmeeting',
  586. Content: EmbedMeetingButton,
  587. group: 4
  588. };
  589. const feedback = _feedbackConfigured && {
  590. key: 'feedback',
  591. Content: FeedbackButton,
  592. group: 4
  593. };
  594. const download = {
  595. key: 'download',
  596. Content: DownloadButton,
  597. group: 4
  598. };
  599. const help = {
  600. key: 'help',
  601. Content: HelpButton,
  602. group: 4
  603. };
  604. return {
  605. microphone,
  606. camera,
  607. profile,
  608. desktop,
  609. chat,
  610. raisehand,
  611. participants,
  612. tileview,
  613. videoQuality,
  614. fullscreen,
  615. security,
  616. info,
  617. cc,
  618. recording,
  619. localRecording,
  620. muteEveryone,
  621. muteVideoEveryone,
  622. livestreaming,
  623. shareVideo,
  624. shareAudio,
  625. etherpad,
  626. virtualBackground,
  627. speakerStats,
  628. settings,
  629. shortcuts,
  630. embed,
  631. feedback,
  632. download,
  633. help
  634. };
  635. }
  636. /**
  637. * Returns all buttons that need to be rendered.
  638. *
  639. * @param {Object} state - The redux state.
  640. * @returns {Object} The visible buttons arrays .
  641. */
  642. _getVisibleButtons() {
  643. const {
  644. _clientWidth,
  645. _shouldShowButton
  646. } = this.props;
  647. const buttons = this._getAllButtons();
  648. const isHangupVisible = _shouldShowButton('hangup');
  649. const { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  650. || THRESHOLDS[THRESHOLDS.length - 1];
  651. let sliceIndex = order.length + 2;
  652. const keys = Object.keys(buttons);
  653. const filtered = [
  654. ...order.map(key => buttons[key]),
  655. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  656. ].filter(Boolean).filter(({ key }) => _shouldShowButton(key));
  657. if (isHangupVisible) {
  658. sliceIndex -= 1;
  659. }
  660. // This implies that the overflow button will be displayed, so save some space for it.
  661. if (sliceIndex < filtered.length) {
  662. sliceIndex -= 1;
  663. }
  664. return {
  665. mainMenuButtons: filtered.slice(0, sliceIndex),
  666. overflowMenuButtons: filtered.slice(sliceIndex)
  667. };
  668. }
  669. _onMouseOut: () => void;
  670. /**
  671. * Dispatches an action signaling the toolbar is not being hovered.
  672. *
  673. * @private
  674. * @returns {void}
  675. */
  676. _onMouseOut() {
  677. this.props.dispatch(setToolbarHovered(false));
  678. }
  679. _onMouseOver: () => void;
  680. /**
  681. * Dispatches an action signaling the toolbar is being hovered.
  682. *
  683. * @private
  684. * @returns {void}
  685. */
  686. _onMouseOver() {
  687. this.props.dispatch(setToolbarHovered(true));
  688. }
  689. _onSetOverflowVisible: (boolean) => void;
  690. /**
  691. * Sets the visibility of the overflow menu.
  692. *
  693. * @param {boolean} visible - Whether or not the overflow menu should be
  694. * displayed.
  695. * @private
  696. * @returns {void}
  697. */
  698. _onSetOverflowVisible(visible) {
  699. this.props.dispatch(setOverflowMenuVisible(visible));
  700. }
  701. _onShortcutToggleChat: () => void;
  702. /**
  703. * Creates an analytics keyboard shortcut event and dispatches an action for
  704. * toggling the display of chat.
  705. *
  706. * @private
  707. * @returns {void}
  708. */
  709. _onShortcutToggleChat() {
  710. sendAnalytics(createShortcutEvent(
  711. 'toggle.chat',
  712. {
  713. enable: !this.props._chatOpen
  714. }));
  715. // Checks if there was any text selected by the user.
  716. // Used for when we press simultaneously keys for copying
  717. // text messages from the chat board
  718. if (window.getSelection().toString() !== '') {
  719. return false;
  720. }
  721. this._doToggleChat();
  722. }
  723. _onShortcutToggleParticipantsPane: () => void;
  724. /**
  725. * Creates an analytics keyboard shortcut event and dispatches an action for
  726. * toggling the display of the participants pane.
  727. *
  728. * @private
  729. * @returns {void}
  730. */
  731. _onShortcutToggleParticipantsPane() {
  732. sendAnalytics(createShortcutEvent(
  733. 'toggle.participants-pane',
  734. {
  735. enable: !this.props._participantsPaneOpen
  736. }));
  737. this._onToolbarToggleParticipantsPane();
  738. }
  739. _onShortcutToggleVideoQuality: () => void;
  740. /**
  741. * Creates an analytics keyboard shortcut event and dispatches an action for
  742. * toggling the display of Video Quality.
  743. *
  744. * @private
  745. * @returns {void}
  746. */
  747. _onShortcutToggleVideoQuality() {
  748. sendAnalytics(createShortcutEvent('video.quality'));
  749. this._doToggleVideoQuality();
  750. }
  751. _onShortcutToggleTileView: () => void;
  752. /**
  753. * Dispatches an action for toggling the tile view.
  754. *
  755. * @private
  756. * @returns {void}
  757. */
  758. _onShortcutToggleTileView() {
  759. sendAnalytics(createShortcutEvent(
  760. 'toggle.tileview',
  761. {
  762. enable: !this.props._tileViewEnabled
  763. }));
  764. this._doToggleTileView();
  765. }
  766. _onShortcutToggleFullScreen: () => void;
  767. /**
  768. * Creates an analytics keyboard shortcut event and dispatches an action for
  769. * toggling full screen mode.
  770. *
  771. * @private
  772. * @returns {void}
  773. */
  774. _onShortcutToggleFullScreen() {
  775. sendAnalytics(createShortcutEvent(
  776. 'toggle.fullscreen',
  777. {
  778. enable: !this.props._fullScreen
  779. }));
  780. this._doToggleFullScreen();
  781. }
  782. _onShortcutToggleRaiseHand: () => void;
  783. /**
  784. * Creates an analytics keyboard shortcut event and dispatches an action for
  785. * toggling raise hand.
  786. *
  787. * @private
  788. * @returns {void}
  789. */
  790. _onShortcutToggleRaiseHand() {
  791. sendAnalytics(createShortcutEvent(
  792. 'toggle.raise.hand',
  793. ACTION_SHORTCUT_TRIGGERED,
  794. { enable: !this.props._raisedHand }));
  795. this._doToggleRaiseHand();
  796. }
  797. _onShortcutToggleScreenshare: () => void;
  798. /**
  799. * Creates an analytics keyboard shortcut event and dispatches an action for
  800. * toggling screensharing.
  801. *
  802. * @private
  803. * @returns {void}
  804. */
  805. _onShortcutToggleScreenshare() {
  806. sendAnalytics(createShortcutEvent(
  807. 'toggle.screen.sharing',
  808. ACTION_SHORTCUT_TRIGGERED,
  809. {
  810. enable: !this.props._screensharing
  811. }));
  812. this._doToggleScreenshare();
  813. }
  814. _onTabIn: () => void;
  815. /**
  816. * Toggle the toolbar visibility when tabbing into it.
  817. *
  818. * @returns {void}
  819. */
  820. _onTabIn() {
  821. if (!this.props._visible) {
  822. this.props.dispatch(showToolbox());
  823. }
  824. }
  825. _onToolbarToggleParticipantsPane: () => void;
  826. /**
  827. * Dispatches an action for toggling the participants pane.
  828. *
  829. * @private
  830. * @returns {void}
  831. */
  832. _onToolbarToggleParticipantsPane() {
  833. const { dispatch, _participantsPaneOpen } = this.props;
  834. if (_participantsPaneOpen) {
  835. dispatch(closeParticipantsPane());
  836. } else {
  837. dispatch(openParticipantsPane());
  838. }
  839. }
  840. _onToolbarOpenVideoQuality: () => void;
  841. /**
  842. * Creates an analytics toolbar event and dispatches an action for toggling
  843. * open the video quality dialog.
  844. *
  845. * @private
  846. * @returns {void}
  847. */
  848. _onToolbarOpenVideoQuality() {
  849. sendAnalytics(createToolbarEvent('video.quality'));
  850. this._doOpenVideoQuality();
  851. }
  852. _onToolbarToggleChat: () => void;
  853. /**
  854. * Creates an analytics toolbar event and dispatches an action for toggling
  855. * the display of chat.
  856. *
  857. * @private
  858. * @returns {void}
  859. */
  860. _onToolbarToggleChat() {
  861. sendAnalytics(createToolbarEvent(
  862. 'toggle.chat',
  863. {
  864. enable: !this.props._chatOpen
  865. }));
  866. this._closeOverflowMenuIfOpen();
  867. this._doToggleChat();
  868. }
  869. _onToolbarToggleFullScreen: () => void;
  870. /**
  871. * Creates an analytics toolbar event and dispatches an action for toggling
  872. * full screen mode.
  873. *
  874. * @private
  875. * @returns {void}
  876. */
  877. _onToolbarToggleFullScreen() {
  878. sendAnalytics(createToolbarEvent(
  879. 'toggle.fullscreen',
  880. {
  881. enable: !this.props._fullScreen
  882. }));
  883. this._closeOverflowMenuIfOpen();
  884. this._doToggleFullScreen();
  885. }
  886. _onToolbarToggleRaiseHand: () => void;
  887. /**
  888. * Creates an analytics toolbar event and dispatches an action for toggling
  889. * raise hand.
  890. *
  891. * @private
  892. * @returns {void}
  893. */
  894. _onToolbarToggleRaiseHand() {
  895. sendAnalytics(createToolbarEvent(
  896. 'raise.hand',
  897. { enable: !this.props._raisedHand }));
  898. this._doToggleRaiseHand();
  899. }
  900. _onToolbarToggleScreenshare: () => void;
  901. /**
  902. * Creates an analytics toolbar event and dispatches an action for toggling
  903. * screensharing.
  904. *
  905. * @private
  906. * @returns {void}
  907. */
  908. _onToolbarToggleScreenshare() {
  909. sendAnalytics(createToolbarEvent(
  910. 'toggle.screen.sharing',
  911. ACTION_SHORTCUT_TRIGGERED,
  912. { enable: !this.props._screensharing }));
  913. this._closeOverflowMenuIfOpen();
  914. this._doToggleScreenshare();
  915. }
  916. /**
  917. * Returns true if the audio sharing button should be visible and
  918. * false otherwise.
  919. *
  920. * @returns {boolean}
  921. */
  922. _showAudioSharingButton() {
  923. const {
  924. _desktopSharingEnabled
  925. } = this.props;
  926. return _desktopSharingEnabled && isScreenAudioSupported();
  927. }
  928. /**
  929. * Returns true if the desktop sharing button should be visible and
  930. * false otherwise.
  931. *
  932. * @returns {boolean}
  933. */
  934. _showDesktopSharingButton() {
  935. const {
  936. _desktopSharingEnabled,
  937. _desktopSharingDisabledTooltipKey
  938. } = this.props;
  939. return _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  940. }
  941. /**
  942. * Returns true if the embed meeting button is visible and false otherwise.
  943. *
  944. * @returns {boolean}
  945. */
  946. _isEmbedMeetingVisible() {
  947. return !this.props._isVpaasMeeting
  948. && !this.props._isMobile;
  949. }
  950. /**
  951. * Returns true if the profile button is visible and false otherwise.
  952. *
  953. * @returns {boolean}
  954. */
  955. _isProfileVisible() {
  956. return !this.props._isProfileDisabled;
  957. }
  958. /**
  959. * Renders the toolbox content.
  960. *
  961. * @returns {ReactElement}
  962. */
  963. _renderToolboxContent() {
  964. const {
  965. _isMobile,
  966. _overflowMenuVisible,
  967. t
  968. } = this.props;
  969. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  970. const containerClassName = `toolbox-content${_isMobile ? ' toolbox-content-mobile' : ''}`;
  971. const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
  972. return (
  973. <div className = { containerClassName }>
  974. <div
  975. className = 'toolbox-content-wrapper'
  976. onFocus = { this._onTabIn }
  977. onMouseOut = { this._onMouseOut }
  978. onMouseOver = { this._onMouseOver }>
  979. <div className = 'toolbox-content-items'>
  980. {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
  981. <Content
  982. { ...rest }
  983. key = { key } />))}
  984. {Boolean(overflowMenuButtons.length) && (
  985. <OverflowMenuButton
  986. ariaControls = 'overflow-menu'
  987. isOpen = { _overflowMenuVisible }
  988. key = 'overflow-menu'
  989. onVisibilityChange = { this._onSetOverflowVisible }>
  990. <ul
  991. aria-label = { t(toolbarAccLabel) }
  992. className = 'overflow-menu'
  993. id = 'overflow-menu'
  994. onKeyDown = { this._onEscKey }
  995. role = 'menu'>
  996. {overflowMenuButtons.map(({ group, key, Content, ...rest }, index, arr) => {
  997. const showSeparator = index > 0 && arr[index - 1].group !== group;
  998. return (
  999. <>
  1000. {showSeparator && <Separator key = { `hr${group}` } />}
  1001. <Content
  1002. { ...rest }
  1003. key = { key }
  1004. showLabel = { true } />
  1005. </>
  1006. );
  1007. })}
  1008. </ul>
  1009. </OverflowMenuButton>
  1010. )}
  1011. <HangupButton
  1012. customClass = 'hangup-button'
  1013. key = 'hangup-button'
  1014. visible = { this.props._shouldShowButton('hangup') } />
  1015. </div>
  1016. </div>
  1017. </div>
  1018. );
  1019. }
  1020. }
  1021. /**
  1022. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1023. * props.
  1024. *
  1025. * @param {Object} state - The redux store/state.
  1026. * @private
  1027. * @returns {{}}
  1028. */
  1029. function _mapStateToProps(state) {
  1030. const { conference } = state['features/base/conference'];
  1031. let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
  1032. const {
  1033. callStatsID,
  1034. enableFeaturesBasedOnToken
  1035. } = state['features/base/config'];
  1036. const {
  1037. fullScreen,
  1038. overflowMenuVisible
  1039. } = state['features/toolbox'];
  1040. const localParticipant = getLocalParticipant(state);
  1041. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1042. const { clientWidth } = state['features/base/responsive-ui'];
  1043. let desktopSharingDisabledTooltipKey;
  1044. if (enableFeaturesBasedOnToken) {
  1045. // we enable desktop sharing if any participant already have this
  1046. // feature enabled
  1047. desktopSharingEnabled = getParticipants(state)
  1048. .find(({ features = {} }) =>
  1049. String(features['screen-sharing']) === 'true') !== undefined;
  1050. desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
  1051. }
  1052. return {
  1053. _chatOpen: state['features/chat'].isOpen,
  1054. _clientWidth: clientWidth,
  1055. _conference: conference,
  1056. _desktopSharingEnabled: desktopSharingEnabled,
  1057. _backgroundType: state['features/virtual-background'].backgroundType,
  1058. _virtualSource: state['features/virtual-background'].virtualSource,
  1059. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  1060. _dialog: Boolean(state['features/base/dialog'].component),
  1061. _feedbackConfigured: Boolean(callStatsID),
  1062. _isProfileDisabled: Boolean(state['features/base/config'].disableProfile),
  1063. _isMobile: isMobileBrowser(),
  1064. _isVpaasMeeting: isVpaasMeeting(state),
  1065. _fullScreen: fullScreen,
  1066. _tileViewEnabled: shouldDisplayTileView(state),
  1067. _localParticipantID: localParticipant.id,
  1068. _localVideo: localVideo,
  1069. _overflowMenuVisible: overflowMenuVisible,
  1070. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1071. _raisedHand: localParticipant.raisedHand,
  1072. _screensharing: isScreenVideoShared(state),
  1073. _shouldShowButton: buttonName => isToolbarButtonEnabled(buttonName)(state),
  1074. _visible: isToolboxVisible(state),
  1075. _visibleButtons: getToolbarButtons(state)
  1076. };
  1077. }
  1078. export default translate(connect(_mapStateToProps)(Toolbox));