選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Toolbox.js 40KB

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