Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

RemoteControlAuthorizationDialog.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { hideDialog } from '../../base/dialog/actions';
  4. import { translate } from '../../base/i18n';
  5. import { getParticipantById } from '../../base/participants';
  6. import { connect } from '../../base/redux';
  7. import { getLocalVideoTrack } from '../../base/tracks';
  8. import Dialog from '../../base/ui/components/web/Dialog';
  9. import { deny, grant } from '../actions';
  10. declare var APP: Object;
  11. /**
  12. * The type of the React {@code Component} props of
  13. * {@link RemoteControlAuthorizationDialog}.
  14. */
  15. type Props = {
  16. /**
  17. * The display name of the participant who is requesting authorization for
  18. * remote desktop control session.
  19. */
  20. _displayName: string,
  21. _isScreenSharing: boolean,
  22. _sourceType: string,
  23. /**
  24. * Used to show/hide the dialog on cancel.
  25. */
  26. dispatch: Function,
  27. /**
  28. * The ID of the participant who is requesting authorization for remote
  29. * desktop control session.
  30. */
  31. participantId: string,
  32. /**
  33. * Invoked to obtain translated strings.
  34. */
  35. t: Function
  36. };
  37. /**
  38. * Implements a dialog for remote control authorization.
  39. */
  40. class RemoteControlAuthorizationDialog extends Component<Props> {
  41. /**
  42. * Initializes a new RemoteControlAuthorizationDialog instance.
  43. *
  44. * @param {Object} props - The read-only properties with which the new
  45. * instance is to be initialized.
  46. */
  47. constructor(props: Props) {
  48. super(props);
  49. this._onCancel = this._onCancel.bind(this);
  50. this._onSubmit = this._onSubmit.bind(this);
  51. }
  52. /**
  53. * Implements React's {@link Component#render()}.
  54. *
  55. * @inheritdoc
  56. */
  57. render() {
  58. return (
  59. <Dialog
  60. ok = {{ translationKey: 'dialog.allow' }}
  61. onCancel = { this._onCancel }
  62. onSubmit = { this._onSubmit }
  63. titleKey = 'dialog.remoteControlTitle'>
  64. {
  65. this.props.t(
  66. 'dialog.remoteControlRequestMessage',
  67. { user: this.props._displayName })
  68. }
  69. {
  70. this._getAdditionalMessage()
  71. }
  72. </Dialog>
  73. );
  74. }
  75. /**
  76. * Renders additional message text for the dialog.
  77. *
  78. * @private
  79. * @returns {ReactElement}
  80. */
  81. _getAdditionalMessage() {
  82. const { _isScreenSharing, _sourceType } = this.props;
  83. if (_isScreenSharing && _sourceType === 'screen') {
  84. return null;
  85. }
  86. return (
  87. <div>
  88. <br />
  89. { this.props.t('dialog.remoteControlShareScreenWarning') }
  90. </div>
  91. );
  92. }
  93. _onCancel: () => boolean;
  94. /**
  95. * Notifies the remote control module about the denial of the remote control
  96. * request.
  97. *
  98. * @private
  99. * @returns {boolean} Returns true to close the dialog.
  100. */
  101. _onCancel() {
  102. const { dispatch, participantId } = this.props;
  103. dispatch(deny(participantId));
  104. return true;
  105. }
  106. _onSubmit: () => boolean;
  107. /**
  108. * Notifies the remote control module that the remote control request is
  109. * accepted.
  110. *
  111. * @private
  112. * @returns {boolean} Returns false to prevent closure because the dialog is
  113. * closed manually to be sure that if the desktop picker dialog can be
  114. * displayed (if this dialog is displayed when we try to display the desktop
  115. * picker window, the action will be ignored).
  116. */
  117. _onSubmit() {
  118. const { dispatch, participantId } = this.props;
  119. dispatch(hideDialog());
  120. dispatch(grant(participantId));
  121. return false;
  122. }
  123. }
  124. /**
  125. * Maps (parts of) the Redux state to the RemoteControlAuthorizationDialog's
  126. * props.
  127. *
  128. * @param {Object} state - The Redux state.
  129. * @param {Object} ownProps - The React Component props passed to the associated
  130. * (instance of) RemoteControlAuthorizationDialog.
  131. * @private
  132. * @returns {{
  133. * _displayName: string,
  134. * _isScreenSharing: boolean,
  135. * _sourceId: string,
  136. * _sourceType: string
  137. * }}
  138. */
  139. function _mapStateToProps(state, ownProps) {
  140. const { _displayName, participantId } = ownProps;
  141. const participant = getParticipantById(state, participantId);
  142. const tracks = state['features/base/tracks'];
  143. const track = getLocalVideoTrack(tracks);
  144. const _isScreenSharing = track?.videoType === 'desktop';
  145. const { sourceType } = track?.jitsiTrack || {};
  146. return {
  147. _displayName: participant ? participant.name : _displayName,
  148. _isScreenSharing,
  149. _sourceType: sourceType
  150. };
  151. }
  152. export default translate(
  153. connect(_mapStateToProps)(RemoteControlAuthorizationDialog));