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

Toolbox.js 41KB

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