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

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