]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4717 Offer a new "Technical Debt" widget
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 27 Sep 2013 13:01:03 +0000 (15:01 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 27 Sep 2013 13:04:51 +0000 (15:04 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtWidget.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt.html.erb [new file with mode: 0644]

index d0315062434bd2b63ca165da09648b6d8c458819..57caf62186359a6d799fc746f182c63d5ac5eefc 100644 (file)
@@ -237,6 +237,7 @@ public final class CorePlugin extends SonarPlugin {
         WelcomeWidget.class,
         DocumentationCommentsWidget.class,
         DuplicationsWidget.class,
+        TechnicalDebtWidget.class,
 
         // dashboards
         ProjectDefaultDashboard.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TechnicalDebtWidget.java
new file mode 100644 (file)
index 0000000..6c977cb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.UserRole;
+import org.sonar.api.web.WidgetCategory;
+
+@UserRole(UserRole.USER)
+@WidgetCategory("Technical Debt")
+public final class TechnicalDebtWidget extends CoreWidget {
+
+  public TechnicalDebtWidget() {
+    super("technicalDebt", "Technical Debt", "/org/sonar/plugins/core/widgets/technical_debt.html.erb");
+  }
+}
index 3f4bd1b2a96ef031f32ce6ce889a152d76ac2d04..8f5ac70a8716c4e93fed81fd7b189a5da9ec6b21 100644 (file)
@@ -1143,6 +1143,10 @@ widget.measure_filter_treemap.property.heightInPercents.name=Height
 widget.measure_filter_treemap.property.heightInPercents.description=Height in percents of width
 widget.measure_filter_treemap.property.displayFilterDescription.name=Display filter description
 
+widget.technical_debt.name=Technical Debt
+widget.technical_debt.days=days
+widget.technical_debt.no_info_available=No information available.
+
 # Below are labels used in widget edition pages
 widget.image.name=Image
 widget.image.description=Shows an image with a link
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt.html.erb
new file mode 100644 (file)
index 0000000..49ba547
--- /dev/null
@@ -0,0 +1,18 @@
+<%
+   index = measure('technical_debt')
+   unless index
+%>
+    <h3><%= message('widget.technical_debt.name') -%></h3>
+    <span style="color: #777777; font-size: 93%; font-style:italic"><%= message('widget.technical_debt.no_info_available') -%></span>
+<%
+   else
+%>
+    <div class="dashbox marginright10">
+      <h3><%= message('widget.technical_debt.name') -%></h3>
+      <p>
+        <a href="<%= url_for_drilldown('sqale_index') -%>">
+          <span class="big"><%= number_with_precision(index.value, :precision => 1) -%></span>&nbsp;<%= message('widget.technical_debt.days') -%></a>
+        <%= dashboard_configuration.selected_period? ? format_variation(index) : trend_icon(index) -%>
+      </p>
+    </div>
+<% end %>