You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LobbyParticipants.tsx 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch, useSelector } from 'react-redux';
  4. import { makeStyles } from 'tss-react/mui';
  5. import Avatar from '../../../base/avatar/components/Avatar';
  6. import Icon from '../../../base/icons/components/Icon';
  7. import { IconCheck, IconCloseLarge } from '../../../base/icons/svg';
  8. import { withPixelLineHeight } from '../../../base/styles/functions.web';
  9. import { admitMultiple } from '../../../lobby/actions.web';
  10. import { getKnockingParticipants, getLobbyEnabled } from '../../../lobby/functions';
  11. import Drawer from '../../../toolbox/components/web/Drawer';
  12. import JitsiPortal from '../../../toolbox/components/web/JitsiPortal';
  13. import { showOverflowDrawer } from '../../../toolbox/functions.web';
  14. import { useLobbyActions, useParticipantDrawer } from '../../hooks';
  15. import LobbyParticipantItems from './LobbyParticipantItems';
  16. const useStyles = makeStyles()(theme => {
  17. return {
  18. drawerActions: {
  19. listStyleType: 'none',
  20. margin: 0,
  21. padding: 0
  22. },
  23. drawerItem: {
  24. alignItems: 'center',
  25. color: theme.palette.text01,
  26. display: 'flex',
  27. padding: '12px 16px',
  28. ...withPixelLineHeight(theme.typography.bodyShortRegularLarge),
  29. '&:first-child': {
  30. marginTop: '15px'
  31. },
  32. '&:hover': {
  33. cursor: 'pointer',
  34. background: theme.palette.action02
  35. }
  36. },
  37. icon: {
  38. marginRight: 16
  39. },
  40. headingContainer: {
  41. alignItems: 'center',
  42. display: 'flex',
  43. justifyContent: 'space-between'
  44. },
  45. heading: {
  46. ...withPixelLineHeight(theme.typography.bodyShortBold),
  47. color: theme.palette.text02
  48. },
  49. link: {
  50. ...withPixelLineHeight(theme.typography.labelBold),
  51. color: theme.palette.link01,
  52. cursor: 'pointer'
  53. }
  54. };
  55. });
  56. /**
  57. * Component used to display a list of participants waiting in the lobby.
  58. *
  59. * @returns {ReactNode}
  60. */
  61. export default function LobbyParticipants() {
  62. const lobbyEnabled = useSelector(getLobbyEnabled);
  63. const participants = useSelector(getKnockingParticipants);
  64. const { t } = useTranslation();
  65. const { classes } = useStyles();
  66. const dispatch = useDispatch();
  67. const admitAll = useCallback(() => {
  68. dispatch(admitMultiple(participants));
  69. }, [ dispatch, participants ]);
  70. const overflowDrawer = useSelector(showOverflowDrawer);
  71. const [ drawerParticipant, closeDrawer, openDrawerForParticipant ] = useParticipantDrawer();
  72. const [ admit, reject ] = useLobbyActions(drawerParticipant, closeDrawer);
  73. if (!lobbyEnabled || !participants.length) {
  74. return null;
  75. }
  76. return (
  77. <>
  78. <div className = { classes.headingContainer }>
  79. <div className = { classes.heading }>
  80. {t('participantsPane.headings.lobby', { count: participants.length })}
  81. </div>
  82. {
  83. participants.length > 1
  84. && <div
  85. className = { classes.link }
  86. onClick = { admitAll }>{t('participantsPane.actions.admitAll')}</div>
  87. }
  88. </div>
  89. <LobbyParticipantItems
  90. openDrawerForParticipant = { openDrawerForParticipant }
  91. overflowDrawer = { overflowDrawer }
  92. participants = { participants } />
  93. <JitsiPortal>
  94. <Drawer
  95. isOpen = { Boolean(drawerParticipant && overflowDrawer) }
  96. onClose = { closeDrawer }>
  97. <ul className = { classes.drawerActions }>
  98. <li className = { classes.drawerItem }>
  99. <Avatar
  100. className = { classes.icon }
  101. participantId = { drawerParticipant?.participantID }
  102. size = { 20 } />
  103. <span>{ drawerParticipant?.displayName }</span>
  104. </li>
  105. <li
  106. className = { classes.drawerItem }
  107. onClick = { admit }>
  108. <Icon
  109. className = { classes.icon }
  110. size = { 20 }
  111. src = { IconCheck } />
  112. <span>{ t('participantsPane.actions.admit') }</span>
  113. </li>
  114. <li
  115. className = { classes.drawerItem }
  116. onClick = { reject }>
  117. <Icon
  118. className = { classes.icon }
  119. size = { 20 }
  120. src = { IconCloseLarge } />
  121. <span>{ t('participantsPane.actions.reject')}</span>
  122. </li>
  123. </ul>
  124. </Drawer>
  125. </JitsiPortal>
  126. </>
  127. );
  128. }