瀏覽代碼

AMBARI-12277. UI: when installing out of development, two stacks are selected (akovalenko)

Aleksandr Kovalenko 10 年之前
父節點
當前提交
f445698020
共有 2 個文件被更改,包括 17 次插入8 次删除
  1. 16 8
      ambari-web/app/controllers/installer.js
  2. 1 0
      ambari-web/test/controllers/installer_test.js

+ 16 - 8
ambari-web/app/controllers/installer.js

@@ -281,9 +281,15 @@ App.InstallerController = App.WizardController.extend({
         error: 'loadStacksVersionsErrorCallback'
         error: 'loadStacksVersionsErrorCallback'
       }));
       }));
     }, this);
     }, this);
+    this.set('loadStacksRequestsCounter', requests.length);
     return requests;
     return requests;
   },
   },
 
 
+  /**
+   * Counter for counting number of successful requests to load stack versions
+   */
+  loadStacksRequestsCounter: 0,
+
   /**
   /**
    * Parse loaded data and create array of stacks objects
    * Parse loaded data and create array of stacks objects
    */
    */
@@ -299,16 +305,18 @@ App.InstallerController = App.WizardController.extend({
       }, this);
       }, this);
     }
     }
     App.stackMapper.map(data);
     App.stackMapper.map(data);
-    if (!isStacksExistInDb) {
-      var defaultStackVersion = App.Stack.find().findProperty('id', App.defaultStackVersion);
-      if (defaultStackVersion) {
-        defaultStackVersion.set('isSelected', true)
-      } else {
-        App.Stack.find().objectAt(0).set('isSelected', true);
+    if (!this.decrementProperty('loadStacksRequestsCounter')) {
+      if (!isStacksExistInDb) {
+        var defaultStackVersion = App.Stack.find().findProperty('id', App.defaultStackVersion);
+        if (defaultStackVersion) {
+          defaultStackVersion.set('isSelected', true)
+        } else {
+          App.Stack.find().objectAt(0).set('isSelected', true);
+        }
       }
       }
+      this.set('content.stacks', App.Stack.find());
+      App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
     }
     }
-    this.set('content.stacks', App.Stack.find());
-    App.set('currentStackVersion', App.Stack.find().findProperty('isSelected').get('id'));
   },
   },
 
 
   /**
   /**

+ 1 - 0
ambari-web/test/controllers/installer_test.js

@@ -45,6 +45,7 @@ describe('App.InstallerController', function () {
       App.store.commit.restore();
       App.store.commit.restore();
     });
     });
     it ('Correct data', function() {
     it ('Correct data', function() {
+      installerController.set('loadStacksRequestsCounter', 1);
       installerController.loadStacksVersionsSuccessCallback(require('test/stack'));
       installerController.loadStacksVersionsSuccessCallback(require('test/stack'));
       expect(installerController.get('content.stacks.length')).to.equal(2);
       expect(installerController.get('content.stacks.length')).to.equal(2);
       expect(installerController.get('content.stacks').everyProperty('isSelected')).to.be.false;
       expect(installerController.get('content.stacks').everyProperty('isSelected')).to.be.false;