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

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