Merge "Move file web_links into the meta_a, meta_b headers"
This commit is contained in:
@@ -3366,6 +3366,8 @@ The `DiffFileMetaInfo` entity contains meta information about a file diff.
|
|||||||
|`name` |The name of the file.
|
|`name` |The name of the file.
|
||||||
|`content_type`|The content type of the file.
|
|`content_type`|The content type of the file.
|
||||||
|`lines` |The total number of lines in the file.
|
|`lines` |The total number of lines in the file.
|
||||||
|
|'web_links' |Links to the file in external sites as a list of
|
||||||
|
link:rest-api-changes.html#web-link-info[WebLinkInfo] entries.
|
||||||
|==========================
|
|==========================
|
||||||
|
|
||||||
[[diff-info]]
|
[[diff-info]]
|
||||||
@@ -3389,12 +3391,6 @@ Intraline status (`OK`, `ERROR`, `TIMEOUT`).
|
|||||||
|`diff_header` ||A list of strings representing the patch set diff header.
|
|`diff_header` ||A list of strings representing the patch set diff header.
|
||||||
|`content` ||The content differences in the file as a list of
|
|`content` ||The content differences in the file as a list of
|
||||||
link:#diff-content[DiffContent] entities.
|
link:#diff-content[DiffContent] entities.
|
||||||
|'web_links_a' |optional|
|
|
||||||
Links to the side A file in external sites as a list of
|
|
||||||
link:rest-api-changes.html#web-link-info[WebLinkInfo] entries.
|
|
||||||
|'web_links_b' |optional|
|
|
||||||
Links to the side B file in external sites as a list of
|
|
||||||
link:rest-api-changes.html#web-link-info[WebLinkInfo] entries.
|
|
||||||
|==========================
|
|==========================
|
||||||
|
|
||||||
[[diff-intraline-info]]
|
[[diff-intraline-info]]
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ public class DiffInfo extends JavaScriptObject {
|
|||||||
public final native FileMeta meta_b() /*-{ return this.meta_b; }-*/;
|
public final native FileMeta meta_b() /*-{ return this.meta_b; }-*/;
|
||||||
public final native JsArrayString diff_header() /*-{ return this.diff_header; }-*/;
|
public final native JsArrayString diff_header() /*-{ return this.diff_header; }-*/;
|
||||||
public final native JsArray<Region> content() /*-{ return this.content; }-*/;
|
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() {
|
public final ChangeType change_type() {
|
||||||
return ChangeType.valueOf(change_typeRaw());
|
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 name() /*-{ return this.name; }-*/;
|
||||||
public final native String content_type() /*-{ return this.content_type; }-*/;
|
public final native String content_type() /*-{ return this.content_type; }-*/;
|
||||||
public final native int lines() /*-{ return this.lines || 0 }-*/;
|
public final native int lines() /*-{ return this.lines || 0 }-*/;
|
||||||
|
public final native JsArray<WebLinkInfo> web_links() /*-{ return this.web_links; }-*/;
|
||||||
|
|
||||||
protected FileMeta() {
|
protected FileMeta() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.client.diff;
|
|||||||
|
|
||||||
import com.google.gerrit.client.account.DiffPreferences;
|
import com.google.gerrit.client.account.DiffPreferences;
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
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.Patch.ChangeType;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
@@ -173,10 +172,8 @@ class DiffTable extends Composite {
|
|||||||
boolean editExists, int currentPatchSet) {
|
boolean editExists, int currentPatchSet) {
|
||||||
this.changeType = info.change_type();
|
this.changeType = info.change_type();
|
||||||
this.autoHideHeader = prefs.autoHideDiffTableHeader();
|
this.autoHideHeader = prefs.autoHideDiffTableHeader();
|
||||||
patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a(),
|
patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a(), editExists, currentPatchSet);
|
||||||
Natives.asList(info.web_links_a()), editExists, currentPatchSet);
|
patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b(), editExists, currentPatchSet);
|
||||||
patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b(),
|
|
||||||
Natives.asList(info.web_links_b()), editExists, currentPatchSet);
|
|
||||||
|
|
||||||
JsArrayString hdr = info.diff_header();
|
JsArrayString hdr = info.diff_header();
|
||||||
if (hdr != null) {
|
if (hdr != null) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.gerrit.client.changes.ChangeFileApi;
|
|||||||
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
||||||
import com.google.gerrit.client.patches.PatchUtil;
|
import com.google.gerrit.client.patches.PatchUtil;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
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.client.ui.InlineHyperlink;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
import com.google.gerrit.reviewdb.client.Patch;
|
||||||
@@ -86,7 +87,7 @@ class PatchSetSelectBox2 extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setUpPatchSetNav(JsArray<RevisionInfo> list, DiffInfo.FileMeta meta,
|
void setUpPatchSetNav(JsArray<RevisionInfo> list, DiffInfo.FileMeta meta,
|
||||||
List<WebLinkInfo> webLinks, boolean editExists, int currentPatchSet) {
|
boolean editExists, int currentPatchSet) {
|
||||||
InlineHyperlink baseLink = null;
|
InlineHyperlink baseLink = null;
|
||||||
InlineHyperlink selectedLink = null;
|
InlineHyperlink selectedLink = null;
|
||||||
if (sideA) {
|
if (sideA) {
|
||||||
@@ -117,6 +118,7 @@ class PatchSetSelectBox2 extends Composite {
|
|||||||
linkPanel.add(createEditIcon());
|
linkPanel.add(createEditIcon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<WebLinkInfo> webLinks = Natives.asList(meta.web_links());
|
||||||
if (webLinks != null) {
|
if (webLinks != null) {
|
||||||
for (WebLinkInfo weblink : webLinks) {
|
for (WebLinkInfo weblink : webLinks) {
|
||||||
Anchor a = new Anchor();
|
Anchor a = new Anchor();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.extensions.common.WebLinkInfo;
|
import com.google.gerrit.extensions.common.WebLinkInfo;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
@@ -57,15 +58,19 @@ public class WebLinks {
|
|||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<WebLinkInfo> getFileLinks(String project, String revision,
|
public List<WebLinkInfo> getFileLinks(String project, String revision,
|
||||||
String file) {
|
String file) {
|
||||||
List<WebLinkInfo> links = Lists.newArrayList();
|
List<WebLinkInfo> links = new ArrayList<>(4);
|
||||||
for (FileWebLink webLink : fileLinks) {
|
for (FileWebLink webLink : fileLinks) {
|
||||||
links.add(new WebLinkInfo(webLink.getLinkName(),
|
String name = webLink.getLinkName();
|
||||||
|
String url = webLink.getFileUrl(project, revision, file);
|
||||||
|
if (!Strings.isNullOrEmpty(name) && !Strings.isNullOrEmpty(url)) {
|
||||||
|
links.add(new WebLinkInfo(name,
|
||||||
webLink.getImageUrl(),
|
webLink.getImageUrl(),
|
||||||
webLink.getFileUrl(project, revision, file),
|
url,
|
||||||
webLink.getTarget()));
|
webLink.getTarget()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
|
|||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.common.data.PatchScript;
|
import com.google.gerrit.common.data.PatchScript;
|
||||||
@@ -47,6 +46,7 @@ import com.google.gerrit.server.project.ProjectCache;
|
|||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import org.eclipse.jgit.diff.Edit;
|
import org.eclipse.jgit.diff.Edit;
|
||||||
import org.eclipse.jgit.diff.ReplaceEdit;
|
import org.eclipse.jgit.diff.ReplaceEdit;
|
||||||
import org.kohsuke.args4j.CmdLineException;
|
import org.kohsuke.args4j.CmdLineException;
|
||||||
@@ -59,7 +59,6 @@ import org.kohsuke.args4j.spi.Parameters;
|
|||||||
import org.kohsuke.args4j.spi.Setter;
|
import org.kohsuke.args4j.spi.Setter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -160,7 +159,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
String rev = basePatchSet != null
|
String rev = basePatchSet != null
|
||||||
? basePatchSet.getRefName()
|
? basePatchSet.getRefName()
|
||||||
: resource.getRevision().getPatchSet().getRefName() + "^1";
|
: resource.getRevision().getPatchSet().getRefName() + "^1";
|
||||||
result.webLinksA =
|
result.metaA.webLinks =
|
||||||
getFileWebLinks(state.getProject(), rev, result.metaA.name);
|
getFileWebLinks(state.getProject(), rev, result.metaA.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +168,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
result.metaB.name = ps.getNewName();
|
result.metaB.name = ps.getNewName();
|
||||||
setContentType(result.metaB, state, ps.getFileModeB(), ps.getMimeTypeB());
|
setContentType(result.metaB, state, ps.getFileModeB(), ps.getMimeTypeB());
|
||||||
result.metaB.lines = ps.getB().size();
|
result.metaB.lines = ps.getB().size();
|
||||||
result.webLinksB = getFileWebLinks(state.getProject(),
|
result.metaB.webLinks = getFileWebLinks(state.getProject(),
|
||||||
resource.getRevision().getPatchSet().getRefName(),
|
resource.getRevision().getPatchSet().getRefName(),
|
||||||
result.metaB.name);
|
result.metaB.name);
|
||||||
}
|
}
|
||||||
@@ -203,14 +202,9 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
|
|
||||||
private List<WebLinkInfo> getFileWebLinks(Project project, String rev,
|
private List<WebLinkInfo> getFileWebLinks(Project project, String rev,
|
||||||
String file) {
|
String file) {
|
||||||
List<WebLinkInfo> fileWebLinks = new ArrayList<>();
|
List<WebLinkInfo> links =
|
||||||
for (WebLinkInfo link : webLinks.getFileLinks(project.getName(),
|
webLinks.getFileLinks(project.getName(), rev, file);
|
||||||
rev, file)) {
|
return !links.isEmpty() ? links : null;
|
||||||
if (!Strings.isNullOrEmpty(link.name) && !Strings.isNullOrEmpty(link.url)) {
|
|
||||||
fileWebLinks.add(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fileWebLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Result {
|
static class Result {
|
||||||
@@ -220,14 +214,13 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
ChangeType changeType;
|
ChangeType changeType;
|
||||||
List<String> diffHeader;
|
List<String> diffHeader;
|
||||||
List<ContentEntry> content;
|
List<ContentEntry> content;
|
||||||
List<WebLinkInfo> webLinksA;
|
|
||||||
List<WebLinkInfo> webLinksB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class FileMeta {
|
static class FileMeta {
|
||||||
String name;
|
String name;
|
||||||
String contentType;
|
String contentType;
|
||||||
Integer lines;
|
Integer lines;
|
||||||
|
List<WebLinkInfo> webLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setContentType(FileMeta meta, ProjectState project,
|
private void setContentType(FileMeta meta, ProjectState project,
|
||||||
|
|||||||
Reference in New Issue
Block a user