You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/12/09 01:40:24 UTC
ambari git commit: AMBARI-14279. Add Service Wizard: Ranger
requirements popup is displayed twice when adding Ranger Service. (jaimin)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 b1149fa7e -> 6054d79b9
AMBARI-14279. Add Service Wizard: Ranger requirements popup is displayed twice when adding Ranger Service. (jaimin)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6054d79b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6054d79b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6054d79b
Branch: refs/heads/branch-2.2
Commit: 6054d79b9e0808fbc17f904b1e0dc7f095fdcf73
Parents: b1149fa
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Tue Dec 8 16:38:27 2015 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Tue Dec 8 16:38:27 2015 -0800
----------------------------------------------------------------------
.../app/controllers/wizard/step4_controller.js | 129 ++++++++++++++-----
.../test/controllers/wizard/step4_test.js | 20 ++-
2 files changed, 116 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6054d79b/ambari-web/app/controllers/wizard/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step4_controller.js b/ambari-web/app/controllers/wizard/step4_controller.js
index 4eefbcf..2fef3d3 100644
--- a/ambari-web/app/controllers/wizard/step4_controller.js
+++ b/ambari-web/app/controllers/wizard/step4_controller.js
@@ -83,46 +83,52 @@ App.WizardStep4Controller = Em.ArrayController.extend({
/**
* Check whether user selected Ambari Metrics service to install and go to next step
+ * @param callback {function}
* @method ambariMetricsValidation
*/
- ambariMetricsValidation: function () {
+ ambariMetricsValidation: function (callback) {
var ambariMetricsService = this.findProperty('serviceName', 'AMBARI_METRICS');
if (ambariMetricsService && !ambariMetricsService.get('isSelected')) {
this.addValidationError({
id: 'ambariMetricsCheck',
type: 'WARNING',
- callback: this.ambariMetricsCheckPopup
+ callback: this.ambariMetricsCheckPopup,
+ callbackParams: [callback]
});
}
},
/**
* Check whether Ranger is selected and show installation requirements if yes
+ * @param {function} callback
* @method rangerValidation
*/
- rangerValidation: function () {
+ rangerValidation: function (callback) {
var rangerService = this.findProperty('serviceName', 'RANGER');
if (rangerService && rangerService.get('isSelected') && !rangerService.get('isInstalled')) {
this.addValidationError({
id: 'rangerRequirements',
type: 'WARNING',
- callback: this.rangerRequirementsPopup
+ callback: this.rangerRequirementsPopup,
+ callbackParams: [callback]
});
}
},
/**
* Warn user if he tries to install Spark with HDP 2.2
+ * @param {function} callback
* @method sparkValidation
*/
- sparkValidation: function () {
+ sparkValidation: function (callback) {
var sparkService = this.findProperty('serviceName', 'SPARK');
if (sparkService && sparkService.get('isSelected') && !sparkService.get('isInstalled') &&
App.get('currentStackName') == 'HDP' && App.get('currentStackVersionNumber') == '2.2') {
this.addValidationError({
id: 'sparkWarning',
type: 'WARNING',
- callback: this.sparkWarningPopup
+ callback: this.sparkWarningPopup,
+ callbackParams: [callback]
});
}
},
@@ -136,6 +142,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({
this.unSelectServices();
this.setGroupedServices();
if (this.validate()) {
+ this.set('isValidating', false);
this.set('errorStack', []);
App.router.send('next');
}
@@ -160,21 +167,26 @@ App.WizardStep4Controller = Em.ArrayController.extend({
**/
validate: function() {
var result;
+ var self = this;
+ // callback function to reset `isValidating` needs to be called everytime when a popup from errorStack is dismissed/proceed by user action
+ var callback = function() {
+ self.set('isValidating', false);
+ };
this.set('isValidating', true);
- this.serviceDependencyValidation();
- this.fileSystemServiceValidation();
+ this.serviceDependencyValidation(callback);
+ this.fileSystemServiceValidation(callback);
if (this.get('wizardController.name') == 'installerController') {
- this.ambariMetricsValidation();
+ this.ambariMetricsValidation(callback);
}
- this.rangerValidation();
- this.sparkValidation();
+ this.rangerValidation(callback);
+ this.sparkValidation(callback);
if (!!this.get('errorStack').filterProperty('isShown', false).length) {
- this.showError(this.get('errorStack').findProperty('isShown', false));
+ var firstError = this.get('errorStack').findProperty('isShown', false);
+ this.showError(firstError);
result = false;
} else {
result = true;
}
- this.set('isValidating', false);
return result;
},
@@ -209,11 +221,16 @@ App.WizardStep4Controller = Em.ArrayController.extend({
* Change isShown state for last shown error.
* Call #submit() method.
*
+ * @param {function} callback
* @method onPrimaryPopupCallback
**/
- onPrimaryPopupCallback: function() {
- if (this.get('errorStack').someProperty('isShown', false)) {
- this.get('errorStack').findProperty('isShown', false).isShown = true;
+ onPrimaryPopupCallback: function(callback) {
+ var firstError = this.get('errorStack').findProperty('isShown', false);
+ if (firstError) {
+ firstError.isShown = true;
+ }
+ if (callback) {
+ callback();
}
this.submit();
},
@@ -271,10 +288,10 @@ App.WizardStep4Controller = Em.ArrayController.extend({
/**
* Checks if a filesystem is selected and only one filesystem is selected
- *
+ * @param {function} callback
* @method isFileSystemCheckFailed
*/
- fileSystemServiceValidation: function() {
+ fileSystemServiceValidation: function(callback) {
if(this.isDFSStack()){
var primaryDFS = this.findProperty('isPrimaryDFS',true);
var primaryDfsDisplayName = primaryDFS.get('displayNameOnSelectServicePage');
@@ -290,7 +307,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({
this.addValidationError({
id: 'multipleDFS',
callback: this.needToAddServicePopup,
- callbackParams: [services, 'multipleDFS', primaryDfsDisplayName]
+ callbackParams: [services, 'multipleDFS', primaryDfsDisplayName, callback]
});
}
}
@@ -298,10 +315,10 @@ App.WizardStep4Controller = Em.ArrayController.extend({
/**
* Checks if a dependent service is selected without selecting the main service.
- *
+ * @param {function} callback
* @method serviceDependencyValidation
*/
- serviceDependencyValidation: function() {
+ serviceDependencyValidation: function(callback) {
var selectedServices = this.filterProperty('isSelected',true);
var missingDependencies = [];
var missingDependenciesDisplayName = [];
@@ -325,7 +342,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({
this.addValidationError({
id: 'serviceCheck_' + missingDependencies[i],
callback: this.needToAddServicePopup,
- callbackParams: [{serviceName: missingDependencies[i], selected: true}, 'serviceCheck', missingDependenciesDisplayName[i]]
+ callbackParams: [{serviceName: missingDependencies[i], selected: true}, 'serviceCheck', missingDependenciesDisplayName[i], callback]
});
}
}
@@ -362,11 +379,12 @@ App.WizardStep4Controller = Em.ArrayController.extend({
* </code>
* @param {string} i18nSuffix
* @param {string} serviceName
+ * @param {function} callback
* @return {App.ModalPopup}
* @method needToAddServicePopup
*/
- needToAddServicePopup: function(services, i18nSuffix, serviceName) {
+ needToAddServicePopup: function(services, i18nSuffix, serviceName, callback) {
if (!(services instanceof Array)) {
services = [services];
}
@@ -378,36 +396,62 @@ App.WizardStep4Controller = Em.ArrayController.extend({
services.forEach(function (service) {
self.findProperty('serviceName', service.serviceName).set('isSelected', service.selected);
});
- self.onPrimaryPopupCallback();
+ self.onPrimaryPopupCallback(callback);
this.hide();
+ },
+ onSecondary: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
+ },
+ onClose: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
}
});
},
/**
* Show popup with info about not selected Ambari Metrics service
+ * @param {function} callback
* @return {App.ModalPopup}
* @method ambariMetricsCheckPopup
*/
- ambariMetricsCheckPopup: function () {
+ ambariMetricsCheckPopup: function (callback) {
var self = this;
return App.ModalPopup.show({
header: Em.I18n.t('installer.step4.ambariMetricsCheck.popup.header'),
body: Em.I18n.t('installer.step4.ambariMetricsCheck.popup.body'),
primary: Em.I18n.t('common.proceedAnyway'),
onPrimary: function () {
- self.onPrimaryPopupCallback();
+ self.onPrimaryPopupCallback(callback);
this.hide();
+ },
+ onSecondary: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
+ },
+ onClose: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
}
});
},
/**
* Show popup with installation requirements for Ranger service
+ * @param {function} callback
* @return {App.ModalPopup}
* @method rangerRequirementsPopup
*/
- rangerRequirementsPopup: function () {
+ rangerRequirementsPopup: function (callback) {
var self = this;
return App.ModalPopup.show({
header: Em.I18n.t('installer.step4.rangerRequirements.popup.header'),
@@ -420,26 +464,51 @@ App.WizardStep4Controller = Em.ArrayController.extend({
return !this.get('isChecked');
}.property('isChecked'),
onPrimary: function () {
- self.onPrimaryPopupCallback();
+ self.onPrimaryPopupCallback(callback);
this.hide();
+ },
+ onSecondary: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
+ },
+ onClose: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
}
});
},
/**
* Show popup with Spark installation warning
+ * @param {function} callback
* @return {App.ModalPopup}
* @method sparkWarningPopup
*/
- sparkWarningPopup: function () {
+ sparkWarningPopup: function (callback) {
var self = this;
return App.ModalPopup.show({
header: Em.I18n.t('common.warning'),
body: Em.I18n.t('installer.step4.sparkWarning.popup.body'),
primary: Em.I18n.t('common.proceed'),
onPrimary: function () {
- self.onPrimaryPopupCallback();
+ self.onPrimaryPopupCallback(callback);
this.hide();
+ },
+ onSecondary: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
+ },
+ onClose: function () {
+ if (callback) {
+ callback();
+ }
+ this._super();
}
});
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6054d79b/ambari-web/test/controllers/wizard/step4_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step4_test.js b/ambari-web/test/controllers/wizard/step4_test.js
index 1327a44..bd38bc3 100644
--- a/ambari-web/test/controllers/wizard/step4_test.js
+++ b/ambari-web/test/controllers/wizard/step4_test.js
@@ -338,6 +338,7 @@ describe('App.WizardStep4Controller', function () {
it(message, function() {
controller.setProperties({
content: generateSelectedServicesContent(test.services),
+ errorStack: [],
wizardController: Em.Object.create({
name: name
})
@@ -352,6 +353,7 @@ describe('App.WizardStep4Controller', function () {
it(item.title, function () {
sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
+ controller.set('errorStack', []);
controller.set('content', generateSelectedServicesContent(['SPARK']));
controller.validate();
expect(controller.get('errorStack').someProperty('id', 'sparkWarning')).to.equal(item.sparkWarningExpected);
@@ -577,9 +579,13 @@ describe('App.WizardStep4Controller', function () {
}
];
+ beforeEach(function() {
+ controller.clear();
+ controller.set('errorStack', []);
+ });
+
cases.forEach(function (item) {
it(item.title, function () {
- controller.clear();
controller.set('content', generateSelectedServicesContent(item.services));
var ams = controller.findProperty('serviceName', 'AMBARI_METRICS');
if (item.services.contains('AMBARI_METRICS')) {
@@ -625,9 +631,13 @@ describe('App.WizardStep4Controller', function () {
}
];
+ beforeEach(function() {
+ controller.clear();
+ controller.set('errorStack', []);
+ });
+
cases.forEach(function (item) {
it(item.title, function () {
- controller.clear();
controller.set('content', generateSelectedServicesContent(item.services));
var ranger = controller.findProperty('serviceName', 'RANGER');
if (item.services.contains('RANGER')) {
@@ -752,6 +762,11 @@ describe('App.WizardStep4Controller', function () {
}
];
+ beforeEach(function() {
+ controller.clear();
+ controller.set('errorStack', []);
+ });
+
afterEach(function () {
App.get.restore();
});
@@ -760,7 +775,6 @@ describe('App.WizardStep4Controller', function () {
it(item.title, function () {
sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
- controller.clear();
controller.set('content', generateSelectedServicesContent(item.services));
var spark = controller.findProperty('serviceName', 'SPARK');
if (item.services.contains('SPARK')) {