Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ParticipantsCount.js 2.7KB

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