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

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