aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/app.js9
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/controller.js1
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/helpers.js11
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-details-view.js10
4 files changed, 27 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/quality-profiles/app.js b/server/sonar-web/src/main/js/quality-profiles/app.js
index e2650a470ff..81f9aa9d4d3 100644
--- a/server/sonar-web/src/main/js/quality-profiles/app.js
+++ b/server/sonar-web/src/main/js/quality-profiles/app.js
@@ -68,10 +68,13 @@ require([
var requestUser = $.get(baseUrl + '/api/users/current').done(function (r) {
- App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
- });
+ App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
+ }),
+ requestExporters = $.get(baseUrl + '/api/qualityprofiles/exporters').done(function (r) {
+ App.exporters = r.exporters;
+ });
- $.when(window.requestMessages(), requestUser).done(function () {
+ $.when(window.requestMessages(), requestUser, requestExporters).done(function () {
App.start();
});
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 f81ff6a0af9..87c481b4436 100644
--- a/server/sonar-web/src/main/js/quality-profiles/controller.js
+++ b/server/sonar-web/src/main/js/quality-profiles/controller.js
@@ -89,6 +89,7 @@ define([
var profileDetailsView = new ProfileDetailsView({
model: profile,
canWrite: that.options.app.canWrite,
+ exporters: that.options.app.exporters,
anchor: that.anchor
});
that.options.app.layout.detailsRegion.show(profileDetailsView);
diff --git a/server/sonar-web/src/main/js/quality-profiles/helpers.js b/server/sonar-web/src/main/js/quality-profiles/helpers.js
index fa3858e126c..a385e045af6 100644
--- a/server/sonar-web/src/main/js/quality-profiles/helpers.js
+++ b/server/sonar-web/src/main/js/quality-profiles/helpers.js
@@ -20,9 +20,20 @@
(function () {
Handlebars.registerHelper('profileUrl', function (key) {
+ //FIXME change me
return baseUrl + '/quality_profiles/show?key=' + encodeURIComponent(key);
});
+ Handlebars.registerHelper('exporterUrl', function (profile, exporterKey) {
+ var url = baseUrl + '/api/qualityprofiles/export';
+ url += '?language=' + encodeURIComponent(profile.language);
+ url += '&name=' + encodeURIComponent(profile.name);
+ if (exporterKey != null) {
+ url += '&exporterKey=' + encodeURIComponent(exporterKey);
+ }
+ return url;
+ });
+
Handlebars.registerHelper('severityChangelog', function (severity) {
var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i>&nbsp;' + t('severity', severity),
message = tp('quality_profiles.severity_set_to_x', label);
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 41455007911..96146f29159 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
@@ -132,12 +132,20 @@ define([
this.scrollTo('#quality-profile-comparison');
},
+ getExporters: function () {
+ var language = this.model.get('language');
+ return this.options.exporters.filter(function (exporter) {
+ return exporter.languages.indexOf(language) !== -1;
+ });
+ },
+
serializeData: function () {
var key = this.model.get('key'),
rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
rulesSearchUrl: rulesSearchUrl,
- canWrite: this.options.canWrite
+ canWrite: this.options.canWrite,
+ exporters: this.getExporters()
});
}
});