Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ParticipantsPane.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. // @flow
  2. import { withStyles } from '@material-ui/core';
  3. import React, { Component } from 'react';
  4. import Button from '../../../base/components/common/Button';
  5. import participantsPaneTheme from '../../../base/components/themes/participantsPaneTheme.json';
  6. import { openDialog } from '../../../base/dialog';
  7. import { translate } from '../../../base/i18n';
  8. import { Icon, IconClose, IconHorizontalPoints } from '../../../base/icons';
  9. import { isLocalParticipantModerator } from '../../../base/participants/functions';
  10. import { BUTTON_TYPES } from '../../../base/react/constants';
  11. import { connect } from '../../../base/redux';
  12. import { isAddBreakoutRoomButtonVisible } from '../../../breakout-rooms/functions';
  13. import { MuteEveryoneDialog } from '../../../video-menu/components/';
  14. import { close } from '../../actions';
  15. import {
  16. findAncestorByClass,
  17. getParticipantsPaneOpen,
  18. isMoreActionsVisible,
  19. isMuteAllVisible
  20. } from '../../functions';
  21. import { AddBreakoutRoomButton } from '../breakout-rooms/components/web/AddBreakoutRoomButton';
  22. import { RoomList } from '../breakout-rooms/components/web/RoomList';
  23. import { FooterContextMenu } from './FooterContextMenu';
  24. import LobbyParticipants from './LobbyParticipants';
  25. import MeetingParticipants from './MeetingParticipants';
  26. /**
  27. * The type of the React {@code Component} props of {@link ParticipantsPane}.
  28. */
  29. type Props = {
  30. /**
  31. * Whether there is backend support for Breakout Rooms.
  32. */
  33. _isBreakoutRoomsSupported: Boolean,
  34. /**
  35. * Whether to display the context menu as a drawer.
  36. */
  37. _overflowDrawer: boolean,
  38. /**
  39. * Is the participants pane open.
  40. */
  41. _paneOpen: boolean,
  42. /**
  43. * Should the add breakout room button be displayed?
  44. */
  45. _showAddRoomButton: boolean,
  46. /**
  47. * Whether to show the more actions button.
  48. */
  49. _showMoreActionsButton: boolean,
  50. /**
  51. * Whether to show the mute all button.
  52. */
  53. _showMuteAllButton: boolean,
  54. /**
  55. * Whether to show the footer menu.
  56. */
  57. _showFooter: boolean,
  58. /**
  59. * The Redux dispatch function.
  60. */
  61. dispatch: Function,
  62. /**
  63. * An object containing the CSS classes.
  64. */
  65. classes: Object,
  66. /**
  67. * The i18n translate function.
  68. */
  69. t: Function
  70. };
  71. /**
  72. * The type of the React {@code Component} state of {@link ParticipantsPane}.
  73. */
  74. type State = {
  75. /**
  76. * Indicates if the footer context menu is open.
  77. */
  78. contextOpen: boolean,
  79. /**
  80. * Participants search string.
  81. */
  82. searchString: string
  83. };
  84. const styles = theme => {
  85. return {
  86. container: {
  87. boxSizing: 'border-box',
  88. flex: 1,
  89. overflowY: 'auto',
  90. position: 'relative',
  91. padding: `0 ${participantsPaneTheme.panePadding}px`,
  92. [`& > * + *:not(.${participantsPaneTheme.ignoredChildClassName})`]: {
  93. marginTop: theme.spacing(3)
  94. },
  95. '&::-webkit-scrollbar': {
  96. display: 'none'
  97. }
  98. },
  99. closeButton: {
  100. alignItems: 'center',
  101. cursor: 'pointer',
  102. display: 'flex',
  103. justifyContent: 'center'
  104. },
  105. header: {
  106. alignItems: 'center',
  107. boxSizing: 'border-box',
  108. display: 'flex',
  109. height: `${participantsPaneTheme.headerSize}px`,
  110. padding: '0 20px',
  111. justifyContent: 'flex-end'
  112. },
  113. antiCollapse: {
  114. fontSize: 0,
  115. '&:first-child': {
  116. display: 'none'
  117. },
  118. '&:first-child + *': {
  119. marginTop: 0
  120. }
  121. },
  122. footer: {
  123. display: 'flex',
  124. justifyContent: 'flex-end',
  125. padding: `${theme.spacing(4)}px ${participantsPaneTheme.panePadding}px`,
  126. '& > *:not(:last-child)': {
  127. marginRight: `${theme.spacing(3)}px`
  128. }
  129. },
  130. footerMoreContainer: {
  131. position: 'relative'
  132. }
  133. };
  134. };
  135. /**
  136. * Implements the participants list.
  137. */
  138. class ParticipantsPane extends Component<Props, State> {
  139. /**
  140. * Initializes a new {@code ParticipantsPane} instance.
  141. *
  142. * @inheritdoc
  143. */
  144. constructor(props) {
  145. super(props);
  146. this.state = {
  147. contextOpen: false,
  148. searchString: ''
  149. };
  150. // Bind event handlers so they are only bound once per instance.
  151. this._onClosePane = this._onClosePane.bind(this);
  152. this._onDrawerClose = this._onDrawerClose.bind(this);
  153. this._onKeyPress = this._onKeyPress.bind(this);
  154. this._onMuteAll = this._onMuteAll.bind(this);
  155. this._onToggleContext = this._onToggleContext.bind(this);
  156. this._onWindowClickListener = this._onWindowClickListener.bind(this);
  157. this.setSearchString = this.setSearchString.bind(this);
  158. }
  159. /**
  160. * Implements React's {@link Component#componentDidMount()}.
  161. *
  162. * @inheritdoc
  163. */
  164. componentDidMount() {
  165. window.addEventListener('click', this._onWindowClickListener);
  166. }
  167. /**
  168. * Implements React's {@link Component#componentWillUnmount()}.
  169. *
  170. * @inheritdoc
  171. */
  172. componentWillUnmount() {
  173. window.removeEventListener('click', this._onWindowClickListener);
  174. }
  175. /**
  176. * Implements React's {@link Component#render}.
  177. *
  178. * @inheritdoc
  179. */
  180. render() {
  181. const {
  182. _isBreakoutRoomsSupported,
  183. _paneOpen,
  184. _showAddRoomButton,
  185. _showFooter,
  186. _showMoreActionsButton,
  187. _showMuteAllButton,
  188. classes,
  189. t
  190. } = this.props;
  191. const { contextOpen, searchString } = this.state;
  192. // when the pane is not open optimize to not
  193. // execute the MeetingParticipantList render for large list of participants
  194. if (!_paneOpen) {
  195. return null;
  196. }
  197. return (
  198. <div className = 'participants_pane'>
  199. <div className = 'participants_pane-content'>
  200. <div className = { classes.header }>
  201. <div
  202. aria-label = { t('participantsPane.close', 'Close') }
  203. className = { classes.closeButton }
  204. onClick = { this._onClosePane }
  205. onKeyPress = { this._onKeyPress }
  206. role = 'button'
  207. tabIndex = { 0 }>
  208. <Icon
  209. size = { 24 }
  210. src = { IconClose } />
  211. </div>
  212. </div>
  213. <div className = { classes.container }>
  214. <LobbyParticipants />
  215. <br className = { classes.antiCollapse } />
  216. <MeetingParticipants
  217. searchString = { searchString }
  218. setSearchString = { this.setSearchString } />
  219. {_isBreakoutRoomsSupported && <RoomList searchString = { searchString } />}
  220. {_showAddRoomButton && <AddBreakoutRoomButton />}
  221. </div>
  222. {_showFooter && (
  223. <div className = { classes.footer }>
  224. {_showMuteAllButton && (
  225. <Button
  226. accessibilityLabel = { t('participantsPane.actions.muteAll') }
  227. label = { t('participantsPane.actions.muteAll') }
  228. onClick = { this._onMuteAll }
  229. type = { BUTTON_TYPES.SECONDARY } />
  230. )}
  231. {_showMoreActionsButton && (
  232. <div className = { classes.footerMoreContainer }>
  233. <Button
  234. accessibilityLabel = { t('participantsPane.actions.moreModerationActions') }
  235. icon = { IconHorizontalPoints }
  236. id = 'participants-pane-context-menu'
  237. onClick = { this._onToggleContext }
  238. type = { BUTTON_TYPES.SECONDARY } />
  239. <FooterContextMenu
  240. isOpen = { contextOpen }
  241. onDrawerClose = { this._onDrawerClose }
  242. onMouseLeave = { this._onToggleContext } />
  243. </div>
  244. )}
  245. </div>
  246. )}
  247. </div>
  248. </div>
  249. );
  250. }
  251. setSearchString: (string) => void;
  252. /**
  253. * Sets the search string.
  254. *
  255. * @param {string} newSearchString - The new search string.
  256. * @returns {void}
  257. */
  258. setSearchString(newSearchString) {
  259. this.setState({
  260. searchString: newSearchString
  261. });
  262. }
  263. _onClosePane: () => void;
  264. /**
  265. * Callback for closing the participant pane.
  266. *
  267. * @private
  268. * @returns {void}
  269. */
  270. _onClosePane() {
  271. this.props.dispatch(close());
  272. }
  273. _onDrawerClose: () => void;
  274. /**
  275. * Callback for closing the drawer.
  276. *
  277. * @private
  278. * @returns {void}
  279. */
  280. _onDrawerClose() {
  281. this.setState({
  282. contextOpen: false
  283. });
  284. }
  285. _onKeyPress: (Object) => void;
  286. /**
  287. * KeyPress handler for accessibility for closing the participants pane.
  288. *
  289. * @param {Object} e - The key event to handle.
  290. *
  291. * @returns {void}
  292. */
  293. _onKeyPress(e) {
  294. if (e.key === ' ' || e.key === 'Enter') {
  295. e.preventDefault();
  296. this._onClosePane();
  297. }
  298. }
  299. _onMuteAll: () => void;
  300. /**
  301. * The handler for clicking mute all button.
  302. *
  303. * @returns {void}
  304. */
  305. _onMuteAll() {
  306. this.props.dispatch(openDialog(MuteEveryoneDialog));
  307. }
  308. _onToggleContext: () => void;
  309. /**
  310. * Handler for toggling open/close of the footer context menu.
  311. *
  312. * @returns {void}
  313. */
  314. _onToggleContext() {
  315. this.setState({
  316. contextOpen: !this.state.contextOpen
  317. });
  318. }
  319. _onWindowClickListener: (event: Object) => void;
  320. /**
  321. * Window click event listener.
  322. *
  323. * @param {Event} e - The click event.
  324. * @returns {void}
  325. */
  326. _onWindowClickListener(e) {
  327. if (this.state.contextOpen && !findAncestorByClass(e.target, this.props.classes.footerMoreContainer)) {
  328. this.setState({
  329. contextOpen: false
  330. });
  331. }
  332. }
  333. }
  334. /**
  335. * Maps (parts of) the redux state to the React {@code Component} props of
  336. * {@code ParticipantsPane}.
  337. *
  338. * @param {Object} state - The redux state.
  339. * @protected
  340. * @returns {Props}
  341. */
  342. function _mapStateToProps(state: Object) {
  343. const isPaneOpen = getParticipantsPaneOpen(state);
  344. const { conference } = state['features/base/conference'];
  345. const _isBreakoutRoomsSupported = conference?.getBreakoutRooms()?.isSupported();
  346. return {
  347. _isBreakoutRoomsSupported,
  348. _paneOpen: isPaneOpen,
  349. _showAddRoomButton: isAddBreakoutRoomButtonVisible(state),
  350. _showFooter: isLocalParticipantModerator(state),
  351. _showMuteAllButton: isMuteAllVisible(state),
  352. _showMoreActionsButton: isMoreActionsVisible(state)
  353. };
  354. }
  355. export default translate(connect(_mapStateToProps)(withStyles(styles)(ParticipantsPane)));