diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index f7a24737f8..a14aebcfc8 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -1775,6 +1775,11 @@ public class MyWeblinkPlugin implements PatchSetWebLink { public String getImageUrl() { return imageUrl; } + + @Override + public String getTarget() { + return "_blank"; + } } ---- diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/WebLinkInfo.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/WebLinkInfo.java index 9f9e9092da..d9a34bf245 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/WebLinkInfo.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/WebLinkInfo.java @@ -18,10 +18,12 @@ public class WebLinkInfo { public String name; public String imageUrl; public String url; + public String target; - public WebLinkInfo(String name, String imageUrl, String url) { + public WebLinkInfo(String name, String imageUrl, String url, String target) { this.name = name; this.imageUrl = imageUrl; this.url = url; + this.target = target; } } diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/WebLink.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/WebLink.java index 581098bafb..4065c68148 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/WebLink.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/WebLink.java @@ -15,6 +15,12 @@ package com.google.gerrit.extensions.webui; public interface WebLink { + public static class Target { + public final static String BLANK = "_blank"; + public final static String SELF = "_self"; + public final static String PARENT = "_parent"; + public final static String TOP = "_top"; + } /** * The link-name displayed in UI. * @@ -29,4 +35,11 @@ public interface WebLink { * Recommended image size is 16x16. */ String getImageUrl(); + + /** + * Target window in which the link should be opened (e.g. "_blank", "_self".). + * + * @return link target, if null the link is opened in the current window + */ + String getTarget(); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/WebLinkInfo.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/WebLinkInfo.java index 3fbc4ff3af..3ed91bed9a 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/WebLinkInfo.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/WebLinkInfo.java @@ -21,6 +21,7 @@ public class WebLinkInfo extends JavaScriptObject { public final native String name() /*-{ return this.name; }-*/; public final native String imageUrl() /*-{ return this.image_url; }-*/; public final native String url() /*-{ return this.url; }-*/; + public final native String target() /*-{ return this.target; }-*/; protected WebLinkInfo() { } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java index c3d9d5f357..9a6dae44c1 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java @@ -399,6 +399,9 @@ public class ProjectBranchesScreen extends ProjectScreen { for (WebLinkInfo weblink : Natives.asList(k.web_links())) { Anchor a = new Anchor(); a.setHref(weblink.url()); + if (weblink.target() != null && !weblink.target().isEmpty()) { + a.setTarget(weblink.target()); + } if (weblink.imageUrl() != null && !weblink.imageUrl().isEmpty()) { Image img = new Image(); img.setAltText(weblink.name()); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java index e81162f0eb..af01ad3228 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectListScreen.java @@ -240,6 +240,9 @@ public class ProjectListScreen extends Screen implements FilteredUserInterface { for (WebLinkInfo weblink : webLinks) { Anchor a = new Anchor(); a.setHref(weblink.url()); + if (weblink.target() != null && !weblink.target().isEmpty()) { + a.setTarget(weblink.target()); + } if (weblink.imageUrl() != null && !weblink.imageUrl().isEmpty()) { Image img = new Image(); img.setAltText(weblink.name()); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java index c5c66c17f5..b32a31b75c 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java @@ -127,20 +127,25 @@ class CommitBox extends Composite { GitwebLink gw = Gerrit.getGitwebLink(); if (gw != null && gw.canLink(revInfo)) { addWebLink(gw.toRevision(change.project(), revision), - gw.getLinkName(), null); + gw.getLinkName(), null, null); } JsArray links = revInfo.web_links(); if (links != null) { for (WebLinkInfo link : Natives.asList(links)) { - addWebLink(link.url(), parenthesize(link.name()), link.imageUrl()); + addWebLink(link.url(), parenthesize(link.name()), link.imageUrl(), + link.target()); } } } - private void addWebLink(String href, String name, String imageUrl) { + private void addWebLink(String href, String name, String imageUrl, + String target) { Anchor a = new Anchor(); a.setHref(href); + if (target != null && !target.isEmpty()) { + a.setTarget(target); + } if (imageUrl != null && !imageUrl.isEmpty()) { Image img = new Image(); img.setAltText(name); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PatchSetSelectBox2.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PatchSetSelectBox2.java index ba64647c55..ecfc7b7e83 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PatchSetSelectBox2.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PatchSetSelectBox2.java @@ -108,6 +108,9 @@ class PatchSetSelectBox2 extends Composite { for (WebLinkInfo weblink : webLinks) { Anchor a = new Anchor(); a.setHref(weblink.url()); + if (weblink.target() != null && !weblink.target().isEmpty()) { + a.setTarget(weblink.target()); + } if (weblink.imageUrl() != null && !weblink.imageUrl().isEmpty()) { Image img = new Image(); img.setAltText(weblink.name()); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/WebLinks.java b/gerrit-server/src/main/java/com/google/gerrit/server/WebLinks.java index 515cd4cb40..629e75b440 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/WebLinks.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/WebLinks.java @@ -46,7 +46,8 @@ public class WebLinks { for (PatchSetWebLink webLink : patchSetLinks) { links.add(new WebLinkInfo(webLink.getLinkName(), webLink.getImageUrl(), - webLink.getPatchSetUrl(project, commit))); + webLink.getPatchSetUrl(project, commit), + webLink.getTarget())); } return links; } @@ -57,7 +58,8 @@ public class WebLinks { for (FileWebLink webLink : fileLinks) { links.add(new WebLinkInfo(webLink.getLinkName(), webLink.getImageUrl(), - webLink.getFileUrl(project, revision, file))); + webLink.getFileUrl(project, revision, file), + webLink.getTarget())); } return links; } @@ -67,7 +69,8 @@ public class WebLinks { for (ProjectWebLink webLink : projectLinks) { links.add(new WebLinkInfo(webLink.getLinkName(), webLink.getImageUrl(), - webLink.getProjectUrl(project))); + webLink.getProjectUrl(project), + webLink.getTarget())); } return links; } @@ -77,7 +80,8 @@ public class WebLinks { for (BranchWebLink webLink : branchLinks) { links.add(new WebLinkInfo(webLink.getLinkName(), webLink.getImageUrl(), - webLink.getBranchUrl(project, branch))); + webLink.getBranchUrl(project, branch), + webLink.getTarget())); } return links; } diff --git a/plugins/its-base b/plugins/its-base new file mode 160000 index 0000000000..e9135f64e4 --- /dev/null +++ b/plugins/its-base @@ -0,0 +1 @@ +Subproject commit e9135f64e4f38229124392e8007e45f8f4ad0e58