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

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