aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/quality-profiles
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/quality-profiles')
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js80
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/controller.js17
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js1
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/helpers.js26
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-details-view.js33
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-view.js5
6 files changed, 159 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js b/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js
new file mode 100644
index 00000000000..27a0611248a
--- /dev/null
+++ b/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js
@@ -0,0 +1,80 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+define([
+ 'common/modal-form',
+ 'templates/quality-profiles'
+], function (ModalFormView) {
+
+ var $ = jQuery;
+
+ return ModalFormView.extend({
+ template: Templates['quality-profiles-change-profile-parent'],
+
+ onRender: function () {
+ ModalFormView.prototype.onRender.apply(this, arguments);
+ this.$('select').select2({
+ width: '250px',
+ minimumResultsForSearch: 50
+ });
+ },
+
+ onFormSubmit: function () {
+ ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+ this.sendRequest();
+ },
+
+ sendRequest: function () {
+ var that = this,
+ url = baseUrl + '/api/qualityprofiles/change_parent',
+ parent = this.$('#change-profile-parent').val(),
+ options = {
+ profileKey: this.model.get('key'),
+ parentKey: parent
+ };
+ return $.ajax({
+ type: 'POST',
+ url: url,
+ data: options,
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ }).done(function () {
+ that.model.collection.fetch();
+ that.model.trigger('select', that.model);
+ that.close();
+ }).fail(function (jqXHR) {
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ });
+ },
+
+ serializeData: function () {
+ var that = this,
+ profilesData = this.model.collection.toJSON(),
+ profiles = _.filter(profilesData, function (profile) {
+ return profile.language === that.model.get('language') && profile.key !== that.model.id;
+ });
+ return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+ profiles: profiles
+ });
+ }
+ });
+
+});
diff --git a/server/sonar-web/src/main/js/quality-profiles/controller.js b/server/sonar-web/src/main/js/quality-profiles/controller.js
index ed58081869e..107cfde9815 100644
--- a/server/sonar-web/src/main/js/quality-profiles/controller.js
+++ b/server/sonar-web/src/main/js/quality-profiles/controller.js
@@ -83,7 +83,10 @@ define([
},
fetchProfile: function (profile) {
- return $.when(this.fetchProfileRules(profile));
+ return $.when(
+ this.fetchProfileRules(profile),
+ this.fetchInheritance(profile)
+ );
},
fetchProfileRules: function (profile) {
@@ -101,6 +104,18 @@ define([
profile.set({ rulesSeverities: severityFacet.values });
}
});
+ },
+
+ fetchInheritance: function (profile) {
+ var url = baseUrl + '/api/qualityprofiles/inheritance',
+ options = { profileKey: profile.id };
+ return $.get(url, options).done(function (r) {
+ profile.set({
+ ancestors: r.ancestors,
+ children: r.children
+ });
+ profile.set(r.profile);
+ });
}
});
diff --git a/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js
index 2c23638432d..570b60f00d8 100644
--- a/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js
@@ -49,6 +49,7 @@ define([
400: null
}
}).done(function () {
+ that.model.collection.fetch();
that.model.trigger('destroy', that.model, that.model.collection);
}).fail(function (jqXHR) {
that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
diff --git a/server/sonar-web/src/main/js/quality-profiles/helpers.js b/server/sonar-web/src/main/js/quality-profiles/helpers.js
new file mode 100644
index 00000000000..e1d3cb57e84
--- /dev/null
+++ b/server/sonar-web/src/main/js/quality-profiles/helpers.js
@@ -0,0 +1,26 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+(function () {
+
+ Handlebars.registerHelper('profileUrl', function (key) {
+ return baseUrl + '/quality_profiles/show?key=' + encodeURIComponent(key);
+ });
+
+})();
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile-details-view.js b/server/sonar-web/src/main/js/quality-profiles/profile-details-view.js
index bf4dc4b5c48..9c08fb31ac8 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profile-details-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profile-details-view.js
@@ -18,9 +18,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
define([
+ 'quality-profiles/change-profile-parent-view',
'common/select-list',
+ 'quality-profiles/helpers',
'templates/quality-profiles'
-], function () {
+], function (ChangeProfileParentView) {
+
+ var $ = jQuery;
return Marionette.ItemView.extend({
template: Templates['quality-profiles-profile-details'],
@@ -29,6 +33,11 @@ define([
'change': 'render'
},
+ events: {
+ 'click .js-profile': 'onProfileClick',
+ 'click #quality-profile-change-parent': 'onChangeParentClick'
+ },
+
onRender: function () {
var key = this.model.get('key');
if (!this.model.get('isDefault')) {
@@ -52,7 +61,7 @@ define([
selected: t('quality_gates.projects.with'),
deselected: t('quality_gates.projects.without'),
all: t('quality_gates.projects.all'),
- noResults: t('quality_gates.projects.noResults'),
+ noResults: t('quality_gates.projects.noResults')
},
tooltips: {
select: t('quality_gates.projects.select_hint'),
@@ -62,6 +71,26 @@ define([
}
},
+ onProfileClick: function (e) {
+ var key = $(e.currentTarget).data('key'),
+ profile = this.model.collection.get(key);
+ if (profile != null) {
+ e.preventDefault();
+ this.model.collection.trigger('select', profile);
+ }
+ },
+
+ onChangeParentClick: function (e) {
+ e.preventDefault();
+ this.changeParent();
+ },
+
+ changeParent: function () {
+ new ChangeProfileParentView({
+ model: this.model
+ }).render();
+ },
+
serializeData: function () {
var key = this.model.get('key'),
rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile-view.js b/server/sonar-web/src/main/js/quality-profiles/profile-view.js
index a2983d17729..680cc25d613 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profile-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profile-view.js
@@ -37,6 +37,11 @@ define([
onRender: function () {
this.$el.toggleClass('active', this.options.highlighted);
this.$el.attr('data-key', this.model.id);
+ this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
+ },
+
+ onClose: function () {
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
onClick: function (e) {