Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  1. // @flow
  2. import { withStyles } from '@material-ui/core/styles';
  3. import clsx from 'clsx';
  4. import React, { Component, Fragment } from 'react';
  5. import keyboardShortcut from '../../../../../modules/keyboardshortcut/keyboardshortcut';
  6. import {
  7. ACTION_SHORTCUT_TRIGGERED,
  8. createShortcutEvent,
  9. createToolbarEvent,
  10. sendAnalytics
  11. } from '../../../analytics';
  12. import { getToolbarButtons } from '../../../base/config';
  13. import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
  14. import { openDialog, toggleDialog } from '../../../base/dialog';
  15. import { isIosMobileBrowser, isMobileBrowser } from '../../../base/environment/utils';
  16. import { translate } from '../../../base/i18n';
  17. import JitsiMeetJS from '../../../base/lib-jitsi-meet';
  18. import {
  19. getLocalParticipant,
  20. hasRaisedHand,
  21. haveParticipantWithScreenSharingFeature,
  22. raiseHand
  23. } from '../../../base/participants';
  24. import { connect } from '../../../base/redux';
  25. import { getLocalVideoTrack } from '../../../base/tracks';
  26. import { toggleChat } from '../../../chat';
  27. import { ChatButton } from '../../../chat/components';
  28. import { DominantSpeakerName } from '../../../display-name';
  29. import { EmbedMeetingButton } from '../../../embed-meeting';
  30. import { SharedDocumentButton } from '../../../etherpad';
  31. import { FeedbackButton } from '../../../feedback';
  32. import { InviteButton } from '../../../invite/components/add-people-dialog';
  33. import { isVpaasMeeting } from '../../../jaas/functions';
  34. import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
  35. import { LocalRecordingButton } from '../../../local-recording';
  36. import {
  37. close as closeParticipantsPane,
  38. open as openParticipantsPane
  39. } from '../../../participants-pane/actions';
  40. import { ParticipantsPaneButton } from '../../../participants-pane/components/web';
  41. import { getParticipantsPaneOpen } from '../../../participants-pane/functions';
  42. import { addReactionToBuffer } from '../../../reactions/actions.any';
  43. import { ReactionsMenuButton } from '../../../reactions/components';
  44. import { REACTIONS, REACTIONS_MENU_HEIGHT } from '../../../reactions/constants';
  45. import { isReactionsEnabled } from '../../../reactions/functions.any';
  46. import {
  47. LiveStreamButton,
  48. RecordButton
  49. } from '../../../recording';
  50. import {
  51. isScreenAudioSupported,
  52. isScreenVideoShared,
  53. ShareAudioButton,
  54. startScreenShareFlow
  55. } from '../../../screen-share/';
  56. import SecurityDialogButton from '../../../security/components/security-dialog/web/SecurityDialogButton';
  57. import { SettingsButton } from '../../../settings';
  58. import { SharedVideoButton } from '../../../shared-video/components';
  59. import { SpeakerStatsButton } from '../../../speaker-stats/components/web';
  60. import {
  61. ClosedCaptionButton
  62. } from '../../../subtitles';
  63. import {
  64. TileViewButton,
  65. shouldDisplayTileView,
  66. toggleTileView
  67. } from '../../../video-layout';
  68. import { VideoQualityDialog, VideoQualityButton } from '../../../video-quality/components';
  69. import { VideoBackgroundButton, toggleBackgroundEffect } from '../../../virtual-background';
  70. import { VIRTUAL_BACKGROUND_TYPE } from '../../../virtual-background/constants';
  71. import {
  72. setFullScreen,
  73. setOverflowMenuVisible,
  74. setToolbarHovered,
  75. showToolbox
  76. } from '../../actions';
  77. import { THRESHOLDS, NOT_APPLICABLE, DRAWER_MAX_HEIGHT, NOTIFY_CLICK_MODE } from '../../constants';
  78. import { isDesktopShareButtonDisabled, isToolboxVisible } from '../../functions';
  79. import DownloadButton from '../DownloadButton';
  80. import HangupButton from '../HangupButton';
  81. import HelpButton from '../HelpButton';
  82. import MuteEveryoneButton from '../MuteEveryoneButton';
  83. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  84. import AudioSettingsButton from './AudioSettingsButton';
  85. import FullscreenButton from './FullscreenButton';
  86. import OverflowMenuButton from './OverflowMenuButton';
  87. import ProfileButton from './ProfileButton';
  88. import Separator from './Separator';
  89. import ShareDesktopButton from './ShareDesktopButton';
  90. import ToggleCameraButton from './ToggleCameraButton';
  91. import VideoSettingsButton from './VideoSettingsButton';
  92. /**
  93. * The type of the React {@code Component} props of {@link Toolbox}.
  94. */
  95. type Props = {
  96. /**
  97. * String showing if the virtual background type is desktop-share.
  98. */
  99. _backgroundType: String,
  100. /**
  101. * Toolbar buttons which have their click exposed through the API.
  102. */
  103. _buttonsWithNotifyClick: Array<string | Object>,
  104. /**
  105. * Whether or not the chat feature is currently displayed.
  106. */
  107. _chatOpen: boolean,
  108. /**
  109. * The width of the client.
  110. */
  111. _clientWidth: number,
  112. /**
  113. * The {@code JitsiConference} for the current conference.
  114. */
  115. _conference: Object,
  116. /**
  117. * Whether or not screensharing button is disabled.
  118. */
  119. _desktopSharingButtonDisabled: boolean,
  120. /**
  121. * The tooltip key to use when screensharing is disabled. Or undefined
  122. * if non to be shown and the button to be hidden.
  123. */
  124. _desktopSharingDisabledTooltipKey: boolean,
  125. /**
  126. * Whether or not screensharing is initialized.
  127. */
  128. _desktopSharingEnabled: boolean,
  129. /**
  130. * Whether or not a dialog is displayed.
  131. */
  132. _dialog: boolean,
  133. /**
  134. * Whether or not the toolbox is disabled. It is for recorders.
  135. */
  136. _disabled: boolean,
  137. /**
  138. * Whether or not call feedback can be sent.
  139. */
  140. _feedbackConfigured: boolean,
  141. /**
  142. * Whether or not the app is currently in full screen.
  143. */
  144. _fullScreen: boolean,
  145. /**
  146. * Whether or not the app is running in an ios mobile browser.
  147. */
  148. _isIosMobile: boolean,
  149. /**
  150. * Whether or not the app is running in mobile browser.
  151. */
  152. _isMobile: boolean,
  153. /**
  154. * Whether or not the profile is disabled.
  155. */
  156. _isProfileDisabled: boolean,
  157. /**
  158. * Whether or not the current meeting belongs to a JaaS user.
  159. */
  160. _isVpaasMeeting: boolean,
  161. /**
  162. * The ID of the local participant.
  163. */
  164. _localParticipantID: String,
  165. /**
  166. * The JitsiLocalTrack to display.
  167. */
  168. _localVideo: Object,
  169. /**
  170. *Whether or not the overflow menu is displayed in a drawer drawer.
  171. */
  172. _overflowDrawer: boolean,
  173. /**
  174. * Whether or not the overflow menu is visible.
  175. */
  176. _overflowMenuVisible: boolean,
  177. /**
  178. * Whether or not the participants pane is open.
  179. */
  180. _participantsPaneOpen: boolean,
  181. /**
  182. * Whether or not the local participant's hand is raised.
  183. */
  184. _raisedHand: boolean,
  185. /**
  186. * Whether or not reactions feature is enabled.
  187. */
  188. _reactionsEnabled: boolean,
  189. /**
  190. * Whether or not the local participant is screenSharing.
  191. */
  192. _screenSharing: boolean,
  193. /**
  194. * Whether or not the local participant is sharing a YouTube video.
  195. */
  196. _sharingVideo: boolean,
  197. /**
  198. * Whether or not to show dominant speaker badge.
  199. */
  200. _showDominantSpeakerBadge: boolean,
  201. /**
  202. * Whether or not the tile view is enabled.
  203. */
  204. _tileViewEnabled: boolean,
  205. /**
  206. * The enabled buttons.
  207. */
  208. _toolbarButtons: Array<string>,
  209. /**
  210. * Flag showing whether toolbar is visible.
  211. */
  212. _visible: boolean,
  213. /**
  214. * Returns the selected virtual source object.
  215. */
  216. _virtualSource: Object,
  217. /**
  218. * An object containing the CSS classes.
  219. */
  220. classes: Object,
  221. /**
  222. * Invoked to active other features of the app.
  223. */
  224. dispatch: Function,
  225. /**
  226. * Invoked to obtain translated strings.
  227. */
  228. t: Function,
  229. /**
  230. * Explicitly passed array with the buttons which this Toolbox should display.
  231. */
  232. toolbarButtons: Array<string>,
  233. };
  234. declare var APP: Object;
  235. const styles = theme => {
  236. return {
  237. overflowMenu: {
  238. fontSize: 14,
  239. listStyleType: 'none',
  240. padding: '8px 0',
  241. backgroundColor: theme.palette.ui03
  242. },
  243. overflowMenuDrawer: {
  244. overflowY: 'auto',
  245. height: `calc(${DRAWER_MAX_HEIGHT} - ${REACTIONS_MENU_HEIGHT}px - 16px)`
  246. }
  247. };
  248. };
  249. /**
  250. * Implements the conference toolbox on React/Web.
  251. *
  252. * @augments Component
  253. */
  254. class Toolbox extends Component<Props> {
  255. /**
  256. * Initializes a new {@code Toolbox} instance.
  257. *
  258. * @param {Props} props - The read-only React {@code Component} props with
  259. * which the new instance is to be initialized.
  260. */
  261. constructor(props: Props) {
  262. super(props);
  263. // Bind event handlers so they are only bound once per instance.
  264. this._onMouseOut = this._onMouseOut.bind(this);
  265. this._onMouseOver = this._onMouseOver.bind(this);
  266. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  267. this._onTabIn = this._onTabIn.bind(this);
  268. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  269. this._onShortcutToggleFullScreen = this._onShortcutToggleFullScreen.bind(this);
  270. this._onShortcutToggleParticipantsPane = this._onShortcutToggleParticipantsPane.bind(this);
  271. this._onShortcutToggleRaiseHand = this._onShortcutToggleRaiseHand.bind(this);
  272. this._onShortcutToggleScreenshare = this._onShortcutToggleScreenshare.bind(this);
  273. this._onShortcutToggleVideoQuality = this._onShortcutToggleVideoQuality.bind(this);
  274. this._onToolbarToggleParticipantsPane = this._onToolbarToggleParticipantsPane.bind(this);
  275. this._onToolbarOpenVideoQuality = this._onToolbarOpenVideoQuality.bind(this);
  276. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  277. this._onToolbarToggleFullScreen = this._onToolbarToggleFullScreen.bind(this);
  278. this._onToolbarToggleRaiseHand = this._onToolbarToggleRaiseHand.bind(this);
  279. this._onToolbarToggleScreenshare = this._onToolbarToggleScreenshare.bind(this);
  280. this._onShortcutToggleTileView = this._onShortcutToggleTileView.bind(this);
  281. this._onEscKey = this._onEscKey.bind(this);
  282. }
  283. /**
  284. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  285. *
  286. * @inheritdoc
  287. * @returns {void}
  288. */
  289. componentDidMount() {
  290. const { _toolbarButtons, t, dispatch, _reactionsEnabled } = this.props;
  291. const KEYBOARD_SHORTCUTS = [
  292. isToolbarButtonEnabled('videoquality', _toolbarButtons) && {
  293. character: 'A',
  294. exec: this._onShortcutToggleVideoQuality,
  295. helpDescription: 'toolbar.callQuality'
  296. },
  297. isToolbarButtonEnabled('chat', _toolbarButtons) && {
  298. character: 'C',
  299. exec: this._onShortcutToggleChat,
  300. helpDescription: 'keyboardShortcuts.toggleChat'
  301. },
  302. isToolbarButtonEnabled('desktop', _toolbarButtons) && {
  303. character: 'D',
  304. exec: this._onShortcutToggleScreenshare,
  305. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  306. },
  307. isToolbarButtonEnabled('participants-pane', _toolbarButtons) && {
  308. character: 'P',
  309. exec: this._onShortcutToggleParticipantsPane,
  310. helpDescription: 'keyboardShortcuts.toggleParticipantsPane'
  311. },
  312. isToolbarButtonEnabled('raisehand', _toolbarButtons) && {
  313. character: 'R',
  314. exec: this._onShortcutToggleRaiseHand,
  315. helpDescription: 'keyboardShortcuts.raiseHand'
  316. },
  317. isToolbarButtonEnabled('fullscreen', _toolbarButtons) && {
  318. character: 'S',
  319. exec: this._onShortcutToggleFullScreen,
  320. helpDescription: 'keyboardShortcuts.fullScreen'
  321. },
  322. isToolbarButtonEnabled('tileview', _toolbarButtons) && {
  323. character: 'W',
  324. exec: this._onShortcutToggleTileView,
  325. helpDescription: 'toolbar.tileViewToggle'
  326. }
  327. ];
  328. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  329. if (typeof shortcut === 'object') {
  330. APP.keyboardshortcut.registerShortcut(
  331. shortcut.character,
  332. null,
  333. shortcut.exec,
  334. shortcut.helpDescription);
  335. }
  336. });
  337. if (_reactionsEnabled) {
  338. const REACTION_SHORTCUTS = Object.keys(REACTIONS).map(key => {
  339. const onShortcutSendReaction = () => {
  340. dispatch(addReactionToBuffer(key));
  341. sendAnalytics(createShortcutEvent(
  342. `reaction.${key}`
  343. ));
  344. };
  345. return {
  346. character: REACTIONS[key].shortcutChar,
  347. exec: onShortcutSendReaction,
  348. helpDescription: t(`toolbar.reaction${key.charAt(0).toUpperCase()}${key.slice(1)}`),
  349. altKey: true
  350. };
  351. });
  352. REACTION_SHORTCUTS.forEach(shortcut => {
  353. APP.keyboardshortcut.registerShortcut(
  354. shortcut.character,
  355. null,
  356. shortcut.exec,
  357. shortcut.helpDescription,
  358. shortcut.altKey);
  359. });
  360. }
  361. }
  362. /**
  363. * Update the visibility of the {@code OverflowMenuButton}.
  364. *
  365. * @inheritdoc
  366. */
  367. componentDidUpdate(prevProps) {
  368. const { _dialog, dispatch } = this.props;
  369. if (prevProps._overflowMenuVisible
  370. && !prevProps._dialog
  371. && _dialog) {
  372. this._onSetOverflowVisible(false);
  373. dispatch(setToolbarHovered(false));
  374. }
  375. }
  376. /**
  377. * Removes keyboard shortcuts registered by this component.
  378. *
  379. * @inheritdoc
  380. * @returns {void}
  381. */
  382. componentWillUnmount() {
  383. [ 'A', 'C', 'D', 'R', 'S' ].forEach(letter =>
  384. APP.keyboardshortcut.unregisterShortcut(letter));
  385. if (this.props._reactionsEnabled) {
  386. Object.keys(REACTIONS).map(key => REACTIONS[key].shortcutChar)
  387. .forEach(letter =>
  388. APP.keyboardshortcut.unregisterShortcut(letter, true));
  389. }
  390. }
  391. /**
  392. * Implements React's {@link Component#render()}.
  393. *
  394. * @inheritdoc
  395. * @returns {ReactElement}
  396. */
  397. render() {
  398. if (this.props._disabled) {
  399. return null;
  400. }
  401. const { _chatOpen, _visible, _toolbarButtons } = this.props;
  402. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  403. _toolbarButtons.length ? '' : 'no-buttons'} ${_chatOpen ? 'shift-right' : ''}`;
  404. return (
  405. <div
  406. className = { rootClassNames }
  407. id = 'new-toolbox'>
  408. { this._renderToolboxContent() }
  409. </div>
  410. );
  411. }
  412. _onEscKey: (KeyboardEvent) => void;
  413. /**
  414. * Key handler for overflow menu.
  415. *
  416. * @param {KeyboardEvent} e - Esc key click to close the popup.
  417. * @returns {void}
  418. */
  419. _onEscKey(e) {
  420. if (e.key === 'Escape') {
  421. e.stopPropagation();
  422. this._closeOverflowMenuIfOpen();
  423. }
  424. }
  425. /**
  426. * Closes the overflow menu if opened.
  427. *
  428. * @private
  429. * @returns {void}
  430. */
  431. _closeOverflowMenuIfOpen() {
  432. const { dispatch, _overflowMenuVisible } = this.props;
  433. _overflowMenuVisible && dispatch(setOverflowMenuVisible(false));
  434. }
  435. /**
  436. * Dispatches an action to open the video quality dialog.
  437. *
  438. * @private
  439. * @returns {void}
  440. */
  441. _doOpenVideoQuality() {
  442. this.props.dispatch(openDialog(VideoQualityDialog));
  443. }
  444. /**
  445. * Dispatches an action to toggle the display of chat.
  446. *
  447. * @private
  448. * @returns {void}
  449. */
  450. _doToggleChat() {
  451. this.props.dispatch(toggleChat());
  452. }
  453. /**
  454. * Dispatches an action to toggle screensharing.
  455. *
  456. * @private
  457. * @returns {void}
  458. */
  459. _doToggleFullScreen() {
  460. const fullScreen = !this.props._fullScreen;
  461. this.props.dispatch(setFullScreen(fullScreen));
  462. }
  463. /**
  464. * Dispatches an action to toggle the local participant's raised hand state.
  465. *
  466. * @private
  467. * @returns {void}
  468. */
  469. _doToggleRaiseHand() {
  470. const { _raisedHand } = this.props;
  471. this.props.dispatch(raiseHand(!_raisedHand));
  472. }
  473. /**
  474. * Dispatches an action to toggle screensharing.
  475. *
  476. * @private
  477. * @param {boolean} enabled - The state to toggle screen sharing to.
  478. * @param {boolean} audioOnly - Only share system audio.
  479. * @returns {void}
  480. */
  481. _doToggleScreenshare() {
  482. const {
  483. _backgroundType,
  484. _desktopSharingButtonDisabled,
  485. _desktopSharingEnabled,
  486. _localVideo,
  487. _virtualSource,
  488. dispatch
  489. } = this.props;
  490. if (_backgroundType === VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE) {
  491. const noneOptions = {
  492. enabled: false,
  493. backgroundType: VIRTUAL_BACKGROUND_TYPE.NONE,
  494. selectedThumbnail: VIRTUAL_BACKGROUND_TYPE.NONE,
  495. backgroundEffectEnabled: false
  496. };
  497. _virtualSource.dispose();
  498. dispatch(toggleBackgroundEffect(noneOptions, _localVideo));
  499. return;
  500. }
  501. if (_desktopSharingEnabled && !_desktopSharingButtonDisabled) {
  502. dispatch(startScreenShareFlow());
  503. }
  504. }
  505. /**
  506. * Dispatches an action to toggle the video quality dialog.
  507. *
  508. * @private
  509. * @returns {void}
  510. */
  511. _doToggleVideoQuality() {
  512. this.props.dispatch(toggleDialog(VideoQualityDialog));
  513. }
  514. /**
  515. * Dispaches an action to toggle tile view.
  516. *
  517. * @private
  518. * @returns {void}
  519. */
  520. _doToggleTileView() {
  521. this.props.dispatch(toggleTileView());
  522. }
  523. /**
  524. * Returns all buttons that could be rendered.
  525. *
  526. * @param {Object} state - The redux state.
  527. * @returns {Object} The button maps mainMenuButtons and overflowMenuButtons.
  528. */
  529. _getAllButtons() {
  530. const {
  531. _feedbackConfigured,
  532. _isIosMobile,
  533. _isMobile,
  534. _screenSharing
  535. } = this.props;
  536. const microphone = {
  537. key: 'microphone',
  538. Content: AudioSettingsButton,
  539. group: 0
  540. };
  541. const camera = {
  542. key: 'camera',
  543. Content: VideoSettingsButton,
  544. group: 0
  545. };
  546. const profile = this._isProfileVisible() && {
  547. key: 'profile',
  548. Content: ProfileButton,
  549. group: 1
  550. };
  551. const chat = {
  552. key: 'chat',
  553. Content: ChatButton,
  554. handleClick: this._onToolbarToggleChat,
  555. group: 2
  556. };
  557. const desktop = this._showDesktopSharingButton() && {
  558. key: 'desktop',
  559. Content: ShareDesktopButton,
  560. handleClick: this._onToolbarToggleScreenshare,
  561. group: 2
  562. };
  563. const raisehand = {
  564. key: 'raisehand',
  565. Content: ReactionsMenuButton,
  566. handleClick: this._onToolbarToggleRaiseHand,
  567. group: 2
  568. };
  569. const participants = {
  570. key: 'participants-pane',
  571. Content: ParticipantsPaneButton,
  572. handleClick: this._onToolbarToggleParticipantsPane,
  573. group: 2
  574. };
  575. const invite = {
  576. key: 'invite',
  577. Content: InviteButton,
  578. group: 2
  579. };
  580. const tileview = {
  581. key: 'tileview',
  582. Content: TileViewButton,
  583. group: 2
  584. };
  585. const toggleCamera = {
  586. key: 'toggle-camera',
  587. Content: ToggleCameraButton,
  588. group: 2
  589. };
  590. const videoQuality = {
  591. key: 'videoquality',
  592. Content: VideoQualityButton,
  593. handleClick: this._onToolbarOpenVideoQuality,
  594. group: 2
  595. };
  596. const fullscreen = !_isIosMobile && {
  597. key: 'fullscreen',
  598. Content: FullscreenButton,
  599. handleClick: this._onToolbarToggleFullScreen,
  600. group: 2
  601. };
  602. const security = {
  603. key: 'security',
  604. alias: 'info',
  605. Content: SecurityDialogButton,
  606. group: 2
  607. };
  608. const cc = {
  609. key: 'closedcaptions',
  610. Content: ClosedCaptionButton,
  611. group: 2
  612. };
  613. const recording = {
  614. key: 'recording',
  615. Content: RecordButton,
  616. group: 2
  617. };
  618. const localRecording = {
  619. key: 'localrecording',
  620. Content: LocalRecordingButton,
  621. group: 2
  622. };
  623. const livestreaming = {
  624. key: 'livestreaming',
  625. Content: LiveStreamButton,
  626. group: 2
  627. };
  628. const muteEveryone = {
  629. key: 'mute-everyone',
  630. Content: MuteEveryoneButton,
  631. group: 2
  632. };
  633. const muteVideoEveryone = {
  634. key: 'mute-video-everyone',
  635. Content: MuteEveryonesVideoButton,
  636. group: 2
  637. };
  638. const shareVideo = {
  639. key: 'sharedvideo',
  640. Content: SharedVideoButton,
  641. group: 3
  642. };
  643. const shareAudio = this._showAudioSharingButton() && {
  644. key: 'shareaudio',
  645. Content: ShareAudioButton,
  646. group: 3
  647. };
  648. const etherpad = {
  649. key: 'etherpad',
  650. Content: SharedDocumentButton,
  651. group: 3
  652. };
  653. const virtualBackground = !_screenSharing && {
  654. key: 'select-background',
  655. Content: VideoBackgroundButton,
  656. group: 3
  657. };
  658. const speakerStats = {
  659. key: 'stats',
  660. Content: SpeakerStatsButton,
  661. group: 3
  662. };
  663. const settings = {
  664. key: 'settings',
  665. Content: SettingsButton,
  666. group: 4
  667. };
  668. const shortcuts = !_isMobile && keyboardShortcut.getEnabled() && {
  669. key: 'shortcuts',
  670. Content: KeyboardShortcutsButton,
  671. group: 4
  672. };
  673. const embed = this._isEmbedMeetingVisible() && {
  674. key: 'embedmeeting',
  675. Content: EmbedMeetingButton,
  676. group: 4
  677. };
  678. const feedback = _feedbackConfigured && {
  679. key: 'feedback',
  680. Content: FeedbackButton,
  681. group: 4
  682. };
  683. const download = {
  684. key: 'download',
  685. Content: DownloadButton,
  686. group: 4
  687. };
  688. const help = {
  689. key: 'help',
  690. Content: HelpButton,
  691. group: 4
  692. };
  693. return {
  694. microphone,
  695. camera,
  696. profile,
  697. desktop,
  698. chat,
  699. raisehand,
  700. participants,
  701. invite,
  702. tileview,
  703. toggleCamera,
  704. videoQuality,
  705. fullscreen,
  706. security,
  707. cc,
  708. recording,
  709. localRecording,
  710. livestreaming,
  711. muteEveryone,
  712. muteVideoEveryone,
  713. shareVideo,
  714. shareAudio,
  715. etherpad,
  716. virtualBackground,
  717. speakerStats,
  718. settings,
  719. shortcuts,
  720. embed,
  721. feedback,
  722. download,
  723. help
  724. };
  725. }
  726. /**
  727. * Sets the notify click mode for the buttons.
  728. *
  729. * @param {Object} buttons - The list of toolbar buttons.
  730. * @returns {void}
  731. */
  732. _setButtonsNotifyClickMode(buttons) {
  733. if (typeof APP === 'undefined' || !this.props._buttonsWithNotifyClick?.length) {
  734. return;
  735. }
  736. Object.values(buttons).forEach((button: any) => {
  737. if (typeof button === 'object') {
  738. const notify = this.props._buttonsWithNotifyClick.find(
  739. (btn: string | Object) =>
  740. (typeof btn === 'string' && btn === button.key)
  741. || (typeof btn === 'object' && btn.key === button.key)
  742. );
  743. if (notify) {
  744. const notifyMode = typeof notify === 'string' || notify.preventExecution
  745. ? NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
  746. : NOTIFY_CLICK_MODE.ONLY_NOTIFY;
  747. button.notifyMode = notifyMode;
  748. }
  749. }
  750. });
  751. }
  752. /**
  753. * Returns all buttons that need to be rendered.
  754. *
  755. * @param {Object} state - The redux state.
  756. * @returns {Object} The visible buttons arrays .
  757. */
  758. _getVisibleButtons() {
  759. const {
  760. _clientWidth,
  761. _toolbarButtons
  762. } = this.props;
  763. const buttons = this._getAllButtons();
  764. this._setButtonsNotifyClickMode(buttons);
  765. const isHangupVisible = isToolbarButtonEnabled('hangup', _toolbarButtons);
  766. const { order } = THRESHOLDS.find(({ width }) => _clientWidth > width)
  767. || THRESHOLDS[THRESHOLDS.length - 1];
  768. let sliceIndex = order.length + 2;
  769. const keys = Object.keys(buttons);
  770. const filtered = [
  771. ...order.map(key => buttons[key]),
  772. ...Object.values(buttons).filter((button, index) => !order.includes(keys[index]))
  773. ].filter(Boolean).filter(({ key, alias = NOT_APPLICABLE }) =>
  774. isToolbarButtonEnabled(key, _toolbarButtons) || isToolbarButtonEnabled(alias, _toolbarButtons));
  775. if (isHangupVisible) {
  776. sliceIndex -= 1;
  777. }
  778. // This implies that the overflow button will be displayed, so save some space for it.
  779. if (sliceIndex < filtered.length) {
  780. sliceIndex -= 1;
  781. }
  782. return {
  783. mainMenuButtons: filtered.slice(0, sliceIndex),
  784. overflowMenuButtons: filtered.slice(sliceIndex)
  785. };
  786. }
  787. _onMouseOut: () => void;
  788. /**
  789. * Dispatches an action signaling the toolbar is not being hovered.
  790. *
  791. * @private
  792. * @returns {void}
  793. */
  794. _onMouseOut() {
  795. const { _overflowMenuVisible, dispatch } = this.props;
  796. !_overflowMenuVisible && dispatch(setToolbarHovered(false));
  797. }
  798. _onMouseOver: () => void;
  799. /**
  800. * Dispatches an action signaling the toolbar is being hovered.
  801. *
  802. * @private
  803. * @returns {void}
  804. */
  805. _onMouseOver() {
  806. this.props.dispatch(setToolbarHovered(true));
  807. }
  808. _onSetOverflowVisible: (boolean) => void;
  809. /**
  810. * Sets the visibility of the overflow menu.
  811. *
  812. * @param {boolean} visible - Whether or not the overflow menu should be
  813. * displayed.
  814. * @private
  815. * @returns {void}
  816. */
  817. _onSetOverflowVisible(visible) {
  818. this.props.dispatch(setOverflowMenuVisible(visible));
  819. this.props.dispatch(setToolbarHovered(visible));
  820. }
  821. _onShortcutToggleChat: () => void;
  822. /**
  823. * Creates an analytics keyboard shortcut event and dispatches an action for
  824. * toggling the display of chat.
  825. *
  826. * @private
  827. * @returns {void}
  828. */
  829. _onShortcutToggleChat() {
  830. sendAnalytics(createShortcutEvent(
  831. 'toggle.chat',
  832. {
  833. enable: !this.props._chatOpen
  834. }));
  835. // Checks if there was any text selected by the user.
  836. // Used for when we press simultaneously keys for copying
  837. // text messages from the chat board
  838. if (window.getSelection().toString() !== '') {
  839. return false;
  840. }
  841. this._doToggleChat();
  842. }
  843. _onShortcutToggleParticipantsPane: () => void;
  844. /**
  845. * Creates an analytics keyboard shortcut event and dispatches an action for
  846. * toggling the display of the participants pane.
  847. *
  848. * @private
  849. * @returns {void}
  850. */
  851. _onShortcutToggleParticipantsPane() {
  852. sendAnalytics(createShortcutEvent(
  853. 'toggle.participants-pane',
  854. {
  855. enable: !this.props._participantsPaneOpen
  856. }));
  857. this._onToolbarToggleParticipantsPane();
  858. }
  859. _onShortcutToggleVideoQuality: () => void;
  860. /**
  861. * Creates an analytics keyboard shortcut event and dispatches an action for
  862. * toggling the display of Video Quality.
  863. *
  864. * @private
  865. * @returns {void}
  866. */
  867. _onShortcutToggleVideoQuality() {
  868. sendAnalytics(createShortcutEvent('video.quality'));
  869. this._doToggleVideoQuality();
  870. }
  871. _onShortcutToggleTileView: () => void;
  872. /**
  873. * Dispatches an action for toggling the tile view.
  874. *
  875. * @private
  876. * @returns {void}
  877. */
  878. _onShortcutToggleTileView() {
  879. sendAnalytics(createShortcutEvent(
  880. 'toggle.tileview',
  881. {
  882. enable: !this.props._tileViewEnabled
  883. }));
  884. this._doToggleTileView();
  885. }
  886. _onShortcutToggleFullScreen: () => void;
  887. /**
  888. * Creates an analytics keyboard shortcut event and dispatches an action for
  889. * toggling full screen mode.
  890. *
  891. * @private
  892. * @returns {void}
  893. */
  894. _onShortcutToggleFullScreen() {
  895. sendAnalytics(createShortcutEvent(
  896. 'toggle.fullscreen',
  897. {
  898. enable: !this.props._fullScreen
  899. }));
  900. this._doToggleFullScreen();
  901. }
  902. _onShortcutToggleRaiseHand: () => void;
  903. /**
  904. * Creates an analytics keyboard shortcut event and dispatches an action for
  905. * toggling raise hand.
  906. *
  907. * @private
  908. * @returns {void}
  909. */
  910. _onShortcutToggleRaiseHand() {
  911. sendAnalytics(createShortcutEvent(
  912. 'toggle.raise.hand',
  913. ACTION_SHORTCUT_TRIGGERED,
  914. { enable: !this.props._raisedHand }));
  915. this._doToggleRaiseHand();
  916. }
  917. _onShortcutToggleScreenshare: () => void;
  918. /**
  919. * Creates an analytics keyboard shortcut event and dispatches an action for
  920. * toggling screensharing.
  921. *
  922. * @private
  923. * @returns {void}
  924. */
  925. _onShortcutToggleScreenshare() {
  926. // Ignore the shortcut if the button is disabled.
  927. if (this.props._desktopSharingButtonDisabled) {
  928. return;
  929. }
  930. sendAnalytics(createShortcutEvent(
  931. 'toggle.screen.sharing',
  932. ACTION_SHORTCUT_TRIGGERED,
  933. {
  934. enable: !this.props._screenSharing
  935. }));
  936. this._doToggleScreenshare();
  937. }
  938. _onTabIn: () => void;
  939. /**
  940. * Toggle the toolbar visibility when tabbing into it.
  941. *
  942. * @returns {void}
  943. */
  944. _onTabIn() {
  945. if (!this.props._visible) {
  946. this.props.dispatch(showToolbox());
  947. }
  948. }
  949. _onToolbarToggleParticipantsPane: () => void;
  950. /**
  951. * Dispatches an action for toggling the participants pane.
  952. *
  953. * @private
  954. * @returns {void}
  955. */
  956. _onToolbarToggleParticipantsPane() {
  957. const { dispatch, _participantsPaneOpen } = this.props;
  958. if (_participantsPaneOpen) {
  959. dispatch(closeParticipantsPane());
  960. } else {
  961. dispatch(openParticipantsPane());
  962. }
  963. }
  964. _onToolbarOpenVideoQuality: () => void;
  965. /**
  966. * Creates an analytics toolbar event and dispatches an action for toggling
  967. * open the video quality dialog.
  968. *
  969. * @private
  970. * @returns {void}
  971. */
  972. _onToolbarOpenVideoQuality() {
  973. sendAnalytics(createToolbarEvent('video.quality'));
  974. this._doOpenVideoQuality();
  975. }
  976. _onToolbarToggleChat: () => void;
  977. /**
  978. * Creates an analytics toolbar event and dispatches an action for toggling
  979. * the display of chat.
  980. *
  981. * @private
  982. * @returns {void}
  983. */
  984. _onToolbarToggleChat() {
  985. sendAnalytics(createToolbarEvent(
  986. 'toggle.chat',
  987. {
  988. enable: !this.props._chatOpen
  989. }));
  990. this._closeOverflowMenuIfOpen();
  991. this._doToggleChat();
  992. }
  993. _onToolbarToggleFullScreen: () => void;
  994. /**
  995. * Creates an analytics toolbar event and dispatches an action for toggling
  996. * full screen mode.
  997. *
  998. * @private
  999. * @returns {void}
  1000. */
  1001. _onToolbarToggleFullScreen() {
  1002. sendAnalytics(createToolbarEvent(
  1003. 'toggle.fullscreen',
  1004. {
  1005. enable: !this.props._fullScreen
  1006. }));
  1007. this._closeOverflowMenuIfOpen();
  1008. this._doToggleFullScreen();
  1009. }
  1010. _onToolbarToggleRaiseHand: () => void;
  1011. /**
  1012. * Creates an analytics toolbar event and dispatches an action for toggling
  1013. * raise hand.
  1014. *
  1015. * @private
  1016. * @returns {void}
  1017. */
  1018. _onToolbarToggleRaiseHand() {
  1019. sendAnalytics(createToolbarEvent(
  1020. 'raise.hand',
  1021. { enable: !this.props._raisedHand }));
  1022. this._doToggleRaiseHand();
  1023. }
  1024. _onToolbarToggleScreenshare: () => void;
  1025. /**
  1026. * Creates an analytics toolbar event and dispatches an action for toggling
  1027. * screensharing.
  1028. *
  1029. * @private
  1030. * @returns {void}
  1031. */
  1032. _onToolbarToggleScreenshare() {
  1033. sendAnalytics(createToolbarEvent(
  1034. 'toggle.screen.sharing',
  1035. ACTION_SHORTCUT_TRIGGERED,
  1036. { enable: !this.props._screenSharing }));
  1037. this._closeOverflowMenuIfOpen();
  1038. this._doToggleScreenshare();
  1039. }
  1040. /**
  1041. * Returns true if the audio sharing button should be visible and
  1042. * false otherwise.
  1043. *
  1044. * @returns {boolean}
  1045. */
  1046. _showAudioSharingButton() {
  1047. const {
  1048. _desktopSharingEnabled
  1049. } = this.props;
  1050. return _desktopSharingEnabled && isScreenAudioSupported();
  1051. }
  1052. /**
  1053. * Returns true if the desktop sharing button should be visible and
  1054. * false otherwise.
  1055. *
  1056. * @returns {boolean}
  1057. */
  1058. _showDesktopSharingButton() {
  1059. const {
  1060. _desktopSharingEnabled,
  1061. _desktopSharingDisabledTooltipKey
  1062. } = this.props;
  1063. return _desktopSharingEnabled || _desktopSharingDisabledTooltipKey;
  1064. }
  1065. /**
  1066. * Returns true if the embed meeting button is visible and false otherwise.
  1067. *
  1068. * @returns {boolean}
  1069. */
  1070. _isEmbedMeetingVisible() {
  1071. return !this.props._isVpaasMeeting
  1072. && !this.props._isMobile;
  1073. }
  1074. /**
  1075. * Returns true if the profile button is visible and false otherwise.
  1076. *
  1077. * @returns {boolean}
  1078. */
  1079. _isProfileVisible() {
  1080. return !this.props._isProfileDisabled;
  1081. }
  1082. /**
  1083. * Renders the toolbox content.
  1084. *
  1085. * @returns {ReactElement}
  1086. */
  1087. _renderToolboxContent() {
  1088. const {
  1089. _isMobile,
  1090. _overflowDrawer,
  1091. _overflowMenuVisible,
  1092. _reactionsEnabled,
  1093. _toolbarButtons,
  1094. _showDominantSpeakerBadge,
  1095. classes,
  1096. t
  1097. } = this.props;
  1098. const toolbarAccLabel = 'toolbar.accessibilityLabel.moreActionsMenu';
  1099. const containerClassName = `toolbox-content${_isMobile ? ' toolbox-content-mobile' : ''}`;
  1100. const { mainMenuButtons, overflowMenuButtons } = this._getVisibleButtons();
  1101. return (
  1102. <div className = { containerClassName }>
  1103. <div
  1104. className = 'toolbox-content-wrapper'
  1105. onFocus = { this._onTabIn }
  1106. { ...(_isMobile ? {} : {
  1107. onMouseOut: this._onMouseOut,
  1108. onMouseOver: this._onMouseOver
  1109. }) }>
  1110. { _showDominantSpeakerBadge && <DominantSpeakerName /> }
  1111. <div className = 'toolbox-content-items'>
  1112. {mainMenuButtons.map(({ Content, key, ...rest }) => Content !== Separator && (
  1113. <Content
  1114. { ...rest }
  1115. buttonKey = { key }
  1116. key = { key } />))}
  1117. {Boolean(overflowMenuButtons.length) && (
  1118. <OverflowMenuButton
  1119. ariaControls = 'overflow-menu'
  1120. isOpen = { _overflowMenuVisible }
  1121. key = 'overflow-menu'
  1122. onVisibilityChange = { this._onSetOverflowVisible }
  1123. showMobileReactions = {
  1124. _reactionsEnabled && overflowMenuButtons.find(({ key }) => key === 'raisehand')
  1125. }>
  1126. <ul
  1127. aria-label = { t(toolbarAccLabel) }
  1128. className = { clsx(classes.overflowMenu,
  1129. _overflowDrawer && classes.overflowMenuDrawer)
  1130. }
  1131. id = 'overflow-menu'
  1132. onKeyDown = { this._onEscKey }
  1133. role = 'menu'>
  1134. {overflowMenuButtons.map(({ group, key, Content, ...rest }, index, arr) => {
  1135. const showSeparator = index > 0 && arr[index - 1].group !== group;
  1136. return (key !== 'raisehand' || !_reactionsEnabled)
  1137. && <Fragment key = { `f${key}` }>
  1138. {showSeparator && <Separator key = { `hr${group}` } />}
  1139. <Content
  1140. { ...rest }
  1141. buttonKey = { key }
  1142. key = { key }
  1143. showLabel = { true } />
  1144. </Fragment>
  1145. ;
  1146. })}
  1147. </ul>
  1148. </OverflowMenuButton>
  1149. )}
  1150. <HangupButton
  1151. customClass = 'hangup-button'
  1152. key = 'hangup-button'
  1153. visible = { isToolbarButtonEnabled('hangup', _toolbarButtons) } />
  1154. </div>
  1155. </div>
  1156. </div>
  1157. );
  1158. }
  1159. }
  1160. /**
  1161. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  1162. * props.
  1163. *
  1164. * @param {Object} state - The redux store/state.
  1165. * @param {Object} ownProps - The props explicitly passed.
  1166. * @private
  1167. * @returns {{}}
  1168. */
  1169. function _mapStateToProps(state, ownProps) {
  1170. const { conference } = state['features/base/conference'];
  1171. let desktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled();
  1172. const {
  1173. buttonsWithNotifyClick,
  1174. callStatsID,
  1175. disableProfile,
  1176. enableFeaturesBasedOnToken,
  1177. hideDominantSpeakerBadge,
  1178. iAmRecorder,
  1179. iAmSipGateway
  1180. } = state['features/base/config'];
  1181. const {
  1182. fullScreen,
  1183. overflowMenuVisible,
  1184. overflowDrawer
  1185. } = state['features/toolbox'];
  1186. const localParticipant = getLocalParticipant(state);
  1187. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  1188. const { clientWidth } = state['features/base/responsive-ui'];
  1189. let desktopSharingDisabledTooltipKey;
  1190. if (enableFeaturesBasedOnToken) {
  1191. if (desktopSharingEnabled) {
  1192. // we enable desktop sharing if any participant already have this
  1193. // feature enabled and if the user supports it.
  1194. desktopSharingEnabled = haveParticipantWithScreenSharingFeature(state);
  1195. desktopSharingDisabledTooltipKey = 'dialog.shareYourScreenDisabled';
  1196. }
  1197. }
  1198. let { toolbarButtons } = ownProps;
  1199. const stateToolbarButtons = getToolbarButtons(state);
  1200. if (toolbarButtons) {
  1201. toolbarButtons = toolbarButtons.filter(name => isToolbarButtonEnabled(name, stateToolbarButtons));
  1202. } else {
  1203. toolbarButtons = stateToolbarButtons;
  1204. }
  1205. return {
  1206. _backgroundType: state['features/virtual-background'].backgroundType,
  1207. _buttonsWithNotifyClick: buttonsWithNotifyClick,
  1208. _chatOpen: state['features/chat'].isOpen,
  1209. _clientWidth: clientWidth,
  1210. _conference: conference,
  1211. _desktopSharingEnabled: desktopSharingEnabled,
  1212. _desktopSharingButtonDisabled: isDesktopShareButtonDisabled(state),
  1213. _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
  1214. _dialog: Boolean(state['features/base/dialog'].component),
  1215. _disabled: Boolean(iAmRecorder || iAmSipGateway),
  1216. _feedbackConfigured: Boolean(callStatsID),
  1217. _fullScreen: fullScreen,
  1218. _isProfileDisabled: Boolean(disableProfile),
  1219. _isIosMobile: isIosMobileBrowser(),
  1220. _isMobile: isMobileBrowser(),
  1221. _isVpaasMeeting: isVpaasMeeting(state),
  1222. _localParticipantID: localParticipant?.id,
  1223. _localVideo: localVideo,
  1224. _overflowMenuVisible: overflowMenuVisible,
  1225. _overflowDrawer: overflowDrawer,
  1226. _participantsPaneOpen: getParticipantsPaneOpen(state),
  1227. _raisedHand: hasRaisedHand(localParticipant),
  1228. _reactionsEnabled: isReactionsEnabled(state),
  1229. _screenSharing: isScreenVideoShared(state),
  1230. _showDominantSpeakerBadge: !hideDominantSpeakerBadge,
  1231. _tileViewEnabled: shouldDisplayTileView(state),
  1232. _toolbarButtons: toolbarButtons,
  1233. _virtualSource: state['features/virtual-background'].virtualSource,
  1234. _visible: isToolboxVisible(state)
  1235. };
  1236. }
  1237. export default translate(connect(_mapStateToProps)(withStyles(styles)(Toolbox)));