| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | // @flow
import React, { Component } from 'react';
import type { Dispatch } from 'redux';
import { ConfirmDialog } from '../../base/dialog';
import { translate } from '../../base/i18n';
import { connect } from '../../base/redux';
import { cancelWaitForOwner, _openLoginDialog } from '../actions';
/**
 * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
 */
type Props = {
    /**
     * The name of the conference room (without the domain part).
     */
    _room: string,
    /**
     * Redux store dispatch function.
     */
    dispatch: Dispatch<any>,
    /**
     * Invoked to obtain translated strings.
     */
    t: Function
};
/**
 * The dialog is display in XMPP password + guest access configuration, after
 * user connects from anonymous domain and the conference does not exist yet.
 *
 * See {@link LoginDialog} description for more details.
 */
class WaitForOwnerDialog extends Component<Props> {
    /**
     * Initializes a new WaitForWonderDialog instance.
     *
     * @param {Object} props - The read-only properties with which the new
     * instance is to be initialized.
     */
    constructor(props) {
        super(props);
        // Bind event handlers so they are only bound once per instance.
        this._onCancel = this._onCancel.bind(this);
        this._onLogin = this._onLogin.bind(this);
    }
    /**
     * Implements React's {@link Component#render()}.
     *
     * @inheritdoc
     * @returns {ReactElement}
     */
    render() {
        const {
            _room: room
        } = this.props;
        return (
            <ConfirmDialog
                contentKey = {
                    {
                        key: 'dialog.WaitForHostMsgWOk',
                        params: { room }
                    }
                }
                onCancel = { this._onCancel }
                onSubmit = { this._onLogin } />
        );
    }
    _onCancel: () => void;
    /**
     * Called when the cancel button is clicked.
     *
     * @private
     * @returns {void}
     */
    _onCancel() {
        this.props.dispatch(cancelWaitForOwner());
    }
    _onLogin: () => void;
    /**
     * Called when the OK button is clicked.
     *
     * @private
     * @returns {void}
     */
    _onLogin() {
        this.props.dispatch(_openLoginDialog());
    }
}
/**
 * Maps (parts of) the Redux state to the associated props for the
 * {@code WaitForOwnerDialog} component.
 *
 * @param {Object} state - The Redux state.
 * @private
 * @returns {{
 *     _room: string
 * }}
 */
function _mapStateToProps(state) {
    const { authRequired } = state['features/base/conference'];
    return {
        _room: authRequired && authRequired.getName()
    };
}
export default translate(connect(_mapStateToProps)(WaitForOwnerDialog));
 |