Reformatted user_settings_security.jsx to meet style guide requirements.
Этот коммит содержится в:
@@ -3,13 +3,23 @@
|
|||||||
|
|
||||||
var SettingItemMin = require('./setting_item_min.jsx');
|
var SettingItemMin = require('./setting_item_min.jsx');
|
||||||
var SettingItemMax = require('./setting_item_max.jsx');
|
var SettingItemMax = require('./setting_item_max.jsx');
|
||||||
var client = require('../utils/client.jsx');
|
var Client = require('../utils/client.jsx');
|
||||||
var AsyncClient = require('../utils/async_client.jsx');
|
var AsyncClient = require('../utils/async_client.jsx');
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
export default class SecurityTab extends React.Component {
|
||||||
displayName: 'SecurityTab',
|
constructor(props) {
|
||||||
submitPassword: function(e) {
|
super(props);
|
||||||
|
|
||||||
|
this.submitPassword = this.submitPassword.bind(this);
|
||||||
|
this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
|
||||||
|
this.updateNewPassword = this.updateNewPassword.bind(this);
|
||||||
|
this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
|
||||||
|
this.handleClose = this.handleClose.bind(this);
|
||||||
|
|
||||||
|
this.state = {currentPassword: '', newPassword: '', confirmPassword: ''};
|
||||||
|
}
|
||||||
|
submitPassword(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var user = this.props.user;
|
var user = this.props.user;
|
||||||
@@ -37,13 +47,13 @@ module.exports = React.createClass({
|
|||||||
data.current_password = currentPassword;
|
data.current_password = currentPassword;
|
||||||
data.new_password = newPassword;
|
data.new_password = newPassword;
|
||||||
|
|
||||||
client.updatePassword(data,
|
Client.updatePassword(data,
|
||||||
function() {
|
function success() {
|
||||||
this.props.updateSection('');
|
this.props.updateSection('');
|
||||||
AsyncClient.getMe();
|
AsyncClient.getMe();
|
||||||
this.setState({currentPassword: '', newPassword: '', confirmPassword: ''});
|
this.setState({currentPassword: '', newPassword: '', confirmPassword: ''});
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function(err) {
|
function fail(err) {
|
||||||
var state = this.getInitialState();
|
var state = this.getInitialState();
|
||||||
if (err.message) {
|
if (err.message) {
|
||||||
state.serverError = err.message;
|
state.serverError = err.message;
|
||||||
@@ -54,43 +64,46 @@ module.exports = React.createClass({
|
|||||||
this.setState(state);
|
this.setState(state);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
updateCurrentPassword: function(e) {
|
updateCurrentPassword(e) {
|
||||||
this.setState({currentPassword: e.target.value});
|
this.setState({currentPassword: e.target.value});
|
||||||
},
|
}
|
||||||
updateNewPassword: function(e) {
|
updateNewPassword(e) {
|
||||||
this.setState({newPassword: e.target.value});
|
this.setState({newPassword: e.target.value});
|
||||||
},
|
}
|
||||||
updateConfirmPassword: function(e) {
|
updateConfirmPassword(e) {
|
||||||
this.setState({confirmPassword: e.target.value});
|
this.setState({confirmPassword: e.target.value});
|
||||||
},
|
}
|
||||||
handleHistoryOpen: function() {
|
handleHistoryOpen() {
|
||||||
$("#user_settings").modal('hide');
|
$('#user_settings').modal('hide');
|
||||||
},
|
}
|
||||||
handleDevicesOpen: function() {
|
handleDevicesOpen() {
|
||||||
$("#user_settings").modal('hide');
|
$('#user_settings').modal('hide');
|
||||||
},
|
}
|
||||||
handleClose: function() {
|
handleClose() {
|
||||||
$(this.getDOMNode()).find('.form-control').each(function() {
|
$(React.findDOMNode(this)).find('.form-control').each(function resetValue() {
|
||||||
this.value = '';
|
this.value = '';
|
||||||
});
|
});
|
||||||
this.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
|
this.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
|
||||||
|
|
||||||
this.props.updateTab('general');
|
this.props.updateTab('general');
|
||||||
},
|
}
|
||||||
componentDidMount: function() {
|
componentDidMount() {
|
||||||
$('#user_settings').on('hidden.bs.modal', this.handleClose);
|
$('#user_settings').on('hidden.bs.modal', this.handleClose);
|
||||||
},
|
}
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount() {
|
||||||
$('#user_settings').off('hidden.bs.modal', this.handleClose);
|
$('#user_settings').off('hidden.bs.modal', this.handleClose);
|
||||||
this.props.updateSection('');
|
this.props.updateSection('');
|
||||||
},
|
}
|
||||||
getInitialState: function() {
|
render() {
|
||||||
return {currentPassword: '', newPassword: '', confirmPassword: ''};
|
var serverError;
|
||||||
},
|
if (this.state.serverError) {
|
||||||
render: function() {
|
serverError = this.state.serverError;
|
||||||
var serverError = this.state.serverError ? this.state.serverError : null;
|
}
|
||||||
var passwordError = this.state.passwordError ? this.state.passwordError : null;
|
var passwordError;
|
||||||
|
if (this.state.passwordError) {
|
||||||
|
passwordError = this.state.passwordError;
|
||||||
|
}
|
||||||
|
|
||||||
var updateSectionStatus;
|
var updateSectionStatus;
|
||||||
var passwordSection;
|
var passwordSection;
|
||||||
@@ -104,7 +117,12 @@ module.exports = React.createClass({
|
|||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
<label className='col-sm-5 control-label'>Current Password</label>
|
<label className='col-sm-5 control-label'>Current Password</label>
|
||||||
<div className='col-sm-7'>
|
<div className='col-sm-7'>
|
||||||
<input className='form-control' type='password' onChange={this.updateCurrentPassword} value={this.state.currentPassword}/>
|
<input
|
||||||
|
className='form-control'
|
||||||
|
type='password'
|
||||||
|
onChange={this.updateCurrentPassword}
|
||||||
|
value={this.state.currentPassword}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -112,7 +130,12 @@ module.exports = React.createClass({
|
|||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
<label className='col-sm-5 control-label'>New Password</label>
|
<label className='col-sm-5 control-label'>New Password</label>
|
||||||
<div className='col-sm-7'>
|
<div className='col-sm-7'>
|
||||||
<input className='form-control' type='password' onChange={this.updateNewPassword} value={this.state.newPassword}/>
|
<input
|
||||||
|
className='form-control'
|
||||||
|
type='password'
|
||||||
|
onChange={this.updateNewPassword}
|
||||||
|
value={this.state.newPassword}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -120,7 +143,12 @@ module.exports = React.createClass({
|
|||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
<label className='col-sm-5 control-label'>Retype New Password</label>
|
<label className='col-sm-5 control-label'>Retype New Password</label>
|
||||||
<div className='col-sm-7'>
|
<div className='col-sm-7'>
|
||||||
<input className='form-control' type='password' onChange={this.updateConfirmPassword} value={this.state.confirmPassword}/>
|
<input
|
||||||
|
className='form-control'
|
||||||
|
type='password'
|
||||||
|
onChange={this.updateConfirmPassword}
|
||||||
|
value={this.state.confirmPassword}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -134,7 +162,7 @@ module.exports = React.createClass({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSectionStatus = function(e) {
|
updateSectionStatus = function resetSection(e) {
|
||||||
self.props.updateSection('');
|
self.props.updateSection('');
|
||||||
self.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
|
self.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -154,15 +182,25 @@ module.exports = React.createClass({
|
|||||||
var describe;
|
var describe;
|
||||||
if (this.props.user.auth_service === '') {
|
if (this.props.user.auth_service === '') {
|
||||||
var d = new Date(this.props.user.last_password_update);
|
var d = new Date(this.props.user.last_password_update);
|
||||||
var hour = d.getHours() % 12 ? String(d.getHours() % 12) : '12';
|
var hour = '12';
|
||||||
var min = d.getMinutes() < 10 ? '0' + d.getMinutes() : String(d.getMinutes());
|
if (d.getHours() % 12) {
|
||||||
var timeOfDay = d.getHours() >= 12 ? ' pm' : ' am';
|
hour = String(d.getHours() % 12);
|
||||||
|
}
|
||||||
|
var min = String(d.getMinutes());
|
||||||
|
if (d.getMinutes() < 10) {
|
||||||
|
min = '0' + d.getMinutes();
|
||||||
|
}
|
||||||
|
var timeOfDay = ' am';
|
||||||
|
if (d.getHours() >= 12) {
|
||||||
|
timeOfDay = ' pm';
|
||||||
|
}
|
||||||
|
|
||||||
describe = 'Last updated ' + Constants.MONTHS[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear() + ' at ' + hour + ':' + min + timeOfDay;
|
describe = 'Last updated ' + Constants.MONTHS[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear() + ' at ' + hour + ':' + min + timeOfDay;
|
||||||
} else {
|
} else {
|
||||||
describe = 'Log in done through GitLab';
|
describe = 'Log in done through GitLab';
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSectionStatus = function() {
|
updateSectionStatus = function updateSection() {
|
||||||
self.props.updateSection('password');
|
self.props.updateSection('password');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -178,8 +216,20 @@ module.exports = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className='modal-header'>
|
<div className='modal-header'>
|
||||||
<button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
|
<button
|
||||||
<h4 className='modal-title' ref='title'><i className='modal-back'></i>Security Settings</h4>
|
type='button'
|
||||||
|
className='close'
|
||||||
|
data-dismiss='modal'
|
||||||
|
aria-label='Close'
|
||||||
|
>
|
||||||
|
<span aria-hidden='true'>×</span>
|
||||||
|
</button>
|
||||||
|
<h4
|
||||||
|
className='modal-title'
|
||||||
|
ref='title'
|
||||||
|
>
|
||||||
|
<i className='modal-back'></i>Security Settings
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className='user-settings'>
|
<div className='user-settings'>
|
||||||
<h3 className='tab-header'>Security Settings</h3>
|
<h3 className='tab-header'>Security Settings</h3>
|
||||||
@@ -187,11 +237,38 @@ module.exports = React.createClass({
|
|||||||
{passwordSection}
|
{passwordSection}
|
||||||
<div className='divider-dark'/>
|
<div className='divider-dark'/>
|
||||||
<br></br>
|
<br></br>
|
||||||
<a data-toggle='modal' className='security-links theme' data-target='#access-history' href='#' onClick={this.handleHistoryOpen}><i className='fa fa-clock-o'></i>View Access History</a>
|
<a
|
||||||
|
data-toggle='modal'
|
||||||
|
className='security-links theme'
|
||||||
|
data-target='#access-history'
|
||||||
|
href='#'
|
||||||
|
onClick={this.handleHistoryOpen}
|
||||||
|
>
|
||||||
|
<i className='fa fa-clock-o'></i>View Access History
|
||||||
|
</a>
|
||||||
<b> </b>
|
<b> </b>
|
||||||
<a data-toggle='modal' className='security-links theme' data-target='#activity-log' href='#' onClick={this.handleDevicesOpen}><i className='fa fa-globe'></i>View and Logout of Active Sessions</a>
|
<a
|
||||||
|
data-toggle='modal'
|
||||||
|
className='security-links theme'
|
||||||
|
data-target='#activity-log'
|
||||||
|
href='#'
|
||||||
|
onClick={this.handleDevicesOpen}
|
||||||
|
>
|
||||||
|
<i className='fa fa-globe'></i>View and Logout of Active Sessions
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
SecurityTab.defaultProps = {
|
||||||
|
user: {},
|
||||||
|
activeSection: ''
|
||||||
|
};
|
||||||
|
SecurityTab.propTypes = {
|
||||||
|
user: React.PropTypes.object,
|
||||||
|
activeSection: React.PropTypes.string,
|
||||||
|
updateSection: React.PropTypes.func,
|
||||||
|
updateTab: React.PropTypes.func
|
||||||
|
};
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user