From 604ec306443465b67ac40423921d04e5d1bc169e Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Tue, 20 Dec 2011 11:48:15 +0100 Subject: [PATCH] SONAR-2662 Add action plan widget --- .../org/sonar/plugins/core/CorePlugin.java | 6 +++ .../actionPlans/ActionPlansWidget.java | 40 ++++++++++++++ .../widgets/reviews/PlannedReviewsWidget.java | 49 +++++++++++++++++ .../reviews/UnplannedReviewsWidget.java | 49 +++++++++++++++++ .../widgets/actionPlans/action_plans.html.erb | 53 +++++++++++++++++++ .../widgets/reviews/planned_reviews.html.erb | 1 + .../reviews/unplanned_reviews.html.erb | 1 + .../resources/org/sonar/l10n/core.properties | 12 +++++ .../app/views/action_plans/index.html.erb | 2 +- .../app/views/layouts/_layout.html.erb | 2 + .../src/main/webapp/stylesheets/style.css | 8 +-- 11 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/actionPlans/ActionPlansWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/PlannedReviewsWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/UnplannedReviewsWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb 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 58b343aeb46..22e2ccd4b8f 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 @@ -42,10 +42,13 @@ import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition; import org.sonar.plugins.core.timemachine.*; import org.sonar.plugins.core.web.Lcom4Viewer; import org.sonar.plugins.core.widgets.*; +import org.sonar.plugins.core.widgets.actionPlans.ActionPlansWidget; import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget; import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget; +import org.sonar.plugins.core.widgets.reviews.PlannedReviewsWidget; import org.sonar.plugins.core.widgets.reviews.ProjectReviewsWidget; import org.sonar.plugins.core.widgets.reviews.ReviewsPerDeveloperWidget; +import org.sonar.plugins.core.widgets.reviews.UnplannedReviewsWidget; import java.util.List; @@ -248,6 +251,9 @@ public class CorePlugin extends SonarPlugin { extensions.add(ProjectReviewsWidget.class); extensions.add(FalsePositiveReviewsWidget.class); extensions.add(ReviewsPerDeveloperWidget.class); + extensions.add(PlannedReviewsWidget.class); + extensions.add(UnplannedReviewsWidget.class); + extensions.add(ActionPlansWidget.class); // dashboards extensions.add(DefaultDashboard.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/actionPlans/ActionPlansWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/actionPlans/ActionPlansWidget.java new file mode 100644 index 00000000000..4950c877018 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/actionPlans/ActionPlansWidget.java @@ -0,0 +1,40 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.widgets.actionPlans; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.WidgetCategory; + +@WidgetCategory({ "Action plans", "Reviews" }) +public class ActionPlansWidget extends AbstractRubyTemplate implements RubyRailsWidget { + public String getId() { + return "action_plans"; + } + + public String getTitle() { + return "Action plans"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb"; + } +} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/PlannedReviewsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/PlannedReviewsWidget.java new file mode 100644 index 00000000000..9299e693a94 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/PlannedReviewsWidget.java @@ -0,0 +1,49 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.widgets.reviews; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory({ "Action plans", "Reviews" }) +@WidgetProperties( + { + @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5", + description="Maximum number of reviews displayed at the same time.") + } +) +public class PlannedReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget { + public String getId() { + return "planned_reviews"; + } + + public String getTitle() { + return "Planned reviews"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb"; + } +} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/UnplannedReviewsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/UnplannedReviewsWidget.java new file mode 100644 index 00000000000..dbe1fc99740 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/reviews/UnplannedReviewsWidget.java @@ -0,0 +1,49 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.widgets.reviews; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.WidgetCategory; +import org.sonar.api.web.WidgetProperties; +import org.sonar.api.web.WidgetProperty; +import org.sonar.api.web.WidgetPropertyType; + +@WidgetCategory({ "Action plans", "Reviews" }) +@WidgetProperties( + { + @WidgetProperty(key = "numberOfLines", type = WidgetPropertyType.INTEGER, defaultValue = "5", + description="Maximum number of reviews displayed at the same time.") + } +) +public class UnplannedReviewsWidget extends AbstractRubyTemplate implements RubyRailsWidget { + public String getId() { + return "unplanned_reviews"; + } + + public String getTitle() { + return "Unplanned reviews"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb"; + } +} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb new file mode 100644 index 00000000000..e3788735a8d --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/actionPlans/action_plans.html.erb @@ -0,0 +1,53 @@ +<% + if has_role?(:user, @project) + action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id], + :include => 'reviews', :order => 'dead_line ASC') + + div_id = "action-plan-widget-#{widget.id.to_s}" +%> + +
+
+ + <%= message('widgets.more') -%> + +
+

<%= message('widget.action_plans.title') -%>

+
+ +<% if action_plans.size ==0 %> + <%= message('widget.action_plans.no_action_plan') -%> +<% else %> + +
+ + + + + + + + <% + action_plans.each do |plan| + %> + + + + <% if plan.progress[:total]==0 %> + + <% else %> + + <% end %> + + <% + end + %> + +
<%= h(plan.name) -%><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%><%= message('action_plans.no_reviews_linked_to_action_plan') -%> + <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%> +
+
+ +<% end %> + +<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb new file mode 100644 index 00000000000..a81fe827804 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/planned_reviews.html.erb @@ -0,0 +1 @@ + Under construction ;-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb new file mode 100644 index 00000000000..1fcfa839580 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/reviews/unplanned_reviews.html.erb @@ -0,0 +1 @@ + Under construction ;-) \ 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 a4c273918e9..ac7dbbf6775 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 @@ -654,6 +654,18 @@ widget.reviews_per_developer.name=Open reviews per developer widget.reviews_per_developer.description=Shows the number of open/reopened reviews per developer. widget.reviews_per_developer.not_assigned=Not assigned +widget.action_plans.name=Action plans +widget.action_plans.description=Shows all the open action plans of the project +widget.action_plans.title=Open action plans +widget.action_plans.no_action_plan=No action plan + +widget.planned_reviews.name=Planned reviews +widget.planned_reviews.description=Shows all the planned reviews of the project, gathered by action plan + +widget.unplanned_reviews.name=Unplanned reviews +widget.unplanned_reviews.description=Shows all the reviews of the project that are not planned yet in an action plan + + #------------------------------------------------------------------------------ # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb index 60fda96d531..38ecf0abd7e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb @@ -8,7 +8,7 @@

<%= message('action_plans.page_title') -%>

- +
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index d88104aad2f..fec76547b34 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -71,8 +71,10 @@
  • <%= message('sidebar.project_settings') -%>
  • <%= message('manual_measures.page') -%>
  • + <% if (@project.project?) %>
  • <%= message('action_plans.page') -%>
  • + <% end %> <% if (@project.project? || @project.module?) %>
  • <%= message('project_settings.page') -%>
  • diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index bd9622f7ab3..06e96e8e81c 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -1228,23 +1228,23 @@ div.comment-excerpt { } /* ACTION PLANS */ -#actionPlans td { +table.actionPlans td { vertical-align: top; } -#actionPlans td.progress { +table.actionPlans td.progress { width: 300px; padding: 0px 40px; } -#actionPlans td.noprogress { +table.actionPlans td.noprogress { color: #777777; font-size: 93%; padding-left: 40px; padding-right: 40px; } -#actionPlans td.over-due { +table.actionPlans td.over-due { color: #CC0000; font-weight: bold; } -- 2.39.5
    <%= message('action_plans.col.status') -%>