Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Toolbox.tsx 46KB

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