您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ToolboxV2.web.js 34KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import {
  5. ACTION_SHORTCUT_TRIGGERED,
  6. createShortcutEvent,
  7. createToolbarEvent,
  8. sendAnalytics
  9. } from '../../analytics';
  10. import { openDialog } from '../../base/dialog';
  11. import { translate } from '../../base/i18n';
  12. import {
  13. PARTICIPANT_ROLE,
  14. getLocalParticipant,
  15. participantUpdated
  16. } from '../../base/participants';
  17. import { getLocalVideoTrack, toggleScreensharing } from '../../base/tracks';
  18. import { ChatCounter } from '../../chat';
  19. import { openDeviceSelectionDialog } from '../../device-selection';
  20. import { toggleDocument } from '../../etherpad';
  21. import { openFeedbackDialog } from '../../feedback';
  22. import { AddPeopleDialog, InfoDialogButton } from '../../invite';
  23. import { openKeyboardShortcutsDialog } from '../../keyboard-shortcuts';
  24. import { RECORDING_TYPES, toggleRecording } from '../../recording';
  25. import { toggleSharedVideo } from '../../shared-video';
  26. import { toggleChat, toggleProfile, toggleSettings } from '../../side-panel';
  27. import { SpeakerStats } from '../../speaker-stats';
  28. import { VideoQualityDialog } from '../../video-quality';
  29. import { setFullScreen, setToolbarHovered } from '../actions';
  30. import OverflowMenuButton from './OverflowMenuButton';
  31. import OverflowMenuItem from './OverflowMenuItem';
  32. import OverflowMenuProfileItem from './OverflowMenuProfileItem';
  33. import ToolbarButtonV2 from './ToolbarButtonV2';
  34. import { AudioMuteButton, HangupButton, VideoMuteButton } from './buttons';
  35. type Props = {
  36. /**
  37. * Whether or not the feature for adding people directly into the call
  38. * is enabled.
  39. */
  40. _addPeopleAvailable: boolean,
  41. /**
  42. * Whether or not the chat feature is currently displayed.
  43. */
  44. _chatOpen: boolean,
  45. /**
  46. * The {@code JitsiConference} for the current conference.
  47. */
  48. _conference: Object,
  49. /**
  50. * Whether or not desktopsharing was explicitly configured to be disabled.
  51. */
  52. _desktopSharingDisabledByConfig: boolean,
  53. /**
  54. * Whether or not screensharing is initialized.
  55. */
  56. _desktopSharingEnabled: boolean,
  57. /**
  58. * Whether or not the feature for telephony to dial out to a number is
  59. * enabled.
  60. */
  61. _dialOutAvailable: boolean,
  62. /**
  63. * Whether or not a dialog is displayed.
  64. */
  65. _dialog: boolean,
  66. /**
  67. * Whether or not the local participant is currently editing a document.
  68. */
  69. _editingDocument: boolean,
  70. /**
  71. * Whether or not collaborative document editing is enabled.
  72. */
  73. _etherpadInitialized: boolean,
  74. /**
  75. * Whether or not call feedback can be sent.
  76. */
  77. _feedbackConfigured: boolean,
  78. /**
  79. * Whether or not the app is currently in full screen.
  80. */
  81. _fullScreen: boolean,
  82. /**
  83. * Whether or not invite should be hidden, regardless of feature
  84. * availability.
  85. */
  86. _hideInviteButton: boolean,
  87. /**
  88. * Whether or not the conference is currently being recorded by the local
  89. * participant.
  90. */
  91. _isRecording: boolean,
  92. /**
  93. * The ID of the local participant.
  94. */
  95. _localParticipantID: String,
  96. /**
  97. * Whether or not the local participant's hand is raised.
  98. */
  99. _raisedHand: boolean,
  100. /**
  101. * Whether or not the recording feature is enabled for use.
  102. */
  103. _recordingEnabled: boolean,
  104. /**
  105. * Whether the recording feature is live streaming (jibri) or is file
  106. * recording (jirecon).
  107. */
  108. _recordingType: String,
  109. /**
  110. * Whether or not the local participant is screensharing.
  111. */
  112. _screensharing: boolean,
  113. /**
  114. * Whether or not the local participant is sharing a YouTube video.
  115. */
  116. _sharingVideo: boolean,
  117. /**
  118. * Flag showing whether toolbar is visible.
  119. */
  120. _visible: boolean,
  121. /**
  122. * Invoked to active other features of the app.
  123. */
  124. dispatch: Function,
  125. /**
  126. * Invoked to obtain translated strings.
  127. */
  128. t: Function
  129. }
  130. type State = {
  131. /**
  132. * Whether or not the overflow menu is visible.
  133. */
  134. showOverflowMenu: boolean
  135. }
  136. declare var APP: Object;
  137. declare var interfaceConfig: Object;
  138. /**
  139. * Implements the conference toolbox on React/Web.
  140. *
  141. * @extends Component
  142. */
  143. class ToolboxV2 extends Component<Props, State> {
  144. _visibleButtons: Object;
  145. state = {
  146. showOverflowMenu: false
  147. }
  148. /**
  149. * Initializes a new {@code Toolbox} instance.
  150. *
  151. * @param {Props} props - The read-only React {@code Component} props with
  152. * which the new instance is to be initialized.
  153. */
  154. constructor(props: Props) {
  155. super(props);
  156. this._visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS);
  157. // Bind event handlers so they are only bound once per instance.
  158. this._onMouseOut = this._onMouseOut.bind(this);
  159. this._onMouseOver = this._onMouseOver.bind(this);
  160. this._onSetOverflowVisible = this._onSetOverflowVisible.bind(this);
  161. this._onShortcutToggleChat = this._onShortcutToggleChat.bind(this);
  162. this._onShortcutToggleFullScreen
  163. = this._onShortcutToggleFullScreen.bind(this);
  164. this._onShortcutToggleRaiseHand
  165. = this._onShortcutToggleRaiseHand.bind(this);
  166. this._onShortcutToggleScreenshare
  167. = this._onShortcutToggleScreenshare.bind(this);
  168. this._onToolbarOpenFeedback
  169. = this._onToolbarOpenFeedback.bind(this);
  170. this._onToolbarOpenInvite = this._onToolbarOpenInvite.bind(this);
  171. this._onToolbarOpenKeyboardShortcuts
  172. = this._onToolbarOpenKeyboardShortcuts.bind(this);
  173. this._onToolbarOpenSpeakerStats
  174. = this._onToolbarOpenSpeakerStats.bind(this);
  175. this._onToolbarOpenVideoQuality
  176. = this._onToolbarOpenVideoQuality.bind(this);
  177. this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
  178. this._onToolbarToggleEtherpad
  179. = this._onToolbarToggleEtherpad.bind(this);
  180. this._onToolbarToggleFullScreen
  181. = this._onToolbarToggleFullScreen.bind(this);
  182. this._onToolbarToggleProfile
  183. = this._onToolbarToggleProfile.bind(this);
  184. this._onToolbarToggleRaiseHand
  185. = this._onToolbarToggleRaiseHand.bind(this);
  186. this._onToolbarToggleRecording
  187. = this._onToolbarToggleRecording.bind(this);
  188. this._onToolbarToggleScreenshare
  189. = this._onToolbarToggleScreenshare.bind(this);
  190. this._onToolbarToggleSettings
  191. = this._onToolbarToggleSettings.bind(this);
  192. this._onToolbarToggleSharedVideo
  193. = this._onToolbarToggleSharedVideo.bind(this);
  194. }
  195. /**
  196. * Sets keyboard shortcuts for to trigger ToolbarButtons actions.
  197. *
  198. * @inheritdoc
  199. * @returns {void}
  200. */
  201. componentDidMount() {
  202. const KEYBOARD_SHORTCUTS = [
  203. this._shouldShowButton('chat') && {
  204. character: 'C',
  205. exec: this._onShortcutToggleChat,
  206. helpDescription: 'keyboardShortcuts.toggleChat'
  207. },
  208. this._shouldShowButton('desktop') && {
  209. character: 'D',
  210. exec: this._onShortcutToggleScreenshare,
  211. helpDescription: 'keyboardShortcuts.toggleScreensharing'
  212. },
  213. this._shouldShowButton('raisehand') && {
  214. character: 'R',
  215. exec: this._onShortcutToggleRaiseHand,
  216. helpDescription: 'keyboardShortcuts.raiseHand'
  217. },
  218. this._shouldShowButton('fullscreen') && {
  219. character: 'S',
  220. exec: this._onShortcutToggleFullScreen,
  221. helpDescription: 'keyboardShortcuts.fullScreen'
  222. }
  223. ];
  224. KEYBOARD_SHORTCUTS.forEach(shortcut => {
  225. if (typeof shortcut === 'object') {
  226. APP.keyboardshortcut.registerShortcut(
  227. shortcut.character,
  228. null,
  229. shortcut.exec,
  230. shortcut.helpDescription);
  231. }
  232. });
  233. }
  234. /**
  235. * Update the visibility of the {@code OverflowMenuButton}.
  236. *
  237. * @inheritdoc
  238. */
  239. componentWillReceiveProps(nextProps) {
  240. // Ensure the dialog is closed when the toolbox becomes hidden.
  241. if (this.state.showOverflowMenu && !nextProps._visible) {
  242. this._onSetOverflowVisible(false);
  243. }
  244. if (this.state.showOverflowMenu
  245. && !this.props._dialog
  246. && nextProps._dialog) {
  247. this._onSetOverflowVisible(false);
  248. this.props.dispatch(setToolbarHovered(false));
  249. }
  250. }
  251. /**
  252. * Removes keyboard shortcuts registered by this component.
  253. *
  254. * @inheritdoc
  255. * @returns {void}
  256. */
  257. componentWillUnmount() {
  258. [ 'C', 'D', 'R', 'S' ].forEach(letter =>
  259. APP.keyboardshortcut.unregisterShortcut(letter));
  260. }
  261. /**
  262. * Implements React's {@link Component#render()}.
  263. *
  264. * @inheritdoc
  265. * @returns {ReactElement}
  266. */
  267. render() {
  268. const {
  269. _chatOpen,
  270. _hideInviteButton,
  271. _raisedHand,
  272. _visible,
  273. t
  274. } = this.props;
  275. const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${
  276. this._visibleButtons.size ? '' : 'no-buttons'}`;
  277. const overflowMenuContent = this._renderOverflowMenuContent();
  278. const overflowHasItems = Boolean(overflowMenuContent.filter(
  279. child => child).length);
  280. return (
  281. <div
  282. className = { rootClassNames }
  283. id = 'new-toolbox'
  284. onMouseOut = { this._onMouseOut }
  285. onMouseOver = { this._onMouseOver }>
  286. <div className = 'button-group-left'>
  287. { this._shouldShowButton('desktop')
  288. && this._renderDesktopSharingButton() }
  289. { this._shouldShowButton('raisehand')
  290. && <ToolbarButtonV2
  291. accessibilityLabel = 'Raised hand'
  292. iconName = { _raisedHand
  293. ? 'icon-raised-hand toggled'
  294. : 'icon-raised-hand' }
  295. onClick = { this._onToolbarToggleRaiseHand }
  296. tooltip = { t('toolbar.raiseHand') } /> }
  297. { this._shouldShowButton('chat')
  298. && <div className = 'toolbar-button-with-badge'>
  299. <ToolbarButtonV2
  300. accessibilityLabel = 'Chat'
  301. iconName = { _chatOpen
  302. ? 'icon-chat toggled'
  303. : 'icon-chat' }
  304. onClick = { this._onToolbarToggleChat }
  305. tooltip = { t('toolbar.chat') } />
  306. <ChatCounter />
  307. </div> }
  308. </div>
  309. <div className = 'button-group-center'>
  310. { this._shouldShowButton('microphone')
  311. && <AudioMuteButton /> }
  312. { this._shouldShowButton('hangup')
  313. && <HangupButton /> }
  314. { this._shouldShowButton('camera')
  315. && <VideoMuteButton /> }
  316. </div>
  317. <div className = 'button-group-right'>
  318. { this._shouldShowButton('invite')
  319. && !_hideInviteButton
  320. && <ToolbarButtonV2
  321. accessibilityLabel = 'Invite'
  322. iconName = 'icon-add'
  323. onClick = { this._onToolbarOpenInvite }
  324. tooltip = { t('addPeople.title') } /> }
  325. { this._shouldShowButton('info') && <InfoDialogButton /> }
  326. { overflowHasItems
  327. && <OverflowMenuButton
  328. isOpen = { this.state.showOverflowMenu }
  329. onVisibilityChange = { this._onSetOverflowVisible }>
  330. <ul
  331. aria-label = 'Overflow menu'
  332. className = 'overflow-menu'>
  333. { overflowMenuContent }
  334. </ul>
  335. </OverflowMenuButton> }
  336. </div>
  337. </div>
  338. );
  339. }
  340. /**
  341. * Callback invoked to display {@code FeedbackDialog}.
  342. *
  343. * @private
  344. * @returns {void}
  345. */
  346. _doOpenFeedback() {
  347. const { _conference } = this.props;
  348. this.props.dispatch(openFeedbackDialog(_conference));
  349. }
  350. /**
  351. * Opens the dialog for inviting people directly into the conference.
  352. *
  353. * @private
  354. * @returns {void}
  355. */
  356. _doOpenInvite() {
  357. const { _addPeopleAvailable, _dialOutAvailable, dispatch } = this.props;
  358. if (_addPeopleAvailable || _dialOutAvailable) {
  359. dispatch(openDialog(AddPeopleDialog, {
  360. enableAddPeople: _addPeopleAvailable,
  361. enableDialOut: _dialOutAvailable
  362. }));
  363. }
  364. }
  365. /**
  366. * Dispatches an action to display {@code KeyboardShortcuts}.
  367. *
  368. * @private
  369. * @returns {void}
  370. */
  371. _doOpenKeyboardShorcuts() {
  372. this.props.dispatch(openKeyboardShortcutsDialog());
  373. }
  374. /**
  375. * Callback invoked to display {@code SpeakerStats}.
  376. *
  377. * @private
  378. * @returns {void}
  379. */
  380. _doOpenSpeakerStats() {
  381. this.props.dispatch(openDialog(SpeakerStats, {
  382. conference: this.props._conference
  383. }));
  384. }
  385. /**
  386. * Dispatches an action to toggle the video quality dialog.
  387. *
  388. * @private
  389. * @returns {void}
  390. */
  391. _doOpenVideoQuality() {
  392. this.props.dispatch(openDialog(VideoQualityDialog));
  393. }
  394. /**
  395. * Dispatches an action to toggle the display of chat.
  396. *
  397. * @private
  398. * @returns {void}
  399. */
  400. _doToggleChat() {
  401. this.props.dispatch(toggleChat());
  402. }
  403. /**
  404. * Dispatches an action to show or hide document editing.
  405. *
  406. * @private
  407. * @returns {void}
  408. */
  409. _doToggleEtherpad() {
  410. this.props.dispatch(toggleDocument());
  411. }
  412. /**
  413. * Dispatches an action to toggle screensharing.
  414. *
  415. * @private
  416. * @returns {void}
  417. */
  418. _doToggleFullScreen() {
  419. const fullScreen = !this.props._fullScreen;
  420. this.props.dispatch(setFullScreen(fullScreen));
  421. }
  422. /**
  423. * Dispatches an action to show or hide the profile edit panel.
  424. *
  425. * @private
  426. * @returns {void}
  427. */
  428. _doToggleProfile() {
  429. this.props.dispatch(toggleProfile());
  430. }
  431. /**
  432. * Dispatches an action to toggle the local participant's raised hand state.
  433. *
  434. * @private
  435. * @returns {void}
  436. */
  437. _doToggleRaiseHand() {
  438. const { _localParticipantID, _raisedHand } = this.props;
  439. this.props.dispatch(participantUpdated({
  440. id: _localParticipantID,
  441. local: true,
  442. raisedHand: !_raisedHand
  443. }));
  444. }
  445. /**
  446. * Dispatches an action to toggle recording.
  447. *
  448. * @private
  449. * @returns {void}
  450. */
  451. _doToggleRecording() {
  452. this.props.dispatch(toggleRecording());
  453. }
  454. /**
  455. * Dispatches an action to toggle screensharing.
  456. *
  457. * @private
  458. * @returns {void}
  459. */
  460. _doToggleScreenshare() {
  461. if (this.props._desktopSharingEnabled) {
  462. this.props.dispatch(toggleScreensharing());
  463. }
  464. }
  465. /**
  466. * Dispatches an action to toggle display of settings, be it the settings
  467. * panel or directly to device selection.
  468. *
  469. * @private
  470. * @returns {void}
  471. */
  472. _doToggleSettings() {
  473. if (interfaceConfig.SETTINGS_SECTIONS.length === 1
  474. && interfaceConfig.SETTINGS_SECTIONS.includes('devices')) {
  475. this.props.dispatch(openDeviceSelectionDialog());
  476. } else {
  477. this.props.dispatch(toggleSettings());
  478. }
  479. }
  480. /**
  481. * Dispatches an action to toggle YouTube video sharing.
  482. *
  483. * @private
  484. * @returns {void}
  485. */
  486. _doToggleSharedVideo() {
  487. this.props.dispatch(toggleSharedVideo());
  488. }
  489. _onMouseOut: () => void;
  490. /**
  491. * Dispatches an action signaling the toolbar is not being hovered.
  492. *
  493. * @private
  494. * @returns {void}
  495. */
  496. _onMouseOut() {
  497. this.props.dispatch(setToolbarHovered(false));
  498. }
  499. _onMouseOver: () => void;
  500. /**
  501. * Dispatches an action signaling the toolbar is being hovered.
  502. *
  503. * @private
  504. * @returns {void}
  505. */
  506. _onMouseOver() {
  507. this.props.dispatch(setToolbarHovered(true));
  508. }
  509. _onSetOverflowVisible: (boolean) => void;
  510. /**
  511. * Sets the visibility of the overflow menu.
  512. *
  513. * @param {boolean} visible - Whether or not the overflow menu should be
  514. * displayed.
  515. * @private
  516. * @returns {void}
  517. */
  518. _onSetOverflowVisible(visible) {
  519. this.setState({ showOverflowMenu: visible });
  520. }
  521. _onShortcutToggleChat: () => void;
  522. /**
  523. * Creates an analytics keyboard shortcut event and dispatches an action for
  524. * toggling the display of chat.
  525. *
  526. * @private
  527. * @returns {void}
  528. */
  529. _onShortcutToggleChat() {
  530. sendAnalytics(createShortcutEvent(
  531. 'toggle.chat',
  532. {
  533. enable: !this.props._chatOpen
  534. }));
  535. this._doToggleChat();
  536. }
  537. _onShortcutToggleFullScreen: () => void;
  538. /**
  539. * Creates an analytics keyboard shortcut event and dispatches an action for
  540. * toggling full screen mode.
  541. *
  542. * @private
  543. * @returns {void}
  544. */
  545. _onShortcutToggleFullScreen() {
  546. sendAnalytics(createShortcutEvent(
  547. 'toggle.fullscreen',
  548. {
  549. enable: !this.props._fullScreen
  550. }));
  551. this._doToggleFullScreen();
  552. }
  553. _onShortcutToggleRaiseHand: () => void;
  554. /**
  555. * Creates an analytics keyboard shortcut event and dispatches an action for
  556. * toggling raise hand.
  557. *
  558. * @private
  559. * @returns {void}
  560. */
  561. _onShortcutToggleRaiseHand() {
  562. sendAnalytics(createShortcutEvent(
  563. 'toggle.raise.hand',
  564. ACTION_SHORTCUT_TRIGGERED,
  565. { enable: !this.props._raisedHand }));
  566. this._doToggleRaiseHand();
  567. }
  568. _onShortcutToggleScreenshare: () => void;
  569. /**
  570. * Creates an analytics keyboard shortcut event and dispatches an action for
  571. * toggling screensharing.
  572. *
  573. * @private
  574. * @returns {void}
  575. */
  576. _onShortcutToggleScreenshare() {
  577. sendAnalytics(createToolbarEvent(
  578. 'screen.sharing',
  579. {
  580. enable: !this.props._screensharing
  581. }));
  582. this._doToggleScreenshare();
  583. }
  584. _onToolbarOpenFeedback: () => void;
  585. /**
  586. * Creates an analytics toolbar event and dispatches an action for toggling
  587. * display of feedback.
  588. *
  589. * @private
  590. * @returns {void}
  591. */
  592. _onToolbarOpenFeedback() {
  593. sendAnalytics(createToolbarEvent('feedback'));
  594. this._doOpenFeedback();
  595. }
  596. _onToolbarOpenInvite: () => void;
  597. /**
  598. * Creates an analytics toolbar event and dispatches an action for opening
  599. * the modal for inviting people directly into the conference.
  600. *
  601. * @private
  602. * @returns {void}
  603. */
  604. _onToolbarOpenInvite() {
  605. sendAnalytics(createToolbarEvent('invite'));
  606. this._doOpenInvite();
  607. }
  608. _onToolbarOpenKeyboardShortcuts: () => void;
  609. /**
  610. * Creates an analytics toolbar event and dispatches an action for opening
  611. * the modal for showing available keyboard shortcuts.
  612. *
  613. * @private
  614. * @returns {void}
  615. */
  616. _onToolbarOpenKeyboardShortcuts() {
  617. sendAnalytics(createToolbarEvent('shortcuts'));
  618. this._doOpenKeyboardShorcuts();
  619. }
  620. _onToolbarOpenSpeakerStats: () => void;
  621. /**
  622. * Creates an analytics toolbar event and dispatches an action for opening
  623. * the speaker stats modal.
  624. *
  625. * @private
  626. * @returns {void}
  627. */
  628. _onToolbarOpenSpeakerStats() {
  629. sendAnalytics(createToolbarEvent('speaker.stats'));
  630. this._doOpenSpeakerStats();
  631. }
  632. _onToolbarOpenVideoQuality: () => void;
  633. /**
  634. * Creates an analytics toolbar event and dispatches an action for toggling
  635. * open the video quality dialog.
  636. *
  637. * @private
  638. * @returns {void}
  639. */
  640. _onToolbarOpenVideoQuality() {
  641. sendAnalytics(createToolbarEvent('video.quality'));
  642. this._doOpenVideoQuality();
  643. }
  644. _onToolbarToggleChat: () => void;
  645. /**
  646. * Creates an analytics toolbar event and dispatches an action for toggling
  647. * the display of chat.
  648. *
  649. * @private
  650. * @returns {void}
  651. */
  652. _onToolbarToggleChat() {
  653. sendAnalytics(createToolbarEvent(
  654. 'toggle.chat',
  655. {
  656. enable: !this.props._chatOpen
  657. }));
  658. this._doToggleChat();
  659. }
  660. _onToolbarToggleEtherpad: () => void;
  661. /**
  662. * Creates an analytics toolbar event and dispatches an action for toggling
  663. * the display of document editing.
  664. *
  665. * @private
  666. * @returns {void}
  667. */
  668. _onToolbarToggleEtherpad() {
  669. sendAnalytics(createToolbarEvent(
  670. 'toggle.etherpad',
  671. {
  672. enable: !this.props._editingDocument
  673. }));
  674. this._doToggleEtherpad();
  675. }
  676. _onToolbarToggleFullScreen: () => void;
  677. /**
  678. * Creates an analytics toolbar event and dispatches an action for toggling
  679. * full screen mode.
  680. *
  681. * @private
  682. * @returns {void}
  683. */
  684. _onToolbarToggleFullScreen() {
  685. sendAnalytics(createToolbarEvent(
  686. 'toggle.fullscreen',
  687. {
  688. enable: !this.props._fullScreen
  689. }));
  690. this._doToggleFullScreen();
  691. }
  692. _onToolbarToggleOverflowMenu: () => void;
  693. /**
  694. * Callback invoked to change whether the {@code OverflowMenu} is displayed
  695. * or not.
  696. *
  697. * @private
  698. * @returns {void}
  699. */
  700. _onToolbarToggleOverflowMenu() {
  701. sendAnalytics(createToolbarEvent('overflow'));
  702. this.setState({ showOverflowMenu: !this.state.showOverflowMenu });
  703. }
  704. _onToolbarToggleProfile: () => void;
  705. /**
  706. * Creates an analytics toolbar event and dispatches an action for showing
  707. * or hiding the profile edit panel.
  708. *
  709. * @private
  710. * @returns {void}
  711. */
  712. _onToolbarToggleProfile() {
  713. sendAnalytics(createToolbarEvent('profile'));
  714. this._doToggleProfile();
  715. }
  716. _onToolbarToggleRaiseHand: () => void;
  717. /**
  718. * Creates an analytics toolbar event and dispatches an action for toggling
  719. * raise hand.
  720. *
  721. * @private
  722. * @returns {void}
  723. */
  724. _onToolbarToggleRaiseHand() {
  725. sendAnalytics(createToolbarEvent(
  726. 'raise.hand',
  727. { enable: !this.props._raisedHand }));
  728. this._doToggleRaiseHand();
  729. }
  730. _onToolbarToggleRecording: () => void;
  731. /**
  732. * Dispatches an action to toggle recording.
  733. *
  734. * @private
  735. * @returns {void}
  736. */
  737. _onToolbarToggleRecording() {
  738. // No analytics handling is added here for the click as this action will
  739. // exercise the old toolbar UI flow, which includes analytics handling.
  740. this._doToggleRecording();
  741. }
  742. _onToolbarToggleScreenshare: () => void;
  743. /**
  744. * Creates an analytics toolbar event and dispatches an action for toggling
  745. * screensharing.
  746. *
  747. * @private
  748. * @returns {void}
  749. */
  750. _onToolbarToggleScreenshare() {
  751. if (!this.props._desktopSharingEnabled) {
  752. return;
  753. }
  754. sendAnalytics(createShortcutEvent(
  755. 'toggle.screen.sharing',
  756. ACTION_SHORTCUT_TRIGGERED,
  757. { enable: !this.props._screensharing }));
  758. this._doToggleScreenshare();
  759. }
  760. _onToolbarToggleSettings: () => void;
  761. /**
  762. * Creates an analytics toolbar event and dispatches an action for toggling
  763. * settings display.
  764. *
  765. * @private
  766. * @returns {void}
  767. */
  768. _onToolbarToggleSettings() {
  769. sendAnalytics(createToolbarEvent('settings'));
  770. this._doToggleSettings();
  771. }
  772. _onToolbarToggleSharedVideo: () => void;
  773. /**
  774. * Creates an analytics toolbar event and dispatches an action for toggling
  775. * the sharing of a YouTube video.
  776. *
  777. * @private
  778. * @returns {void}
  779. */
  780. _onToolbarToggleSharedVideo() {
  781. sendAnalytics(createToolbarEvent('shared.video.toggled',
  782. {
  783. enable: !this.props._sharingVideo
  784. }));
  785. this._doToggleSharedVideo();
  786. }
  787. /**
  788. * Renders a button for toggleing screen sharing.
  789. *
  790. * @private
  791. * @returns {ReactElement|null}
  792. */
  793. _renderDesktopSharingButton() {
  794. const {
  795. _desktopSharingDisabledByConfig,
  796. _desktopSharingEnabled,
  797. _screensharing,
  798. t
  799. } = this.props;
  800. const disabledTooltipText
  801. = interfaceConfig.DESKTOP_SHARING_BUTTON_DISABLED_TOOLTIP;
  802. const showDisabledTooltip
  803. = disabledTooltipText && _desktopSharingDisabledByConfig;
  804. const visible = _desktopSharingEnabled || showDisabledTooltip;
  805. if (!visible) {
  806. return null;
  807. }
  808. const classNames = `icon-share-desktop ${
  809. _screensharing ? 'toggled' : ''} ${
  810. _desktopSharingEnabled ? '' : 'disabled'}`;
  811. const tooltip = showDisabledTooltip
  812. ? disabledTooltipText
  813. : t('toolbar.sharescreen');
  814. return (
  815. <ToolbarButtonV2
  816. accessibilityLabel = 'Screenshare'
  817. iconName = { classNames }
  818. onClick = { this._onToolbarToggleScreenshare }
  819. tooltip = { tooltip } />
  820. );
  821. }
  822. /**
  823. * Renders the list elements of the overflow menu.
  824. *
  825. * @private
  826. * @returns {Array<ReactElement>}
  827. */
  828. _renderOverflowMenuContent() {
  829. const {
  830. _editingDocument,
  831. _etherpadInitialized,
  832. _feedbackConfigured,
  833. _fullScreen,
  834. _sharingVideo,
  835. t
  836. } = this.props;
  837. return [
  838. this._shouldShowButton('profile')
  839. && <OverflowMenuProfileItem
  840. key = 'profile'
  841. onClick = { this._onToolbarToggleProfile } />,
  842. this._shouldShowButton('settings')
  843. && <OverflowMenuItem
  844. accessibilityLabel = 'Settings'
  845. icon = 'icon-settings'
  846. key = 'settings'
  847. onClick = { this._onToolbarToggleSettings }
  848. text = { t('toolbar.Settings') } />,
  849. this._shouldShowButton('sharedvideo')
  850. && <OverflowMenuItem
  851. accessibilityLabel = 'Shared video'
  852. icon = 'icon-shared-video'
  853. key = 'sharedvideo'
  854. onClick = { this._onToolbarToggleSharedVideo }
  855. text = { _sharingVideo
  856. ? t('toolbar.stopSharedVideo')
  857. : t('toolbar.sharedvideo') } />,
  858. this._shouldShowButton('etherpad')
  859. && _etherpadInitialized
  860. && <OverflowMenuItem
  861. accessibilityLabel = 'Etherpad'
  862. icon = 'icon-share-doc'
  863. key = 'etherpad'
  864. onClick = { this._onToolbarToggleEtherpad }
  865. text = { _editingDocument
  866. ? t('toolbar.documentClose')
  867. : t('toolbar.documentOpen') } />,
  868. this._shouldShowButton('fullscreen')
  869. && <OverflowMenuItem
  870. accessibilityLabel = 'Full screen'
  871. icon = { _fullScreen
  872. ? 'icon-exit-full-screen'
  873. : 'icon-full-screen' }
  874. key = 'fullscreen'
  875. onClick = { this._onToolbarToggleFullScreen }
  876. text = { _fullScreen
  877. ? t('toolbar.exitFullScreen')
  878. : t('toolbar.enterFullScreen') } />,
  879. this._renderRecordingButton(),
  880. this._shouldShowButton('videoquality')
  881. && <OverflowMenuItem
  882. accessibilityLabel = 'Call quality'
  883. icon = { 'icon-visibility' }
  884. key = 'videoquality'
  885. onClick = { this._onToolbarOpenVideoQuality }
  886. text = { t('toolbar.callQuality') } />,
  887. this._shouldShowButton('stats')
  888. && <OverflowMenuItem
  889. accessibilityLabel = 'Speaker stats'
  890. icon = 'icon-presentation'
  891. key = 'stats'
  892. onClick = { this._onToolbarOpenSpeakerStats }
  893. text = { t('toolbar.speakerStats') } />,
  894. this._shouldShowButton('feedback')
  895. && _feedbackConfigured
  896. && <OverflowMenuItem
  897. accessibilityLabel = 'Feedback'
  898. icon = 'icon-feedback'
  899. key = 'feedback'
  900. onClick = { this._onToolbarOpenFeedback }
  901. text = { t('toolbar.feedback') } />,
  902. this._shouldShowButton('shortcuts')
  903. && <OverflowMenuItem
  904. accessibilityLabel = 'Shortcuts'
  905. icon = 'icon-open_in_new'
  906. key = 'shortcuts'
  907. onClick = { this._onToolbarOpenKeyboardShortcuts }
  908. text = { t('toolbar.shortcuts') } />
  909. ];
  910. }
  911. /**
  912. * Renders an {@code OverflowMenuItem} depending on the current recording
  913. * state.
  914. *
  915. * @private
  916. * @returns {ReactElement|null}
  917. */
  918. _renderRecordingButton() {
  919. const {
  920. _isRecording,
  921. _recordingEnabled,
  922. _recordingType,
  923. t
  924. } = this.props;
  925. if (!_recordingEnabled || !this._shouldShowButton('recording')) {
  926. return null;
  927. }
  928. let translationKey;
  929. if (_recordingType === RECORDING_TYPES.JIBRI) {
  930. translationKey = _isRecording
  931. ? 'dialog.stopLiveStreaming'
  932. : 'dialog.startLiveStreaming';
  933. } else {
  934. translationKey = _isRecording
  935. ? 'dialog.stopRecording'
  936. : 'dialog.startRecording';
  937. }
  938. return (
  939. <OverflowMenuItem
  940. accessibilityLabel = 'Record'
  941. icon = 'fa fa-play-circle'
  942. key = 'recording'
  943. onClick = { this._onToolbarToggleRecording }
  944. text = { t(translationKey) } />
  945. );
  946. }
  947. _shouldShowButton: (string) => boolean;
  948. /**
  949. * Returns if a button name has been explicitly configured to be displayed.
  950. *
  951. * @param {string} buttonName - The name of the button, as expected in
  952. * {@link intefaceConfig}.
  953. * @private
  954. * @returns {boolean} True if the button should be displayed.
  955. */
  956. _shouldShowButton(buttonName) {
  957. return this._visibleButtons.has(buttonName);
  958. }
  959. }
  960. /**
  961. * Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
  962. * props.
  963. *
  964. * @param {Object} state - The redux store/state.
  965. * @private
  966. * @returns {{}}
  967. */
  968. function _mapStateToProps(state) {
  969. const {
  970. conference,
  971. desktopSharingEnabled
  972. } = state['features/base/conference'];
  973. const {
  974. callStatsID,
  975. disableDesktopSharing,
  976. enableRecording,
  977. enableUserRolesBasedOnToken,
  978. iAmRecorder
  979. } = state['features/base/config'];
  980. const { isGuest } = state['features/base/jwt'];
  981. const { isRecording, recordingType } = state['features/recording'];
  982. const sharedVideoStatus = state['features/shared-video'].status;
  983. const { current } = state['features/side-panel'];
  984. const {
  985. alwaysVisible,
  986. fullScreen,
  987. timeoutID,
  988. visible
  989. } = state['features/toolbox'];
  990. const localParticipant = getLocalParticipant(state);
  991. const localVideo = getLocalVideoTrack(state['features/base/tracks']);
  992. const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
  993. const isAddPeopleAvailable = !isGuest;
  994. const isDialOutAvailable
  995. = isModerator
  996. && conference && conference.isSIPCallingSupported()
  997. && (!enableUserRolesBasedOnToken || !isGuest);
  998. return {
  999. _addPeopleAvailable: isAddPeopleAvailable,
  1000. _chatOpen: current === 'chat_container',
  1001. _conference: conference,
  1002. _desktopSharingEnabled: desktopSharingEnabled,
  1003. _desktopSharingDisabledByConfig: disableDesktopSharing,
  1004. _dialOutAvailable: isDialOutAvailable,
  1005. _dialog: Boolean(state['features/base/dialog'].component),
  1006. _editingDocument: Boolean(state['features/etherpad'].editing),
  1007. _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
  1008. _feedbackConfigured: Boolean(callStatsID),
  1009. _hideInviteButton: iAmRecorder
  1010. || (!isAddPeopleAvailable && !isDialOutAvailable),
  1011. _isRecording: isRecording,
  1012. _fullScreen: fullScreen,
  1013. _localParticipantID: localParticipant.id,
  1014. _raisedHand: localParticipant.raisedHand,
  1015. _recordingEnabled: isModerator && enableRecording
  1016. && (conference && conference.isRecordingSupported()),
  1017. _recordingType: recordingType,
  1018. _screensharing: localVideo && localVideo.videoType === 'desktop',
  1019. _sharingVideo: sharedVideoStatus === 'playing'
  1020. || sharedVideoStatus === 'start'
  1021. || sharedVideoStatus === 'pause',
  1022. _visible: Boolean(timeoutID || visible || alwaysVisible)
  1023. };
  1024. }
  1025. export default translate(connect(_mapStateToProps)(ToolboxV2));