2017-04-13 00:23:43 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import { setPassword } from '../../base/conference';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
|
|
|
|
/**
|
2017-04-18 21:49:52 +00:00
|
|
|
* A React {@code Component} for removing a lock from a JitsiConference.
|
2017-04-13 00:23:43 +00:00
|
|
|
*/
|
|
|
|
class RemovePasswordForm extends Component {
|
|
|
|
/**
|
2017-04-18 21:49:52 +00:00
|
|
|
* {@code RemovePasswordForm}'s property types.
|
2017-04-13 00:23:43 +00:00
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* The JitsiConference on which remove a lock.
|
|
|
|
*
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
conference: React.PropTypes.object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to send a password removal request.
|
|
|
|
*/
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the room lock, if any, was set by the local user.
|
|
|
|
*/
|
|
|
|
lockedLocally: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current known password for the JitsiConference.
|
|
|
|
*/
|
|
|
|
password: React.PropTypes.string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: React.PropTypes.func
|
2017-06-02 02:01:50 +00:00
|
|
|
};
|
2017-04-13 00:23:43 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-18 21:49:52 +00:00
|
|
|
* Initializes a new {@code RemovePasswordForm} instance.
|
2017-04-13 00:23:43 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2017-04-18 21:49:52 +00:00
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
2017-04-13 00:23:43 +00:00
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className = 'remove-password'>
|
|
|
|
<div className = 'remove-password-description'>
|
|
|
|
{ this._getPasswordPreviewText() }
|
|
|
|
</div>
|
|
|
|
<a
|
|
|
|
className = 'remove-password-link'
|
|
|
|
id = 'inviteDialogRemovePassword'
|
|
|
|
onClick = { this._onClick }>
|
|
|
|
{ this.props.t('dialog.removePassword') }
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a ReactElement for displaying the current password.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_getPasswordPreviewText() {
|
2017-04-18 21:49:52 +00:00
|
|
|
const { lockedLocally, password, t } = this.props;
|
|
|
|
|
2017-04-13 00:23:43 +00:00
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<span>
|
2017-04-18 21:49:52 +00:00
|
|
|
{ `${t('dialog.currentPassword')} ` }
|
2017-04-13 00:23:43 +00:00
|
|
|
</span>
|
|
|
|
<span className = 'remove-password-current'>
|
2017-04-18 21:49:52 +00:00
|
|
|
{ lockedLocally ? password : t('passwordSetRemotely') }
|
2017-04-13 00:23:43 +00:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches a request to remove any set password on the JitsiConference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
2017-04-18 21:49:52 +00:00
|
|
|
const { conference } = this.props;
|
2017-04-13 00:23:43 +00:00
|
|
|
|
|
|
|
this.props.dispatch(setPassword(
|
|
|
|
conference,
|
|
|
|
conference.lock,
|
|
|
|
''
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect()(RemovePasswordForm));
|