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.

RemoteControlAuthorizationDialog.js 4.5KB

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