Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 99f923889 -> aa1bc2f9e


Revert "AMBARI-20255 Sometimes the Hosts page shows a different page for page 
1. (atkach)"

This reverts commit 106f62269ae1cb1f4d8a131c261af6353d4a920b.


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

Branch: refs/heads/branch-2.5
Commit: aa1bc2f9e0d3b5131e6e28d7570525bd175d2c70
Parents: 99f9238
Author: Jaimin Jetly <[email protected]>
Authored: Fri Mar 3 15:49:53 2017 -0800
Committer: Jaimin Jetly <[email protected]>
Committed: Fri Mar 3 15:49:53 2017 -0800

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js |  3 +--
 ambari-web/app/controllers/main/host.js         | 25 +++++++++----------
 .../mixins/common/table_server_view_mixin.js    |  2 --
 ambari-web/app/views/common/table_view.js       |  8 ------
 ambari-web/app/views/main/host.js               |  8 ++----
 .../common/table_server_view_mixin_test.js      | 17 -------------
 ambari-web/test/views/common/table_view_test.js | 26 +-------------------
 ambari-web/test/views/main/host_test.js         |  6 -----
 8 files changed, 15 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js 
b/ambari-web/app/controllers/global/update_controller.js
index e53f79d..7b8a80e 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -244,8 +244,7 @@ App.UpdateController = Em.Controller.extend({
           {
             key: 'Hosts/host_name',
             value: [hostDetailsFilter],
-            type: 'MULTIPLE',
-            isHostDetails: true
+            type: 'MULTIPLE'
           }
         ]);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js 
b/ambari-web/app/controllers/main/host.js
index 05551af..336bd25 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -312,20 +312,17 @@ App.MainHostController = 
Em.ArrayController.extend(App.TableServerMixin, {
       }
     }, this);
 
-    if (!oldProperties.findProperty('isHostDetails')) {
-      // shouldn't reset start index after coming back from Host Details page
-      if (queryParams.filterProperty('isFilter').length !== 
oldProperties.filterProperty('isFilter').length) {
-        queryParams.findProperty('key', 'from').value = 0;
-        this.set('resetStartIndex', true);
-      } else {
-        queryParams.filterProperty('isFilter').forEach(function (queryParam) {
-          var oldProperty = 
oldProperties.filterProperty('isFilter').findProperty('key', queryParam.key);
-          if (!oldProperty || JSON.stringify(oldProperty.value) !== 
JSON.stringify(queryParam.value)) {
-            queryParams.findProperty('key', 'from').value = 0;
-            this.set('resetStartIndex', true);
-          }
-        }, this);
-      }
+    if (queryParams.filterProperty('isFilter').length !== 
oldProperties.filterProperty('isFilter').length) {
+      queryParams.findProperty('key', 'from').value = 0;
+      this.set('resetStartIndex', true);
+    } else {
+      queryParams.filterProperty('isFilter').forEach(function (queryParam) {
+        var oldProperty = 
oldProperties.filterProperty('isFilter').findProperty('key', queryParam.key);
+        if (!oldProperty || JSON.stringify(oldProperty.value) !== 
JSON.stringify(queryParam.value)) {
+          queryParams.findProperty('key', 'from').value = 0;
+          this.set('resetStartIndex', true);
+        }
+      }, this);
     }
 
     if (!skipNonFilterProperties) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/app/mixins/common/table_server_view_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_view_mixin.js 
b/ambari-web/app/mixins/common/table_server_view_mixin.js
index ae949d0..4e982d7 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -157,8 +157,6 @@ App.TableServerViewMixin = Em.Mixin.create({
   resetStartIndex: function () {
     if (this.get('controller.resetStartIndex') && this.get('filteredCount') > 
0) {
       this.set('startIndex', 1);
-      this.saveStartIndex();
-      this.updatePagination('SKIP_REFRESH');
     }
   }.observes('controller.resetStartIndex')
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js 
b/ambari-web/app/views/common/table_view.js
index 4cc266d..b8d4380 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -414,14 +414,6 @@ App.TableView = Em.View.extend(App.UserPref, {
     return result;
   },
 
-  clearStartIndex: function() {
-    if (this.get('controller.startIndex') !== 1) {
-      this.set('controller.resetStartIndex', true);
-      return true;
-    }
-    return false;
-  },
-
   /**
    * Contain filter conditions for each column
    * @type {Array}

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js 
b/ambari-web/app/views/main/host.js
index 52692cc..a7cdb29 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -170,10 +170,8 @@ App.MainHostView = 
App.TableView.extend(App.TableServerViewMixin, {
    */
   willInsertElement: function () {
     if (!this.get('controller.showFilterConditionsFirstLoad')) {
-      // filters and start index should be cleared when we enter Hosts page
-      var didClearedFilters = this.clearFilterConditionsFromLocalStorage();
-      var didClearStartIndex = this.clearStartIndex();
-      this.set('controller.filterChangeHappened', didClearedFilters || 
didClearStartIndex);
+      var didClearedSomething = this.clearFilterConditionsFromLocalStorage();
+      this.set('controller.filterChangeHappened', didClearedSomething);
     }
     this._super();
     this.set('startIndex', this.get('controller.startIndex'));
@@ -196,8 +194,6 @@ App.MainHostView = 
App.TableView.extend(App.TableServerViewMixin, {
     this.addObserver('startIndex', this, 'updatePagination');
     this.addObserver('displayLength', this, 'updatePagination');
     this.addObserver('filteredCount', this, this.updatePaging);
-    // should show overlay even when filtering has begun before observer was 
added
-    this.overlayObserver();
   },
 
   willDestroyElement: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/test/mixins/common/table_server_view_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/table_server_view_mixin_test.js 
b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
index e5b6f08..2a9c409 100644
--- a/ambari-web/test/mixins/common/table_server_view_mixin_test.js
+++ b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
@@ -28,7 +28,6 @@ describe('App.MainConfigHistoryView', function() {
     filteredContent: [],
     refresh: Em.K,
     saveFilterConditions: Em.K,
-    saveStartIndex: sinon.spy(),
     controller: Em.Object.create({
       name: 'mainConfigHistoryController',
       paginationProps: [
@@ -184,14 +183,12 @@ describe('App.MainConfigHistoryView', function() {
     beforeEach(function () {
       sinon.stub(view, 'saveFilterConditions', Em.K);
       sinon.stub(view, 'refresh', Em.K);
-      sinon.stub(view, 'resetStartIndex');
       sinon.spy(view, 'updateFilter');
       this.clock = sinon.useFakeTimers();
     });
     afterEach(function () {
       view.saveFilterConditions.restore();
       view.updateFilter.restore();
-      view.resetStartIndex.restore();
       view.refresh.restore();
       this.clock.restore();
     });
@@ -234,20 +231,12 @@ describe('App.MainConfigHistoryView', function() {
   });
 
   describe('#resetStartIndex()', function() {
-    beforeEach(function () {
-      sinon.stub(view, 'updatePagination');
-    });
-    afterEach(function () {
-      view.updatePagination.restore();
-    });
     it('resetStartIndex is false and filteredCount is 0', function() {
       view.set('filteredCount', 0);
       view.set('controller.resetStartIndex', false);
       view.set('startIndex', 0);
       view.resetStartIndex();
       expect(view.get('startIndex')).to.equal(0);
-      expect(view.saveStartIndex.called).to.be.false;
-      expect(view.updatePagination.called).to.be.false;
     });
     it('resetStartIndex is true and filteredCount is 0', function() {
       view.set('filteredCount', 0);
@@ -255,8 +244,6 @@ describe('App.MainConfigHistoryView', function() {
       view.set('startIndex', 0);
       view.resetStartIndex();
       expect(view.get('startIndex')).to.equal(0);
-      expect(view.saveStartIndex.called).to.be.false;
-      expect(view.updatePagination.called).to.be.false;
     });
     it('resetStartIndex is false and filteredCount is 5', function() {
       view.set('filteredCount', 5);
@@ -264,8 +251,6 @@ describe('App.MainConfigHistoryView', function() {
       view.set('startIndex', 0);
       view.resetStartIndex();
       expect(view.get('startIndex')).to.equal(0);
-      expect(view.saveStartIndex.called).to.be.false;
-      expect(view.updatePagination.called).to.be.false;
     });
     it('resetStartIndex is true and filteredCount is 5', function() {
       view.set('controller.resetStartIndex', true);
@@ -273,8 +258,6 @@ describe('App.MainConfigHistoryView', function() {
       view.set('startIndex', 0);
       view.resetStartIndex();
       expect(view.get('startIndex')).to.equal(1);
-      expect(view.saveStartIndex.called).to.be.true;
-      expect(view.updatePagination.called).to.be.true;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/test/views/common/table_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/table_view_test.js 
b/ambari-web/test/views/common/table_view_test.js
index dd289b0..37dd911 100644
--- a/ambari-web/test/views/common/table_view_test.js
+++ b/ambari-web/test/views/common/table_view_test.js
@@ -25,9 +25,7 @@ require('mixins/common/userPref');
 require('views/common/table_view');
 
 function getView() {
-  return App.TableView.create({
-    controller: Em.Object.create()
-  });
+  return App.TableView.create();
 }
 
 describe('App.TableView', function () {
@@ -395,26 +393,4 @@ describe('App.TableView', function () {
 
   });
 
-  describe('#clearStartIndex', function() {
-    var view;
-
-    beforeEach(function() {
-      view = getView();
-    });
-
-    it('should reset start index', function() {
-      view.set('controller.resetStartIndex', false);
-      view.set('controller.startIndex', 11);
-      expect(view.clearStartIndex()).to.be.true;
-      expect(view.get('controller.resetStartIndex')).to.be.true;
-    });
-
-    it('should not reset start index', function() {
-      view.set('controller.resetStartIndex', false);
-      view.set('controller.startIndex', 1);
-      expect(view.clearStartIndex()).to.be.false;
-      expect(view.get('controller.resetStartIndex')).to.be.false;
-    });
-  });
-
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa1bc2f9/ambari-web/test/views/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host_test.js 
b/ambari-web/test/views/main/host_test.js
index 7978fea..6bb3462 100644
--- a/ambari-web/test/views/main/host_test.js
+++ b/ambari-web/test/views/main/host_test.js
@@ -66,14 +66,12 @@ describe('App.MainHostView', function () {
       cases.forEach(function (item) {
         sinon.stub(view, item.methodName, Em.K);
       });
-      sinon.stub(view, 'overlayObserver');
     });
 
     afterEach(function () {
       cases.forEach(function (item) {
         view[item.methodName].restore();
       });
-      view.overlayObserver.restore();
     });
 
     cases.forEach(function (item) {
@@ -84,10 +82,6 @@ describe('App.MainHostView', function () {
       });
     });
 
-    it('overlayObserver should be called', function () {
-      view.didInsertElement();
-      expect(view.overlayObserver.calledOnce).to.be.true;
-    });
   });
 
   describe('#HostView', function () {

Reply via email to