aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-17 11:00:50 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-17 11:32:33 +0200
commitb07a2570e213f7919b69b4a2d43ed327f7f3d938 (patch)
tree54c2922baab390349b388bf42889393f79568a8b /server/sonar-web/src/main
parente5c9087d3bb50e74a80b64624d6425dc5cda4641 (diff)
downloadsonarqube-b07a2570e213f7919b69b4a2d43ed327f7f3d938.tar.gz
sonarqube-b07a2570e213f7919b69b4a2d43ed327f7f3d938.zip
SONAR-5851 fix profile restoring
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js
index 75b7a735cdd..24f7ae3409b 100644
--- a/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js
@@ -20,8 +20,9 @@
define([
'common/modal-form',
'common/file-upload',
+ 'quality-profiles/profile',
'templates/quality-profiles'
-], function (ModalFormView, uploader) {
+], function (ModalFormView, uploader, Profile) {
var $ = jQuery;
@@ -31,21 +32,23 @@ define([
onFormSubmit: function (e) {
var that = this;
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
- this.disableForm();
uploader({ form: $(e.currentTarget) }).done(function (r) {
if (_.isArray(r.errors) || _.isArray(r.warnings)) {
that.showErrors(r.errors, r.warnings);
- that.enableForm();
} else {
- that.collection.fetch().done(function () {
- var profile = that.collection.findWhere({ key: r.profile.key });
- if (profile != null) {
- profile.trigger('select', profile);
- }
- });
+ that.addProfile(r.profile);
that.close();
}
});
+ },
+
+ addProfile: function (profileData) {
+ var profile = new Profile(profileData);
+ this.collection.add([profile], { merge: true });
+ var addedProfile = this.collection.get(profile.id);
+ if (addedProfile != null) {
+ addedProfile.trigger('select', addedProfile);
+ }
}
});