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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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('dialog.remoteControlRequestMessage',
  69. { user: this.props._displayName })
  70. }
  71. {
  72. this._getAdditionalMessage()
  73. }
  74. </Dialog>
  75. );
  76. }
  77. /**
  78. * Renders additional message text for the dialog.
  79. *
  80. * @private
  81. * @returns {ReactElement}
  82. */
  83. _getAdditionalMessage() {
  84. // FIXME: Once we have this information in redux we should
  85. // start getting it from there.
  86. if (APP.conference.isSharingScreen) {
  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 = getParticipantById(
  140. state['features/base/participants'], participantId);
  141. return {
  142. _displayName: participant ? participant.name : _displayName
  143. };
  144. }
  145. export default translate(
  146. connect(_mapStateToProps)(RemoteControlAuthorizationDialog));