From b114062c1b8128fe650fce72454ba4f1fcbe5733 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Wed, 6 Jul 2016 16:07:56 -0400
Subject: PLT-3237 Update displayed config values in admin console after saving
 (#3506)

* Reloaded admin console data when settings are saved

* Fixed attempting to save an invalid config setting overwriting the stored config
---
 webapp/components/admin_console/admin_settings.jsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'webapp/components/admin_console/admin_settings.jsx')

diff --git a/webapp/components/admin_console/admin_settings.jsx b/webapp/components/admin_console/admin_settings.jsx
index 2ab2c6332..e11d843a7 100644
--- a/webapp/components/admin_console/admin_settings.jsx
+++ b/webapp/components/admin_console/admin_settings.jsx
@@ -24,11 +24,11 @@ export default class AdminSettings extends React.Component {
         this.handleSubmit = this.handleSubmit.bind(this);
         this.onKeyDown = this.onKeyDown.bind(this);
 
-        this.state = {
+        this.state = Object.assign(this.getStateFromConfig(props.config), {
             saveNeeded: false,
             saving: false,
             serverError: null
-        };
+        });
     }
 
     handleChange(id, value) {
@@ -60,12 +60,17 @@ export default class AdminSettings extends React.Component {
             serverError: null
         });
 
-        const config = this.getConfigFromState(this.props.config);
+        // clone config so that we aren't modifying data in the stores
+        let config = JSON.parse(JSON.stringify(this.props.config));
+        config = this.getConfigFromState(config);
 
         Client.saveConfig(
             config,
             () => {
-                AsyncClient.getConfig();
+                AsyncClient.getConfig((savedConfig) => {
+                    this.setState(this.getStateFromConfig(savedConfig));
+                });
+
                 this.setState({
                     saveNeeded: false,
                     saving: false
-- 
cgit v1.2.3-1-g7c22

