Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Toolbox.js 41KB

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