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.

ParticipantNotificationList.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import React from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { Avatar } from '../../../base/avatar';
  5. import { HIDDEN_EMAILS } from '../../../lobby/constants';
  6. import NotificationButton from './NotificationButton';
  7. type Props = {
  8. /**
  9. * Callback used when clicking the ok/approve button.
  10. */
  11. onApprove: Function,
  12. /**
  13. * Callback used when clicking the reject button.
  14. */
  15. onReject: Function,
  16. /**
  17. * Array of participants to be displayed.
  18. */
  19. participants: Array<Object>,
  20. /**
  21. * String prefix used for button `test-id`.
  22. */
  23. testIdPrefix: string
  24. }
  25. /**
  26. * Component used to display a list of notifications based on a list of participants.
  27. * This is visible only to moderators.
  28. *
  29. * @returns {React$Element<'div'> | null}
  30. */
  31. export default function({ onApprove, onReject, participants, testIdPrefix }: Props): React$Element<'ul'> {
  32. const { t } = useTranslation();
  33. return (
  34. <ul className = 'knocking-participants-container'>
  35. { participants.map(p => (
  36. <li
  37. className = 'knocking-participant'
  38. key = { p.id }>
  39. <Avatar
  40. displayName = { p.name }
  41. size = { 48 }
  42. testId = { `${testIdPrefix}.avatar` }
  43. url = { p.loadableAvatarUrl } />
  44. <div className = 'details'>
  45. <span data-testid = { `${testIdPrefix}.name` }>
  46. { p.name }
  47. </span>
  48. { p.email && !HIDDEN_EMAILS.includes(p.email) && (
  49. <span data-testid = { `${testIdPrefix}.email` }>
  50. { p.email }
  51. </span>
  52. ) }
  53. </div>
  54. <NotificationButton
  55. action = { onApprove }
  56. className = 'primary'
  57. participant = { p }
  58. testId = { `${testIdPrefix}.allow` }>
  59. { t('lobby.allow') }
  60. </NotificationButton>
  61. <NotificationButton
  62. action = { onReject }
  63. className = 'borderLess'
  64. participant = { p }
  65. testId = { `${testIdPrefix}.reject` }>
  66. { t('lobby.reject') }
  67. </NotificationButton>
  68. </li>
  69. )) }
  70. </ul>);
  71. }