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 2015/12/08 15:24:40 UTC

ambari git commit: AMBARI-14266 Smart config Tabs: UI should not automatically navigate to 1st tab when a configs is saved on a tab. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/trunk d925b2fa2 -> 94878ae09


AMBARI-14266 Smart config Tabs: UI should not automatically navigate to 1st tab when a configs is saved on a tab. (atkach)


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

Branch: refs/heads/trunk
Commit: 94878ae094111e8bbaf490fdf08edc016eb3b1ca
Parents: d925b2f
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Tue Dec 8 16:19:35 2015 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Tue Dec 8 16:19:35 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/models/configs/theme/tab.js      |  6 +++
 .../views/common/configs/service_config_view.js | 16 +++-----
 .../app/views/main/service/info/configs.js      |  8 ++++
 .../test/views/main/service/info/config_test.js | 39 +++++++++++++++++---
 4 files changed, 52 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/94878ae0/ambari-web/app/models/configs/theme/tab.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/theme/tab.js b/ambari-web/app/models/configs/theme/tab.js
index 3b3c6d2..ad3e6e4 100644
--- a/ambari-web/app/models/configs/theme/tab.js
+++ b/ambari-web/app/models/configs/theme/tab.js
@@ -31,6 +31,12 @@ App.Tab = DS.Model.extend({
   isRendered: DS.attr('boolean', {defaultValue: false}),
 
   /**
+   * @type {boolean}
+   * @default false
+   */
+  isActive: false,
+
+  /**
    * Determines if all <code>configs</code> were attached to tab.
    */
   isConfigsPrepared: DS.attr('boolean', {defaultValue: false}),

http://git-wip-us.apache.org/repos/asf/ambari/blob/94878ae0/ambari-web/app/views/common/configs/service_config_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_config_view.js b/ambari-web/app/views/common/configs/service_config_view.js
index 39d61e9..5b6f8ec 100644
--- a/ambari-web/app/views/common/configs/service_config_view.js
+++ b/ambari-web/app/views/common/configs/service_config_view.js
@@ -34,7 +34,7 @@ App.ServiceConfigView = Em.View.extend({
    * Determines that active tab is set during view initialize.
    * @type {boolean}
    */
-  initalActiveTabIsSet: false,
+  initialActiveTabIsSet: false,
 
   /**
    * Bound from parent view in the template
@@ -136,10 +136,6 @@ App.ServiceConfigView = Em.View.extend({
     this.checkCanEdit();
   },
 
-  willDestroyElement: function() {
-    this.get('tabs').setEach('isActive', false);
-  },
-
   /**
    * Check if we should show Custom Property category
    * @method checkCanEdit
@@ -161,7 +157,7 @@ App.ServiceConfigView = Em.View.extend({
 
   setActiveTab: function (event) {
     if (event.context.get('isHiddenByFilter')) return false;
-    this.set('initalActiveTabIsSet', true);
+    this.set('initialActiveTabIsSet', true);
     this.get('tabs').forEach(function (tab) {
       tab.set('isActive', false);
     });
@@ -180,10 +176,9 @@ App.ServiceConfigView = Em.View.extend({
       return Em.A([]);
     }
     var tabs = App.Tab.find().filterProperty('serviceName', this.get('controller.selectedService.serviceName'));
-    tabs.setEach('isActive', false);
     var advancedTab = tabs.findProperty('isAdvanced', true);
     if (advancedTab) {
-      advancedTab.set('isRendered', false);
+      advancedTab.set('isRendered', advancedTab.get('isActive'));
     }
     this.processTabs(tabs);
     return tabs;
@@ -194,10 +189,9 @@ App.ServiceConfigView = Em.View.extend({
    */
   initialActiveTabObserver: function() {
     var tabs = this.get('tabs').filterProperty('isAdvanced', false);
-    if (tabs.everyProperty('isConfigsPrepared', true) && !this.get('initalActiveTabIsSet')) {
-      this.get('tabs').setEach('isActive', false);
+    if (tabs.everyProperty('isConfigsPrepared', true) && !this.get('initialActiveTabIsSet')) {
       this.pickActiveTab(this.get('tabs'));
-      this.set('initalActiveTabIsSet', true);
+      this.set('initialActiveTabIsSet', true);
     }
   }.observes('tabs.@each.isConfigsPrepared'),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/94878ae0/ambari-web/app/views/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/configs.js b/ambari-web/app/views/main/service/info/configs.js
index 45faeaa..44c2455 100644
--- a/ambari-web/app/views/main/service/info/configs.js
+++ b/ambari-web/app/views/main/service/info/configs.js
@@ -28,6 +28,7 @@ App.MainServiceInfoConfigsView = Em.View.extend({
     App.router.get('mainController').isLoading.call(App.router.get('clusterController'), 'isConfigsPropertiesLoaded').done(function () {
       self.get('controller').loadStep();
     });
+    this.resetConfigTabSelection();
   },
 
   willDestroyElement: function() {
@@ -35,6 +36,13 @@ App.MainServiceInfoConfigsView = Em.View.extend({
   },
 
   /**
+   * reset selection flag of tabs on entering Configs page
+   */
+  resetConfigTabSelection: function() {
+    App.Tab.find().filterProperty('serviceName', this.get('controller.content.serviceName')).setEach('isActive', false);
+  },
+
+  /**
    * Number of components that should be restarted
    * @type {number}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/94878ae0/ambari-web/test/views/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/config_test.js b/ambari-web/test/views/main/service/info/config_test.js
index 583dfa5..4e369ea 100644
--- a/ambari-web/test/views/main/service/info/config_test.js
+++ b/ambari-web/test/views/main/service/info/config_test.js
@@ -20,13 +20,40 @@
 var App = require('app');
 require('views/main/service/info/configs');
 
-describe('App.MainServiceInfoConfigsView', function() {
+describe('App.MainServiceInfoConfigsView', function () {
 
-  var view = App.MainServiceInfoConfigsView.create({
-    controller: Em.Object.create()
+  var view;
+
+  beforeEach(function () {
+    view = App.MainServiceInfoConfigsView.create({
+      controller: Em.Object.create()
+    });
+  });
+
+  describe("#resetConfigTabSelection()", function () {
+    var tab = Em.Object.create({
+      serviceName: 'S1',
+      isActive: true
+    });
+
+    beforeEach(function () {
+      sinon.stub(App.Tab, 'find').returns([tab]);
+      sinon.stub(view, 'updateComponentInformation');
+    });
+
+    afterEach(function () {
+      App.Tab.find.restore();
+      view.updateComponentInformation.restore();
+    });
+
+    it("isActive should be false", function () {
+      view.set('controller.content', Em.Object.create({serviceName: 'S1'}));
+      view.resetConfigTabSelection();
+      expect(tab.get('isActive')).to.be.false;
+    });
   });
 
-  describe('#updateComponentInformation', function() {
+  describe('#updateComponentInformation', function () {
 
     var testCases = [
       {
@@ -64,8 +91,8 @@ describe('App.MainServiceInfoConfigsView', function() {
         }
       }
     ];
-    testCases.forEach(function(test) {
-      it(test.title, function() {
+    testCases.forEach(function (test) {
+      it(test.title, function () {
         view.set('controller.content', test.content);
         view.updateComponentInformation();
         expect(view.get('componentsCount')).to.equal(test.result.componentsCount);