2021-03-24 16:09:40 +02:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-10-17 14:27:48 +03:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
2022-10-17 14:27:48 +03:00
|
|
|
|
2023-08-22 15:55:14 -05:00
|
|
|
import { IReduxState, IStore } from '../../../app/types';
|
2022-10-17 14:27:48 +03:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
|
import Dialog from '../../../base/ui/components/web/Dialog';
|
2023-07-15 17:33:26 -05:00
|
|
|
import { cancelWaitForOwner, login } from '../../actions.web';
|
2021-03-24 16:09:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
interface IProps extends WithTranslation {
|
2021-03-24 16:09:40 +02:00
|
|
|
|
2023-08-22 15:55:14 -05:00
|
|
|
/**
|
|
|
|
|
* Whether to show alternative cancel button text.
|
|
|
|
|
*/
|
|
|
|
|
_alternativeCancelText?: boolean;
|
|
|
|
|
|
2024-05-21 13:39:35 +02:00
|
|
|
/**
|
|
|
|
|
* Whether to hide the login button.
|
|
|
|
|
*/
|
|
|
|
|
_hideLoginButton?: boolean;
|
|
|
|
|
|
2021-03-24 16:09:40 +02:00
|
|
|
/**
|
|
|
|
|
* Redux store dispatch method.
|
|
|
|
|
*/
|
2022-10-17 14:27:48 +03:00
|
|
|
dispatch: IStore['dispatch'];
|
2021-03-24 16:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Authentication message dialog for host confirmation.
|
|
|
|
|
*
|
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
class WaitForOwnerDialog extends PureComponent<IProps> {
|
2021-03-24 16:09:40 +02:00
|
|
|
/**
|
|
|
|
|
* Instantiates a new component.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
|
* instance is to be initialized.
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
constructor(props: IProps) {
|
2021-03-24 16:09:40 +02:00
|
|
|
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 19:59:17 +03:00
|
|
|
dispatch(cancelWaitForOwner());
|
2021-03-24 16:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when the OK button is clicked.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_onIAmHost() {
|
2023-07-15 17:33:26 -05:00
|
|
|
this.props.dispatch(login());
|
2021-03-24 16:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
|
*
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2025-03-12 10:19:11 -05:00
|
|
|
override render() {
|
2021-03-24 16:09:40 +02:00
|
|
|
const {
|
|
|
|
|
t
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Dialog
|
2023-08-22 15:55:14 -05:00
|
|
|
cancel = {{ translationKey:
|
|
|
|
|
this.props._alternativeCancelText ? 'dialog.WaitingForHostButton' : 'dialog.Cancel' }}
|
2022-10-17 14:27:48 +03:00
|
|
|
disableBackdropClose = { true }
|
|
|
|
|
hideCloseButton = { true }
|
2024-05-21 13:39:35 +02:00
|
|
|
ok = { this.props._hideLoginButton ? { hidden: true,
|
|
|
|
|
disabled: true } : { translationKey: 'dialog.IamHost' } }
|
2021-03-24 16:09:40 +02:00
|
|
|
onCancel = { this._onCancelWaitForOwner }
|
|
|
|
|
onSubmit = { this._onIAmHost }
|
2022-10-17 14:27:48 +03:00
|
|
|
titleKey = { t('dialog.WaitingForHostTitle') }>
|
2021-03-24 16:09:40 +02:00
|
|
|
<span>
|
2024-05-21 13:39:35 +02:00
|
|
|
{ this.props._hideLoginButton ? t('dialog.WaitForHostNoAuthMsg') : t('dialog.WaitForHostMsg') }
|
2021-03-24 16:09:40 +02:00
|
|
|
</span>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 15:55:14 -05:00
|
|
|
/**
|
|
|
|
|
* Maps (parts of) the redux state to the associated
|
|
|
|
|
* {@code WaitForOwnerDialog}'s props.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {IProps}
|
|
|
|
|
*/
|
|
|
|
|
function mapStateToProps(state: IReduxState) {
|
|
|
|
|
const { membersOnly, lobbyWaitingForHost } = state['features/base/conference'];
|
2024-05-21 13:39:35 +02:00
|
|
|
const { hideLoginButton } = state['features/base/config'];
|
2023-08-22 15:55:14 -05:00
|
|
|
|
|
|
|
|
return {
|
2024-05-21 13:39:35 +02:00
|
|
|
_alternativeCancelText: membersOnly && lobbyWaitingForHost,
|
|
|
|
|
_hideLoginButton: hideLoginButton
|
2023-08-22 15:55:14 -05:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps)(WaitForOwnerDialog));
|