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

ishanbha 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 05bc12d  [AMBARI-23711] Customize Services - The selected 
service/Modified con… (#1117)
05bc12d is described below

commit 05bc12d4590970017575bb1b51f144219fd055bd
Author: Ishan Bhatt <[email protected]>
AuthorDate: Mon Apr 30 12:55:07 2018 -0400

    [AMBARI-23711] Customize Services - The selected service/Modified con… 
(#1117)
    
    * [AMBARI-23711] Customize Services - The selected service/Modified 
configurations are not remembered when navigating away/to the configuration 
tabs.
    
    * Removed logger
---
 ambari-web/app/controllers/wizard.js               | 11 ++++++--
 .../app/controllers/wizard/step7_controller.js     | 16 ++++++++++-
 ambari-web/app/messages.js                         |  2 +-
 ambari-web/app/routes/add_host_routes.js           |  9 +++++-
 ambari-web/app/routes/add_service_routes.js        | 17 ++++++++---
 ambari-web/app/routes/installer.js                 |  6 ++--
 .../app/views/wizard/step7/directories_tab_view.js |  8 +++++-
 ambari-web/app/views/wizard/step7_view.js          |  1 +
 ambari-web/test/controllers/wizard/step7_test.js   | 33 +++++++++++++++++++++-
 9 files changed, 89 insertions(+), 14 deletions(-)

diff --git a/ambari-web/app/controllers/wizard.js 
b/ambari-web/app/controllers/wizard.js
index eb1de68..979806a 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -238,9 +238,11 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     if (this.get('isStepDisabled').findProperty('step', step).get('value') !== 
false) {
       return false;
     }
+    var currentStep = this.get('currentStep');
+    var currentControllerName = this.get('content.controllerName');
     // if going back from Step 9 in Install Wizard, delete the checkpoint so 
that the user is not redirected
     // to Step 9
-    if (this.get('content.controllerName') === 'installerController' && 
this.get('currentStep') === '9' && step < 9) {
+    if (currentControllerName === 'installerController' && currentStep === '9' 
&& step < 9) {
       App.clusterStatus.setClusterStatus({
         clusterName: this.get('clusterName'),
         clusterState: 'CLUSTER_NOT_CREATED_1',
@@ -248,7 +250,12 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
         localdb: {}
       });
     }
-    if ((this.get('currentStep') - step) > 1 && !disableNaviWarning) {
+    var isCustomizeServicesStep = false;
+    if ((currentControllerName === 'installerController' && currentStep === 
'7') || ((currentControllerName === 'addServiceController'|| 
currentControllerName === 'addHostController' ) && currentStep === '4')) {
+      isCustomizeServicesStep = true;
+    }
+    var stepDiff = currentStep - step;
+    if (!disableNaviWarning && (stepDiff  > 1 || (isCustomizeServicesStep && 
stepDiff > 0))) {
       App.ModalPopup.show({
         header: Em.I18n.t('installer.navigation.warning.header'),
         onPrimary: function () {
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js 
b/ambari-web/app/controllers/wizard/step7_controller.js
index 855817d..30131a8 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -360,6 +360,10 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
     this.get('filterColumns').setEach('selected', false);
   },
 
+  clearLastSelectedService: function () {
+    
this.get('tabs').filterProperty('selectedServiceName').setEach('selectedServiceName',
 null);
+  },
+
   /**
    * Generate "finger-print" for current <code>stepConfigs[0]</code>
    * Used to determine, if user has some unsaved changes (comparing with 
<code>hash</code>)
@@ -1087,12 +1091,17 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
   },
 
   /**
+   * Select previously selected service if not within the tab for the first 
time
    * Select first addable service for <code>addServiceWizard</code>
    * Select first service at all in other cases
    * @method selectProperService
    */
   selectProperService: function () {
-    if (this.get('wizardController.name') === 'addServiceController') {
+    var tabSelectedServiceName = this.get('tabs').findProperty('isActive', 
true).get('selectedServiceName');
+    var lastSelectedService = tabSelectedServiceName ? 
this.get('stepConfigs').findProperty('serviceName', tabSelectedServiceName) : 
null
+    if(tabSelectedServiceName && lastSelectedService) {
+      this.set('selectedService', lastSelectedService);
+    } else if (this.get('wizardController.name') === 'addServiceController') {
       this.set('selectedService', 
this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
     } else {
       this.set('selectedService', 
this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
@@ -1653,6 +1662,8 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
       },
       onSecondary: function () {
         this.hide();
+        App.set('router.btnClickInProgress', false);
+        App.set('router.backBtnClickInProgress', false);
       }
     });
   },
@@ -1840,6 +1851,7 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
 
   selectService: function (event) {
     this.set('selectedService', event.context);
+    this.get('tabs').findProperty('isActive', true).set('selectedServiceName', 
event.context.serviceName);
   },
 
   /**
@@ -1873,6 +1885,7 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
         isActive: false,
         isDisabled: false,
         isSkipped: false,
+        selectedServiceName: null,
         tabView: App.DirectoriesTabOnStep7View
       }),
       Em.Object.create({
@@ -1891,6 +1904,7 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
         isActive: false,
         isDisabled: false,
         isSkipped: false,
+        selectedServiceName: null,
         tabView: App.ServicesConfigView
       })
     ];
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 3849fac..087fff6 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2312,7 +2312,7 @@ Em.I18n.translations = {
   'services.service.config.configOverride.head':'Config Override',
   'services.service.config.configOverride.body':'Cannot override a config that 
has not been saved yet.',
   'services.service.config.exitPopup.body':'You have unsaved changes. Save 
changes or discard?',
-  'services.service.config.exitChangesPopup.body':'You will be brought back to 
the \"Assign Slaves and Clients\" step and will lose all your current 
customizations. Are you sure?',
+  'services.service.config.exitChangesPopup.body':'Going back to the previous 
step will result in losing all your current customizations. Are you sure?',
   'services.service.config.propertyFilterPopover.title':'Properties filter',
   'services.service.config.propertyFilterPopover.content':'Enter keywords to 
filter properties by property name, value, or description.',
   'services.service.config.hive.oozie.postgresql': 'Existing PostgreSQL 
Database',
diff --git a/ambari-web/app/routes/add_host_routes.js 
b/ambari-web/app/routes/add_host_routes.js
index 0158269..f1fc892 100644
--- a/ambari-web/app/routes/add_host_routes.js
+++ b/ambari-web/app/routes/add_host_routes.js
@@ -227,7 +227,14 @@ module.exports = App.WizardRoute.extend({
       });
     },
     backTransition: function (router) {
-      router.transitionTo('step3');
+      var goToPreviousStep = function() {
+        router.transitionTo(step);
+      };
+      if (wizardStep7Controller.hasChanges()) {
+        wizardStep7Controller.showChangesWarningPopup(goToPreviousStep);
+      } else {
+        goToPreviousStep();
+      }
     },
     nextTransition: function (router) {
       var addHostController = router.get('addHostController');
diff --git a/ambari-web/app/routes/add_service_routes.js 
b/ambari-web/app/routes/add_service_routes.js
index 8413986..0325ad5 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -268,13 +268,22 @@ module.exports = App.WizardRoute.extend({
 
     backTransition: function (router) {
       var controller = router.get('addServiceController');
+      var wizardStep7Controller = router.get('wizardStep7Controller');
+      var step = 'step1';
       if (!controller.get('content.skipSlavesStep')) {
-        return router.transitionTo('step3');
+        step = 'step3';
       }
-      if (!controller.get('content.skipMasterStep')) {
-        return router.transitionTo('step2');
+      else if (!controller.get('content.skipMasterStep')) {
+        step = 'step2';
+      }
+      var goToPreviousStep = function() {
+        router.transitionTo(step);
+      };
+      if (wizardStep7Controller.hasChanges()) {
+        wizardStep7Controller.showChangesWarningPopup(goToPreviousStep);
+      } else {
+        goToPreviousStep();
       }
-      return router.transitionTo('step1');
     },
     next: function (router) {
       var addServiceController = router.get('addServiceController');
diff --git a/ambari-web/app/routes/installer.js 
b/ambari-web/app/routes/installer.js
index 2efc47b..fe49015 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -425,14 +425,14 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
       var step = router.get('installerController.content.skipSlavesStep') ? 
'step5' : 'step6';
       var wizardStep7Controller = router.get('wizardStep7Controller');
 
-      var goToNextStep = function() {
+      var goToPreviousStep = function() {
         router.transitionTo(step);
       };
 
       if (wizardStep7Controller.hasChanges()) {
-        wizardStep7Controller.showChangesWarningPopup(goToNextStep);
+        wizardStep7Controller.showChangesWarningPopup(goToPreviousStep);
       } else {
-        goToNextStep();
+        goToPreviousStep();
       }
       console.timeEnd('step7 back');
     },
diff --git a/ambari-web/app/views/wizard/step7/directories_tab_view.js 
b/ambari-web/app/views/wizard/step7/directories_tab_view.js
index 5e50469..8353bf0 100644
--- a/ambari-web/app/views/wizard/step7/directories_tab_view.js
+++ b/ambari-web/app/views/wizard/step7/directories_tab_view.js
@@ -29,6 +29,7 @@ App.DirectoriesTabOnStep7View = Em.View.extend({
     var services = [];
     var directoriesTabs = App.Tab.find().filterProperty('themeName', 
'directories');
     var stepConfigs = this.get('controller.stepConfigs');
+    var lastSelectedService = 
this.get('controller.tabs').findProperty('isActive').get('selectedServiceName')
     stepConfigs.forEach(function (stepConfig) {
       var tab = directoriesTabs.findProperty('serviceName', 
stepConfig.get('serviceName'));
       if (tab) {
@@ -37,7 +38,11 @@ App.DirectoriesTabOnStep7View = Em.View.extend({
     });
     this.set('services', services);
     this.get('services').setEach('isActive', false);
-    this.set('controller.selectedService', stepConfigs[0]);
+    if (lastSelectedService) {
+      this.set('controller.selectedService', 
stepConfigs.findProperty('serviceName', lastSelectedService));
+    } else {
+      this.set('controller.selectedService', stepConfigs[0]);
+    }
     this.get('controller').selectedServiceObserver();
   }.observes('controller.stepConfigs'),
 
@@ -47,6 +52,7 @@ App.DirectoriesTabOnStep7View = Em.View.extend({
     this.get('services').setEach('isActive', false);
     event.context.set('isActive', true);
     this.set('controller.selectedService', 
this.get('controller.stepConfigs').findProperty('serviceName', 
event.context.get('serviceName')));
+    this.get('controller.tabs').findProperty('isActive', 
true).set('selectedServiceName', event.context.get('serviceName'));
   },
 
   didInsertElement: function () {
diff --git a/ambari-web/app/views/wizard/step7_view.js 
b/ambari-web/app/views/wizard/step7_view.js
index af0c8a9..fb6fe4e 100644
--- a/ambari-web/app/views/wizard/step7_view.js
+++ b/ambari-web/app/views/wizard/step7_view.js
@@ -34,6 +34,7 @@ App.WizardStep7View = Em.View.extend({
 
   willDestroyElement: function () {
     this.get('controller').clearStep();
+    this.get('controller').clearLastSelectedService();
   },
 
   /**
diff --git a/ambari-web/test/controllers/wizard/step7_test.js 
b/ambari-web/test/controllers/wizard/step7_test.js
index 1071534..302d8de 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -801,6 +801,9 @@ describe('App.InstallerStep7Controller', function () {
             {selected: true, name: 'n2'},
             {selected: true, name: 'n3'}
           ],
+          tabs: [
+            Em.Object.create({isActive: true, selectedServiceName: null})
+          ],
           e: 'n2'
         },
         {
@@ -810,7 +813,34 @@ describe('App.InstallerStep7Controller', function () {
             {showConfig: false, name: 'n2'},
             {showConfig: true, name: 'n3'}
           ],
+          tabs: [
+            Em.Object.create({isActive: true, selectedServiceName: null})
+          ],
           e: 'n3'
+        },
+        {
+          name: 'addServiceController',
+          stepConfigs: [
+            {selected: true, name: 'n1'},
+            {selected: true, name: 'n2'},
+            {selected: true, name: 'n3'}
+          ],
+          tabs: [
+            Em.Object.create({isActive: true, selectedServiceName: 'n1'})
+          ],
+          e: 'n1'
+        },
+        {
+          name: 'installerController',
+          stepConfigs: [
+            {showConfig: true, name: 'n1'},
+            {showConfig: false, name: 'n2'},
+            {showConfig: true, name: 'n3'}
+          ],
+          tabs: [
+            Em.Object.create({isActive: true, selectedServiceName: 'n1'})
+          ],
+          e: 'n1'
         }
       ]).forEach(function (test) {
         describe(test.name, function () {
@@ -821,7 +851,8 @@ describe('App.InstallerStep7Controller', function () {
               wizardController: Em.Object.create({
                 name: test.name
               }),
-              stepConfigs: test.stepConfigs
+              stepConfigs: test.stepConfigs,
+              tabs: test.tabs
             });
             installerStep7Controller.selectProperService();
           });

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to