Expose RevisionInfo to panel extension points

Currently there is no way for panel extension points to retrieve the
revision information. This is needed to call the plugin specific
RevisionResource endpoints. For example, verify-status plugin needs
this to retrieve verification info for the patch set that is currently
displayed on the change screen.

Change-Id: Ifd1f1636684054a9cf188a10d50dd4af6ee77976
This commit is contained in:
David Ostrovsky 2016-03-15 17:05:41 +01:00 committed by Hugo Arès
parent 2c71febfee
commit 916ae0c982
3 changed files with 12 additions and 9 deletions

View File

@ -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
current change.
+
The link:rest-api-changes.html#revision-info[RevisionInfo] entity for
the current patch set.
* Project Info Screen:
** `GerritUiExtensionPoint.PROJECT_INFO_SCREEN_TOP`:

View File

@ -34,6 +34,6 @@ public enum GerritUiExtensionPoint {
PROJECT_INFO_SCREEN_TOP, PROJECT_INFO_SCREEN_BOTTOM;
public enum Key {
ACCOUNT_INFO, CHANGE_INFO, PROJECT_NAME
ACCOUNT_INFO, CHANGE_INFO, PROJECT_NAME, REVISION_INFO
}
}

View File

@ -278,8 +278,7 @@ public class ChangeScreen extends Screen {
@Override
public void onSuccess(ChangeInfo info) {
info.init();
addExtensionPoints(info);
initCurrentRevision(info);
addExtensionPoints(info, initCurrentRevision(info));
loadConfigInfo(info, base);
}
}));
@ -324,22 +323,23 @@ public class ChangeScreen extends Screen {
return resolveRevisionToDisplay(info);
}
private void addExtensionPoints(ChangeInfo change) {
private void addExtensionPoints(ChangeInfo change, RevisionInfo rev) {
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
headerExtension, change);
headerExtension, change, rev);
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
headerExtensionMiddle, change);
headerExtensionMiddle, change, rev);
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
headerExtensionRight, change);
headerExtensionRight, change, rev);
addExtensionPoint(
GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
changeExtension, change);
changeExtension, change, rev);
}
private void addExtensionPoint(GerritUiExtensionPoint extensionPoint,
Panel p, ChangeInfo change) {
Panel p, ChangeInfo change, RevisionInfo rev) {
ExtensionPanel extensionPanel = new ExtensionPanel(extensionPoint);
extensionPanel.putObject(GerritUiExtensionPoint.Key.CHANGE_INFO, change);
extensionPanel.putObject(GerritUiExtensionPoint.Key.REVISION_INFO, rev);
p.add(extensionPanel);
}