Преглед изворни кода

AMBARI-11544. Edit Widget:Confirmation for shared widget pops up on clicking Next in Metric and Expression page.(XIWANG)

Xi Wang пре 10 година
родитељ
комит
01e9655cfb

+ 5 - 2
ambari-web/app/controllers/main/service/widgets/create/step3_controller.js

@@ -92,8 +92,11 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
     this.set('widgetDescription', this.get('content.widgetDescription'));
     this.set('isSharedChecked', this.get('content.widgetScope') == 'CLUSTER');
     // on editing, don't allow changing from shared scope to unshare
-    this.set('isSharedCheckboxDisabled', this.get('content.widgetScope') == 'CLUSTER' && this.get('isEditController'));
-    this.addObserver('isSharedChecked', this, this.showConfirmationOnSharing);
+    var isSharedCheckboxDisabled = ((this.get('content.widgetScope') == 'CLUSTER') && this.get('isEditController'));
+    this.set('isSharedCheckboxDisabled', isSharedCheckboxDisabled);
+    if (!isSharedCheckboxDisabled) {
+      this.addObserver('isSharedChecked', this, this.showConfirmationOnSharing);
+    }
   },
 
   /**

+ 2 - 1
ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js

@@ -94,7 +94,8 @@ describe('App.WidgetWizardStep3Controller', function () {
         controllerName: 'widgetEditController'
       }));
       controller.initPreviewData();
-      expect(controller.addObserver.calledWith('isSharedChecked')).to.be.true;
+      controller.get('isSharedCheckboxDisabled') ? expect(controller.addObserver.calledWith('isSharedChecked')).to.be.false:
+        expect(controller.addObserver.calledWith('isSharedChecked')).to.be.true;
       expect(controller.get('widgetProperties')).to.equal('widgetProperties');
       expect(controller.get('widgetValues')).to.equal('widgetValues');
       expect(controller.get('widgetMetrics')).to.equal('widgetMetrics');