diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-06-04 14:20:47 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-06-04 14:20:53 +0200 |
commit | 37a018029bb7382f293d20d81e03a2d5e716dfcd (patch) | |
tree | 929fcb9758136e803e9cb4811a7fb542a96f3b35 | |
parent | f5d7b41d9bb0a4e6db975cf4d3dc4bc7bb498339 (diff) | |
download | sonarqube-37a018029bb7382f293d20d81e03a2d5e716dfcd.tar.gz sonarqube-37a018029bb7382f293d20d81e03a2d5e716dfcd.zip |
SONAR-6595 show error message when activate a rule with a parameter is set to an erroneous value
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js | 32 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs | 2 |
2 files changed, 19 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 5381c6299bc..e12c4730469 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -18,30 +18,32 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ define([ - 'components/common/modals', + 'components/common/modal-form', '../templates' -], function (Modal) { +], function (ModalForm) { var $ = jQuery; - return Modal.extend({ + return ModalForm.extend({ template: Templates['coding-rules-profile-activation'], - ui: { - qualityProfileSelect: '#coding-rules-quality-profile-activation-select', - qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', - qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', - qualityProfileParameters: '[name]' + ui: function () { + return _.extend(this._super(), { + qualityProfileSelect: '#coding-rules-quality-profile-activation-select', + qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', + qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', + qualityProfileParameters: '[name]' + }); }, events: function () { - return _.extend(Modal.prototype.events.apply(this, arguments), { + return _.extend(this._super(), { 'click @ui.qualityProfileActivate': 'activate' }); }, onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); this.ui.qualityProfileSelect.select2({ width: '250px', @@ -93,7 +95,7 @@ define([ var severity = this.ui.qualityProfileSeverity.val(), ruleKey = this.options.rule.get('key'); - this.close(); + this.disableForm(); return jQuery.ajax({ type: 'POST', @@ -109,9 +111,11 @@ define([ 400: null } }).done(function () { + that.close(); that.trigger('profileActivated', severity, params); - }).fail(function () { - that.trigger('profileActivationFailed'); + }).fail(function (jqXHR) { + that.enableForm(); + that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); }, @@ -142,7 +146,7 @@ define([ var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); - return _.extend(Modal.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { change: this.model && this.model.has('severity'), params: params, qualityProfiles: availableProfiles, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs index 2b47036fd89..e7a7164d4c4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs @@ -8,7 +8,7 @@ </div> <div class="modal-body modal-body-select2"> - <div class="alert alert-danger"></div> + <div class="js-modal-messages"></div> {{#empty qualityProfiles}} {{#unless change}} |