aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-03-11 13:55:22 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-03-11 13:55:31 +0100
commit58324bc44a6adabada7125e2b76884a5f7d218b7 (patch)
tree88a9ab4a316e24d55ac2fef2f529c8c412318fe4 /server/sonar-web
parentb74d5c59e89691d509bd1677491bdfef626fd7c9 (diff)
downloadsonarqube-58324bc44a6adabada7125e2b76884a5f7d218b7.tar.gz
sonarqube-58324bc44a6adabada7125e2b76884a5f7d218b7.zip
SONAR-6234 apply feedback
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/widgets/issue-filter.js24
-rw-r--r--server/sonar-web/src/test/js/project-issue-filter-widget.js71
-rw-r--r--server/sonar-web/src/test/json/project-issues-filter-widget/unresolved-issues-by-severity-with-IGNORED-differential-period.json32
3 files changed, 123 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/widgets/issue-filter.js b/server/sonar-web/src/main/js/widgets/issue-filter.js
index 03479ae361a..e43c28ab946 100644
--- a/server/sonar-web/src/main/js/widgets/issue-filter.js
+++ b/server/sonar-web/src/main/js/widgets/issue-filter.js
@@ -220,12 +220,19 @@ define(['templates/widgets'], function () {
},
initialize: function () {
+ this.shouldIgnorePeriod = false;
this.model = new Backbone.Model({
query: this.options.query,
parsedQuery: this.getParsedQuery(),
- property: this.options.distributionAxis,
- periodDate: this.options.periodDate
+ property: this.options.distributionAxis
});
+
+ // Ignore the period date if the filter contains any date criteria
+ // `this.shouldIgnorePeriod` is set in `this.getParsedQuery()`
+ if (!this.shouldIgnorePeriod) {
+ this.model.set({ periodDate: this.options.periodDate });
+ }
+
this.listenTo(this.model, 'change', this.render);
this.conf = byDistributionConf[this.options.distributionAxis];
this.query = this.getParsedQuery();
@@ -244,12 +251,21 @@ define(['templates/widgets'], function () {
if (this.options.componentKey != null) {
_.extend(query, { componentKey: this.options.componentKey });
}
- if (this.options.periodDate != null) {
+ if (!this.hasDateFilter(query) && this.options.periodDate != null) {
_.extend(query, { createdAfter: this.options.periodDate });
+ } else {
+ this.shouldIgnorePeriod = true;
}
return query;
},
+ hasDateFilter: function (query) {
+ var q = query || this.model.get('parsedQuery');
+ return _.some(['createdAt', 'createdBefore', 'createdAfter', 'createdInLast'], function (p) {
+ return q[p] != null;
+ });
+ },
+
sortItems: function (items) {
var comparator = this.conf != null && this.conf.comparator != null ? this.conf.comparator : defaultComparator;
return _.sortBy(items, comparator);
@@ -288,7 +304,7 @@ define(['templates/widgets'], function () {
if (this.options.componentUuid != null) {
_.extend(options, { componentUuids: this.options.componentUuid });
}
- if (this.options.periodDate != null) {
+ if (this.options.periodDate != null && !this.shouldIgnorePeriod) {
_.extend(options, { createdAfter: this.options.periodDate });
}
return $.get(url, options).done(function (r) {
diff --git a/server/sonar-web/src/test/js/project-issue-filter-widget.js b/server/sonar-web/src/test/js/project-issue-filter-widget.js
index 961c79a987c..6b7a1a30116 100644
--- a/server/sonar-web/src/test/js/project-issue-filter-widget.js
+++ b/server/sonar-web/src/test/js/project-issue-filter-widget.js
@@ -219,3 +219,74 @@ casper.test.begin(testName('Unresolved Issues By Severity With Differential Peri
test.done();
});
});
+
+
+casper.test.begin(testName('Unresolved Issues By Severity With IGNORED Differential Period'), 19, function (test) {
+ casper
+ .start(lib.buildUrl('issue-filter-widget'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequest('/api/l10n/index', '{}');
+ lib.mockRequestFromFile('/api/issues/search',
+ 'unresolved-issues-by-severity-with-IGNORED-differential-period.json',
+ { data: { resolved: 'false', createdInLast: '1w' } });
+ })
+
+ .then(function () {
+ casper.evaluate(function () {
+ require(['/js/widgets/issue-filter.js'], function (IssueFilter) {
+ window.requestMessages().done(function () {
+ new IssueFilter({
+ el: '#issue-filter-widget',
+ query: 'resolved=false|createdInLast=1w',
+ distributionAxis: 'severities',
+ periodDate: '2014-12-09T17:12:38+0100',
+ componentUuid: '69e57151-be0d-4157-adff-c06741d88879',
+ componentKey: 'org.codehaus.sonar:sonar'
+ });
+ });
+ });
+ });
+ })
+
+ .then(function () {
+ casper.waitForSelector('#issue-filter-widget > table');
+ })
+
+ .then(function () {
+ // check count
+ test.assertElementCount('tr', 6);
+
+ // check order and values
+ test.assertSelectorContains('tr:nth-child(1)', '549');
+ test.assertSelectorContains('tr:nth-child(2)', '0');
+ test.assertSelectorContains('tr:nth-child(3)', '59');
+ test.assertSelectorContains('tr:nth-child(4)', '306');
+ test.assertSelectorContains('tr:nth-child(5)', '135');
+ test.assertSelectorContains('tr:nth-child(6)', '49');
+
+ // check that differential period is ignored
+ test.assertSelectorDoesntContain('tr:nth-child(1)', '+');
+ test.assertSelectorDoesntContain('tr:nth-child(2)', '+');
+ test.assertSelectorDoesntContain('tr:nth-child(3)', '+');
+ test.assertSelectorDoesntContain('tr:nth-child(4)', '+');
+ test.assertSelectorDoesntContain('tr:nth-child(5)', '+');
+ test.assertSelectorDoesntContain('tr:nth-child(6)', '+');
+
+ // check links
+ test.assertExists('tr:nth-child(1) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w"]');
+ test.assertExists('tr:nth-child(2) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w|severities=BLOCKER"]');
+ test.assertExists('tr:nth-child(3) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w|severities=CRITICAL"]');
+ test.assertExists('tr:nth-child(4) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w|severities=MAJOR"]');
+ test.assertExists('tr:nth-child(5) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w|severities=MINOR"]');
+ test.assertExists('tr:nth-child(6) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdInLast=1w|severities=INFO"]');
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});
diff --git a/server/sonar-web/src/test/json/project-issues-filter-widget/unresolved-issues-by-severity-with-IGNORED-differential-period.json b/server/sonar-web/src/test/json/project-issues-filter-widget/unresolved-issues-by-severity-with-IGNORED-differential-period.json
new file mode 100644
index 00000000000..afa5ed4f5cc
--- /dev/null
+++ b/server/sonar-web/src/test/json/project-issues-filter-widget/unresolved-issues-by-severity-with-IGNORED-differential-period.json
@@ -0,0 +1,32 @@
+{
+ "total": 549,
+ "p": 1,
+ "ps": 1,
+ "facets": [
+ {
+ "property": "severities",
+ "values": [
+ {
+ "val": "MAJOR",
+ "count": 306
+ },
+ {
+ "val": "MINOR",
+ "count": 135
+ },
+ {
+ "val": "CRITICAL",
+ "count": 59
+ },
+ {
+ "val": "INFO",
+ "count": 49
+ },
+ {
+ "val": "BLOCKER",
+ "count": 0
+ }
+ ]
+ }
+ ]
+}