Repository: ambari Updated Branches: refs/heads/trunk e65996f94 -> 8f8582bb8
AMBARI-19447 Handle cancelling of add/delete component by user. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8f8582bb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8f8582bb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8f8582bb Branch: refs/heads/trunk Commit: 8f8582bb81b18e703c83b7f634ee489fab8f1f71 Parents: e65996f Author: ababiichuk <[email protected]> Authored: Tue Jan 10 19:13:32 2017 +0200 Committer: ababiichuk <[email protected]> Committed: Tue Jan 10 20:52:20 2017 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 25 ++++++++---- .../test/controllers/main/host/details_test.js | 40 +++++++++++++++++++- 2 files changed, 57 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8f8582bb/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index e2a2d8e..1fcc14d 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -22,7 +22,7 @@ var hostsManagement = require('utils/hosts'); var stringUtils = require('utils/string_utils'); require('utils/configs/add_component_config_initializer'); -App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDownload, App.InstallComponent, App.InstallNewVersion, App.CheckHostMixin, { +App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDownload, App.InstallComponent, App.InstallNewVersion, App.CheckHostMixin, App.TrackRequestMixin, { name: 'mainHostDetailsController', @@ -194,6 +194,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow clearConfigsChanges: function () { var arrayNames = ['allPropertiesToChange', 'recommendedPropertiesToChange', 'requiredPropertiesToChange', 'groupedPropertiesToChange']; + this.abortRequests(); arrayNames.forEach(function (arrayName) { this.get(arrayName).clear(); }, this); @@ -462,6 +463,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow if (componentsMapItem.deletePropertyName) { this.set(componentsMapItem.deletePropertyName, true); } + this.clearConfigsChanges(); this.set('isReconfigureRequired', true); returnFunc = this.showDeleteComponentPopup(component, componentsMapItem.configsCallbackName); } else if (componentName === 'JOURNALNODE') { @@ -738,6 +740,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow this.set(componentsMapItem.addPropertyName, false); }; } + this.clearConfigsChanges(); this.set('isReconfigureRequired', true); returnFunc = self.showAddComponentPopup(component, hostName, null, componentsMapItem.configsCallbackName, primary); } else if (componentName === 'JOURNALNODE') { @@ -870,7 +873,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method loadStormConfigs */ loadStormConfigs: function (data) { - App.ajax.send({ + var request = App.ajax.send({ name: 'admin.get.all_configurations', sender: this, data: { @@ -878,6 +881,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow }, success: 'onLoadStormConfigs' }); + this.trackRequest(request); }, /** @@ -1014,7 +1018,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method loadWebHCatConfigs */ loadWebHCatConfigs: function (data) { - return App.ajax.send({ + var request = App.ajax.send({ name: 'admin.get.all_configurations', sender: this, data: { @@ -1028,6 +1032,8 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow }, success: 'onLoadHiveConfigs' }); + this.trackRequest(request); + return request; }, /** @@ -1038,7 +1044,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method loadHiveConfigs */ loadHiveConfigs: function (data) { - return App.ajax.send({ + var request = App.ajax.send({ name: 'admin.get.all_configurations', sender: this, data: { @@ -1051,6 +1057,8 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow }, success: 'onLoadHiveConfigs' }); + this.trackRequest(request); + return request; }, /** @@ -1270,7 +1278,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method loadRangerConfigs */ loadRangerConfigs: function (data) { - App.ajax.send({ + var request = App.ajax.send({ name: 'admin.get.all_configurations', sender: this, data: { @@ -1278,6 +1286,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow }, success: 'onLoadRangerConfigs' }); + this.trackRequest(request); }, /** @@ -1445,12 +1454,13 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method loadConfigs */ loadConfigs: function (callback) { - App.ajax.send({ + var request = App.ajax.send({ name: 'config.tags', sender: this, success: callback ? callback : 'loadConfigsSuccessCallback', error: 'onLoadConfigsErrorCallback' }); + this.trackRequest(request); }, /** @@ -1469,7 +1479,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow loadConfigsSuccessCallback: function (data) { var urlParams = this.constructConfigUrlParams(data); if (urlParams.length > 0) { - App.ajax.send({ + var request = App.ajax.send({ name: 'reassign.load_configs', sender: this, data: { @@ -1477,6 +1487,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow }, success: 'saveZkConfigs' }); + this.trackRequest(request); return true; } return false; http://git-wip-us.apache.org/repos/asf/ambari/blob/8f8582bb/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index f047f15..ff5887c 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -525,6 +525,7 @@ describe('App.MainHostDetailsController', function () { beforeEach(function () { sinon.stub(controller, "checkComponentDependencies", Em.K); sinon.stub(controller, "showAddComponentPopup", Em.K); + sinon.stub(controller, "clearConfigsChanges", Em.K); sinon.stub(App, "showConfirmationPopup", Em.K); controller.set('content', { hostComponents: [Em.Object.create({ @@ -536,6 +537,7 @@ describe('App.MainHostDetailsController', function () { afterEach(function () { controller.checkComponentDependencies.restore(); controller.showAddComponentPopup.restore(); + controller.clearConfigsChanges.restore(); App.showConfirmationPopup.restore(); }); @@ -618,7 +620,7 @@ describe('App.MainHostDetailsController', function () { sinon.stub(controller, 'updateZkConfigs', Em.K); sinon.stub(controller, 'saveConfigsBatch', Em.K); controller.set('nimbusHost', 'host2'); - controller.onLoadStormConfigs(data, null, {}); + controller.onLoadStormConfigs(data); }); afterEach(function () { controller.getStormNimbusHosts.restore(); @@ -3948,4 +3950,40 @@ describe('App.MainHostDetailsController', function () { }); }); + + describe('#clearConfigsChanges', function () { + + beforeEach(function () { + sinon.stub(controller, 'abortRequests', Em.K); + controller.setProperties({ + allPropertiesToChange: [{}], + recommendedPropertiesToChange: [{}], + requiredPropertiesToChange: [{}], + groupedPropertiesToChange: [{}], + isReconfigureRequired: true + }); + controller.clearConfigsChanges(); + }); + + afterEach(function () { + controller.abortRequests.restore(); + }); + + it('allPropertiesToChange', function () { + expect(controller.get('allPropertiesToChange')).to.have.length(0); + }); + + it('recommendedPropertiesToChange', function () { + expect(controller.get('recommendedPropertiesToChange')).to.have.length(0); + }); + + it('groupedPropertiesToChange', function () { + expect(controller.get('groupedPropertiesToChange')).to.have.length(0); + }); + + it('isReconfigureRequired', function () { + expect(controller.get('isReconfigureRequired')).to.be.false; + }); + + }); });
