Move file web_links into the meta_a, meta_b headers

Web links should be part of the metadata for the two halves of a diff.
The protocol uses meta_a and meta_b to represent the halves, with
contained fields for specific values.

Also avoid unnecessary copying of the WebLinkInfo by reusing the
created list from the WebLinks factory.

Change-Id: I2c31cad2a4fed11e513f81cd613742534662a663
This commit is contained in:
Shawn Pearce
2014-10-16 22:48:33 -07:00
parent 2ae832e7ed
commit b62414c0c3
6 changed files with 26 additions and 34 deletions

View File

@@ -28,8 +28,6 @@ public class DiffInfo extends JavaScriptObject {
public final native FileMeta meta_b() /*-{ return this.meta_b; }-*/;
public final native JsArrayString diff_header() /*-{ return this.diff_header; }-*/;
public final native JsArray<Region> content() /*-{ return this.content; }-*/;
public final native JsArray<WebLinkInfo> web_links_a() /*-{ return this.web_links_a; }-*/;
public final native JsArray<WebLinkInfo> web_links_b() /*-{ return this.web_links_b; }-*/;
public final ChangeType change_type() {
return ChangeType.valueOf(change_typeRaw());
@@ -103,6 +101,7 @@ public class DiffInfo extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
public final native String content_type() /*-{ return this.content_type; }-*/;
public final native int lines() /*-{ return this.lines || 0 }-*/;
public final native JsArray<WebLinkInfo> web_links() /*-{ return this.web_links; }-*/;
protected FileMeta() {
}

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.diff;
import com.google.gerrit.client.account.DiffPreferences;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.core.client.GWT;
@@ -173,10 +172,8 @@ class DiffTable extends Composite {
boolean editExists, int currentPatchSet) {
this.changeType = info.change_type();
this.autoHideHeader = prefs.autoHideDiffTableHeader();
patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a(),
Natives.asList(info.web_links_a()), editExists, currentPatchSet);
patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b(),
Natives.asList(info.web_links_b()), editExists, currentPatchSet);
patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a(), editExists, currentPatchSet);
patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b(), editExists, currentPatchSet);
JsArrayString hdr = info.diff_header();
if (hdr != null) {

View File

@@ -22,6 +22,7 @@ import com.google.gerrit.client.changes.ChangeFileApi;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.InlineHyperlink;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
@@ -86,7 +87,7 @@ class PatchSetSelectBox2 extends Composite {
}
void setUpPatchSetNav(JsArray<RevisionInfo> list, DiffInfo.FileMeta meta,
List<WebLinkInfo> webLinks, boolean editExists, int currentPatchSet) {
boolean editExists, int currentPatchSet) {
InlineHyperlink baseLink = null;
InlineHyperlink selectedLink = null;
if (sideA) {
@@ -117,6 +118,7 @@ class PatchSetSelectBox2 extends Composite {
linkPanel.add(createEditIcon());
}
}
List<WebLinkInfo> webLinks = Natives.asList(meta.web_links());
if (webLinks != null) {
for (WebLinkInfo weblink : webLinks) {
Anchor a = new Anchor();