diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 17:44:23 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 17:44:23 +0200 |
commit | f2e47675ce6516c502a5d531bd0ea3fbd9183747 (patch) | |
tree | 72ef26c3f7ac2668c4b17a216bc6ee44cf12f36b /server/sonar-web | |
parent | ffd1fc743ca5ffff409b5376b8d68b80114b8ab1 (diff) | |
download | sonarqube-f2e47675ce6516c502a5d531bd0ea3fbd9183747.tar.gz sonarqube-f2e47675ce6516c502a5d531bd0ea3fbd9183747.zip |
SONAR-6779 show a functional error in the select list component
Diffstat (limited to 'server/sonar-web')
-rw-r--r-- | server/sonar-web/src/main/js/components/common/select-list.js | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/js/components/common/select-list.js b/server/sonar-web/src/main/js/components/common/select-list.js index b14b83b2676..06504e8da06 100644 --- a/server/sonar-web/src/main/js/components/common/select-list.js +++ b/server/sonar-web/src/main/js/components/common/select-list.js @@ -128,14 +128,21 @@ define(function () { $.ajax({ url: url, type: 'POST', - data: data + data: data, + statusCode: { + // do not show global error + 400: null, + 401: null, + 403: null, + 500: null + } }) .done(function () { that.model.set('selected', !selected); }) - .fail(function () { + .fail(function (jqXHR) { that.render(); - showError(); + showError(jqXHR); }) .always(function () { that.$el.removeClass('progress'); @@ -241,10 +248,15 @@ define(function () { this.listItemViews = []; - showError = function () { + showError = function (jqXHR) { + var message = window.t('default_error_message'); + if (jqXHR != null && jqXHR.responseJSON != null && jqXHR.responseJSON.errors != null) { + message = _.pluck(jqXHR.responseJSON.errors, 'msg').join('. '); + } + that.$el.prevAll('.alert').remove(); $('<div>') - .addClass('alert alert-danger').text(that.settings.errorMessage) + .addClass('alert alert-danger').text(message) .insertBefore(that.$el); }; |