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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. data-testid = { p.id }
  52. key = { p.id }>
  53. <Avatar
  54. displayName = { p.name }
  55. size = { 48 }
  56. testId = { `${testIdPrefix}.avatar` }
  57. url = { p.loadableAvatarUrl } />
  58. <div className = 'details'>
  59. <span data-testid = { `${testIdPrefix}.name` }>
  60. { p.name }
  61. </span>
  62. { p.email && !HIDDEN_EMAILS.includes(p.email) && (
  63. <span data-testid = { `${testIdPrefix}.email` }>
  64. { p.email }
  65. </span>
  66. ) }
  67. </div>
  68. { <NotificationButton
  69. action = { onApprove }
  70. className = 'primary'
  71. id = 'unmute-button'
  72. participant = { p }
  73. testId = { `${testIdPrefix}.allow` }>
  74. { approveButtonText }
  75. </NotificationButton> }
  76. { <NotificationButton
  77. action = { onReject }
  78. className = 'borderLess'
  79. id = 'dismiss-button'
  80. participant = { p }
  81. testId = { `${testIdPrefix}.reject` }>
  82. { rejectButtonText }
  83. </NotificationButton>}
  84. </li>
  85. )) }
  86. </ul>);
  87. }