aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-04-28 11:30:13 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-04-28 14:14:55 +0200
commite3a6ba3fd6a43896a718ead80a081540d0b24841 (patch)
treec3b47a725b2c0ade478ab800881d18bd0de8502a
parentadab7517ae4c4cfa293b5720b66fd7b5ec4e026b (diff)
downloadsonarqube-e3a6ba3fd6a43896a718ead80a081540d0b24841.tar.gz
sonarqube-e3a6ba3fd6a43896a718ead80a081540d0b24841.zip
SONAR-4927 Merge new QG widget with old one, update layout
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java1
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java6
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java33
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb79
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb63
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java12
7 files changed, 85 insertions, 118 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 6268c9b7109..6a7499e2332 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -213,7 +213,6 @@ public final class CorePlugin extends SonarPlugin {
// widgets
AlertsWidget.class,
- QualityGateWidget.class,
CoverageWidget.class,
ItCoverageWidget.class,
DescriptionWidget.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
index 738d6153fb4..c794e898573 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
@@ -19,9 +19,11 @@
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.WidgetLayout;
-import org.sonar.api.web.WidgetLayoutType;
+import org.sonar.api.web.*;
+@WidgetProperties({
+ @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"),
+})
@WidgetLayout(WidgetLayoutType.NONE)
public class AlertsWidget extends CoreWidget {
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java
deleted file mode 100644
index dd7e1d0cf85..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.core.widgets;
-
-import org.sonar.api.web.*;
-
-@WidgetProperties({
- @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"),
-})
-@WidgetLayout(WidgetLayoutType.NONE)
-public class QualityGateWidget extends CoreWidget {
-
- public QualityGateWidget() {
- super("quality_gate", "Quality Gate Details", "/org/sonar/plugins/core/widgets/quality_gate.html.erb");
- }
-}
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
index 1f1f243340a..0b1c505466f 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
@@ -1,14 +1,73 @@
+<% m=measure(Metric::QUALITY_GATE_DETAILS)
+ if m && !m.data.blank?
+ details = JSON.parse m.data
+ m.alert_status = details['level']
+ conditions = details['conditions']
+ alert_metric = metric(Metric::ALERT_STATUS)
+
+ warn_message = message('measure_filter.criteria.alert.warn')
+ error_message = message('measure_filter.criteria.alert.error')
+
+ css_class = "color_#{m.alert_status}"
+ if m.alert_status==Metric::TYPE_LEVEL_OK
+ label = "#{message('widget.alerts.no_alert')}."
+ elsif m.alert_status==Metric::TYPE_LEVEL_WARN
+ label = "#{message('widget.alerts.warnings')}"
+ else
+ label = "#{message('widget.alerts.errors')}"
+ end
+-%><div class="widget <%= css_class -%>" style="color: black !important" id="quality_gate_widget_<%= widget.id -%>">
+ <div><%= format_measure(measure(Metric::ALERT_STATUS)) -%> <%= label -%></div>
+ <% if conditions.any? {|condition| condition['level'] != 'OK'} || widget_properties['show_ok'] && !conditions.empty? -%>
+ <% details['conditions'].sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition|
+
+ level = condition['level']
+ condition_metric = metric(condition['metric'])
+ operator = message("quality_gates.operator.#{condition['op']}.short")
+ period = condition['period']
+ warning_value = condition['warning']
+ error_value = condition['error']
+ actual_value = condition['actual']
+
+ detail_measure = ProjectMeasure.new :metric => alert_metric, :alert_status => level
+
+ drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period)
+
+ actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value, :alert_status => level
+ warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value
+ error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value
+
+
+ unless level == 'OK' && !widget_properties['show_ok']
+ -%>
+ <div class="dashbox" style="margin: 10px">
+ <p class="title"><%= condition_metric.short_name -%></p>
+ <span class="big"><%= format_measure(actual_measure, :url => drilldown_url) -%></span>
+ <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%>
+ <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%>
+ <% if level == 'OK' -%>
+ <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end -%>
+ <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end -%>
+ <% end -%>
+ <p><%= period_label(@snapshot, period) unless period.blank? -%></p>
+ </div>
+ <% end
+ end
+ end -%>
+</div>
+<% else -%>
<% m=measure(Metric::ALERT_STATUS)
if m && !m.alert_status.blank?
- css_class = "widget color_#{m.alert_status}"
- if m.alert_status==Metric::TYPE_LEVEL_OK
- label = "<b>#{message('widget.alerts.no_alert')}</b>."
- elsif m.alert_status==Metric::TYPE_LEVEL_WARN
- label = "<b>#{message('widget.alerts.warnings')}</b>#{h(m.alert_text)}."
- else
- label = "<b>#{message('widget.alerts.errors')}</b>#{h(m.alert_text)}."
- end
-%><div class="<%= css_class -%>" id="alerts_widget">
+ css_class = "widget color_#{m.alert_status}"
+ if m.alert_status==Metric::TYPE_LEVEL_OK
+ label = "<b>#{message('widget.alerts.no_alert')}</b>."
+ elsif m.alert_status==Metric::TYPE_LEVEL_WARN
+ label = "<b>#{message('widget.alerts.warnings')}</b>#{h(m.alert_text)}."
+ else
+ label = "<b>#{message('widget.alerts.errors')}</b>#{h(m.alert_text)}."
+ end
+-%><div class="<%= css_class -%>" id="alerts_widget">
<div><%= format_measure(m) -%> <%= label -%></div>
</div>
-<% end %>
+<% end
+end -%>
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb
deleted file mode 100644
index af8143e1a58..00000000000
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb
+++ /dev/null
@@ -1,63 +0,0 @@
-<% m=measure(Metric::QUALITY_GATE_DETAILS)
- if m && !m.measure_data.blank?
-
- details = JSON.parse m.measure_data.data
- m.alert_status = details['level']
-
- warn_message = message('measure_filter.criteria.alert.warn')
- error_message = message('measure_filter.criteria.alert.error')
-
- css_class = "color_#{m.alert_status}"
- if m.alert_status==Metric::TYPE_LEVEL_OK
- label = "<b>#{message('widget.alerts.no_alert')}.</b>"
- elsif m.alert_status==Metric::TYPE_LEVEL_WARN
- label = "<b>#{message('widget.alerts.warnings')}</b>"
- else
- label = "<b>#{message('widget.alerts.errors')}</b>"
- end
--%><div class="widget <%= css_class -%>" id="quality_gate_widget_<%= widget.id -%>">
- <div><%= format_measure(m) -%> <%= label -%></div>
- <table class="data" style="color: black; margin-top: 10px">
- <thead>
- <tr></tr>
- </thead>
- <tbody>
- <% details['conditions'].sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition|
-
- level = condition['level']
- condition_metric = metric(condition['metric'])
- operator = message("quality_gates.operator.#{condition['op']}.short")
- period = condition['period']
- warning_value = condition['warning']
- error_value = condition['error']
- actual_value = condition['actual']
-
- detail_measure = ProjectMeasure.new :metric => m.metric, :alert_status => level
-
- drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period)
-
- actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value
- warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value
- error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value
-
-
- unless level == 'OK' && !widget_properties['show_ok']
- -%>
- <tr>
- <td><%= format_measure(detail_measure) -%></td>
- <td><%= link_to "#{condition_metric.short_name} #{period_label(@snapshot, period) unless period.blank?}", drilldown_url, {:class => 'nolink'} -%></td>
- <td align="right"><%= link_to format_measure(actual_measure), drilldown_url, {:class => 'nolink'} -%></td>
- <td>
- <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%>
- <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%>
- <% if level == 'OK' -%>
- <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end %>
- <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end %>
- <% end -%>
- </tr>
- <% end
- end -%>
- </tbody>
- </table>
-</div>
-<% end %>
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 3fa124b3aae..9ea0b618707 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -974,15 +974,12 @@ widgets.more=More
widget.error_occurred_please_read_logs=An error occurred while trying to display the widget "{0}". Please contact the administrator.
widget.unsupported_browser_warning=Your browser is out of date and does not support this widget.
-widget.alerts.name=Quality Gate Summary
-widget.alerts.description=Displays a summary of the project's quality gate status.
+widget.alerts.name=Quality Gate
+widget.alerts.description=Displays the project's quality gate status.
widget.alerts.no_alert=The project has passed the quality gate
widget.alerts.warnings=The project has warnings on the following quality gate conditions:\u00a0
widget.alerts.errors=The project failed the quality gate on the following conditions:\u00a0
-
-widget.quality_gate.name=Quality Gate Details
-widget.quality_gate.description=Displays a detailed view of the project's quality gate status.
-widget.quality_gate.property.show_ok.name=Show passed conditions
+widget.alerts.property.show_ok.name=Show passed conditions
widget.code_coverage.name=Unit Tests Coverage
widget.code_coverage.description=Reports on units tests and code coverage by unit tests.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index f1c7f33a454..cfdecedd856 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -2201,11 +2201,17 @@ public final class CoreMetrics {
.setDomain(DOMAIN_GENERAL)
.create();
+ /**
+ * @since 4.4
+ */
public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
- public static final Metric QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.LEVEL)
+ /**
+ * The project detailed status with regard to its quality gate.
+ * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
+ * @since 4.4
+ */
+ public static final Metric QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
.setDescription("The project detailed status with regard to its quality gate.")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
.setDomain(DOMAIN_GENERAL)
.create();