You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Toolbox.js 41KB

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