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.

ParticipantsCount.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import type { Dispatch } from 'redux';
  4. import { openDialog } from '../../../base/dialog';
  5. import { getParticipantCount } from '../../../base/participants';
  6. import { connect } from '../../../base/redux';
  7. import { SpeakerStats } from '../../../speaker-stats';
  8. /**
  9. * The type of the React {@code Component} props of {@link ParticipantsCount}.
  10. */
  11. type Props = {
  12. /**
  13. * Number of the conference participants.
  14. */
  15. count: string,
  16. /**
  17. * Conference data.
  18. */
  19. conference: Object,
  20. /**
  21. * Invoked to open Speaker stats.
  22. */
  23. dispatch: Dispatch<any>,
  24. };
  25. /**
  26. * ParticipantsCount react component.
  27. * Displays the number of participants and opens Speaker stats on click.
  28. *
  29. * @class ParticipantsCount
  30. */
  31. class ParticipantsCount extends PureComponent<Props> {
  32. /**
  33. * Initializes a new ParticipantsCount instance.
  34. *
  35. * @param {Object} props - The read-only properties with which the new
  36. * instance is to be initialized.
  37. */
  38. constructor(props: Props) {
  39. super(props);
  40. this._onClick = this._onClick.bind(this);
  41. }
  42. _onClick: () => void;
  43. /**
  44. * Callback invoked to display {@code SpeakerStats}.
  45. *
  46. * @private
  47. * @returns {void}
  48. */
  49. _onClick() {
  50. const { dispatch, conference } = this.props;
  51. dispatch(openDialog(SpeakerStats, { conference }));
  52. }
  53. /**
  54. * Implements React's {@link PureComponent#render()}.
  55. *
  56. * @inheritdoc
  57. * @returns {ReactElement}
  58. */
  59. render() {
  60. return (
  61. <div
  62. className = 'participants-count'
  63. onClick = { this._onClick }>
  64. <span className = 'participants-count-number'>
  65. {this.props.count}
  66. </span>
  67. <span className = 'participants-count-icon' />
  68. </div>
  69. );
  70. }
  71. }
  72. /**
  73. * Maps (parts of) the Redux state to the associated props for the
  74. * {@code ParticipantsCount} component.
  75. *
  76. * @param {Object} state - The Redux state.
  77. * @private
  78. * @returns {Props}
  79. */
  80. function mapStateToProps(state) {
  81. return {
  82. conference: state['features/base/conference'].conference,
  83. count: getParticipantCount(state)
  84. };
  85. }
  86. export default connect(mapStateToProps)(ParticipantsCount);