From 45b9f6870c36040482930d73237d6d98a282f904 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Thu, 9 Oct 2014 12:53:42 +0200 Subject: [PATCH] SONAR-5712 Merge package_design widget into file_design widget --- .../dashboards/ProjectDefaultDashboard.java | 1 - .../ProjectDefaultDashboardTest.java | 2 +- .../sonar/plugins/design/DesignPlugin.java | 4 +- .../ui/widgets/PackageDesignWidget.java | 43 ------ .../design/ui/widgets/file_design.html.erb | 128 ++++++++++++++---- .../design/ui/widgets/package_design.html.erb | 62 --------- 6 files changed, 102 insertions(+), 138 deletions(-) delete mode 100644 plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java delete mode 100644 plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java index 96799dfec2c..b7deddf94a0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java @@ -57,7 +57,6 @@ public final class ProjectDefaultDashboard extends DashboardTemplate { dashboard.addWidget("rules", 2); dashboard.addWidget("alerts", 2); dashboard.addWidget("file_design", 2); - dashboard.addWidget("package_design", 2); dashboard.addWidget("code_coverage", 2); } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java index 9da3ea6f7fe..ad3afee325c 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboardTest.java @@ -44,6 +44,6 @@ public class ProjectDefaultDashboardTest { Dashboard dashboard = template.createDashboard(); assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(11); + assertThat(dashboard.getWidgets()).hasSize(10); } } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java index bc464fe4b96..9c12c1bfe5c 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java @@ -27,7 +27,6 @@ import org.sonar.plugins.design.batch.MavenDependenciesSensor; import org.sonar.plugins.design.batch.PackageTangleIndexDecorator; import org.sonar.plugins.design.batch.ProjectDsmDecorator; import org.sonar.plugins.design.ui.widgets.FileDesignWidget; -import org.sonar.plugins.design.ui.widgets.PackageDesignWidget; import java.util.List; @@ -42,7 +41,6 @@ public class DesignPlugin extends SonarPlugin { FileTangleIndexDecorator.class, // UI - FileDesignWidget.class, - PackageDesignWidget.class); + FileDesignWidget.class); } } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java deleted file mode 100644 index d79f9337d68..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/PackageDesignWidget.java +++ /dev/null @@ -1,43 +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.design.ui.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.RubyRailsWidget; -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@UserRole(UserRole.USER) -@WidgetCategory({ "Design" }) -public final class PackageDesignWidget extends AbstractRubyTemplate implements RubyRailsWidget { - - public String getId() { - return "package_design"; - } - - public String getTitle() { - return "File design"; - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/plugins/design/ui/widgets/package_design.html.erb"; - } -} diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb index 2fcac1fc7a9..63e9020b77b 100644 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb @@ -1,38 +1,110 @@ <% + dsm_url = ApplicationController.root_context + '/design/index/' + @resource.key + file_tangle_index=measure('file_tangle_index') if file_tangle_index file_cycles=measure('file_cycles') file_feedback_edges=measure('file_feedback_edges') %> - - - - - - - -
-
-

<%= message('widget.file_design.file_tangle_index') -%>

-

- <%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%> <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%> -

- <% if file_cycles %> -

- > <%= format_measure(file_cycles, :suffix => message('widget.file_design.cycles.suffix'), :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%> -

- <% end %> +
+
+
+
+ <%= message('widget.file_design.file_tangle_index') -%> + + <%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => dsm_url) -%> + <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%> + +
+ + <% if file_cycles %> +
+ <%= message('widget.file_design.cycles.suffix') -%> + + > + <%= format_measure(file_cycles, :default => '-', :url => dsm_url) %> + <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%> +
-
- <% if file_feedback_edges %> -
-

<%= message('widget.file_design.suspect_file_dependencies') -%>

-

- <%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%> <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%> -

+ <% end %> +
+ + +
+ <% if file_feedback_edges %> +
+
+ <%= message('widget.file_design.suspect_file_dependencies') -%> + + <%= format_measure(file_feedback_edges, :url => dsm_url) -%> + <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%> + +
+
+ <% end %> +
+ +<% + else + package_tangle_index=measure('package_tangle_index') + if package_tangle_index + package_cycles=measure('package_cycles') + package_feedback_edges=measure('package_feedback_edges') + package_tangles=measure('package_tangles') +%> +
+
+
+
+ <%= message('widget.package_design.package_tangle_index') -%> + + <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => dsm_url) %> + <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index) -%> + +
+ + <% if package_cycles %> +
+ <%= message('widget.package_design.cycles.suffix') -%> + + > + <%= format_measure(package_cycles, :default => '-', :url => dsm_url) %> + <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%> + +
+ <% end %> +
+
+ +
+
+
+ <%= message('widget.package_design.dependencies_to_cut') -%> +
+ + <% if package_feedback_edges %> +
+ <%= message('widget.package_design.between_packages.suffix') -%> + + <%= format_measure(package_feedback_edges, :default => '-', :url => dsm_url) %> + <%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%> +
- <% end %> -
+ <% end %> + + <% if package_tangles %> +
+ <%= message('widget.package_design.between_files.suffix') -%> + + <%= format_measure(package_tangles, :default => '-', :url => dsm_url) %> + <%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%> + +
+ <% end %> + + + <% + end end -%> \ No newline at end of file +%> diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb deleted file mode 100644 index b036433449a..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb +++ /dev/null @@ -1,62 +0,0 @@ -<% - package_tangle_index=measure('package_tangle_index') - if package_tangle_index - package_cycles=measure('package_cycles') - package_feedback_edges=measure('package_feedback_edges') - package_tangles=measure('package_tangles') - dsm_url = ApplicationController.root_context + '/design/index/' + @resource.key -%> -
-
-
-
- <%= message('widget.package_design.package_tangle_index') -%> - - <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index) -%> - -
- - <% if package_cycles %> -
- <%= message('widget.package_design.cycles.suffix') -%> - - > - <%= format_measure(package_cycles, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%> - -
- <% end %> -
-
- -
-
-
- <%= message('widget.package_design.dependencies_to_cut') -%> -
- - <% if package_feedback_edges %> -
- <%= message('widget.package_design.between_packages.suffix') -%> - - <%= format_measure(package_feedback_edges, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%> - -
- <% end %> - - <% if package_tangles %> -
- <%= message('widget.package_design.between_files.suffix') -%> - - <%= format_measure(package_tangles, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%> - -
- <% end %> -
-
-
- -<% end %> -- 2.39.5