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.

ContactListPanel.web.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* @flow */
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { getAvatarURL, getParticipants } from '../../base/participants';
  7. import ContactListItem from './ContactListItem';
  8. declare var interfaceConfig: Object;
  9. /**
  10. * React component for showing a list of current conference participants.
  11. *
  12. * @extends Component
  13. */
  14. class ContactListPanel extends Component {
  15. /**
  16. * Default values for {@code ContactListPanel} component's properties.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. /**
  22. * The participants to show in the contact list.
  23. */
  24. _participants: PropTypes.array,
  25. /**
  26. * Whether or not participant avatars should be displayed.
  27. */
  28. _showAvatars: PropTypes.bool,
  29. /**
  30. * Invoked to obtain translated strings.
  31. */
  32. t: PropTypes.func
  33. };
  34. /**
  35. * Implements React's {@link Component#render()}.
  36. *
  37. * @inheritdoc
  38. */
  39. render() {
  40. const { _participants, t } = this.props;
  41. return (
  42. <div className = 'contact-list-panel'>
  43. <div className = 'title'>
  44. { t('contactlist', { count: _participants.length }) }
  45. </div>
  46. <ul id = 'contacts'>
  47. { this._renderContacts() }
  48. </ul>
  49. </div>
  50. );
  51. }
  52. /**
  53. * Renders React Elements for displaying information about each participant
  54. * in the contact list.
  55. *
  56. * @private
  57. * @returns {ReactElement[]}
  58. */
  59. _renderContacts() {
  60. return this.props._participants.map(participant => {
  61. const { id, name } = participant;
  62. return (
  63. <ContactListItem
  64. avatarURI = { this.props._showAvatars
  65. ? getAvatarURL(participant) : null }
  66. id = { id }
  67. key = { id }
  68. name = { name } />
  69. );
  70. });
  71. }
  72. }
  73. /**
  74. * Maps (parts of) the Redux state to the associated {@code ContactListPanel}'s
  75. * props.
  76. *
  77. * @param {Object} state - The Redux state.
  78. * @private
  79. * @returns {{
  80. * _locked: boolean,
  81. * _participants: Array
  82. * }}
  83. */
  84. function _mapStateToProps(state) {
  85. return {
  86. _participants: getParticipants(state),
  87. _showAvatars: interfaceConfig.SHOW_CONTACTLIST_AVATARS
  88. };
  89. }
  90. export default translate(connect(_mapStateToProps)(ContactListPanel));