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

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