Merge changes from topic 'revision-info-in-panel-extension-point'
* changes: Expose RevisionInfo to panel extension points ChangeScreen#loadConfigInfo: factor out current revision initialization ChangeScreen: Remove unneded 'final' modifier
This commit is contained in:
@@ -1065,6 +1065,9 @@ Panel will be shown below the change info block.
|
|||||||
+
|
+
|
||||||
The link:rest-api-changes.html#change-info[ChangeInfo] entity for the
|
The link:rest-api-changes.html#change-info[ChangeInfo] entity for the
|
||||||
current change.
|
current change.
|
||||||
|
+
|
||||||
|
The link:rest-api-changes.html#revision-info[RevisionInfo] entity for
|
||||||
|
the current patch set.
|
||||||
|
|
||||||
* Project Info Screen:
|
* Project Info Screen:
|
||||||
** `GerritUiExtensionPoint.PROJECT_INFO_SCREEN_TOP`:
|
** `GerritUiExtensionPoint.PROJECT_INFO_SCREEN_TOP`:
|
||||||
|
@@ -34,6 +34,6 @@ public enum GerritUiExtensionPoint {
|
|||||||
PROJECT_INFO_SCREEN_TOP, PROJECT_INFO_SCREEN_BOTTOM;
|
PROJECT_INFO_SCREEN_TOP, PROJECT_INFO_SCREEN_BOTTOM;
|
||||||
|
|
||||||
public enum Key {
|
public enum Key {
|
||||||
ACCOUNT_INFO, CHANGE_INFO, PROJECT_NAME
|
ACCOUNT_INFO, CHANGE_INFO, PROJECT_NAME, REVISION_INFO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -278,28 +278,68 @@ public class ChangeScreen extends Screen {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(ChangeInfo info) {
|
public void onSuccess(ChangeInfo info) {
|
||||||
info.init();
|
info.init();
|
||||||
addExtensionPoints(info);
|
addExtensionPoints(info, initCurrentRevision(info));
|
||||||
loadConfigInfo(info, base);
|
loadConfigInfo(info, base);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExtensionPoints(ChangeInfo change) {
|
private RevisionInfo initCurrentRevision(ChangeInfo info) {
|
||||||
|
info.revisions().copyKeysIntoChildren("name");
|
||||||
|
if (edit != null) {
|
||||||
|
edit.setName(edit.commit().commit());
|
||||||
|
info.setEdit(edit);
|
||||||
|
if (edit.hasFiles()) {
|
||||||
|
edit.files().copyKeysIntoChildren("path");
|
||||||
|
}
|
||||||
|
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
|
||||||
|
JsArray<RevisionInfo> list = info.revisions().values();
|
||||||
|
|
||||||
|
// Edit is converted to a regular revision (with number = 0) and
|
||||||
|
// added to the list of revisions. Additionally under certain
|
||||||
|
// circumstances change edit is assigned to be the current revision
|
||||||
|
// and is selected to be shown on the change screen.
|
||||||
|
// We have two different strategies to assign edit to the current ps:
|
||||||
|
// 1. revision == null: no revision is selected, so use the edit only
|
||||||
|
// if it is based on the latest patch set
|
||||||
|
// 2. edit was selected explicitly from ps drop down:
|
||||||
|
// use the edit regardless of which patch set it is based on
|
||||||
|
if (revision == null) {
|
||||||
|
RevisionInfo.sortRevisionInfoByNumber(list);
|
||||||
|
RevisionInfo rev = list.get(list.length() - 1);
|
||||||
|
if (rev.isEdit()) {
|
||||||
|
info.setCurrentRevision(rev.name());
|
||||||
|
}
|
||||||
|
} else if (revision.equals("edit") || revision.equals("0")) {
|
||||||
|
for (int i = 0; i < list.length(); i++) {
|
||||||
|
RevisionInfo r = list.get(i);
|
||||||
|
if (r.isEdit()) {
|
||||||
|
info.setCurrentRevision(r.name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resolveRevisionToDisplay(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExtensionPoints(ChangeInfo change, RevisionInfo rev) {
|
||||||
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
|
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
|
||||||
headerExtension, change);
|
headerExtension, change, rev);
|
||||||
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
|
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
|
||||||
headerExtensionMiddle, change);
|
headerExtensionMiddle, change, rev);
|
||||||
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
|
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
|
||||||
headerExtensionRight, change);
|
headerExtensionRight, change, rev);
|
||||||
addExtensionPoint(
|
addExtensionPoint(
|
||||||
GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
|
GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
|
||||||
changeExtension, change);
|
changeExtension, change, rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExtensionPoint(GerritUiExtensionPoint extensionPoint,
|
private void addExtensionPoint(GerritUiExtensionPoint extensionPoint,
|
||||||
Panel p, ChangeInfo change) {
|
Panel p, ChangeInfo change, RevisionInfo rev) {
|
||||||
ExtensionPanel extensionPanel = new ExtensionPanel(extensionPoint);
|
ExtensionPanel extensionPanel = new ExtensionPanel(extensionPoint);
|
||||||
extensionPanel.putObject(GerritUiExtensionPoint.Key.CHANGE_INFO, change);
|
extensionPanel.putObject(GerritUiExtensionPoint.Key.CHANGE_INFO, change);
|
||||||
|
extensionPanel.putObject(GerritUiExtensionPoint.Key.REVISION_INFO, rev);
|
||||||
p.add(extensionPanel);
|
p.add(extensionPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +415,7 @@ public class ChangeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gotoSibling(final int offset) {
|
private void gotoSibling(int offset) {
|
||||||
if (offset > 0 && changeInfo.currentRevision().equals(revision)) {
|
if (offset > 0 && changeInfo.currentRevision().equals(revision)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -598,24 +638,24 @@ public class ChangeScreen extends Screen {
|
|||||||
KeyCommandSet keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
|
KeyCommandSet keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
|
||||||
keysNavigation.add(new KeyCommand(0, 'u', Util.C.upToChangeList()) {
|
keysNavigation.add(new KeyCommand(0, 'u', Util.C.upToChangeList()) {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
Gerrit.displayLastChangeList();
|
Gerrit.displayLastChangeList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadChange()) {
|
keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadChange()) {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
Gerrit.display(PageLinks.toChange(changeId));
|
Gerrit.display(PageLinks.toChange(changeId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
keysNavigation.add(new KeyCommand(0, 'n', Util.C.keyNextPatchSet()) {
|
keysNavigation.add(new KeyCommand(0, 'n', Util.C.keyNextPatchSet()) {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
gotoSibling(1);
|
gotoSibling(1);
|
||||||
}
|
}
|
||||||
}, new KeyCommand(0, 'p', Util.C.keyPreviousPatchSet()) {
|
}, new KeyCommand(0, 'p', Util.C.keyPreviousPatchSet()) {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
gotoSibling(-1);
|
gotoSibling(-1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -858,44 +898,9 @@ public class ChangeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfigInfo(final ChangeInfo info, final String base) {
|
private void loadConfigInfo(final ChangeInfo info, String base) {
|
||||||
info.revisions().copyKeysIntoChildren("name");
|
RevisionInfo rev = info.revision(revision);
|
||||||
if (edit != null) {
|
RevisionInfo b = resolveRevisionOrPatchSetId(info, base, null);
|
||||||
edit.setName(edit.commit().commit());
|
|
||||||
info.setEdit(edit);
|
|
||||||
if (edit.hasFiles()) {
|
|
||||||
edit.files().copyKeysIntoChildren("path");
|
|
||||||
}
|
|
||||||
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
|
|
||||||
JsArray<RevisionInfo> list = info.revisions().values();
|
|
||||||
|
|
||||||
// Edit is converted to a regular revision (with number = 0) and
|
|
||||||
// added to the list of revisions. Additionally under certain
|
|
||||||
// circumstances change edit is assigned to be the current revision
|
|
||||||
// and is selected to be shown on the change screen.
|
|
||||||
// We have two different strategies to assign edit to the current ps:
|
|
||||||
// 1. revision == null: no revision is selected, so use the edit only
|
|
||||||
// if it is based on the latest patch set
|
|
||||||
// 2. edit was selected explicitly from ps drop down:
|
|
||||||
// use the edit regardless of which patch set it is based on
|
|
||||||
if (revision == null) {
|
|
||||||
RevisionInfo.sortRevisionInfoByNumber(list);
|
|
||||||
RevisionInfo rev = list.get(list.length() - 1);
|
|
||||||
if (rev.isEdit()) {
|
|
||||||
info.setCurrentRevision(rev.name());
|
|
||||||
}
|
|
||||||
} else if (revision.equals("edit") || revision.equals("0")) {
|
|
||||||
for (int i = 0; i < list.length(); i++) {
|
|
||||||
RevisionInfo r = list.get(i);
|
|
||||||
if (r.isEdit()) {
|
|
||||||
info.setCurrentRevision(r.name());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final RevisionInfo rev = resolveRevisionToDisplay(info);
|
|
||||||
final RevisionInfo b = resolveRevisionOrPatchSetId(info, base, null);
|
|
||||||
|
|
||||||
CallbackGroup group = new CallbackGroup();
|
CallbackGroup group = new CallbackGroup();
|
||||||
Timestamp lastReply = myLastReply(info);
|
Timestamp lastReply = myLastReply(info);
|
||||||
@@ -944,10 +949,10 @@ public class ChangeScreen extends Screen {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDiff(final RevisionInfo base, final RevisionInfo rev,
|
private void loadDiff(RevisionInfo base, RevisionInfo rev,
|
||||||
final Timestamp myLastReply, CallbackGroup group) {
|
Timestamp myLastReply, CallbackGroup group) {
|
||||||
final List<NativeMap<JsArray<CommentInfo>>> comments = loadComments(rev, group);
|
List<NativeMap<JsArray<CommentInfo>>> comments = loadComments(rev, group);
|
||||||
final List<NativeMap<JsArray<CommentInfo>>> drafts = loadDrafts(rev, group);
|
List<NativeMap<JsArray<CommentInfo>>> drafts = loadDrafts(rev, group);
|
||||||
loadFileList(base, rev, myLastReply, group, comments, drafts);
|
loadFileList(base, rev, myLastReply, group, comments, drafts);
|
||||||
|
|
||||||
if (Gerrit.isSignedIn() && fileTableMode == FileTable.Mode.REVIEW) {
|
if (Gerrit.isSignedIn() && fileTableMode == FileTable.Mode.REVIEW) {
|
||||||
|
Reference in New Issue
Block a user