2021-03-24 14:09:40 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-10-17 11:27:48 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { IStore } from '../../../app/types';
|
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
import { connect } from '../../../base/redux/functions';
|
|
|
|
import Dialog from '../../../base/ui/components/web/Dialog';
|
2021-04-22 15:05:14 +00:00
|
|
|
import { cancelWaitForOwner } from '../../actions.web';
|
2021-03-24 14:09:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
interface Props extends WithTranslation {
|
2021-03-24 14:09:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Redux store dispatch method.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
dispatch: IStore['dispatch'];
|
2021-03-24 14:09:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be invoked after click.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
onAuthNow?: Function;
|
2021-03-24 14:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authentication message dialog for host confirmation.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
|
|
|
class WaitForOwnerDialog extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onCancelWaitForOwner = this._onCancelWaitForOwner.bind(this);
|
|
|
|
this._onIAmHost = this._onIAmHost.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the cancel button is clicked.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onCancelWaitForOwner() {
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
2021-08-23 16:59:17 +00:00
|
|
|
dispatch(cancelWaitForOwner());
|
2021-03-24 14:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the OK button is clicked.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onIAmHost() {
|
2021-04-22 15:05:14 +00:00
|
|
|
const { onAuthNow } = this.props;
|
2021-03-24 14:09:40 +00:00
|
|
|
|
2022-10-17 11:27:48 +00:00
|
|
|
onAuthNow?.();
|
2021-03-24 14:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
t
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
2022-10-17 11:27:48 +00:00
|
|
|
disableBackdropClose = { true }
|
|
|
|
hideCloseButton = { true }
|
|
|
|
ok = {{ translationKey: 'dialog.IamHost' }}
|
2021-03-24 14:09:40 +00:00
|
|
|
onCancel = { this._onCancelWaitForOwner }
|
|
|
|
onSubmit = { this._onIAmHost }
|
2022-10-17 11:27:48 +00:00
|
|
|
titleKey = { t('dialog.WaitingForHostTitle') }>
|
2021-03-24 14:09:40 +00:00
|
|
|
<span>
|
2022-03-02 15:28:42 +00:00
|
|
|
{ t('dialog.WaitForHostMsg') }
|
2021-03-24 14:09:40 +00:00
|
|
|
</span>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 15:28:42 +00:00
|
|
|
export default translate(connect()(WaitForOwnerDialog));
|