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. // @flow
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { connect } from 'react-redux';
  5. import { Dialog, hideDialog } from '../../base/dialog';
  6. import { translate } from '../../base/i18n';
  7. import { getParticipantById } from '../../base/participants';
  8. declare var APP: Object;
  9. /**
  10. * Implements a dialog for remote control authorization.
  11. */
  12. class RemoteControlAuthorizationDialog extends Component<*> {
  13. /**
  14. * RemoteControlAuthorizationDialog component's property types.
  15. *
  16. * @static
  17. */
  18. static propTypes = {
  19. /**
  20. * The display name of the participant who is requesting authorization
  21. * for remote desktop control session.
  22. *
  23. * @private
  24. */
  25. _displayName: PropTypes.string,
  26. /**
  27. * Used to show/hide the dialog on cancel.
  28. */
  29. dispatch: PropTypes.func,
  30. /**
  31. * The ID of the participant who is requesting authorization for remote
  32. * desktop control session.
  33. *
  34. * @public
  35. */
  36. participantId: PropTypes.string,
  37. /**
  38. * Invoked to obtain translated strings.
  39. */
  40. t: PropTypes.func
  41. };
  42. /**
  43. * Initializes a new RemoteControlAuthorizationDialog instance.
  44. *
  45. * @param {Object} props - The read-only properties with which the new
  46. * instance is to be initialized.
  47. */
  48. constructor(props) {
  49. super(props);
  50. this._onCancel = this._onCancel.bind(this);
  51. this._onSubmit = this._onSubmit.bind(this);
  52. }
  53. /**
  54. * Implements React's {@link Component#render()}.
  55. *
  56. * @inheritdoc
  57. */
  58. render() {
  59. return (
  60. <Dialog
  61. okTitleKey = { 'dialog.allow' }
  62. onCancel = { this._onCancel }
  63. onSubmit = { this._onSubmit }
  64. titleKey = 'dialog.remoteControlTitle'
  65. width = 'small'>
  66. {
  67. this.props.t(
  68. '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. && APP.conference.getDesktopSharingSourceType() === 'screen') {
  88. return null;
  89. }
  90. return (
  91. <div>
  92. <br />
  93. { this.props.t('dialog.remoteControlShareScreenWarning') }
  94. </div>
  95. );
  96. }
  97. _onCancel: () => boolean;
  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. _onSubmit: () => boolean;
  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 = getParticipantById(state, participantId);
  143. return {
  144. _displayName: participant ? participant.name : _displayName
  145. };
  146. }
  147. export default translate(
  148. connect(_mapStateToProps)(RemoteControlAuthorizationDialog));