You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2018/07/19 15:05:08 UTC

[ambari] branch trunk updated: AMBARI-24313 Service disappear from the UI when Going back to "Customize Services" page or doing page refresh

This is an automated email from the ASF dual-hosted git repository.

atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 00fbca6  AMBARI-24313 Service disappear from the UI when Going back to "Customize Services" page or doing page refresh
00fbca6 is described below

commit 00fbca662d4e7727da738831e9cf66ad17736149
Author: Andrii Tkach <at...@apache.org>
AuthorDate: Thu Jul 19 16:54:27 2018 +0300

    AMBARI-24313 Service disappear from the UI when Going back to "Customize Services" page or doing page refresh
---
 ambari-web/app/controllers/wizard.js           | 14 ++++++++--
 ambari-web/app/mappers/stack_service_mapper.js |  3 --
 ambari-web/test/controllers/wizard_test.js     | 38 +++++++++++++++++++++++++-
 3 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 979806a..f2adde7 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -645,9 +645,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     this.set('content.selectedServiceNames', savedSelectedServices);
     this.set('content.installedServiceNames', savedInstalledServices);
     if (!savedSelectedServices) {
-      jsonData.items.forEach(function (service) {
-        service.StackServices.is_selected = !(service.StackServices.selection === "TECH_PREVIEW");
-      }, this);
+      jsonData.items.forEach(this.setStackServiceSelectedByDefault);
     } else {
       jsonData.items.forEach(function (service) {
         service.StackServices.is_selected = savedSelectedServices.contains(service.StackServices.service_name);
@@ -669,6 +667,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
 
   loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
   },
+  
+  /**
+   * @param {object} service
+   */
+  setStackServiceSelectedByDefault: function (service) {
+    service.StackServices.is_selected = !(service.StackServices.selection === "TECH_PREVIEW");
+    if (service.StackServices.service_type === 'HCFS' && service.StackServices.service_name !== 'HDFS') {
+      service.StackServices.is_selected = false;
+    }
+  },
 
   /**
    * load version for services to display on Choose Servoces page
diff --git a/ambari-web/app/mappers/stack_service_mapper.js b/ambari-web/app/mappers/stack_service_mapper.js
index 9b55a05..dd42e13 100644
--- a/ambari-web/app/mappers/stack_service_mapper.js
+++ b/ambari-web/app/mappers/stack_service_mapper.js
@@ -120,9 +120,6 @@ App.stackServiceMapper = App.QuickDataMapper.create({
         stackService.is_installable = false;
         stackService.is_selected = false;
       }
-      if (stackService.service_type === 'HCFS' && stackService.service_name !== 'HDFS') {
-        stackService.is_selected = false;
-      }
       if(stackService.selection === "MANDATORY") {
         stackService.is_mandatory = true;
       }
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 0f70959..291ef55 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1754,6 +1754,42 @@ describe('App.WizardController', function () {
       ]);
     });
   });
-
+  
+  describe('#setStackServiceSelectedByDefault', function() {
+   
+    it('regular service should be selected', function() {
+      var service = {
+        StackServices: {
+          selection: null,
+          service_name: 'S1'
+        }
+      };
+      c.setStackServiceSelectedByDefault(service);
+      expect(service.StackServices.is_selected).to.be.true;
+    });
+  
+    it('TECH_PREVIEW service should not be selected', function() {
+      var service = {
+        StackServices: {
+          selection: "TECH_PREVIEW",
+          service_name: 'S1'
+        }
+      };
+      c.setStackServiceSelectedByDefault(service);
+      expect(service.StackServices.is_selected).to.be.false;
+    });
+  
+    it('service_type service should not be selected', function() {
+      var service = {
+        StackServices: {
+          selection: null,
+          service_name: 'S1',
+          service_type: 'HCFS'
+        }
+      };
+      c.setStackServiceSelectedByDefault(service);
+      expect(service.StackServices.is_selected).to.be.false;
+    });
+  });
 
 });