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.

Subject.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/functions.web';
  7. import ConferenceTimer from '../ConferenceTimer';
  8. import ParticipantsCount from './ParticipantsCount';
  9. /**
  10. * The type of the React {@code Component} props of {@link Subject}.
  11. */
  12. type Props = {
  13. /**
  14. * Whether the conference timer should be shown or not.
  15. */
  16. _hideConferenceTimer: Boolean,
  17. /**
  18. * Whether the participant count should be shown or not.
  19. */
  20. _showParticipantCount: boolean,
  21. /**
  22. * Whether the conference subject should be shown or not.
  23. */
  24. _showSubject: boolean,
  25. /**
  26. * The subject or the of the conference.
  27. * Falls back to conference name.
  28. */
  29. _subject: string,
  30. /**
  31. * Indicates whether the component should be visible or not.
  32. */
  33. _visible: boolean
  34. };
  35. /**
  36. * Subject react component.
  37. *
  38. * @class Subject
  39. */
  40. class Subject extends Component<Props> {
  41. /**
  42. * Implements React's {@link Component#render()}.
  43. *
  44. * @inheritdoc
  45. * @returns {ReactElement}
  46. */
  47. render() {
  48. const { _hideConferenceTimer, _showParticipantCount, _showSubject, _subject, _visible } = this.props;
  49. let className = `subject ${_visible ? 'visible' : ''}`;
  50. if (!_hideConferenceTimer || _showParticipantCount || _showSubject) {
  51. className += ' gradient';
  52. }
  53. return (
  54. <div className = { className }>
  55. { _showSubject && <span className = 'subject-text'>{ _subject }</span>}
  56. { _showParticipantCount && <ParticipantsCount /> }
  57. { !_hideConferenceTimer && <ConferenceTimer /> }
  58. </div>
  59. );
  60. }
  61. }
  62. /**
  63. * Maps (parts of) the Redux state to the associated
  64. * {@code Subject}'s props.
  65. *
  66. * @param {Object} state - The Redux state.
  67. * @private
  68. * @returns {{
  69. * _hideConferenceTimer: boolean,
  70. * _showParticipantCount: boolean,
  71. * _showSubject: boolean,
  72. * _subject: string,
  73. * _visible: boolean
  74. * }}
  75. */
  76. function _mapStateToProps(state) {
  77. const participantCount = getParticipantCount(state);
  78. const { hideConferenceTimer, hideConferenceSubject, hideParticipantsStats } = state['features/base/config'];
  79. return {
  80. _hideConferenceTimer: Boolean(hideConferenceTimer),
  81. _showParticipantCount: participantCount > 2 && !hideParticipantsStats,
  82. _showSubject: !hideConferenceSubject,
  83. _subject: getConferenceName(state),
  84. _visible: isToolboxVisible(state)
  85. };
  86. }
  87. export default connect(_mapStateToProps)(Subject);