Merge pull request #309 from nickago/MM-1691

MM-1691/1692 Reset User settings tab on close
Этот коммит содержится в:
Christopher Speller
2015-08-04 09:00:45 -04:00
родитель 42c5d0d366 ac53536385
Коммит 2c46ee8420
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@@ -102,6 +102,8 @@ var NotificationsTab = React.createClass({
}); });
this.setState(assign({},getNotificationsStateFromStores(),{server_error: null})); this.setState(assign({},getNotificationsStateFromStores(),{server_error: null}));
this.props.updateTab('general');
}, },
componentDidMount: function() { componentDidMount: function() {
UserStore.addChangeListener(this._onChange); UserStore.addChangeListener(this._onChange);
@@ -110,6 +112,7 @@ var NotificationsTab = React.createClass({
componentWillUnmount: function() { componentWillUnmount: function() {
UserStore.removeChangeListener(this._onChange); UserStore.removeChangeListener(this._onChange);
$('#user_settings1').off('hidden.bs.modal', this.handleClose); $('#user_settings1').off('hidden.bs.modal', this.handleClose);
this.props.updateSection('');
}, },
_onChange: function() { _onChange: function() {
var newState = getNotificationsStateFromStores(); var newState = getNotificationsStateFromStores();
@@ -522,12 +525,14 @@ var SecurityTab = React.createClass({
this.value = ""; this.value = "";
}); });
this.setState({current_password: '', new_password: '', confirm_password: '', server_error: null, password_error: null}); this.setState({current_password: '', new_password: '', confirm_password: '', server_error: null, password_error: null});
this.props.updateTab('general');
}, },
componentDidMount: function() { componentDidMount: function() {
$('#user_settings1').on('hidden.bs.modal', this.handleClose); $('#user_settings1').on('hidden.bs.modal', this.handleClose);
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
$('#user_settings1').off('hidden.bs.modal', this.handleClose); $('#user_settings1').off('hidden.bs.modal', this.handleClose);
this.props.updateSection('');
}, },
getInitialState: function() { getInitialState: function() {
return { current_password: '', new_password: '', confirm_password: '' }; return { current_password: '', new_password: '', confirm_password: '' };
@@ -794,6 +799,7 @@ var GeneralTab = React.createClass({
}); });
this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null})); this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null}));
this.props.updateSection('');
}, },
componentDidMount: function() { componentDidMount: function() {
$('#user_settings1').on('hidden.bs.modal', this.handleClose); $('#user_settings1').on('hidden.bs.modal', this.handleClose);
@@ -1063,6 +1069,7 @@ var AppearanceTab = React.createClass({
}, },
handleClose: function() { handleClose: function() {
this.setState({server_error: null}); this.setState({server_error: null});
this.props.updateTab('general');
}, },
componentDidMount: function() { componentDidMount: function() {
if (this.props.activeSection === "theme") { if (this.props.activeSection === "theme") {
@@ -1078,6 +1085,7 @@ var AppearanceTab = React.createClass({
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
$('#user_settings1').off('hidden.bs.modal', this.handleClose); $('#user_settings1').off('hidden.bs.modal', this.handleClose);
this.props.updateSection('');
}, },
getInitialState: function() { getInitialState: function() {
var user = UserStore.getCurrentUser(); var user = UserStore.getCurrentUser();
@@ -1146,10 +1154,11 @@ var AppearanceTab = React.createClass({
</div> </div>
</div> </div>
); );
} }
}); });
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'UserSettings',
componentDidMount: function() { componentDidMount: function() {
UserStore.addChangeListener(this._onChange); UserStore.addChangeListener(this._onChange);
}, },
@@ -1175,19 +1184,19 @@ module.exports = React.createClass({
} else if (this.props.activeTab === 'security') { } else if (this.props.activeTab === 'security') {
return ( return (
<div> <div>
<SecurityTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <SecurityTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} updateTab={this.props.updateTab} />
</div> </div>
); );
} else if (this.props.activeTab === 'notifications') { } else if (this.props.activeTab === 'notifications') {
return ( return (
<div> <div>
<NotificationsTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <NotificationsTab user={this.state.user} activeSection={this.props.activeSection} updateSection={this.props.updateSection} updateTab={this.props.updateTab} />
</div> </div>
); );
} else if (this.props.activeTab === 'appearance') { } else if (this.props.activeTab === 'appearance') {
return ( return (
<div> <div>
<AppearanceTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} /> <AppearanceTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} updateTab={this.props.updateTab} />
</div> </div>
); );
} else { } else {

Просмотреть файл

@@ -53,6 +53,7 @@ module.exports = React.createClass({
activeTab={this.state.active_tab} activeTab={this.state.active_tab}
activeSection={this.state.active_section} activeSection={this.state.active_section}
updateSection={this.updateSection} updateSection={this.updateSection}
updateTab={this.updateTab}
/> />
</div> </div>
</div> </div>