]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7327 Display a warning when no components selected on the Measures page
authorStas Vilchik <vilchiks@gmail.com>
Fri, 13 May 2016 11:32:12 +0000 (13:32 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 13 May 2016 11:32:18 +0000 (13:32 +0200)
server/sonar-web/src/main/js/apps/measures/app.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index a0979df4f13f901f507ada37e51a23f3bb3802c9..f3ce71cbaaf4dfc4cb95f045bb80e4ee0b9a58aa 100644 (file)
@@ -82,6 +82,15 @@ const newAlertFilter = function () {
   });
 };
 
+const showAlert = text => {
+  const alert = document.createElement('div');
+  alert.classList.add('alert', 'alert-warning');
+  alert.textContent = text;
+
+  const container = document.querySelector('.navigator-details');
+  container.insertBefore(alert, container.firstChild);
+};
+
 const init = function () {
   NavigatorApp.addRegions({ filtersRegion: '.navigator-filters' });
 
@@ -169,6 +178,21 @@ const init = function () {
     NavigatorApp.filterBarView.restoreFromQuery(window.queryParams);
   }
   key.setScope('list');
+
+  if (window.queryParams) {
+    const qualifiersFilter = window.queryParams.find(p => p.key === 'qualifiers[]');
+    const noQualifiers = !qualifiersFilter || !qualifiersFilter.value || !qualifiersFilter.value.length;
+
+    const baseFilter = window.queryParams.find(p => p.key === 'base');
+    const noBase = !baseFilter || !baseFilter.value || !baseFilter.value.length;
+
+    const favoritesFilter = window.queryParams.find(p => p.key === 'onFavourites');
+    const noFavorites = !favoritesFilter || !favoritesFilter.value;
+
+    if (noQualifiers && noBase && noFavorites) {
+      showAlert(translate('measures.select_components'));
+    }
+  }
 };
 
 NavigatorApp.on('start', function () {
index 45971557aebb6541f696ace1e389cd3a036a5c36..f62395c7968cc6dd2365a498ec678f2db98f283c 100644 (file)
@@ -567,9 +567,10 @@ session.flash_notice.logged_out=You have been logged out.
 
 #------------------------------------------------------------------------------
 #
-# MEASURE FILTERS
+# MEASURES & MEASURE FILTERS
 #
 #------------------------------------------------------------------------------
+measures.select_components=Please select "Components", "Components of" or "Favorites only" filter to see results.
 measure_filter.delete_column=Delete column
 measure_filter.no_filters=No filters
 measure_filter.display_as=Display as