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.

MeetingParticipantItem.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // @flow
  2. import React from 'react';
  3. import { getParticipantByIdOrUndefined, getParticipantDisplayName } from '../../base/participants';
  4. import { connect } from '../../base/redux';
  5. import { isParticipantAudioMuted, isParticipantVideoMuted } from '../../base/tracks';
  6. import { ACTION_TRIGGER, MEDIA_STATE, type MediaState } from '../constants';
  7. import { getParticipantAudioMediaState, getQuickActionButtonType } from '../functions';
  8. import ParticipantItem from './ParticipantItem';
  9. import ParticipantQuickAction from './ParticipantQuickAction';
  10. import { ParticipantActionEllipsis } from './styled';
  11. type Props = {
  12. /**
  13. * Media state for audio.
  14. */
  15. _audioMediaState: MediaState,
  16. /**
  17. * The display name of the participant.
  18. */
  19. _displayName: string,
  20. /**
  21. * True if the participant is video muted.
  22. */
  23. _isVideoMuted: boolean,
  24. /**
  25. * True if the participant is the local participant.
  26. */
  27. _local: boolean,
  28. /**
  29. * The participant ID.
  30. *
  31. * NOTE: This ID may be different from participantID prop in the case when we pass undefined for the local
  32. * participant. In this case the local participant ID will be filled trough _participantID prop.
  33. */
  34. _participantID: string,
  35. /**
  36. * The type of button to be rendered for the quick action.
  37. */
  38. _quickActionButtonType: string,
  39. /**
  40. * True if the participant have raised hand.
  41. */
  42. _raisedHand: boolean,
  43. /**
  44. * The translated ask unmute text for the qiuck action buttons.
  45. */
  46. askUnmuteText: string,
  47. /**
  48. * Is this item highlighted
  49. */
  50. isHighlighted: boolean,
  51. /**
  52. * Callback used to open a confirmation dialog for audio muting.
  53. */
  54. muteAudio: Function,
  55. /**
  56. * The translated text for the mute participant button.
  57. */
  58. muteParticipantButtonText: string,
  59. /**
  60. * Callback for the activation of this item's context menu
  61. */
  62. onContextMenu: Function,
  63. /**
  64. * Callback for the mouse leaving this item
  65. */
  66. onLeave: Function,
  67. /**
  68. * The aria-label for the ellipsis action.
  69. */
  70. participantActionEllipsisLabel: string,
  71. /**
  72. * The ID of the participant.
  73. */
  74. participantID: ?string,
  75. /**
  76. * The translated "you" text.
  77. */
  78. youText: string
  79. };
  80. /**
  81. * Implements the MeetingParticipantItem component.
  82. *
  83. * @param {Props} props - The props of the component.
  84. * @returns {ReactElement}
  85. */
  86. function MeetingParticipantItem({
  87. _audioMediaState,
  88. _displayName,
  89. _isVideoMuted,
  90. _local,
  91. _participantID,
  92. _quickActionButtonType,
  93. _raisedHand,
  94. askUnmuteText,
  95. isHighlighted,
  96. onContextMenu,
  97. onLeave,
  98. muteAudio,
  99. muteParticipantButtonText,
  100. participantActionEllipsisLabel,
  101. youText
  102. }: Props) {
  103. return (
  104. <ParticipantItem
  105. actionsTrigger = { ACTION_TRIGGER.HOVER }
  106. audioMediaState = { _audioMediaState }
  107. displayName = { _displayName }
  108. isHighlighted = { isHighlighted }
  109. local = { _local }
  110. onLeave = { onLeave }
  111. participantID = { _participantID }
  112. raisedHand = { _raisedHand }
  113. videoMuteState = { _isVideoMuted ? MEDIA_STATE.MUTED : MEDIA_STATE.UNMUTED }
  114. youText = { youText }>
  115. <ParticipantQuickAction
  116. askUnmuteText = { askUnmuteText }
  117. buttonType = { _quickActionButtonType }
  118. muteAudio = { muteAudio }
  119. muteParticipantButtonText = { muteParticipantButtonText }
  120. participantID = { _participantID } />
  121. <ParticipantActionEllipsis
  122. aria-label = { participantActionEllipsisLabel }
  123. onClick = { onContextMenu } />
  124. </ParticipantItem>
  125. );
  126. }
  127. /**
  128. * Maps (parts of) the redux state to the associated props for this component.
  129. *
  130. * @param {Object} state - The Redux state.
  131. * @param {Object} ownProps - The own props of the component.
  132. * @private
  133. * @returns {Props}
  134. */
  135. function _mapStateToProps(state, ownProps): Object {
  136. const { participantID } = ownProps;
  137. const participant = getParticipantByIdOrUndefined(state, participantID);
  138. const _isAudioMuted = isParticipantAudioMuted(participant, state);
  139. const _isVideoMuted = isParticipantVideoMuted(participant, state);
  140. const _audioMediaState = getParticipantAudioMediaState(participant, _isAudioMuted, state);
  141. const _quickActionButtonType = getQuickActionButtonType(participant, _isAudioMuted, state);
  142. return {
  143. _audioMediaState,
  144. _displayName: getParticipantDisplayName(state, participant?.id),
  145. _isAudioMuted,
  146. _isVideoMuted,
  147. _local: Boolean(participant?.local),
  148. _participantID: participant?.id,
  149. _quickActionButtonType,
  150. _raisedHand: Boolean(participant?.raisedHand)
  151. };
  152. }
  153. export default connect(_mapStateToProps)(MeetingParticipantItem);