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.

RemoteVideoMenuTriggerButton.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import AKInlineDialog from '@atlaskit/inline-dialog';
  2. import React, { Component } from 'react';
  3. import {
  4. MuteButton,
  5. KickButton,
  6. RemoteControlButton,
  7. RemoteVideoMenu,
  8. VolumeSlider
  9. } from './';
  10. declare var $: Object;
  11. declare var interfaceConfig: Object;
  12. /**
  13. * React {@code Component} for displaying an icon associated with opening the
  14. * the {@code RemoteVideoMenu}.
  15. *
  16. * @extends {Component}
  17. */
  18. class RemoteVideoMenuTriggerButton extends Component {
  19. static propTypes = {
  20. /**
  21. * A value between 0 and 1 indicating the volume of the participant's
  22. * audio element.
  23. */
  24. initialVolumeValue: React.PropTypes.number,
  25. /**
  26. * Whether or not the participant is currently muted.
  27. */
  28. isAudioMuted: React.PropTypes.bool,
  29. /**
  30. * Whether or not the participant is a conference moderator.
  31. */
  32. isModerator: React.PropTypes.bool,
  33. /**
  34. * Callback to invoke when the popover has been displayed.
  35. */
  36. onMenuDisplay: React.PropTypes.func,
  37. /**
  38. * Callback to invoke choosing to start a remote control session with
  39. * the participant.
  40. */
  41. onRemoteControlToggle: React.PropTypes.func,
  42. /**
  43. * Callback to invoke when changing the level of the participant's
  44. * audio element.
  45. */
  46. onVolumeChange: React.PropTypes.func,
  47. /**
  48. * The ID for the participant on which the remote video menu will act.
  49. */
  50. participantID: React.PropTypes.string,
  51. /**
  52. * The current state of the participant's remote control session.
  53. */
  54. remoteControlState: React.PropTypes.number
  55. };
  56. /**
  57. * Initializes a new {#@code RemoteVideoMenuTriggerButton} instance.
  58. *
  59. * @param {Object} props - The read-only properties with which the new
  60. * instance is to be initialized.
  61. */
  62. constructor(props) {
  63. super(props);
  64. this.state = {
  65. showRemoteMenu: false
  66. };
  67. /**
  68. * The internal reference to topmost DOM/HTML element backing the React
  69. * {@code Component}. Accessed directly for associating an element as
  70. * the trigger for a popover.
  71. *
  72. * @private
  73. * @type {HTMLDivElement}
  74. */
  75. this._rootElement = null;
  76. // Bind event handlers so they are only bound once for every instance.
  77. this._onRemoteMenuClose = this._onRemoteMenuClose.bind(this);
  78. this._onRemoteMenuToggle = this._onRemoteMenuToggle.bind(this);
  79. }
  80. /**
  81. * Implements React's {@link Component#render()}.
  82. *
  83. * @inheritdoc
  84. * @returns {ReactElement}
  85. */
  86. render() {
  87. return (
  88. <AKInlineDialog
  89. content = { this._renderRemoteVideoMenu() }
  90. isOpen = { this.state.showRemoteMenu }
  91. onClose = { this._onRemoteMenuClose }
  92. position = { interfaceConfig.VERTICAL_FILMSTRIP
  93. ? 'left middle' : 'top center' }
  94. shouldFlip = { true }>
  95. <span
  96. className = 'popover-trigger remote-video-menu-trigger'
  97. onClick = { this._onRemoteMenuToggle }>
  98. <i
  99. className = 'icon-thumb-menu'
  100. title = 'Remote user controls' />
  101. </span>
  102. </AKInlineDialog>
  103. );
  104. }
  105. /**
  106. * Closes the {@code RemoteVideoMenu}.
  107. *
  108. * @private
  109. * @returns {void}
  110. */
  111. _onRemoteMenuClose() {
  112. this.setState({ showRemoteMenu: false });
  113. }
  114. /**
  115. * Opens or closes the {@code RemoteVideoMenu}.
  116. *
  117. * @private
  118. * @returns {void}
  119. */
  120. _onRemoteMenuToggle() {
  121. const willShowRemoteMenu = !this.state.showRemoteMenu;
  122. if (willShowRemoteMenu) {
  123. this.props.onMenuDisplay();
  124. }
  125. this.setState({ showRemoteMenu: willShowRemoteMenu });
  126. }
  127. /**
  128. * Creates a new {@code RemoteVideoMenu} with buttons for interacting with
  129. * the remote participant.
  130. *
  131. * @private
  132. * @returns {ReactElement}
  133. */
  134. _renderRemoteVideoMenu() {
  135. const {
  136. initialVolumeValue,
  137. isAudioMuted,
  138. isModerator,
  139. onRemoteControlToggle,
  140. onVolumeChange,
  141. remoteControlState,
  142. participantID
  143. } = this.props;
  144. return (
  145. <RemoteVideoMenu id = { participantID }>
  146. { isModerator
  147. ? <MuteButton
  148. isAudioMuted = { isAudioMuted }
  149. onClick = { this._onRemoteMenuClose }
  150. participantID = { participantID } />
  151. : null }
  152. { isModerator
  153. ? <KickButton
  154. onClick = { this._onRemoteMenuClose }
  155. participantID = { participantID } />
  156. : null }
  157. { remoteControlState
  158. ? <RemoteControlButton
  159. onClick = { onRemoteControlToggle }
  160. participantID = { participantID }
  161. remoteControlState = { remoteControlState } />
  162. : null }
  163. { onVolumeChange
  164. ? <VolumeSlider
  165. initialValue = { initialVolumeValue }
  166. onChange = { onVolumeChange } />
  167. : null }
  168. </RemoteVideoMenu>
  169. );
  170. }
  171. }
  172. export default RemoteVideoMenuTriggerButton;