Просмотр исходного кода

AMBARI-16183. Metrics widgets update is invoked after Cancel action in Custom time range popup (alexantonenko)

Alex Antonenko 9 лет назад
Родитель
Сommit
ce279f7d8f

+ 2 - 1
ambari-web/app/mixins/common/widgets/time_range_mixin.js

@@ -101,6 +101,7 @@ App.TimeRangeMixin = Em.Mixin.create({
         if (callback) {
           callback();
         }
+        this.set('currentTimeRangeIndex', index);
         this.setProperties(timeRange);
         if (context) {
           context.setProperties(timeRange);
@@ -141,13 +142,13 @@ App.TimeRangeMixin = Em.Mixin.create({
     } else {
       // Preset time range is specified by user
       this.setProperties({
+        currentTimeRangeIndex: index,
         customStartTime: null,
         customEndTime: null,
         customDurationFormatted: null
       });
     }
 
-    this.set('currentTimeRangeIndex', index);
   },
 
   timeRangeListView: App.TimeRangeListView.extend()

+ 8 - 2
ambari-web/test/mixins/common/widgets/time_range_mixin_test.js

@@ -49,12 +49,14 @@ describe('App.TimeRangeMixin', function () {
     var indexCases = [
         {
           index: 1,
+          currentTimeRangeIndex: 1,
           showCustomDatePopupCallCount: 0,
           title: 'preset time range',
           popupTestTitle: 'popup should not be displayed'
         },
         {
           index: 8,
+          currentTimeRangeIndex: 0,
           showCustomDatePopupCallCount: 1,
           title: 'custom time range',
           popupTestTitle: 'popup should be displayed'
@@ -63,6 +65,7 @@ describe('App.TimeRangeMixin', function () {
       rangeCases = [
         {
           index: 1,
+          currentTimeRangeIndex: 1,
           customStartTime: null,
           customEndTime: null,
           customDurationFormatted: null,
@@ -71,6 +74,7 @@ describe('App.TimeRangeMixin', function () {
         },
         {
           index: 8,
+          currentTimeRangeIndex: 0,
           customStartTime: 1,
           customEndTime: 1,
           customDurationFormatted: '1 hour',
@@ -80,6 +84,7 @@ describe('App.TimeRangeMixin', function () {
       ];
 
     beforeEach(function () {
+      obj.set('currentTimeRangeIndex', 0);
       sinon.stub(timeRangePopup, 'showCustomDatePopup', Em.K);
     });
 
@@ -100,7 +105,7 @@ describe('App.TimeRangeMixin', function () {
         });
 
         it('should set time range', function () {
-          expect(obj.get('currentTimeRangeIndex')).to.equal(item.index);
+          expect(obj.get('currentTimeRangeIndex')).to.equal(item.currentTimeRangeIndex);
         });
 
         it(item.popupTestTitle, function () {
@@ -129,7 +134,8 @@ describe('App.TimeRangeMixin', function () {
         });
 
         it(item.testTitle, function () {
-          expect(obj.getProperties(['customStartTime', 'customEndTime', 'customDurationFormatted'])).to.eql({
+          expect(obj.getProperties(['currentTimeRangeIndex', 'customStartTime', 'customEndTime', 'customDurationFormatted'])).to.eql({
+            currentTimeRangeIndex: item.currentTimeRangeIndex,
             customStartTime: item.customStartTime,
             customEndTime: item.customEndTime,
             customDurationFormatted: item.customDurationFormatted