diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-04-24 15:27:46 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-04-24 15:28:42 +0200 |
commit | 3a1215b87a8e1192aeb62bc9697ba8e8520ab18c (patch) | |
tree | ab2679e21671711168bb4cec3105501788561346 /server/sonar-web/src | |
parent | 5522a2ac8d150a3317fc11bfff14b0ee33407d2d (diff) | |
download | sonarqube-3a1215b87a8e1192aeb62bc9697ba8e8520ab18c.tar.gz sonarqube-3a1215b87a8e1192aeb62bc9697ba8e8520ab18c.zip |
SONAR-6138 limit default list of favorites to 6 items, add favorites to search results
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r-- | server/sonar-web/src/main/js/nav/search-view.js | 23 | ||||
-rw-r--r-- | server/sonar-web/src/test/js/nav-spec.js | 5 | ||||
-rw-r--r-- | server/sonar-web/src/test/json/nav-spec/favorite.json | 8 |
3 files changed, 29 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/nav/search-view.js b/server/sonar-web/src/main/js/nav/search-view.js index 33ae41ee564..007a2ebf537 100644 --- a/server/sonar-web/src/main/js/nav/search-view.js +++ b/server/sonar-web/src/main/js/nav/search-view.js @@ -165,7 +165,7 @@ define([ extra: index === 0 ? '' : null }; }); - this.results.reset([].concat(history, this.favorite, qualifiers)); + this.results.reset([].concat(history, _.first(this.favorite, 6), qualifiers)); }, search: function (q) { @@ -187,7 +187,12 @@ define([ })); }); }); - that.results.reset([].concat(that.getNavigationFindings(q), that.getGlobalDashboardFindings(q), collection)); + that.results.reset([].concat( + that.getNavigationFindings(q), + that.getGlobalDashboardFindings(q), + that.getFavoriteFindings(q), + collection + )); }); }, @@ -211,7 +216,7 @@ define([ if (findings.length > 0) { findings[0].extra = t('navigation'); } - return findings; + return _.first(findings, 6); }, getGlobalDashboardFindings: function (q) { @@ -225,7 +230,17 @@ define([ if (findings.length > 0) { findings[0].extra = t('dashboard.global_dashboards'); } - return findings; + return _.first(findings, 6); + }, + + getFavoriteFindings: function (q) { + var findings = this.favorite.filter(function (f) { + return f.name.match(new RegExp(q, 'i')); + }); + if (findings.length > 0) { + findings[0].extra = t('favorite'); + } + return _.first(findings, 6); } }); diff --git a/server/sonar-web/src/test/js/nav-spec.js b/server/sonar-web/src/test/js/nav-spec.js index 82101ec34e2..89f7552246f 100644 --- a/server/sonar-web/src/test/js/nav-spec.js +++ b/server/sonar-web/src/test/js/nav-spec.js @@ -228,7 +228,7 @@ casper.test.begin(testName('Login'), 3, function (test) { }); -casper.test.begin(testName('Search'), 23, function (test) { +casper.test.begin(testName('Search'), 24, function (test) { casper .start(lib.buildUrl('nav'), function () { lib.setDefaultViewport(); @@ -289,10 +289,11 @@ casper.test.begin(testName('Search'), 23, function (test) { }) .then(function () { - test.assertElementCount('.js-search-results a', 6); + test.assertElementCount('.js-search-results a', 7); test.assertExists('.js-search-results a[href*="/profiles"]'); test.assertExists('.js-search-results a[href*="/quality_gates"]'); test.assertExists('.js-search-results a[href*="/dashboard/?did=50"]'); + test.assertExists('.js-search-results a[href*="quality-project"]'); test.assertSelectorContains('.js-search-results a', 'SonarQube Java'); test.assertSelectorContains('.js-search-results a', 'SonarQube Java :: Squid'); test.assertSelectorContains('.js-search-results a', 'SonarQube Java :: Checks'); diff --git a/server/sonar-web/src/test/json/nav-spec/favorite.json b/server/sonar-web/src/test/json/nav-spec/favorite.json index 471a15610ae..da8f54ec6fc 100644 --- a/server/sonar-web/src/test/json/nav-spec/favorite.json +++ b/server/sonar-web/src/test/json/nav-spec/favorite.json @@ -2,7 +2,7 @@ { "key": "favorite-project-key", "name": "Favorite Project", - "lname": "SonarSource :: Rule API", + "lname": "Favorite Project", "qualifier": "TRK" }, { @@ -10,5 +10,11 @@ "name": "FavoriteFile.java", "lname": "src/main/java/com/example/FavoriteFile.java", "qualifier": "FIL" + }, + { + "key": "quality-project", + "name": "Quality Project", + "lname": "Quality Project", + "qualifier": "TRK" } ] |