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
This commit is contained in:
@@ -69,6 +69,10 @@ public class PageLinks {
|
|||||||
return toChangeQuery(op("owner", fullname) + " " + status(status), TOP);
|
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) {
|
public static String toProjectDashboards(Project.NameKey proj) {
|
||||||
return ADMIN_PROJECTS + proj.get() + ",dashboards";
|
return ADMIN_PROJECTS + proj.get() + ",dashboards";
|
||||||
}
|
}
|
||||||
|
@@ -73,6 +73,7 @@ import com.google.gerrit.client.dashboards.DashboardInfo;
|
|||||||
import com.google.gerrit.client.dashboards.DashboardList;
|
import com.google.gerrit.client.dashboards.DashboardList;
|
||||||
import com.google.gerrit.client.patches.PatchScreen;
|
import com.google.gerrit.client.patches.PatchScreen;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
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.client.ui.Screen;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.auth.SignInMode;
|
import com.google.gerrit.common.auth.SignInMode;
|
||||||
@@ -406,8 +407,10 @@ public class Dispatcher {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(DashboardInfo result) {
|
public void onSuccess(DashboardInfo result) {
|
||||||
if (matchPrefix("/dashboard/", result.url())) {
|
if (matchPrefix("/dashboard/", result.url())) {
|
||||||
String rest = skip(result.url());
|
String params = skip(result.url()).substring(1);
|
||||||
Gerrit.display(token, new CustomDashboardScreen(rest.substring(1)));
|
CustomDashboardScreen dash = new CustomDashboardScreen(params);
|
||||||
|
dash.setTitle(new InlineHyperlink(dash.getTitle(), PageLinks.toCustomDashboard(params)));
|
||||||
|
Gerrit.display(token, dash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import java.util.List;
|
|||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
public class CustomDashboardScreen extends Screen implements ChangeListScreen {
|
public class CustomDashboardScreen extends Screen implements ChangeListScreen {
|
||||||
|
private String params;
|
||||||
private String title;
|
private String title;
|
||||||
private List<String> titles;
|
private List<String> titles;
|
||||||
private List<String> queries;
|
private List<String> queries;
|
||||||
@@ -34,6 +35,7 @@ public class CustomDashboardScreen extends Screen implements ChangeListScreen {
|
|||||||
private List<ChangeTable2.Section> sections;
|
private List<ChangeTable2.Section> sections;
|
||||||
|
|
||||||
public CustomDashboardScreen(String params) {
|
public CustomDashboardScreen(String params) {
|
||||||
|
this.params = params;
|
||||||
titles = new ArrayList<String>();
|
titles = new ArrayList<String>();
|
||||||
queries = new ArrayList<String>();
|
queries = new ArrayList<String>();
|
||||||
String foreach = null;
|
String foreach = null;
|
||||||
@@ -123,4 +125,8 @@ public class CustomDashboardScreen extends Screen implements ChangeListScreen {
|
|||||||
super.registerKeys();
|
super.registerKeys();
|
||||||
table.setRegisterKeys(true);
|
table.setRegisterKeys(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@ public abstract class Screen extends View {
|
|||||||
private String token;
|
private String token;
|
||||||
private boolean requiresSignIn;
|
private boolean requiresSignIn;
|
||||||
private String windowTitle;
|
private String windowTitle;
|
||||||
|
private Widget titleWidget;
|
||||||
|
|
||||||
protected Screen() {
|
protected Screen() {
|
||||||
initWidget(new FlowPanel());
|
initWidget(new FlowPanel());
|
||||||
@@ -65,8 +66,12 @@ public abstract class Screen extends View {
|
|||||||
me.add(header = new Grid(1, Cols.values().length));
|
me.add(header = new Grid(1, Cols.values().length));
|
||||||
me.add(body = new FlowPanel());
|
me.add(body = new FlowPanel());
|
||||||
|
|
||||||
|
headerText = new InlineLabel();
|
||||||
|
if (titleWidget == null) {
|
||||||
|
titleWidget = headerText;
|
||||||
|
}
|
||||||
FlowPanel title = new FlowPanel();
|
FlowPanel title = new FlowPanel();
|
||||||
title.add(headerText = new InlineLabel());
|
title.add(titleWidget);
|
||||||
title.setStyleName(Gerrit.RESOURCES.css().screenHeader());
|
title.setStyleName(Gerrit.RESOURCES.css().screenHeader());
|
||||||
header.setWidget(0, Cols.Title.ordinal(), title);
|
header.setWidget(0, Cols.Title.ordinal(), title);
|
||||||
|
|
||||||
@@ -99,6 +104,10 @@ public abstract class Screen extends View {
|
|||||||
header.setVisible(value);
|
header.setVisible(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(final Widget w) {
|
||||||
|
titleWidget = w;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setTitleEast(final Widget w) {
|
protected void setTitleEast(final Widget w) {
|
||||||
header.setWidget(0, Cols.East.ordinal(), w);
|
header.setWidget(0, Cols.East.ordinal(), w);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user