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

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