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

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