]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5851 fix profile restoring
authorStas Vilchik <vilchiks@gmail.com>
Tue, 14 Apr 2015 14:36:58 +0000 (16:36 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 14 Apr 2015 15:22:07 +0000 (17:22 +0200)
server/sonar-web/src/main/js/quality-profiles/actions-view.js
server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js

index d06e62675af11c070c9567dcd0886ae4372129d2..67f4caceba9daf3b0b6d79cf9af7d79449777599 100644 (file)
@@ -61,7 +61,9 @@ define([
     },
 
     restore: function () {
-      new RestoreProfileView().render();
+      new RestoreProfileView({
+        collection: this.collection
+      }).render();
     },
 
     restoreBuiltIn: function () {
index 8a3f49ea62ac0b70fd4c3d3a5a7eb53756c2f029..dea4bfeeab0b440235a664a42a7dbe5397178c70 100644 (file)
@@ -32,12 +32,17 @@ define([
       var that = this;
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
       uploader({ form: $(e.currentTarget) }).done(function (r) {
-        if (typeof r === 'object' && _.isArray(r.errors) || _.isArray(r.warning)) {
+        if (_.isArray(r.errors) || _.isArray(r.warnings)) {
           that.showErrors(r.errors, r.warnings);
-          return;
+        } else {
+          that.collection.fetch().done(function () {
+            var profile = that.collection.findWhere({ key: r.profile.key });
+            if (profile != null) {
+              profile.trigger('select', profile);
+            }
+          });
+          that.close();
         }
-        that.collection.fetch();
-        that.close();
       });
     }
   });