From 9fa3c996d522589139f56964087022bd0942e5e4 Mon Sep 17 00:00:00 2001
From: Stas Vovk <stas@vovk.me>
Date: Sun, 18 Oct 2015 18:55:04 +0300
Subject: change url when a user navigates between tabs [#962]

---
 web/react/components/admin_console/admin_controller.jsx | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

(limited to 'web/react/components/admin_console/admin_controller.jsx')

diff --git a/web/react/components/admin_console/admin_controller.jsx b/web/react/components/admin_console/admin_controller.jsx
index f2fb8ac78..f770d166c 100644
--- a/web/react/components/admin_console/admin_controller.jsx
+++ b/web/react/components/admin_console/admin_controller.jsx
@@ -40,9 +40,13 @@ export default class AdminController extends React.Component {
             config: AdminStore.getConfig(),
             teams: AdminStore.getAllTeams(),
             selectedTeams,
-            selected: 'service_settings',
-            selectedTeam: null
+            selected: props.tab || 'service_settings',
+            selectedTeam: props.teamId || null
         };
+
+        if (!props.tab) {
+            history.replaceState(null, null, `/admin_console/${this.state.selected}`);
+        }
     }
 
     componentDidMount() {
@@ -142,7 +146,9 @@ export default class AdminController extends React.Component {
             } else if (this.state.selected === 'service_settings') {
                 tab = <ServiceSettingsTab config={this.state.config} />;
             } else if (this.state.selected === 'team_users') {
-                tab = <TeamUsersTab team={this.state.teams[this.state.selectedTeam]} />;
+                if (this.state.teams) {
+                    tab = <TeamUsersTab team={this.state.teams[this.state.selectedTeam]} />;
+                }
             }
         }
 
-- 
cgit v1.2.3-1-g7c22

