SideBySide2: Add download links
Re-implemented the old download links. To avoid adding bogus links on empty files, PatchSetSelectBox2 needs to know the meta info for the diff. Don't add the download link if meta == null. Change-Id: Ied3e0287a17144ab2d6d50289625495568cb53a6
This commit is contained in:
@@ -133,9 +133,9 @@ class DiffTable extends Composite {
|
||||
return fileCommentRow.getOffsetHeight() + patchSetSelectBoxA.getOffsetHeight();
|
||||
}
|
||||
|
||||
void setUpPatchSetNav(JsArray<RevisionInfo> list) {
|
||||
patchSetSelectBoxA.setUpPatchSetNav(list);
|
||||
patchSetSelectBoxB.setUpPatchSetNav(list);
|
||||
void setUpPatchSetNav(JsArray<RevisionInfo> list, DiffInfo info) {
|
||||
patchSetSelectBoxA.setUpPatchSetNav(list, info.meta_a());
|
||||
patchSetSelectBoxB.setUpPatchSetNav(list, info.meta_b());
|
||||
}
|
||||
|
||||
void add(Widget widget) {
|
||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
||||
import com.google.gerrit.client.patches.PatchUtil;
|
||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
@@ -28,14 +29,14 @@ import com.google.gwt.resources.client.CssResource;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.ImageResourceRenderer;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
|
||||
/**
|
||||
* HTMLPanel to select among patch sets
|
||||
* TODO: Implement download link.
|
||||
*/
|
||||
/** HTMLPanel to select among patch sets */
|
||||
class PatchSetSelectBox2 extends Composite {
|
||||
interface Binder extends UiBinder<HTMLPanel, PatchSetSelectBox2> {}
|
||||
private static final Binder uiBinder = GWT.create(Binder.class);
|
||||
@@ -71,7 +72,7 @@ class PatchSetSelectBox2 extends Composite {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
void setUpPatchSetNav(JsArray<RevisionInfo> list) {
|
||||
void setUpPatchSetNav(JsArray<RevisionInfo> list, DiffInfo.FileMeta meta) {
|
||||
InlineHyperlink baseLink = null;
|
||||
InlineHyperlink selectedLink = null;
|
||||
if (sideA) {
|
||||
@@ -92,6 +93,9 @@ class PatchSetSelectBox2 extends Composite {
|
||||
} else if (sideA) {
|
||||
baseLink.setStyleName(style.selected());
|
||||
}
|
||||
if (meta != null && !Patch.COMMIT_MSG.equals(path)) {
|
||||
linkPanel.add(createDownloadLink());
|
||||
}
|
||||
}
|
||||
|
||||
static void link(PatchSetSelectBox2 a, PatchSetSelectBox2 b) {
|
||||
@@ -110,6 +114,17 @@ class PatchSetSelectBox2 extends Composite {
|
||||
path));
|
||||
}
|
||||
|
||||
private Anchor createDownloadLink() {
|
||||
PatchSet.Id id = (idActive == null) ? other.idActive : idActive;
|
||||
String sideURL = (idActive == null) ? "1" : "0";
|
||||
String base = GWT.getHostPageBaseURL() + "cat/";
|
||||
Anchor anchor = new Anchor(
|
||||
new ImageResourceRenderer().render(Gerrit.RESOURCES.downloadIcon()),
|
||||
base + KeyUtil.encode(id + "," + path) + "^" + sideURL);
|
||||
anchor.setTitle(PatchUtil.C.download());
|
||||
return anchor;
|
||||
}
|
||||
|
||||
@UiHandler("icon")
|
||||
void onIconClick(ClickEvent e) {
|
||||
table.createOrEditFileComment(side);
|
||||
|
@@ -204,6 +204,18 @@ public class SideBySide2 extends Screen {
|
||||
CommentApi.drafts(revision, group.add(getCommentCallback(DisplaySide.B, true)));
|
||||
}
|
||||
|
||||
RestApi call = ChangeApi.detail(changeId.get());
|
||||
ChangeList.addOptions(call, EnumSet.of(
|
||||
ListChangesOption.ALL_REVISIONS));
|
||||
call.get(group.add(new GerritCallback<ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeInfo info) {
|
||||
info.revisions().copyKeysIntoChildren("name");
|
||||
JsArray<RevisionInfo> list = info.revisions().values();
|
||||
RevisionInfo.sortRevisionInfoByNumber(list);
|
||||
diffTable.setUpPatchSetNav(list, diff);
|
||||
}}));
|
||||
|
||||
ConfigInfoCache.get(changeId, group.addFinal(
|
||||
new ScreenLoadCallback<ConfigInfoCache.Entry>(SideBySide2.this) {
|
||||
@Override
|
||||
@@ -216,18 +228,6 @@ public class SideBySide2 extends Screen {
|
||||
display(diffInfo);
|
||||
}
|
||||
}));
|
||||
|
||||
RestApi call = ChangeApi.detail(changeId.get());
|
||||
ChangeList.addOptions(call, EnumSet.of(
|
||||
ListChangesOption.ALL_REVISIONS));
|
||||
call.get(new GerritCallback<ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeInfo info) {
|
||||
info.revisions().copyKeysIntoChildren("name");
|
||||
JsArray<RevisionInfo> list = info.revisions().values();
|
||||
RevisionInfo.sortRevisionInfoByNumber(list);
|
||||
diffTable.setUpPatchSetNav(list);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user