ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [21/50] [abbrv] ambari git commit: AMBARI-19960 No config properties are changed after deleting service if it's performed after service page refresh. (ababiichuk)
Date Mon, 13 Feb 2017 22:13:29 GMT
AMBARI-19960 No config properties are changed after deleting service if it's performed after
service page refresh. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eecb5a31
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eecb5a31
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eecb5a31

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: eecb5a311626f2bab09688d37949f0ccedde86a8
Parents: c9bea4a
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Fri Feb 10 16:02:12 2017 +0200
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Fri Feb 10 18:22:30 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service/item.js | 67 +++++++++++---------
 .../test/controllers/main/service/item_test.js  | 46 +++++++++++++-
 2 files changed, 81 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eecb5a31/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 7010ab5..a7ed493 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -144,8 +144,9 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
    * @type {String[]}
    */
   dependentServiceNames: function() {
-    return App.StackService.find(this.get('content.serviceName')).get('dependentServiceNames');
-  }.property('content.serviceName'),
+    return App.get('router.clusterController.isConfigsPropertiesLoaded') ?
+      App.StackService.find(this.get('content.serviceName')).get('dependentServiceNames')
: [];
+  }.property('content.serviceName', 'App.router.clusterController.isConfigsPropertiesLoaded'),
 
   /**
    * List of service names that could be deleted
@@ -204,32 +205,35 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
    */
   onLoadConfigsTags: function (data) {
     var self = this;
-    var sitesToLoad = this.get('sitesToLoad'), allConfigs = [];
-    var loadedSites = data.Clusters.desired_configs;
-    var siteTagsToLoad = [];
-    for (var site in loadedSites) {
-      if (sitesToLoad.contains(site)) {
-        siteTagsToLoad.push({
-          siteName: site,
-          tagName: loadedSites[site].tag
-        });
+    App.get('router.mainController.isLoading').call(App.get('router.clusterController'),
'isConfigsPropertiesLoaded').done(function () {
+      var sitesToLoad = self.get('sitesToLoad'),
+        allConfigs = [],
+        loadedSites = data.Clusters.desired_configs,
+        siteTagsToLoad = [];
+      for (var site in loadedSites) {
+        if (sitesToLoad.contains(site)) {
+          siteTagsToLoad.push({
+            siteName: site,
+            tagName: loadedSites[site].tag
+          });
+        }
       }
-    }
-    App.router.get('configurationController').getConfigsByTags(siteTagsToLoad).done(function
(configs) {
-      configs.forEach(function (site) {
-        self.get('configs')[site.type] = site.properties;
-        allConfigs = allConfigs.concat(App.config.getConfigsFromJSON(site, true));
-      });
+      App.router.get('configurationController').getConfigsByTags(siteTagsToLoad).done(function
(configs) {
+        configs.forEach(function (site) {
+          self.get('configs')[site.type] = site.properties;
+          allConfigs = allConfigs.concat(App.config.getConfigsFromJSON(site, true));
+        });
 
-      self.get('dependentServiceNames').forEach(function(serviceName) {
-        var configTypes = App.StackService.find(serviceName).get('configTypeList');
-        var configsByService = allConfigs.filter(function (c) {
-          return configTypes.contains(App.config.getConfigTagFromFileName(c.get('filename')));
+        self.get('dependentServiceNames').forEach(function(serviceName) {
+          var configTypes = App.StackService.find(serviceName).get('configTypeList');
+          var configsByService = allConfigs.filter(function (c) {
+            return configTypes.contains(App.config.getConfigTagFromFileName(c.get('filename')));
+          });
+          self.get('stepConfigs').pushObject(App.config.createServiceConfig(serviceName,
[], configsByService));
         });
-        self.get('stepConfigs').pushObject(App.config.createServiceConfig(serviceName, [],
configsByService));
-      });
 
-      self.set('isServiceConfigsLoaded', true);
+        self.set('isServiceConfigsLoaded', true);
+      });
     });
   },
 
@@ -1290,7 +1294,13 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
       popupHeader = Em.I18n.t('services.service.delete.popup.header'),
       popupPrimary = Em.I18n.t('common.delete'),
       warningMessage = Em.I18n.t('services.service.delete.popup.warning').format(displayName)
+
-        (interDependentServices.length ? Em.I18n.t('services.service.delete.popup.warning.dependent').format(dependentServicesToDeleteFmt)
: '');
+        (interDependentServices.length ? Em.I18n.t('services.service.delete.popup.warning.dependent').format(dependentServicesToDeleteFmt)
: ''),
+      callback = this.loadConfigRecommendations.bind(this, null, function () {
+        var serviceNames = self.get('changedProperties').mapProperty('serviceName').uniq();
+        self.loadConfigGroups(serviceNames).done(function () {
+          self.set('isRecommendationInProgress', false);
+        })
+      });
     this.clearRecommendations();
     this.setProperties({
       isRecommendationInProgress: true,
@@ -1298,12 +1308,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
         isDefault: true
       })
     });
-    this.loadConfigRecommendations(null, function () {
-      var serviceNames = self.get('changedProperties').mapProperty('serviceName').uniq();
-      self.loadConfigGroups(serviceNames).done(function () {
-        self.set('isRecommendationInProgress', false);
-      })
-    });
+    App.get('router.mainController.isLoading').call(this, 'isServiceConfigsLoaded').done(callback);
     return App.ModalPopup.show({
       controller: self,
       header: popupHeader,

http://git-wip-us.apache.org/repos/asf/ambari/blob/eecb5a31/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js
index 302a9a5..6430ab6 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1719,7 +1719,7 @@ describe('App.MainServiceItemController', function () {
       mainServiceItemController.deleteServiceCall.restore();
     });
 
-    it("window.location.reload should be called", function() {
+    it("saveConfigs should be called", function() {
       mainServiceItemController.deleteServiceCallSuccessCallback([], null, {});
       expect(mainServiceItemController.deleteServiceCall.called).to.be.false;
       expect(mainServiceItemController.saveConfigs.calledOnce).to.be.true;
@@ -1878,4 +1878,48 @@ describe('App.MainServiceItemController', function () {
       expect(mainServiceItemController.isRangerPluginEnabled()).to.be.true;
     });
   });
+
+  describe('#dependentServiceNames', function () {
+
+    var controller,
+      serviceName = 's0',
+      dependentServiceNames = ['s1', 's2'],
+      testCases = [
+        {
+          isConfigsPropertiesLoaded: true,
+          dependentServiceNames: dependentServiceNames,
+          message: 'model is ready'
+        },
+        {
+          isConfigsPropertiesLoaded: false,
+          dependentServiceNames: [],
+          message: 'model is not ready'
+        }
+      ];
+
+    beforeEach(function () {
+      controller = App.MainServiceItemController.create({
+        content: {
+          serviceName: serviceName
+        }
+      });
+      sinon.stub(App.StackService, 'find').returns(Em.Object.create({
+        dependentServiceNames: dependentServiceNames
+      }));
+    });
+
+    afterEach(function () {
+      App.StackService.find.restore();
+    });
+
+    testCases.forEach(function (test) {
+
+      it(test.message, function () {
+        App.set('router.clusterController.isConfigsPropertiesLoaded', test.isConfigsPropertiesLoaded);
+        expect(controller.get('dependentServiceNames')).to.eql(test.dependentServiceNames);
+      });
+
+    });
+
+  });
 });


Mime
View raw message