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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. return null;
  89. }
  90. return (
  91. <div>
  92. <br />
  93. { this.props.t('dialog.remoteControlShareScreenWarning') }
  94. </div>
  95. );
  96. }
  97. /**
  98. * Notifies the remote control module about the denial of the remote control
  99. * request.
  100. *
  101. * @private
  102. * @returns {boolean} Returns true to close the dialog.
  103. */
  104. _onCancel() {
  105. // FIXME: This should be action one day.
  106. APP.remoteControl.receiver.deny(this.props.participantId);
  107. return true;
  108. }
  109. /**
  110. * Notifies the remote control module that the remote control request is
  111. * accepted.
  112. *
  113. * @private
  114. * @returns {boolean} Returns false to prevent closure because the dialog is
  115. * closed manually to be sure that if the desktop picker dialog can be
  116. * displayed (if this dialog is displayed when we try to display the desktop
  117. * picker window, the action will be ignored).
  118. */
  119. _onSubmit() {
  120. this.props.dispatch(hideDialog());
  121. // FIXME: This should be action one day.
  122. APP.remoteControl.receiver.grant(this.props.participantId);
  123. return false;
  124. }
  125. }
  126. /**
  127. * Maps (parts of) the Redux state to the RemoteControlAuthorizationDialog's
  128. * props.
  129. *
  130. * @param {Object} state - The Redux state.
  131. * @param {Object} ownProps - The React Component props passed to the associated
  132. * (instance of) RemoteControlAuthorizationDialog.
  133. * @private
  134. * @returns {{
  135. * _displayName: string
  136. * }}
  137. */
  138. function _mapStateToProps(state, ownProps) {
  139. const { _displayName, participantId } = ownProps;
  140. const participant
  141. = getParticipantById(
  142. state['features/base/participants'],
  143. participantId);
  144. return {
  145. _displayName: participant ? participant.name : _displayName
  146. };
  147. }
  148. export default translate(
  149. connect(_mapStateToProps)(RemoteControlAuthorizationDialog));