From 5d3d62b840255f41ecb079271f6c3df3187da468 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 13 May 2016 13:32:12 +0200 Subject: [PATCH] SONAR-7327 Display a warning when no components selected on the Measures page --- .../src/main/js/apps/measures/app.js | 24 +++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/apps/measures/app.js b/server/sonar-web/src/main/js/apps/measures/app.js index a0979df4f13..f3ce71cbaaf 100644 --- a/server/sonar-web/src/main/js/apps/measures/app.js +++ b/server/sonar-web/src/main/js/apps/measures/app.js @@ -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 () { 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 45971557aeb..f62395c7968 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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 -- 2.39.5