From e8cdc53a9e7b329abe80622bb7a36320d1dc3bd8 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Fri, 23 Mar 2012 16:41:26 +0100 Subject: [PATCH] SONAR-3354 Display an explicit message if no measure is available --- .../core/widgets/time_machine.html.erb | 76 ++++++++++--------- .../resources/org/sonar/l10n/core.properties | 1 + 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb index 91526be032b..ea8e590b194 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/time_machine.html.erb @@ -29,46 +29,48 @@ ] ) - # And prepare the rows to display - snapshot_by_id={} - snapshots.each do |s| - snapshot_by_id[s.id]=s - end - rows_by_metric_id={} - measures.each do |measure| - next unless measure.metric + + if measures.size > 0 + # Prepare the rows to display + snapshot_by_id={} + snapshots.each do |s| + snapshot_by_id[s.id]=s + end + rows_by_metric_id={} + measures.each do |measure| + next unless measure.metric - if measure.metric.timemachine? && (measure.value || measure.text_value) - row=rows_by_metric_id[measure.metric_id] - unless row - row=Sonar::TimemachineRow.new(measure.metric) - rows_by_metric_id[measure.metric_id]=row - end + if measure.metric.timemachine? && (measure.value || measure.text_value) + row=rows_by_metric_id[measure.metric_id] + unless row + row=Sonar::TimemachineRow.new(measure.metric) + rows_by_metric_id[measure.metric_id]=row + end - #optimization : avoid eager loading of snapshots - measure.snapshot=snapshot_by_id[measure.snapshot_id] - row.add_measure(measure) + #optimization : avoid eager loading of snapshots + measure.snapshot=snapshot_by_id[measure.snapshot_id] + row.add_measure(measure) + end end - end - # Create the list of rows to display in the same order as defined by the user - rows=[] - metric_ids.each do |metric_id| - row = rows_by_metric_id[metric_id] - if row - rows<
@@ -121,4 +123,10 @@ -
\ No newline at end of file + + +<% else %> + +<%= message('widget.time_machine.no_data_for_selected_metrics') -%> + +<% end %> \ No newline at end of file diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index d41cd3320c9..dd803c76893 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -677,6 +677,7 @@ widget.timeline.timeline_not_displayed=No history widget.time_machine.name=History Table widget.time_machine.description=Displays up to 10 metrics in a table, showing their value for a specified number of past snapshots. +widget.time_machine.no_data_for_selected_metrics=No data for selected metrics widget.ckjm.name=Chidamber & Kemerer widget.ckjm.description=Reports on LCOM4 and RFC average and distribution. -- 2.39.5