2016-12-12 01:02:50 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2017-03-07 16:02:52 +00:00
|
|
|
import { Dialog } from '../../base/dialog';
|
2016-12-12 01:02:50 +00:00
|
|
|
|
|
|
|
import { setPassword } from '../../base/conference';
|
2017-02-23 16:56:25 +00:00
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* Implements a React Component which prompts the user when a password is
|
|
|
|
* required to join a conference.
|
|
|
|
*/
|
|
|
|
class PasswordRequiredPrompt extends Component {
|
|
|
|
/**
|
|
|
|
* PasswordRequiredPrompt component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* The JitsiConference which requires a password.
|
|
|
|
*
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
conference: React.PropTypes.object,
|
2017-03-07 16:02:52 +00:00
|
|
|
dispatch: React.PropTypes.func
|
2017-06-02 02:01:50 +00:00
|
|
|
};
|
2016-12-12 01:02:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new PasswordRequiredPrompt 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 for every instance.
|
|
|
|
this._onCancel = this._onCancel.bind(this);
|
|
|
|
this._onSubmit = this._onSubmit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
2017-03-07 16:02:52 +00:00
|
|
|
<Dialog
|
|
|
|
bodyKey = 'dialog.passwordLabel'
|
2016-12-12 01:02:50 +00:00
|
|
|
onCancel = { this._onCancel }
|
|
|
|
onSubmit = { this._onSubmit }
|
2017-03-07 16:02:52 +00:00
|
|
|
titleKey = 'dialog.passwordRequired' />
|
2016-12-12 01:02:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies this prompt that it has been dismissed by cancel.
|
|
|
|
*
|
|
|
|
* @private
|
2017-04-04 18:35:44 +00:00
|
|
|
* @returns {boolean} True to hide this dialog/prompt; otherwise, false.
|
2016-12-12 01:02:50 +00:00
|
|
|
*/
|
|
|
|
_onCancel() {
|
|
|
|
// XXX The user has canceled this prompt for a password so we are to
|
|
|
|
// attempt joining the conference without a password. If the conference
|
|
|
|
// still requires a password to join, the user will be prompted again
|
|
|
|
// later.
|
2017-03-07 16:02:52 +00:00
|
|
|
return this._onSubmit(undefined);
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies this prompt that it has been dismissed by submitting a specific
|
|
|
|
* value.
|
|
|
|
*
|
|
|
|
* @param {string} value - The submitted value.
|
|
|
|
* @private
|
2017-04-04 18:35:44 +00:00
|
|
|
* @returns {boolean} True to hide this dialog/prompt; otherwise, false.
|
2016-12-12 01:02:50 +00:00
|
|
|
*/
|
|
|
|
_onSubmit(value) {
|
|
|
|
const conference = this.props.conference;
|
|
|
|
|
|
|
|
this.props.dispatch(setPassword(conference, conference.join, value));
|
2017-03-07 16:02:52 +00:00
|
|
|
|
|
|
|
return true;
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-07 16:02:52 +00:00
|
|
|
export default connect()(PasswordRequiredPrompt);
|