aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-20 09:27:49 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-20 10:11:33 +0200
commita800a109eb410143fb781b3cc33d42c576e77e3f (patch)
treec5a72939e90ab42b63ed0d67b56c9951e35803d6 /server/sonar-web/src
parent36d6b6ca0d6f7f67bbb4ba0621cb161da021a87d (diff)
downloadsonarqube-a800a109eb410143fb781b3cc33d42c576e77e3f.tar.gz
sonarqube-a800a109eb410143fb781b3cc33d42c576e77e3f.zip
SONAR-5851 show exporters
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs11
-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
-rw-r--r--server/sonar-web/src/test/js/quality-profiles.js21
-rw-r--r--server/sonar-web/src/test/json/quality-profiles/exporters.json8
7 files changed, 66 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs
index 31b21d1c8bb..b1c487315c4 100644
--- a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs
+++ b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs
@@ -51,7 +51,16 @@
<header class="page-header">
<h3 class="page-title">{{t 'permalinks'}}</h3>
</header>
- <p class="alert alert-warning">Coming soon...</p>
+ <ul class="list-inline">
+ <li>
+ <a href="{{exporterUrl this null}}" target="_blank"><i class="icon-detach"></i>&nbsp;{{t 'quality_profiles.export_all_rules'}}</a>
+ </li>
+ {{#each exporters}}
+ <li>
+ <a href="{{exporterUrl ../this key}}" target="_blank"><i class="icon-detach"></i>&nbsp;{{name}}</a>
+ </li>
+ {{/each}}
+ </ul>
</div>
<div class="panel panel-vertical" id="quality-profile-inheritance">
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()
});
}
});
diff --git a/server/sonar-web/src/test/js/quality-profiles.js b/server/sonar-web/src/test/js/quality-profiles.js
index 19aec79ae04..63e7a65ea55 100644
--- a/server/sonar-web/src/test/js/quality-profiles.js
+++ b/server/sonar-web/src/test/js/quality-profiles.js
@@ -34,6 +34,7 @@ casper.test.begin(testName('Should Show List'), 9, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
})
@@ -78,6 +79,7 @@ casper.test.begin(testName('Should Filter List By Language'), 15, function (test
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
})
@@ -141,6 +143,7 @@ casper.test.begin(testName('Should Show Details'), 10, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json',
{ data: { qprofile: 'java-sonar-way-67887', activation: 'true' }});
@@ -195,6 +198,7 @@ casper.test.begin(testName('Should Show Details', 'Admin'), 10, function (test)
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json',
{ data: { qprofile: 'java-sonar-way-67887', activation: 'true' }});
@@ -249,6 +253,7 @@ casper.test.begin(testName('Should Show Inheritance Details'), 10, function (tes
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-inheritance.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance-plus.json', {
@@ -303,6 +308,7 @@ casper.test.begin(testName('Should Show Selected Projects'), 2, function (test)
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/projects?key=php-psr-2-46772', 'projects.json');
@@ -350,6 +356,7 @@ casper.test.begin(testName('Should Move Between Profiles'), 1, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-inheritance.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
this.rulesMock = lib.mockRequestFromFile('/api/rules/search', 'rules.json',
{ data: { qprofile: 'java-inherited-profile-85155', activation: 'true' }});
@@ -403,6 +410,7 @@ casper.test.begin(testName('Copy Profile'), 5, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -465,6 +473,7 @@ casper.test.begin(testName('Rename Profile'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -527,6 +536,7 @@ casper.test.begin(testName('Make Profile Default'), 4, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -583,6 +593,7 @@ casper.test.begin(testName('Delete Profile'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-with-copy.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -642,6 +653,7 @@ casper.test.begin(testName('Create Profile'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
@@ -698,6 +710,7 @@ casper.test.begin(testName('Restore Profile'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -746,6 +759,7 @@ casper.test.begin(testName('Importers'), 6, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
@@ -808,6 +822,7 @@ casper.test.begin(testName('Restore Built-in Profiles'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-modified.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
lib.mockRequest('/api/qualityprofiles/restore_built_in', '{}', {
@@ -865,6 +880,7 @@ casper.test.begin(testName('Change Parent'), 1, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-change-parent.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
this.inheritanceMock = lib.mockRequestFromFile('/api/qualityprofiles/inheritance',
@@ -929,6 +945,7 @@ casper.test.begin(testName('Permalink'), 9, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user-admin.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -974,6 +991,7 @@ casper.test.begin(testName('Changelog'), 21, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -1051,6 +1069,7 @@ casper.test.begin(testName('Changelog Permalink'), 2, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -1109,6 +1128,7 @@ casper.test.begin(testName('Comparison'), 12, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-with-copy.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
@@ -1167,6 +1187,7 @@ casper.test.begin(testName('Comparison Permalink'), 4, function (test) {
lib.mockRequestFromFile('/api/users/current', 'user.json');
lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-with-copy.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/exporters', 'exporters.json');
lib.mockRequestFromFile('/api/languages/list', 'languages.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
diff --git a/server/sonar-web/src/test/json/quality-profiles/exporters.json b/server/sonar-web/src/test/json/quality-profiles/exporters.json
new file mode 100644
index 00000000000..86d3e20568d
--- /dev/null
+++ b/server/sonar-web/src/test/json/quality-profiles/exporters.json
@@ -0,0 +1,8 @@
+{
+ "exporters": [
+ {"key": "pmd", "name": "PMD", "languages": ["java"]},
+ {"key": "checkstyle", "name": "Checkstyle", "languages": ["java"]},
+ {"key": "js-lint", "name": "JS Lint", "languages": ["js"]},
+ {"key": "android-lint", "name": "Android Lint", "languages": ["xml", "java"]}
+ ]
+}