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.

NotificationWithParticipants.js 2.8KB

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