From d28a121fe58d6155048ba244e92a36540cba9990 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 7 Dec 2015 17:35:03 +0100 Subject: [PATCH] SONAR-7030 Update widgets from Custom dashboard --- ...board.java => ProjectCustomDashboard.java} | 19 +++++++++++-------- .../platformlevel/PlatformLevel4.java | 4 ++-- ...t.java => ProjectCustomDashboardTest.java} | 10 +++++----- .../filters.xml | 0 4 files changed, 18 insertions(+), 15 deletions(-) rename server/sonar-server/src/main/java/org/sonar/server/dashboard/template/{ProjectDefaultDashboard.java => ProjectCustomDashboard.java} (83%) rename server/sonar-server/src/test/java/org/sonar/server/dashboard/template/{ProjectDefaultDashboardTest.java => ProjectCustomDashboardTest.java} (89%) rename server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/{ProjectDefaultDashboardTest => ProjectCustomDashboardTest}/filters.xml (100%) diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java similarity index 83% rename from server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java rename to server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java index 3803fb2db63..bb24d96305b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectDefaultDashboard.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java @@ -28,21 +28,21 @@ import org.sonar.db.issue.IssueFilterDto; import org.sonar.server.dashboard.widget.ProjectIssueFilterWidget; /** - * Default dashboard + * Custom dashboard * * @since 2.13 */ -public final class ProjectDefaultDashboard extends DashboardTemplate { +public final class ProjectCustomDashboard extends DashboardTemplate { private final IssueFilterDao issueFilterDao; - public ProjectDefaultDashboard(IssueFilterDao issueFilterDao) { + public ProjectCustomDashboard(IssueFilterDao issueFilterDao) { this.issueFilterDao = issueFilterDao; } @Override public String getName() { - return "Dashboard"; + return "Custom"; } @Override @@ -55,16 +55,19 @@ public final class ProjectDefaultDashboard extends DashboardTemplate { } private void addFirstColumn(Dashboard dashboard) { - dashboard.addWidget("technical_debt_pyramid", 1); + dashboard.addWidget("size", 1); + dashboard.addWidget("code_coverage", 1); + dashboard.addWidget("duplications", 1); + dashboard.addWidget("documentation_comments", 1); } private void addSecondColumn(Dashboard dashboard) { + dashboard.addWidget("rules", 2); + dashboard.addWidget("timeline", 2); IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues"); - dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) - .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "severities") - .setProperty(ProjectIssueFilterWidget.DISPLAY_MODE, "debt"); + .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "createdAt"); } private IssueFilterDto getIssueFilterByName(String name) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index de74d22e9fe..53b153bb349 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -66,7 +66,7 @@ import org.sonar.server.computation.taskprocessor.CeTaskProcessorModule; import org.sonar.server.computation.ws.CeWsModule; import org.sonar.server.config.ws.PropertiesWs; import org.sonar.server.dashboard.template.GlobalDefaultDashboard; -import org.sonar.server.dashboard.template.ProjectDefaultDashboard; +import org.sonar.server.dashboard.template.ProjectCustomDashboard; import org.sonar.server.dashboard.widget.ActionPlansWidget; import org.sonar.server.dashboard.widget.AlertsWidget; import org.sonar.server.dashboard.widget.BubbleChartWidget; @@ -352,7 +352,7 @@ public class PlatformLevel4 extends PlatformLevel { // Dashboard DashboardsWs.class, org.sonar.server.dashboard.ws.ShowAction.class, - ProjectDefaultDashboard.class, + ProjectCustomDashboard.class, GlobalDefaultDashboard.class, AlertsWidget.class, CoverageWidget.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java similarity index 89% rename from server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java rename to server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java index 55d1b2120f3..b2b44a0c7f4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java @@ -33,22 +33,22 @@ import org.sonar.test.DbTests; import static org.assertj.core.api.Assertions.assertThat; @Category(DbTests.class) -public class ProjectDefaultDashboardTest { +public class ProjectCustomDashboardTest { @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); - ProjectDefaultDashboard template; + ProjectCustomDashboard template; @Before public void setUp() { IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis()); - template = new ProjectDefaultDashboard(issueFilterDao); + template = new ProjectCustomDashboard(issueFilterDao); } @Test public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("Dashboard"); + assertThat(template.getName()).isEqualTo("Custom"); } @Test @@ -57,7 +57,7 @@ public class ProjectDefaultDashboardTest { Dashboard dashboard = template.createDashboard(); assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(2); + assertThat(dashboard.getWidgets()).hasSize(7); } @Test diff --git a/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest/filters.xml b/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml similarity index 100% rename from server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectDefaultDashboardTest/filters.xml rename to server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml -- 2.39.5