aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-14 14:09:47 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-14 14:14:13 +0200
commitbb004b10dbe983c8042713de7ffb91429419f6ab (patch)
treef998fb5b1ce698c4dddd1533588370359bb985f0 /server/sonar-web/src/main
parent24b1763ced175d963fca52105b743a534941ac08 (diff)
downloadsonarqube-bb004b10dbe983c8042713de7ffb91429419f6ab.tar.gz
sonarqube-bb004b10dbe983c8042713de7ffb91429419f6ab.zip
SONAR-5851 add changelog
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/hbs/quality-profiles/quality-profile-changelog.hbs48
-rw-r--r--server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile-details.hbs7
-rw-r--r--server/sonar-web/src/main/js/common/handlebars-extensions.js9
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/helpers.js14
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-changelog-view.js43
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-details-view.js70
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile.js20
7 files changed, 175 insertions, 36 deletions
diff --git a/server/sonar-web/src/main/hbs/quality-profiles/quality-profile-changelog.hbs b/server/sonar-web/src/main/hbs/quality-profiles/quality-profile-changelog.hbs
new file mode 100644
index 00000000000..d9b184cdb6d
--- /dev/null
+++ b/server/sonar-web/src/main/hbs/quality-profiles/quality-profile-changelog.hbs
@@ -0,0 +1,48 @@
+<header class="page-header">
+ <div class="page-title">
+ <span class="h3">{{t 'changelog'}}</span>{{#unless totalEvents}}&nbsp;&nbsp;<a class="js-show-changelog small" href="#">{{t 'show_verb'}}</a>{{/unless}}
+ </div>
+</header>
+
+{{#notEmpty events}}
+ <table class="width-100 data zebra">
+ <thead>
+ <tr>
+ <th>{{t 'date'}}</th>
+ <th>{{t 'user'}}</th>
+ <th>{{t 'action'}}</th>
+ <th>{{t 'rule'}}</th>
+ <th>{{t 'parameters'}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#each events}}
+ <tr>
+ <td class="text-top nowrap thin">{{dt date}}</td>
+ <td class="text-top nowrap thin">{{default authorName 'System'}}</td>
+ <td class="text-top nowrap">{{t 'quality_profiles.changelog' action}}</td>
+ <td class="text-top"><a href="{{rulePermalink ruleKey}}">{{ruleName}}</a></td>
+ <td class="text-top thin">
+ <ul>
+ {{#each params}}
+ <li>
+ {{#eq @key 'severity'}}
+ <span class="nowrap">{{severityChangelog this}}</span>
+ {{else}}
+ {{parameterChangelog @key this}}
+ {{/eq}}
+ </li>
+ {{/each}}
+ </ul>
+ </td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+
+ {{#unlessLength events totalEvents}}
+ <p class="spacer-top text-center">
+ <a class="js-show-more-changelog" href="#">{{t 'show_more'}}</a>
+ </p>
+ {{/unlessLength}}
+{{/notEmpty}}
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 2dbd17a71ca..502448d9f7a 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
@@ -108,9 +108,4 @@
</div>
</div>
-<div class="panel panel-vertical" id="quality-profile-changelog">
- <header class="page-header">
- <h3 class="page-title">{{t 'changelog'}}</h3>
- </header>
- <p class="alert alert-warning">Coming soon...</p>
-</div>
+<div class="panel panel-vertical" id="quality-profile-changelog"></div>
diff --git a/server/sonar-web/src/main/js/common/handlebars-extensions.js b/server/sonar-web/src/main/js/common/handlebars-extensions.js
index c449d0278cc..42d3b0085d8 100644
--- a/server/sonar-web/src/main/js/common/handlebars-extensions.js
+++ b/server/sonar-web/src/main/js/common/handlebars-extensions.js
@@ -30,6 +30,10 @@
return baseUrl + url;
});
+ Handlebars.registerHelper('rulePermalink', function (ruleKey) {
+ return baseUrl + '/coding_rules#rule_key=' + encodeURIComponent(ruleKey);
+ });
+
Handlebars.registerHelper('isActiveLink', function () {
var args = Array.prototype.slice.call(arguments, 0, -1),
options = arguments[arguments.length - 1],
@@ -236,6 +240,11 @@
return cond ? options.fn(this) : options.inverse(this);
});
+ Handlebars.registerHelper('unlessLength', function (array, len, options) {
+ var cond = _.isArray(array) && array.length === +len;
+ return cond ? options.inverse(this) : options.fn(this);
+ });
+
Handlebars.registerHelper('eachReverse', function (array, options) {
var ret = '';
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 e1d3cb57e84..fa3858e126c 100644
--- a/server/sonar-web/src/main/js/quality-profiles/helpers.js
+++ b/server/sonar-web/src/main/js/quality-profiles/helpers.js
@@ -23,4 +23,18 @@
return baseUrl + '/quality_profiles/show?key=' + encodeURIComponent(key);
});
+ 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);
+ return new Handlebars.SafeString(message);
+ });
+
+ Handlebars.registerHelper('parameterChangelog', function (value, parameter) {
+ if (parameter) {
+ return new Handlebars.SafeString(tp('quality_profiles.parameter_set_to_x', value, parameter));
+ } else {
+ return new Handlebars.SafeString(tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter));
+ }
+ });
+
})();
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile-changelog-view.js b/server/sonar-web/src/main/js/quality-profiles/profile-changelog-view.js
new file mode 100644
index 00000000000..b87406132cd
--- /dev/null
+++ b/server/sonar-web/src/main/js/quality-profiles/profile-changelog-view.js
@@ -0,0 +1,43 @@
+/*
+ * 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([
+ 'templates/quality-profiles'
+], function () {
+
+ return Marionette.ItemView.extend({
+ template: Templates['quality-profile-changelog'],
+
+ events: {
+ 'click .js-show-changelog': 'onShowChangelogClick',
+ 'click .js-show-more-changelog': 'onShowMoreChangelogClick'
+ },
+
+ onShowChangelogClick: function (e) {
+ e.preventDefault();
+ this.model.fetchChangelog();
+ },
+
+ onShowMoreChangelogClick: function (e) {
+ e.preventDefault();
+ this.model.fetchChangelog({ next: true });
+ }
+ });
+
+});
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 8a3ab3fcc51..8c26922ad85 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
@@ -19,16 +19,21 @@
*/
define([
'quality-profiles/change-profile-parent-view',
+ 'quality-profiles/profile-changelog-view',
'common/select-list',
'quality-profiles/helpers',
'templates/quality-profiles'
-], function (ChangeProfileParentView) {
+], function (ChangeProfileParentView, ProfileChangelogView) {
var $ = jQuery;
- return Marionette.ItemView.extend({
+ return Marionette.Layout.extend({
template: Templates['quality-profiles-profile-details'],
+ regions: {
+ changelogRegion: '#quality-profile-changelog'
+ },
+
modelEvents: {
'change': 'render'
},
@@ -39,36 +44,41 @@ define([
},
onRender: function () {
- var key = this.model.get('key');
if (!this.model.get('isDefault')) {
- new SelectList({
- el: this.$('#quality-profile-projects-list'),
- width: '100%',
- readOnly: false,
- focusSearch: false,
- format: function (item) {
- return item.name;
- },
- searchUrl: baseUrl + '/api/qualityprofiles/projects?key=' + encodeURIComponent(key),
- selectUrl: baseUrl + '/api/qualityprofiles/add_project',
- deselectUrl: baseUrl + '/api/qualityprofiles/remove_project',
- extra: {
- profileKey: key
- },
- selectParameter: 'projectUuid',
- selectParameterValue: 'uuid',
- labels: {
- selected: t('quality_gates.projects.with'),
- deselected: t('quality_gates.projects.without'),
- all: t('quality_gates.projects.all'),
- noResults: t('quality_gates.projects.noResults')
- },
- tooltips: {
- select: t('quality_gates.projects.select_hint'),
- deselect: t('quality_gates.projects.deselect_hint')
- }
- });
+ this.initProjectsSelect();
}
+ this.changelogRegion.show(new ProfileChangelogView({ model: this.model }));
+ },
+
+ initProjectsSelect: function () {
+ var key = this.model.get('key');
+ new window.SelectList({
+ el: this.$('#quality-profile-projects-list'),
+ width: '100%',
+ readOnly: false,
+ focusSearch: false,
+ format: function (item) {
+ return item.name;
+ },
+ searchUrl: baseUrl + '/api/qualityprofiles/projects?key=' + encodeURIComponent(key),
+ selectUrl: baseUrl + '/api/qualityprofiles/add_project',
+ deselectUrl: baseUrl + '/api/qualityprofiles/remove_project',
+ extra: {
+ profileKey: key
+ },
+ selectParameter: 'projectUuid',
+ selectParameterValue: 'uuid',
+ labels: {
+ selected: t('quality_gates.projects.with'),
+ deselected: t('quality_gates.projects.without'),
+ all: t('quality_gates.projects.all'),
+ noResults: t('quality_gates.projects.noResults')
+ },
+ tooltips: {
+ select: t('quality_gates.projects.select_hint'),
+ deselect: t('quality_gates.projects.deselect_hint')
+ }
+ });
},
onProfileClick: function (e) {
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile.js b/server/sonar-web/src/main/js/quality-profiles/profile.js
index c88f747cf97..31339ec98db 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profile.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profile.js
@@ -72,6 +72,26 @@ define(function () {
children: r.children
});
});
+ },
+
+ fetchChangelog: function (options) {
+ var that = this,
+ url = baseUrl + '/api/qualityprofiles/changelog',
+ opts = { ps: 100, profileKey: this.id };
+ options = _.defaults(options || {}, { next: false });
+ if (options.next) {
+ var page = this.get('eventsPage') || 0;
+ _.extend(opts, { p: page + 1 });
+ }
+ return $.get(url, opts).done(function (r) {
+ var events = options.next ? that.get('events') : [];
+ events = events.concat(r.events);
+ that.set({
+ events: events,
+ eventsPage: r.p,
+ totalEvents: r.total
+ });
+ });
}
});