Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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