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

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