From 3decc025e9efb2d545b497f06ac06d9fd388da1b Mon Sep 17 00:00:00 2001 From: Martin Fick Date: Wed, 21 Nov 2012 15:25:49 -0700 Subject: [PATCH] Link dashboard title to a url version of itself When using a stable project dashboard URL, the url obfuscates the content of the dashboard which can make it hard to debug a dashboard or copy and modify it. In the special case of stable dashboards, make the title a link to an unstable url version of the dashboard with the url reflecting the actual dashboard contents the way a custom dashboard does. Change-Id: I7916bdd8767b5f0854e4b0e1a05ff8eb3bfc3a16 --- .../main/java/com/google/gerrit/common/PageLinks.java | 4 ++++ .../java/com/google/gerrit/client/Dispatcher.java | 7 +++++-- .../gerrit/client/changes/CustomDashboardScreen.java | 6 ++++++ .../main/java/com/google/gerrit/client/ui/Screen.java | 11 ++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/PageLinks.java b/gerrit-common/src/main/java/com/google/gerrit/common/PageLinks.java index 0ad7552a58..6be3a1c420 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/PageLinks.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/PageLinks.java @@ -69,6 +69,10 @@ public class PageLinks { return toChangeQuery(op("owner", fullname) + " " + status(status), TOP); } + public static String toCustomDashboard(final String params) { + return "/dashboard/?" + params; + } + public static String toProjectDashboards(Project.NameKey proj) { return ADMIN_PROJECTS + proj.get() + ",dashboards"; } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java index dd9e481cdd..cc3408a33a 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Dispatcher.java @@ -73,6 +73,7 @@ import com.google.gerrit.client.dashboards.DashboardInfo; import com.google.gerrit.client.dashboards.DashboardList; import com.google.gerrit.client.patches.PatchScreen; import com.google.gerrit.client.rpc.GerritCallback; +import com.google.gerrit.client.ui.InlineHyperlink; import com.google.gerrit.client.ui.Screen; import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.auth.SignInMode; @@ -406,8 +407,10 @@ public class Dispatcher { @Override public void onSuccess(DashboardInfo result) { if (matchPrefix("/dashboard/", result.url())) { - String rest = skip(result.url()); - Gerrit.display(token, new CustomDashboardScreen(rest.substring(1))); + String params = skip(result.url()).substring(1); + CustomDashboardScreen dash = new CustomDashboardScreen(params); + dash.setTitle(new InlineHyperlink(dash.getTitle(), PageLinks.toCustomDashboard(params))); + Gerrit.display(token, dash); } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/CustomDashboardScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/CustomDashboardScreen.java index f630248243..606a981f9f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/CustomDashboardScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/CustomDashboardScreen.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.ListIterator; public class CustomDashboardScreen extends Screen implements ChangeListScreen { + private String params; private String title; private List titles; private List queries; @@ -34,6 +35,7 @@ public class CustomDashboardScreen extends Screen implements ChangeListScreen { private List sections; public CustomDashboardScreen(String params) { + this.params = params; titles = new ArrayList(); queries = new ArrayList(); String foreach = null; @@ -123,4 +125,8 @@ public class CustomDashboardScreen extends Screen implements ChangeListScreen { super.registerKeys(); table.setRegisterKeys(true); } + + public String getTitle() { + return title; + } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Screen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Screen.java index 8f01e2d3de..47cc03850b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Screen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Screen.java @@ -39,6 +39,7 @@ public abstract class Screen extends View { private String token; private boolean requiresSignIn; private String windowTitle; + private Widget titleWidget; protected Screen() { initWidget(new FlowPanel()); @@ -65,8 +66,12 @@ public abstract class Screen extends View { me.add(header = new Grid(1, Cols.values().length)); me.add(body = new FlowPanel()); + headerText = new InlineLabel(); + if (titleWidget == null) { + titleWidget = headerText; + } FlowPanel title = new FlowPanel(); - title.add(headerText = new InlineLabel()); + title.add(titleWidget); title.setStyleName(Gerrit.RESOURCES.css().screenHeader()); header.setWidget(0, Cols.Title.ordinal(), title); @@ -99,6 +104,10 @@ public abstract class Screen extends View { header.setVisible(value); } + public void setTitle(final Widget w) { + titleWidget = w; + } + protected void setTitleEast(final Widget w) { header.setWidget(0, Cols.East.ordinal(), w); }