您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ContactListPanel.web.js 2.5KB

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