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 5.9KB

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