Display submit type in the change info block
This is a preparation for a Prolog based submit type rule which will compute submit type for each change. In this first step we simply return the project-wide default submit type for each change. Change-Id: I38745e544b215197074ce1fb8d6b106f3c1c1e56 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:

committed by
Gerrit Code Review

parent
edb573adbb
commit
dad5620441
@@ -17,6 +17,7 @@ package com.google.gerrit.common.data;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -40,6 +41,7 @@ public class ChangeDetail {
|
|||||||
protected List<PatchSet> patchSets;
|
protected List<PatchSet> patchSets;
|
||||||
protected List<ApprovalDetail> approvals;
|
protected List<ApprovalDetail> approvals;
|
||||||
protected List<SubmitRecord> submitRecords;
|
protected List<SubmitRecord> submitRecords;
|
||||||
|
protected Project.SubmitType submitType;
|
||||||
protected boolean canSubmit;
|
protected boolean canSubmit;
|
||||||
protected List<ChangeMessage> messages;
|
protected List<ChangeMessage> messages;
|
||||||
protected PatchSet.Id currentPatchSetId;
|
protected PatchSet.Id currentPatchSetId;
|
||||||
@@ -187,6 +189,14 @@ public class ChangeDetail {
|
|||||||
return submitRecords;
|
return submitRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSubmitType(Project.SubmitType submitType) {
|
||||||
|
this.submitType = submitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project.SubmitType getSubmitType() {
|
||||||
|
return submitType;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCurrentPatchSet(final PatchSetDetail detail) {
|
public boolean isCurrentPatchSet(final PatchSetDetail detail) {
|
||||||
return currentPatchSetId != null
|
return currentPatchSetId != null
|
||||||
&& detail.getPatchSet().getId().equals(currentPatchSetId);
|
&& detail.getPatchSet().getId().equals(currentPatchSetId);
|
||||||
|
@@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -33,6 +34,7 @@ public class PatchSetPublishDetail {
|
|||||||
protected List<PermissionRange> labels;
|
protected List<PermissionRange> labels;
|
||||||
protected List<ApprovalDetail> approvals;
|
protected List<ApprovalDetail> approvals;
|
||||||
protected List<SubmitRecord> submitRecords;
|
protected List<SubmitRecord> submitRecords;
|
||||||
|
protected Project.SubmitType submitType;
|
||||||
protected List<PatchSetApproval> given;
|
protected List<PatchSetApproval> given;
|
||||||
protected boolean canSubmit;
|
protected boolean canSubmit;
|
||||||
|
|
||||||
@@ -61,6 +63,14 @@ public class PatchSetPublishDetail {
|
|||||||
return submitRecords;
|
return submitRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSubmitType(Project.SubmitType submitType) {
|
||||||
|
this.submitType = submitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project.SubmitType getSubmitType() {
|
||||||
|
return submitType;
|
||||||
|
}
|
||||||
|
|
||||||
public List<PatchSetApproval> getGiven() {
|
public List<PatchSetApproval> getGiven() {
|
||||||
return given;
|
return given;
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,7 @@ public interface ChangeConstants extends Constants {
|
|||||||
String changeInfoBlockUploaded();
|
String changeInfoBlockUploaded();
|
||||||
String changeInfoBlockUpdated();
|
String changeInfoBlockUpdated();
|
||||||
String changeInfoBlockStatus();
|
String changeInfoBlockStatus();
|
||||||
|
String changeInfoBlockSubmitType();
|
||||||
String changePermalink();
|
String changePermalink();
|
||||||
String changeInfoBlockCanMerge();
|
String changeInfoBlockCanMerge();
|
||||||
String changeInfoBlockCanMergeYes();
|
String changeInfoBlockCanMergeYes();
|
||||||
|
@@ -72,6 +72,7 @@ changeInfoBlockTopic = Topic
|
|||||||
changeInfoBlockUploaded = Uploaded
|
changeInfoBlockUploaded = Uploaded
|
||||||
changeInfoBlockUpdated = Updated
|
changeInfoBlockUpdated = Updated
|
||||||
changeInfoBlockStatus = Status
|
changeInfoBlockStatus = Status
|
||||||
|
changeInfoBlockSubmitType = Submit Type
|
||||||
changePermalink = Permalink
|
changePermalink = Permalink
|
||||||
changeInfoBlockCanMerge = Can Merge
|
changeInfoBlockCanMerge = Can Merge
|
||||||
changeInfoBlockCanMergeYes = Yes
|
changeInfoBlockCanMergeYes = Yes
|
||||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.client.changes;
|
|||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
import com.google.gerrit.common.data.AccountInfoCache;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
||||||
@@ -36,8 +37,8 @@ public class ChangeDescriptionBlock extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void display(Change chg, Boolean starred, PatchSetInfo info,
|
public void display(Change chg, Boolean starred, PatchSetInfo info,
|
||||||
final AccountInfoCache acc) {
|
final AccountInfoCache acc, Project.SubmitType submitType) {
|
||||||
infoBlock.display(chg, acc);
|
infoBlock.display(chg, acc, submitType);
|
||||||
messageBlock.display(chg.getId(), starred, info.getMessage());
|
messageBlock.display(chg.getId(), starred, info.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import com.google.gerrit.client.ui.ProjectLink;
|
|||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
import com.google.gerrit.common.data.AccountInfoCache;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||||
@@ -36,9 +37,10 @@ public class ChangeInfoBlock extends Composite {
|
|||||||
private static final int R_TOPIC = 4;
|
private static final int R_TOPIC = 4;
|
||||||
private static final int R_UPLOADED = 5;
|
private static final int R_UPLOADED = 5;
|
||||||
private static final int R_UPDATED = 6;
|
private static final int R_UPDATED = 6;
|
||||||
private static final int R_STATUS = 7;
|
private static final int R_SUBMIT_TYPE = 7;
|
||||||
private static final int R_MERGE_TEST = 8;
|
private static final int R_STATUS = 8;
|
||||||
private static final int R_CNT = 9;
|
private static final int R_MERGE_TEST = 9;
|
||||||
|
private static final int R_CNT = 10;
|
||||||
|
|
||||||
private final Grid table;
|
private final Grid table;
|
||||||
|
|
||||||
@@ -59,6 +61,7 @@ public class ChangeInfoBlock extends Composite {
|
|||||||
initRow(R_UPLOADED, Util.C.changeInfoBlockUploaded());
|
initRow(R_UPLOADED, Util.C.changeInfoBlockUploaded());
|
||||||
initRow(R_UPDATED, Util.C.changeInfoBlockUpdated());
|
initRow(R_UPDATED, Util.C.changeInfoBlockUpdated());
|
||||||
initRow(R_STATUS, Util.C.changeInfoBlockStatus());
|
initRow(R_STATUS, Util.C.changeInfoBlockStatus());
|
||||||
|
initRow(R_SUBMIT_TYPE, Util.C.changeInfoBlockSubmitType());
|
||||||
if (Gerrit.getConfig().testChangeMerge()) {
|
if (Gerrit.getConfig().testChangeMerge()) {
|
||||||
initRow(R_MERGE_TEST, Util.C.changeInfoBlockCanMerge());
|
initRow(R_MERGE_TEST, Util.C.changeInfoBlockCanMerge());
|
||||||
}
|
}
|
||||||
@@ -77,7 +80,8 @@ public class ChangeInfoBlock extends Composite {
|
|||||||
table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header());
|
table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(final Change chg, final AccountInfoCache acc) {
|
public void display(final Change chg, final AccountInfoCache acc,
|
||||||
|
Project.SubmitType submitType) {
|
||||||
final Branch.NameKey dst = chg.getDest();
|
final Branch.NameKey dst = chg.getDest();
|
||||||
|
|
||||||
CopyableLabel changeIdLabel =
|
CopyableLabel changeIdLabel =
|
||||||
@@ -94,6 +98,8 @@ public class ChangeInfoBlock extends Composite {
|
|||||||
table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn()));
|
table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn()));
|
||||||
table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn()));
|
table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn()));
|
||||||
table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus()));
|
table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus()));
|
||||||
|
table.setText(R_SUBMIT_TYPE, 1,
|
||||||
|
com.google.gerrit.client.admin.Util.toLongString(submitType));
|
||||||
final Change.Status status = chg.getStatus();
|
final Change.Status status = chg.getStatus();
|
||||||
if (Gerrit.getConfig().testChangeMerge()) {
|
if (Gerrit.getConfig().testChangeMerge()) {
|
||||||
if (status.equals(Change.Status.NEW) || status.equals(Change.Status.DRAFT)) {
|
if (status.equals(Change.Status.NEW) || status.equals(Change.Status.DRAFT)) {
|
||||||
|
@@ -282,7 +282,7 @@ public class ChangeScreen extends Screen
|
|||||||
descriptionBlock.display(detail.getChange(),
|
descriptionBlock.display(detail.getChange(),
|
||||||
detail.isStarred(),
|
detail.isStarred(),
|
||||||
detail.getCurrentPatchSetDetail().getInfo(),
|
detail.getCurrentPatchSetDetail().getInfo(),
|
||||||
detail.getAccounts());
|
detail.getAccounts(), detail.getSubmitType());
|
||||||
dependsOn.display(detail.getDependsOn());
|
dependsOn.display(detail.getDependsOn());
|
||||||
neededBy.display(detail.getNeededBy());
|
neededBy.display(detail.getNeededBy());
|
||||||
approvals.display(detail);
|
approvals.display(detail);
|
||||||
|
@@ -274,7 +274,8 @@ public class PublishCommentScreen extends AccountScreen implements
|
|||||||
private void display(final PatchSetPublishDetail r) {
|
private void display(final PatchSetPublishDetail r) {
|
||||||
setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(),
|
setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(),
|
||||||
patchSetId.get()));
|
patchSetId.get()));
|
||||||
descBlock.display(r.getChange(), null, r.getPatchSetInfo(), r.getAccounts());
|
descBlock.display(r.getChange(), null, r.getPatchSetInfo(), r.getAccounts(),
|
||||||
|
r.getSubmitType());
|
||||||
|
|
||||||
if (r.getChange().getStatus().isOpen()) {
|
if (r.getChange().getStatus().isOpen()) {
|
||||||
initApprovals(r, approvalPanel);
|
initApprovals(r, approvalPanel);
|
||||||
|
@@ -168,6 +168,8 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
|
|||||||
}
|
}
|
||||||
detail.setSubmitRecords(submitRecords);
|
detail.setSubmitRecords(submitRecords);
|
||||||
|
|
||||||
|
detail.setSubmitType(control.getSubmitType());
|
||||||
|
|
||||||
patchsetsById = new HashMap<PatchSet.Id, PatchSet>();
|
patchsetsById = new HashMap<PatchSet.Id, PatchSet>();
|
||||||
loadPatchSets();
|
loadPatchSets();
|
||||||
loadMessages();
|
loadMessages();
|
||||||
|
@@ -34,6 +34,7 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
|||||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||||
import com.google.gerrit.server.project.ChangeControl;
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.gerrit.server.workflow.CategoryFunction;
|
import com.google.gerrit.server.workflow.CategoryFunction;
|
||||||
import com.google.gerrit.server.workflow.FunctionState;
|
import com.google.gerrit.server.workflow.FunctionState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -60,6 +61,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
|||||||
private final ApprovalTypes approvalTypes;
|
private final ApprovalTypes approvalTypes;
|
||||||
private final AccountInfoCacheFactory aic;
|
private final AccountInfoCacheFactory aic;
|
||||||
private final IdentifiedUser user;
|
private final IdentifiedUser user;
|
||||||
|
private final ProjectCache projectCache;
|
||||||
|
|
||||||
private final PatchSet.Id patchSetId;
|
private final PatchSet.Id patchSetId;
|
||||||
|
|
||||||
@@ -76,7 +78,9 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
|||||||
final ChangeControl.GenericFactory changeControlGenericFactory,
|
final ChangeControl.GenericFactory changeControlGenericFactory,
|
||||||
final IdentifiedUser.GenericFactory identifiedUserFactory,
|
final IdentifiedUser.GenericFactory identifiedUserFactory,
|
||||||
final ApprovalTypes approvalTypes,
|
final ApprovalTypes approvalTypes,
|
||||||
final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) {
|
final IdentifiedUser user,
|
||||||
|
final ProjectCache projectCache,
|
||||||
|
@Assisted final PatchSet.Id patchSetId) {
|
||||||
this.infoFactory = infoFactory;
|
this.infoFactory = infoFactory;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.functionState = functionState;
|
this.functionState = functionState;
|
||||||
@@ -86,6 +90,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
|||||||
this.approvalTypes = approvalTypes;
|
this.approvalTypes = approvalTypes;
|
||||||
this.aic = accountInfoCacheFactory.create();
|
this.aic = accountInfoCacheFactory.create();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
this.projectCache = projectCache;
|
||||||
|
|
||||||
this.patchSetId = patchSetId;
|
this.patchSetId = patchSetId;
|
||||||
}
|
}
|
||||||
@@ -186,6 +191,9 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
|||||||
detail.setSubmitRecords(submitRecords);
|
detail.setSubmitRecords(submitRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detail.setSubmitType(projectCache.get(change.getProject())
|
||||||
|
.getProject().getSubmitType());
|
||||||
|
|
||||||
detail.setLabels(allowed);
|
detail.setLabels(allowed);
|
||||||
detail.setGiven(given);
|
detail.setGiven(given);
|
||||||
loadApprovals(detail, control);
|
loadApprovals(detail, control);
|
||||||
|
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.rules.PrologEnvironment;
|
import com.google.gerrit.rules.PrologEnvironment;
|
||||||
import com.google.gerrit.rules.StoredValues;
|
import com.google.gerrit.rules.StoredValues;
|
||||||
@@ -528,6 +529,11 @@ public class ChangeControl {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubmitType getSubmitType() {
|
||||||
|
ProjectState projectState = getProjectControl().getProjectState();
|
||||||
|
return projectState.getProject().getSubmitType();
|
||||||
|
}
|
||||||
|
|
||||||
private List<SubmitRecord> logInvalidResult(Term rule, Term record) {
|
private List<SubmitRecord> logInvalidResult(Term rule, Term record) {
|
||||||
return logRuleError("Submit rule " + rule + " for change " + change.getId()
|
return logRuleError("Submit rule " + rule + " for change " + change.getId()
|
||||||
+ " of " + getProject().getName() + " output invalid result: " + record);
|
+ " of " + getProject().getName() + " output invalid result: " + record);
|
||||||
|
Reference in New Issue
Block a user