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

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