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.

MeetingParticipantContextMenu.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import {
  5. getLocalParticipant,
  6. getParticipantByIdOrUndefined
  7. } from '../../../base/participants';
  8. import { connect } from '../../../base/redux';
  9. import FakeParticipantContextMenu from '../../../video-menu/components/web/FakeParticipantContextMenu';
  10. import ParticipantContextMenu from '../../../video-menu/components/web/ParticipantContextMenu';
  11. type Props = {
  12. /**
  13. * Shared video local participant owner.
  14. */
  15. _localVideoOwner: boolean,
  16. /**
  17. * Participant reference.
  18. */
  19. _participant: Object,
  20. /**
  21. * Closes a drawer if open.
  22. */
  23. closeDrawer: Function,
  24. /**
  25. * The dispatch function from redux.
  26. */
  27. dispatch: Function,
  28. /**
  29. * The participant for which the drawer is open.
  30. * It contains the displayName & participantID.
  31. */
  32. drawerParticipant: Object,
  33. /**
  34. * Target elements against which positioning calculations are made.
  35. */
  36. offsetTarget?: HTMLElement,
  37. /**
  38. * Callback for the mouse entering the component.
  39. */
  40. onEnter: Function,
  41. /**
  42. * Callback for the mouse leaving the component.
  43. */
  44. onLeave: Function,
  45. /**
  46. * Callback for making a selection in the menu.
  47. */
  48. onSelect: Function,
  49. /**
  50. * The ID of the participant.
  51. */
  52. participantID: string
  53. };
  54. /**
  55. * Implements the MeetingParticipantContextMenu component.
  56. */
  57. class MeetingParticipantContextMenu extends Component<Props> {
  58. /**
  59. * Implements React's {@link Component#render()}.
  60. *
  61. * @inheritdoc
  62. * @returns {ReactElement}
  63. */
  64. render() {
  65. const {
  66. _localVideoOwner,
  67. _participant,
  68. closeDrawer,
  69. drawerParticipant,
  70. offsetTarget,
  71. onEnter,
  72. onLeave,
  73. onSelect
  74. } = this.props;
  75. if (!_participant) {
  76. return null;
  77. }
  78. const props = {
  79. closeDrawer,
  80. drawerParticipant,
  81. offsetTarget,
  82. onEnter,
  83. onLeave,
  84. onSelect,
  85. participant: _participant,
  86. thumbnailMenu: false
  87. };
  88. if (_participant?.fakeParticipant) {
  89. return (
  90. <FakeParticipantContextMenu
  91. { ...props }
  92. localVideoOwner = { _localVideoOwner } />
  93. );
  94. }
  95. return <ParticipantContextMenu { ...props } />;
  96. }
  97. }
  98. /**
  99. * Maps (parts of) the redux state to the associated props for this component.
  100. *
  101. * @param {Object} state - The Redux state.
  102. * @param {Object} ownProps - The own props of the component.
  103. * @private
  104. * @returns {Props}
  105. */
  106. function _mapStateToProps(state, ownProps): Object {
  107. const { participantID, overflowDrawer, drawerParticipant } = ownProps;
  108. const { ownerId } = state['features/shared-video'];
  109. const localParticipantId = getLocalParticipant(state).id;
  110. const participant = getParticipantByIdOrUndefined(state,
  111. overflowDrawer ? drawerParticipant?.participantID : participantID);
  112. return {
  113. _localVideoOwner: Boolean(ownerId === localParticipantId),
  114. _participant: participant
  115. };
  116. }
  117. export default translate(connect(_mapStateToProps)(MeetingParticipantContextMenu));