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 45KB

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