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

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