2017-11-16 18:26:14 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
import { getParticipantById } from '../../base/participants';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2020-11-14 04:09:25 +00:00
|
|
|
import { getLocalVideoTrack } from '../../base/tracks';
|
2022-10-17 11:27:48 +00:00
|
|
|
import Dialog from '../../base/ui/components/web/Dialog';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { deny, grant } from '../actions';
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link RemoteControlAuthorizationDialog}.
|
2017-05-03 23:57:52 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The display name of the participant who is requesting authorization for
|
|
|
|
* remote desktop control session.
|
|
|
|
*/
|
|
|
|
_displayName: string,
|
|
|
|
|
2020-11-14 04:09:25 +00:00
|
|
|
_isScreenSharing: boolean,
|
|
|
|
_sourceType: string,
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Used to show/hide the dialog on cancel.
|
2017-05-03 23:57:52 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
dispatch: Function,
|
2017-05-03 23:57:52 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant who is requesting authorization for remote
|
|
|
|
* desktop control session.
|
|
|
|
*/
|
|
|
|
participantId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a dialog for remote control authorization.
|
|
|
|
*/
|
|
|
|
class RemoteControlAuthorizationDialog extends Component<Props> {
|
2017-05-03 23:57:52 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new RemoteControlAuthorizationDialog instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
constructor(props: Props) {
|
2017-05-03 23:57:52 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onCancel = this._onCancel.bind(this);
|
|
|
|
this._onSubmit = this._onSubmit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Dialog
|
2022-10-17 11:27:48 +00:00
|
|
|
ok = {{ translationKey: 'dialog.allow' }}
|
2017-05-03 23:57:52 +00:00
|
|
|
onCancel = { this._onCancel }
|
|
|
|
onSubmit = { this._onSubmit }
|
2022-10-17 11:27:48 +00:00
|
|
|
titleKey = 'dialog.remoteControlTitle'>
|
2017-05-03 23:57:52 +00:00
|
|
|
{
|
2017-06-15 00:40:51 +00:00
|
|
|
this.props.t(
|
|
|
|
'dialog.remoteControlRequestMessage',
|
|
|
|
{ user: this.props._displayName })
|
2017-05-03 23:57:52 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
this._getAdditionalMessage()
|
|
|
|
}
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders additional message text for the dialog.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_getAdditionalMessage() {
|
2020-11-14 04:09:25 +00:00
|
|
|
const { _isScreenSharing, _sourceType } = this.props;
|
|
|
|
|
|
|
|
if (_isScreenSharing && _sourceType === 'screen') {
|
2017-05-03 23:57:52 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<br />
|
|
|
|
{ this.props.t('dialog.remoteControlShareScreenWarning') }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-11-16 18:26:14 +00:00
|
|
|
_onCancel: () => boolean;
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
/**
|
|
|
|
* Notifies the remote control module about the denial of the remote control
|
|
|
|
* request.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {boolean} Returns true to close the dialog.
|
|
|
|
*/
|
|
|
|
_onCancel() {
|
2020-11-14 04:09:25 +00:00
|
|
|
const { dispatch, participantId } = this.props;
|
|
|
|
|
|
|
|
dispatch(deny(participantId));
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-16 18:26:14 +00:00
|
|
|
_onSubmit: () => boolean;
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
/**
|
|
|
|
* Notifies the remote control module that the remote control request is
|
|
|
|
* accepted.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {boolean} Returns false to prevent closure because the dialog is
|
|
|
|
* closed manually to be sure that if the desktop picker dialog can be
|
|
|
|
* displayed (if this dialog is displayed when we try to display the desktop
|
|
|
|
* picker window, the action will be ignored).
|
|
|
|
*/
|
|
|
|
_onSubmit() {
|
2020-11-14 04:09:25 +00:00
|
|
|
const { dispatch, participantId } = this.props;
|
2017-05-03 23:57:52 +00:00
|
|
|
|
2020-11-14 04:09:25 +00:00
|
|
|
dispatch(grant(participantId));
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the RemoteControlAuthorizationDialog's
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - The React Component props passed to the associated
|
|
|
|
* (instance of) RemoteControlAuthorizationDialog.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2020-11-14 04:09:25 +00:00
|
|
|
* _displayName: string,
|
|
|
|
* _isScreenSharing: boolean,
|
|
|
|
* _sourceId: string,
|
|
|
|
* _sourceType: string
|
2017-05-03 23:57:52 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state, ownProps) {
|
|
|
|
const { _displayName, participantId } = ownProps;
|
2018-05-22 22:41:53 +00:00
|
|
|
const participant = getParticipantById(state, participantId);
|
2020-11-14 04:09:25 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
const track = getLocalVideoTrack(tracks);
|
|
|
|
const _isScreenSharing = track?.videoType === 'desktop';
|
|
|
|
const { sourceType } = track?.jitsiTrack || {};
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
return {
|
2020-11-14 04:09:25 +00:00
|
|
|
_displayName: participant ? participant.name : _displayName,
|
|
|
|
_isScreenSharing,
|
|
|
|
_sourceType: sourceType
|
2017-05-03 23:57:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(
|
|
|
|
connect(_mapStateToProps)(RemoteControlAuthorizationDialog));
|