2016-12-13 09:14:04 +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-13 09:14:04 +00:00
|
|
|
|
2017-03-01 02:55:12 +00:00
|
|
|
import { endRoomLockRequest } from '../actions';
|
2017-02-23 16:56:25 +00:00
|
|
|
|
2016-12-13 09:14:04 +00:00
|
|
|
/**
|
|
|
|
* Implements a React Component which prompts the user for a password to lock a
|
|
|
|
* conference/room.
|
|
|
|
*/
|
|
|
|
class RoomLockPrompt extends Component {
|
|
|
|
/**
|
|
|
|
* RoomLockPrompt 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-13 09:14:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new RoomLockPrompt 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-13 09:14:04 +00:00
|
|
|
onCancel = { this._onCancel }
|
|
|
|
onSubmit = { this._onSubmit }
|
2017-03-07 16:02:52 +00:00
|
|
|
titleKey = 'toolbar.lock' />
|
2016-12-13 09:14:04 +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-13 09:14:04 +00:00
|
|
|
*/
|
|
|
|
_onCancel() {
|
|
|
|
// An undefined password is understood to cancel the request to lock the
|
|
|
|
// conference/room.
|
2017-03-07 16:02:52 +00:00
|
|
|
return this._onSubmit(undefined);
|
2016-12-13 09:14:04 +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} False because we do not want to hide this
|
|
|
|
* dialog/prompt as the hiding will be handled inside endRoomLockRequest
|
|
|
|
* after setting the password is resolved.
|
2016-12-13 09:14:04 +00:00
|
|
|
*/
|
|
|
|
_onSubmit(value) {
|
|
|
|
this.props.dispatch(endRoomLockRequest(this.props.conference, value));
|
2017-03-07 16:02:52 +00:00
|
|
|
|
2017-04-04 18:35:44 +00:00
|
|
|
return false; // Do not hide.
|
2016-12-13 09:14:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-07 16:02:52 +00:00
|
|
|
export default connect()(RoomLockPrompt);
|