From ac53536385a4ba828f09800a053885db5e5b9e02 Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Fri, 31 Jul 2015 09:51:37 -0700
Subject: User Settings modal resets to General tab with nothing open on close

---
 web/react/components/user_settings.jsx | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

(limited to 'web/react/components/user_settings.jsx')

diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index 902989b7b..819d5494e 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -102,6 +102,8 @@ var NotificationsTab = React.createClass({
         });
 
         this.setState(assign({},getNotificationsStateFromStores(),{server_error: null}));
+
+        this.props.updateTab('general');
     },
     componentDidMount: function() {
         UserStore.addChangeListener(this._onChange);
@@ -110,6 +112,7 @@ var NotificationsTab = React.createClass({
     componentWillUnmount: function() {
         UserStore.removeChangeListener(this._onChange);
         $('#user_settings1').off('hidden.bs.modal', this.handleClose);
+        this.props.updateSection('');
     },
     _onChange: function() {
         var newState = getNotificationsStateFromStores();
@@ -522,12 +525,14 @@ var SecurityTab = React.createClass({
             this.value = "";
         });
         this.setState({current_password: '', new_password: '', confirm_password: '', server_error: null, password_error: null});
+        this.props.updateTab('general');
     },
     componentDidMount: function() {
         $('#user_settings1').on('hidden.bs.modal', this.handleClose);
     },
     componentWillUnmount: function() {
         $('#user_settings1').off('hidden.bs.modal', this.handleClose);
+        this.props.updateSection('');
     },
     getInitialState: function() {
         return { current_password: '', new_password: '', confirm_password: '' };
@@ -790,6 +795,7 @@ var GeneralTab = React.createClass({
         });
 
         this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null}));
+        this.props.updateSection('');
     },
     componentDidMount: function() {
         $('#user_settings1').on('hidden.bs.modal', this.handleClose);
@@ -1042,6 +1048,7 @@ var AppearanceTab = React.createClass({
     },
     handleClose: function() {
         this.setState({server_error: null});
+        this.props.updateTab('general');
     },
     componentDidMount: function() {
         if (this.props.activeSection === "theme") {
@@ -1057,6 +1064,7 @@ var AppearanceTab = React.createClass({
     },
     componentWillUnmount: function() {
         $('#user_settings1').off('hidden.bs.modal', this.handleClose);
+        this.props.updateSection('');
     },
     getInitialState: function() {
         var user = UserStore.getCurrentUser();
@@ -1125,10 +1133,11 @@ var AppearanceTab = React.createClass({
                 </div>
             </div>
         );
-     }
+    }
 });
 
 module.exports = React.createClass({
+    displayName: 'UserSettings',
     componentDidMount: function() {
         UserStore.addChangeListener(this._onChange);
     },
@@ -1154,19 +1163,19 @@ module.exports = React.createClass({
         } else if (this.props.activeTab === 'security') {
             return (
                 <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>
             );
         } else if (this.props.activeTab === 'notifications') {
             return (
                 <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>
             );
         } else if (this.props.activeTab === 'appearance') {
             return (
                 <div>
-                    <AppearanceTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
+                    <AppearanceTab activeSection={this.props.activeSection} updateSection={this.props.updateSection} updateTab={this.props.updateTab} />
                 </div>
             );
         } else {
-- 
cgit v1.2.3-1-g7c22

