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.

KnockingParticipantList.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // @flow
  2. import React from 'react';
  3. import { Avatar } from '../../../base/avatar';
  4. import { translate } from '../../../base/i18n';
  5. import { connect } from '../../../base/redux';
  6. import { isToolboxVisible } from '../../../toolbox/functions.web';
  7. import { HIDDEN_EMAILS } from '../../constants';
  8. import AbstractKnockingParticipantList, {
  9. mapStateToProps as abstractMapStateToProps,
  10. type Props as AbstractProps
  11. } from '../AbstractKnockingParticipantList';
  12. type Props = AbstractProps & {
  13. /**
  14. * True if the toolbox is visible, so we need to adjust the position.
  15. */
  16. _toolboxVisible: boolean,
  17. };
  18. /**
  19. * Component to render a list for the actively knocking participants.
  20. */
  21. class KnockingParticipantList extends AbstractKnockingParticipantList<Props> {
  22. /**
  23. * Implements {@code PureComponent#render}.
  24. *
  25. * @inheritdoc
  26. */
  27. render() {
  28. const { _participants, _toolboxVisible, _visible, t } = this.props;
  29. if (!_visible) {
  30. return null;
  31. }
  32. return (
  33. <div
  34. className = { _toolboxVisible ? 'toolbox-visible' : '' }
  35. id = 'knocking-participant-list'>
  36. <span className = 'title'>
  37. { t('lobby.knockingParticipantList') }
  38. </span>
  39. <ul className = 'knocking-participants-container'>
  40. { _participants.map(p => (
  41. <li
  42. className = 'knocking-participant'
  43. key = { p.id }>
  44. <Avatar
  45. displayName = { p.name }
  46. size = { 48 }
  47. testId = 'knockingParticipant.avatar'
  48. url = { p.loadableAvatarUrl } />
  49. <div className = 'details'>
  50. <span data-testid = 'knockingParticipant.name'>
  51. { p.name }
  52. </span>
  53. { p.email && !HIDDEN_EMAILS.includes(p.email) && (
  54. <span data-testid = 'knockingParticipant.email'>
  55. { p.email }
  56. </span>
  57. ) }
  58. </div>
  59. <button
  60. className = 'primary'
  61. data-testid = 'lobby.allow'
  62. onClick = { this._onRespondToParticipant(p.id, true) }
  63. type = 'button'>
  64. { t('lobby.allow') }
  65. </button>
  66. <button
  67. className = 'borderLess'
  68. data-testid = 'lobby.reject'
  69. onClick = { this._onRespondToParticipant(p.id, false) }
  70. type = 'button'>
  71. { t('lobby.reject') }
  72. </button>
  73. </li>
  74. )) }
  75. </ul>
  76. </div>
  77. );
  78. }
  79. _onRespondToParticipant: (string, boolean) => Function;
  80. }
  81. /**
  82. * Maps part of the Redux state to the props of this component.
  83. *
  84. * @param {Object} state - The Redux state.
  85. * @returns {Props}
  86. */
  87. function _mapStateToProps(state: Object): $Shape<Props> {
  88. return {
  89. ...abstractMapStateToProps(state),
  90. _toolboxVisible: isToolboxVisible(state)
  91. };
  92. }
  93. export default translate(connect(_mapStateToProps)(KnockingParticipantList));