瀏覽代碼

AMBARI-15441. Service Configs page is broken after another user close the wizard (onechiporenko)

Oleg Nechiporenko 9 年之前
父節點
當前提交
df2d304b18

+ 2 - 1
ambari-web/app/routes/main.js

@@ -689,7 +689,8 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         },
         exitRoute: function (router, context, callback) {
           var controller = router.get('mainServiceInfoConfigsController');
-          if (controller.hasUnsavedChanges()) {
+          // If another user is running some wizard, current user can't save configs
+          if (controller.hasUnsavedChanges() && !router.get('wizardWatcherController.isWizardRunning')) {
             controller.showSavePopup(callback);
           } else {
             callback();

+ 10 - 0
ambari-web/app/views/main/service/info/configs.js

@@ -31,6 +31,16 @@ App.MainServiceInfoConfigsView = Em.View.extend({
     this.resetConfigTabSelection();
   },
 
+  /**
+   * If user A is on the Service Configs page and B starts some Wizard, user A should be moved-out and then moved-in this page
+   * It's done to properly disable "admin"-elements
+   * This code can't be moved to the controller, because it should work only if user is in the configs page (this view exists)
+   */
+  simulateRefresh: function() {
+    App.router.transitionTo('main.services.service.summary', this.get('controller.content'));
+    App.router.transitionTo('main.services.service.configs', this.get('controller.content'));
+  }.observes('App.router.wizardWatcherController.isWizardRunning'),
+
   willDestroyElement: function() {
     this.get('controller').clearStep();
   },

+ 19 - 8
ambari-web/app/views/main/service/item.js

@@ -184,8 +184,9 @@ App.MainServiceItemView = Em.View.extend({
       var knoxGatewayComponent = App.StackServiceComponent.find().findProperty('componentName','KNOX_GATEWAY');
       if (serviceName === 'HDFS' && nnComponent) {
         var namenodeCustomCommands = nnComponent.get('customCommands');
-        if (namenodeCustomCommands && namenodeCustomCommands.contains('REBALANCEHDFS'))
-        options.push(actionMap.REBALANCEHDFS);
+        if (namenodeCustomCommands && namenodeCustomCommands.contains('REBALANCEHDFS')) {
+          options.push(actionMap.REBALANCEHDFS);
+        }
       }
 
       if (serviceName === 'KNOX' && knoxGatewayComponent) {
@@ -203,8 +204,7 @@ App.MainServiceItemView = Em.View.extend({
       if(serviceName === 'HAWQ') {
         var hawqMasterComponent = App.StackServiceComponent.find().findProperty('componentName','HAWQMASTER');
         var hawqStandByComponent = App.StackServiceComponent.find().findProperty('componentName','HAWQSTANDBY');
-        components = [hawqMasterComponent,hawqStandByComponent]
-        components.forEach(function(component){
+        [hawqMasterComponent,hawqStandByComponent].forEach(function(component){
           component.get('customCommands').forEach(function(command){
             options.push(self.createOption(actionMap[command], {
               context: {
@@ -241,12 +241,12 @@ App.MainServiceItemView = Em.View.extend({
         var commands = component.get('customCommands');
 
         if (!commands.length) {
-          return false;
+          return;
         }
 
         commands.forEach(function(command) {
           if (excludedCommands[master] && excludedCommands[master].contains(command)){
-            return false;
+            return;
           }
 
           options.push(self.createOption(actionMap.MASTER_CUSTOM_COMMAND, {
@@ -268,14 +268,25 @@ App.MainServiceItemView = Em.View.extend({
 
     options.push(actionMap.DELETE_SERVICE);
 
+    /**
+     * When some Wizard is running by another user, "Service Actions" is hidden and there is no sense to calculate its items
+     * Also, when this menu is not empty and becomes visible, there are some JS-errors based on Ember inner logic for adding Listeners
+     * To avoid this behavior it's cleaned while it's not visible
+     */
+    if (App.router.get('wizardWatcherController.isWizardRunning')) {
+      this.set('maintenance', []);
+      this.set('isMaintenanceSet', true);
+      return;
+    }
+
     if (this.get('maintenance.length')) {
       this.get('maintenance').forEach(function(option, index) {
-        if (JSON.stringify(option) != JSON.stringify(options[index])) {
+        if (JSON.stringify(option) !== JSON.stringify(options[index])) {
           self.get('maintenance').removeAt(index).insertAt(index, options[index]);
         }
       });
       options.forEach(function(opt, index) {
-        if (JSON.stringify(opt) != JSON.stringify(self.get('maintenance')[index])) {
+        if (JSON.stringify(opt) !== JSON.stringify(self.get('maintenance')[index])) {
           self.get('maintenance').pushObject(opt);
         }
       });

+ 1 - 3
ambari-web/test/mixins/wizard/wizardProgressPageController_test.js

@@ -188,9 +188,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
 
     it('when credentials are ok, createComponent method called', function() {
       this.KDCStub.returns({
-        getKDCSessionState: function(sCallback, eCallback) {
-          sCallback();
-        }
+        getKDCSessionState: Em.clb
       });
       mixedObjectInstance.createInstallComponentTask('componentName', 'hostName', 'serviceName');
       assert.isTrue(mixedObjectInstance.createComponent.calledOnce, 'createComponent should be called');