Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ParticipantsCount.js 2.4KB

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