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.

StatusIndicators.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { getLocalParticipant, getParticipantById, PARTICIPANT_ROLE } from '../../../base/participants';
  4. import { connect } from '../../../base/redux';
  5. import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
  6. import AudioMutedIndicator from './AudioMutedIndicator';
  7. import ModeratorIndicator from './ModeratorIndicator';
  8. import ScreenShareIndicator from './ScreenShareIndicator';
  9. import VideoMutedIndicator from './VideoMutedIndicator';
  10. declare var interfaceConfig: Object;
  11. /**
  12. * The type of the React {@code Component} props of {@link StatusIndicators}.
  13. */
  14. type Props = {
  15. /**
  16. * The current layout of the filmstrip.
  17. */
  18. _currentLayout: string,
  19. /**
  20. * Indicates if the moderator indicator should be visible or not.
  21. */
  22. _showModeratorIndicator: Boolean,
  23. /**
  24. * Indicates if the audio muted indicator should be visible or not.
  25. */
  26. showAudioMutedIndicator: Boolean,
  27. /**
  28. * Indicates if the screen share indicator should be visible or not.
  29. */
  30. showScreenShareIndicator: Boolean,
  31. /**
  32. * Indicates if the video muted indicator should be visible or not.
  33. */
  34. showVideoMutedIndicator: Boolean,
  35. /**
  36. * The ID of the participant for which the status bar is rendered.
  37. */
  38. participantID: String
  39. };
  40. /**
  41. * React {@code Component} for showing the status bar in a thumbnail.
  42. *
  43. * @extends Component
  44. */
  45. class StatusIndicators extends Component<Props> {
  46. /**
  47. * Implements React's {@link Component#render()}.
  48. *
  49. * @inheritdoc
  50. * @returns {ReactElement}
  51. */
  52. render() {
  53. const {
  54. _currentLayout,
  55. _showModeratorIndicator,
  56. showAudioMutedIndicator,
  57. showScreenShareIndicator,
  58. showVideoMutedIndicator
  59. } = this.props;
  60. let tooltipPosition;
  61. switch (_currentLayout) {
  62. case LAYOUTS.TILE_VIEW:
  63. tooltipPosition = 'right';
  64. break;
  65. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  66. tooltipPosition = 'left';
  67. break;
  68. default:
  69. tooltipPosition = 'top';
  70. }
  71. return (
  72. <div>
  73. { showAudioMutedIndicator ? <AudioMutedIndicator tooltipPosition = { tooltipPosition } /> : null }
  74. { showScreenShareIndicator ? <ScreenShareIndicator tooltipPosition = { tooltipPosition } /> : null }
  75. { showVideoMutedIndicator ? <VideoMutedIndicator tooltipPosition = { tooltipPosition } /> : null }
  76. { _showModeratorIndicator ? <ModeratorIndicator tooltipPosition = { tooltipPosition } /> : null }
  77. </div>
  78. );
  79. }
  80. }
  81. /**
  82. * Maps (parts of) the Redux state to the associated {@code StatusIndicators}'s props.
  83. *
  84. * @param {Object} state - The Redux state.
  85. * @param {Object} ownProps - The own props of the component.
  86. * @private
  87. * @returns {{
  88. * _currentLayout: string,
  89. * _showModeratorIndicator: boolean
  90. * }}
  91. */
  92. function _mapStateToProps(state, ownProps) {
  93. const { participantID } = ownProps;
  94. // Only the local participant won't have id for the time when the conference is not yet joined.
  95. const participant = participantID ? getParticipantById(state, participantID) : getLocalParticipant(state);
  96. return {
  97. _currentLayout: getCurrentLayout(state),
  98. _showModeratorIndicator:
  99. !interfaceConfig.DISABLE_FOCUS_INDICATOR && participant && participant.role === PARTICIPANT_ROLE.MODERATOR
  100. };
  101. }
  102. export default connect(_mapStateToProps)(StatusIndicators);