Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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