Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Subject.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { getConferenceName } from '../../../base/conference/functions';
  4. import { getParticipantCount } from '../../../base/participants/functions';
  5. import { connect } from '../../../base/redux';
  6. import { isToolboxVisible } from '../../../toolbox';
  7. import ParticipantsCount from './ParticipantsCount';
  8. /**
  9. * The type of the React {@code Component} props of {@link Subject}.
  10. */
  11. type Props = {
  12. /**
  13. * Whether then participant count should be shown or not.
  14. */
  15. _showParticipantCount: boolean,
  16. /**
  17. * The subject or the of the conference.
  18. * Falls back to conference name.
  19. */
  20. _subject: string,
  21. /**
  22. * Indicates whether the component should be visible or not.
  23. */
  24. _visible: boolean
  25. };
  26. /**
  27. * Subject react component.
  28. *
  29. * @class Subject
  30. */
  31. class Subject extends Component<Props> {
  32. /**
  33. * Implements React's {@link Component#render()}.
  34. *
  35. * @inheritdoc
  36. * @returns {ReactElement}
  37. */
  38. render() {
  39. const { _showParticipantCount, _subject, _visible } = this.props;
  40. return (
  41. <div className = { `subject ${_visible ? 'visible' : ''}` }>
  42. <span className = 'subject-text'>{ _subject }</span>
  43. { _showParticipantCount && <ParticipantsCount /> }
  44. </div>
  45. );
  46. }
  47. }
  48. /**
  49. * Maps (parts of) the Redux state to the associated
  50. * {@code Subject}'s props.
  51. *
  52. * @param {Object} state - The Redux state.
  53. * @private
  54. * @returns {{
  55. * _subject: string,
  56. * _visible: boolean
  57. * }}
  58. */
  59. function _mapStateToProps(state) {
  60. const participantCount = getParticipantCount(state);
  61. return {
  62. _showParticipantCount: participantCount > 2,
  63. _subject: getConferenceName(state),
  64. _visible: isToolboxVisible(state)
  65. };
  66. }
  67. export default connect(_mapStateToProps)(Subject);