Add `tooltip` field to `WebLinkInfo` entity.
We would like to show icons only in some places of the UI when
rendering weblinks. That requires having a tooltip, otherwise the user
will have a hard time exploring what the purpose of the icon is.
Release-Notes: skip
Change-Id: Iab92bc74cf79162c89b26e7956f70834334c7853
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index 2d78c86..d8a95ef 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -7633,18 +7633,19 @@
[[diff-web-link-info]]
=== DiffWebLinkInfo
-The `DiffWebLinkInfo` entity describes a link on a diff screen to an
-external site.
+The `DiffWebLinkInfo` entity extends link:#web-link-info[WebLinkInfo] and
+describes a link on a diff screen to an external site.
-[options="header",cols="1,6"]
+[options="header",cols="1,^1,5"]
|=======================
-|Field Name|Description
-|`name` |The link name.
-|`url` |The link URL.
-|`image_url`|URL to the icon of the link.
-|show_on_side_by_side_diff_view|
+|Field Name||Description
+|`name` ||See link:#web-link-info[WebLinkInfo]
+|`tooltip` |optional|See link:#web-link-info[WebLinkInfo]
+|`url` ||See link:#web-link-info[WebLinkInfo]
+|`image_url`|optional|See link:#web-link-info[WebLinkInfo]
+|show_on_side_by_side_diff_view||
Whether the web link should be shown on the side-by-side diff screen.
-|show_on_unified_diff_view|
+|show_on_unified_diff_view||
Whether the web link should be shown on the unified diff screen.
|=======================
@@ -8925,12 +8926,21 @@
[[web-link-info]]
=== WebLinkInfo
-The `WebLinkInfo` entity describes a link to an external site.
+The `WebLinkInfo` entity describes a link to an external site. Depending on the
+context and the provided data the UI may decide to show the link as a text link,
+a linkified icon, or both.
+
+If the `tooltip` is not provided, then the UI may fall back to showing something
+like "Open in External Tool".
+
+Weblinks will always be opened in a new tab.
[options="header",cols="1,^1,5"]
|========================
|Field Name ||Description
-|`name` ||The link name.
+|`name` ||The text to be linkified.
+|`tooltip` |optional|Tooltip to show when hovering over the link. Using "Open
+in $NAME_OF_EXTERNAL_TOOL" is a good option here.
|`url` ||The link URL.
|`image_url`|optional|URL to the icon of the link.
|========================
diff --git a/java/com/google/gerrit/extensions/common/WebLinkInfo.java b/java/com/google/gerrit/extensions/common/WebLinkInfo.java
index a651a4d..eeed284 100644
--- a/java/com/google/gerrit/extensions/common/WebLinkInfo.java
+++ b/java/com/google/gerrit/extensions/common/WebLinkInfo.java
@@ -19,6 +19,7 @@
public class WebLinkInfo {
public String name;
+ public String tooltip;
public String imageUrl;
public String url;
@@ -41,13 +42,14 @@
}
WebLinkInfo i = (WebLinkInfo) o;
return Objects.equals(name, i.name)
+ && Objects.equals(tooltip, i.tooltip)
&& Objects.equals(imageUrl, i.imageUrl)
&& Objects.equals(url, i.url);
}
@Override
public int hashCode() {
- return Objects.hash(name, imageUrl, url);
+ return Objects.hash(name, tooltip, imageUrl, url);
}
@Override
@@ -55,6 +57,8 @@
return getClass().getSimpleName()
+ "{name="
+ name
+ + ", tooltip="
+ + tooltip
+ ", imageUrl="
+ imageUrl
+ ", url="
diff --git a/java/com/google/gerrit/server/config/GitwebConfig.java b/java/com/google/gerrit/server/config/GitwebConfig.java
index 6185df7..f8c0592 100644
--- a/java/com/google/gerrit/server/config/GitwebConfig.java
+++ b/java/com/google/gerrit/server/config/GitwebConfig.java
@@ -383,7 +383,9 @@
}
private WebLinkInfo link(String rest) {
- return new WebLinkInfo(type.getLinkName(), null, url + rest);
+ WebLinkInfo webLink = new WebLinkInfo(type.getLinkName(), null, url + rest);
+ webLink.tooltip = "Open in GitWeb";
+ return webLink;
}
@Nullable
diff --git a/polygerrit-ui/app/api/rest-api.ts b/polygerrit-ui/app/api/rest-api.ts
index 1e12b32..9a483f0 100644
--- a/polygerrit-ui/app/api/rest-api.ts
+++ b/polygerrit-ui/app/api/rest-api.ts
@@ -1095,8 +1095,10 @@
* https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#web-link-info
*/
export declare interface WebLinkInfo {
- /** The link name. */
+ /** The text to be linkified. */
name: string;
+ /** Tooltip to show when hovering over the link. */
+ tooltip?: string;
/** The link URL. */
url: string;
/** URL to the icon of the link. */