Forráskód Böngészése

AMBARI-11359. Create/Edit widget: Wizard doesn't navigate to the current wizard page when another window is open. (jaimin)

Jaimin Jetly 10 éve
szülő
commit
5be5b138b8

+ 1 - 1
ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js

@@ -161,7 +161,7 @@ App.WidgetWizardController = App.WizardController.extend({
   saveClusterStatus: function (clusterStatus) {
     App.clusterStatus.setClusterStatus({
       clusterState: clusterStatus,
-      wizardControllerName: 'widgetWizardController',
+      wizardControllerName: this.get('name'),
       localdb: App.db.data
     });
   },

+ 76 - 0
ambari-web/app/data/controller_route.js

@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+/**
+ * This is required to reroute directly to the wizard controller. This is desired in following scenarios
+ * 1. A wizard is being navigated and another browser window is simultaneously opened by the same or another user
+ * 2. browser window crashed while navigating through any wizard and a new browser window is opened to complete the wizard
+ * @type {Array} Array of Objects
+ */
+module.exports = [
+  {
+    wizardControllerName: App.router.get('addHostController.name'),
+    route: 'main.hostAdd'
+  },
+  {
+    wizardControllerName: App.router.get('addSecurityController.name'),
+    route: 'main.admin.adminSecurity'
+  },
+  {
+    wizardControllerName: App.router.get('mainAdminSecurityDisableController.name'),
+    route: 'main.admin.adminSecurity'
+  },
+  {
+    wizardControllerName: App.router.get('kerberosWizardController.name'),
+    route: 'main.admin.adminKerberos.adminAddKerberos'
+  },
+  {
+    wizardControllerName: App.router.get('addServiceController.name'),
+    route: 'main.serviceAdd'
+  },
+  {
+    wizardControllerName: App.router.get('reassignMasterController.name'),
+    route: 'main.reassign'
+  },
+  {
+    wizardControllerName: App.router.get('highAvailabilityWizardController.name'),
+    route: 'main.services.enableHighAvailability'
+  },
+  {
+    wizardControllerName: App.router.get('rMHighAvailabilityWizardController.name'),
+    route: 'main.services.enableRMHighAvailability'
+  },
+  {
+    wizardControllerName: App.router.get('rollbackHighAvailabilityWizardController.name'),
+    route: 'main.services.rollbackHighAvailability'
+  },
+  {
+    wizardControllerName: App.router.get('mainAdminStackAndUpgradeController.name'),
+    route: 'main.admin.stackAndUpgrade'
+  },
+  {
+    wizardControllerName: App.router.get('widgetWizardController.name'),
+    route: 'main.createWidget'
+  },
+  {
+    wizardControllerName: App.router.get('widgetEditController.name'),
+    route: 'main.editWidget'
+  }
+];

+ 7 - 28
ambari-web/app/router.js

@@ -361,35 +361,14 @@ App.Router = Em.Router.extend({
     } else {
       if (this.get('clusterInstallCompleted')) {
         App.clusterStatus.updateFromServer(false).complete(function () {
-          var clusterStatusOnServer = App.clusterStatus.get('value');
           var route = 'main.dashboard.index';
-          if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('addHostController.name')) {
-            // if wizardControllerName == "addHostController", then it means someone closed the browser or the browser was crashed when we were last in Add Hosts wizard
-            route = 'main.hostAdd';
-          } else if (clusterStatusOnServer && (clusterStatusOnServer.wizardControllerName === App.router.get('addSecurityController.name') || clusterStatusOnServer.wizardControllerName === App.router.get('mainAdminSecurityDisableController.name'))) {
-            // if wizardControllerName == "addSecurityController", then it means someone closed the browser or the browser was crashed when we were last in Add Security wizard
-            route = 'main.admin.adminSecurity';
-          } else if (clusterStatusOnServer && (clusterStatusOnServer.wizardControllerName === App.router.get('kerberosWizardController.name'))) {
-            // if wizardControllerName == "adminKerberosController", then it means someone closed the browser or the browser was crashed when we were last in Add Kerberos wizard
-            route = 'main.admin.adminKerberos.adminAddKerberos';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('addServiceController.name')) {
-            // if wizardControllerName == "addHostController", then it means someone closed the browser or the browser was crashed when we were last in Add Hosts wizard
-            route = 'main.serviceAdd';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('reassignMasterController.name')) {
-            // if wizardControllerName == "reassignMasterController", then it means someone closed the browser or the browser was crashed when we were last in Reassign Master wizard
-            route = 'main.reassign';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('highAvailabilityWizardController.name')) {
-            // if wizardControllerName == "highAvailabilityWizardController", then it means someone closed the browser or the browser was crashed when we were last in NameNode High Availability wizard
-            route = 'main.services.enableHighAvailability';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('rMHighAvailabilityWizardController.name')) {
-            // if wizardControllerName == "highAvailabilityWizardController", then it means someone closed the browser or the browser was crashed when we were last in NameNode High Availability wizard
-            route = 'main.services.enableRMHighAvailability';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('rollbackHighAvailabilityWizardController.name')) {
-            // if wizardControllerName == "highAvailabilityRollbackController", then it means someone closed the browser or the browser was crashed when we were last in NameNode High Availability Rollback wizard
-            route = 'main.services.rollbackHighAvailability';
-          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('mainAdminStackAndUpgradeController.name')) {
-            // if wizardControllerName == "mainAdminStackAndUpgradeController", then it means someone closed the browser or the browser was crashed when we were last in Rolling Upgrade wizard
-            route = 'main.admin.stackAndUpgrade';
+          var clusterStatusOnServer = App.clusterStatus.get('value');
+          if (clusterStatusOnServer) {
+            var wizardControllerRoutes = require('data/controller_route');
+            var wizardControllerRoute =  wizardControllerRoutes.findProperty('wizardControllerName', clusterStatusOnServer.wizardControllerName);
+            if (wizardControllerRoute) {
+              route =  wizardControllerRoute.route;
+            }
           }
           callback(route);
         });