aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/nav/search-view.js39
-rw-r--r--server/sonar-web/src/test/js/nav-spec.js11
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
3 files changed, 46 insertions, 5 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 8554a6d133b..33ae41ee564 100644
--- a/server/sonar-web/src/main/js/nav/search-view.js
+++ b/server/sonar-web/src/main/js/nav/search-view.js
@@ -187,8 +187,45 @@ define([
}));
});
});
- that.results.reset(collection);
+ that.results.reset([].concat(that.getNavigationFindings(q), that.getGlobalDashboardFindings(q), collection));
});
+ },
+
+ getNavigationFindings: function (q) {
+ var DEFAULT_ITEMS = [
+ { name: t('issues.page'), url: baseUrl + '/issues/search' },
+ { name: t('layout.measures'), url: baseUrl + '/measures/search?qualifiers[]=TRK' },
+ { name: t('coding_rules.page'), url: baseUrl + '/coding_rules' },
+ { name: t('quality_profiles.page'), url: baseUrl + '/profiles' },
+ { name: t('quality_gates.page'), url: baseUrl + '/quality_gates' },
+ { name: t('comparison_global.page'), url: baseUrl + '/comparison' },
+ { name: t('dependencies.page'), url: baseUrl + '/dependencies' }
+ ],
+ customItems = [];
+ if (window.SS.isUserAdmin) {
+ customItems.push({ name: t('layout.settings'), url: baseUrl + '/settings' });
+ }
+ var findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) {
+ return f.name.match(new RegExp(q, 'i'));
+ });
+ if (findings.length > 0) {
+ findings[0].extra = t('navigation');
+ }
+ return findings;
+ },
+
+ getGlobalDashboardFindings: function (q) {
+ var dashboards = this.model.get('globalDashboards') || [],
+ items = dashboards.map(function (d) {
+ return { name: d.name, url: baseUrl + d.url };
+ });
+ var findings = items.filter(function (f) {
+ return f.name.match(new RegExp(q, 'i'));
+ });
+ if (findings.length > 0) {
+ findings[0].extra = t('dashboard.global_dashboards');
+ }
+ return findings;
}
});
diff --git a/server/sonar-web/src/test/js/nav-spec.js b/server/sonar-web/src/test/js/nav-spec.js
index 15c4ee64058..82101ec34e2 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'), 20, function (test) {
+casper.test.begin(testName('Search'), 23, function (test) {
casper
.start(lib.buildUrl('nav'), function () {
lib.setDefaultViewport();
@@ -243,6 +243,7 @@ casper.test.begin(testName('Search'), 20, function (test) {
window.SS.isUserAdmin = false;
window.navbarOptions = new Backbone.Model();
window.navbarOptions.set({ qualifiers: ['TRK', 'VW', 'DEV'] });
+ window.navbarOptions.set({ globalDashboards: [{ name: 'Quality', url: '/dashboard/?did=50' }] });
window.localStorage.setItem('sonar_recent_history',
'[{"key":"localhistoryproject","name":"Local History Project","icon":"trk"}]');
@@ -261,7 +262,6 @@ casper.test.begin(testName('Search'), 20, function (test) {
})
.then(function () {
- lib.capture();
// for top-level qualifiers
test.assertExists('.js-search-results a[href*="/all_projects?qualifier=TRK"]');
test.assertExists('.js-search-results a[href*="/all_projects?qualifier=VW"]');
@@ -280,7 +280,7 @@ casper.test.begin(testName('Search'), 20, function (test) {
.then(function () {
casper.evaluate(function () {
- jQuery('.navbar-search [name="q"]').val('search query').keyup();
+ jQuery('.navbar-search [name="q"]').val('quality').keyup();
});
casper.evaluate(function () {
jQuery('.navbar-search [name="q"]').keyup();
@@ -289,7 +289,10 @@ casper.test.begin(testName('Search'), 20, function (test) {
})
.then(function () {
- test.assertElementCount('.js-search-results a', 3);
+ test.assertElementCount('.js-search-results a', 6);
+ 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.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/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 929f532acb2..d236951d8a2 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -98,6 +98,7 @@ more_actions=More Actions
moreCriteria=+ More Criteria
name=Name
name_too_long_x=Name is too long (maximum is {0} characters)
+navigation=Navigation
none=None
unassigned=Not assigned
off=Off