diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java index 614be13d21..3342bc2854 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java @@ -20,6 +20,7 @@ import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; import java.util.List; +import java.util.Set; /** Detail necessary to display a change. */ public class ChangeDetail { @@ -38,6 +39,7 @@ public class ChangeDetail { protected List dependsOn; protected List neededBy; protected List patchSets; + protected Set patchSetsWithDraftComments; protected List submitRecords; protected Project.SubmitType submitType; protected SubmitTypeRecord submitTypeRecord; @@ -196,6 +198,14 @@ public class ChangeDetail { patchSets = s; } + public void setPatchSetsWithDraftComments(Set pwdc) { + this.patchSetsWithDraftComments = pwdc; + } + + public boolean hasDraftComments(PatchSet.Id id) { + return patchSetsWithDraftComments.contains(id); + } + public void setSubmitRecords(List all) { submitRecords = all; } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritCss.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritCss.java index d13c17c727..a33556ee5a 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritCss.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritCss.java @@ -178,7 +178,6 @@ public interface GerritCss extends CssResource { String patchSetLink(); String patchSetRevision(); String patchSetUserIdentity(); - String patchSetWithDraft(); String patchSizeCell(); String pluginsTable(); String posscore(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java index d3f47c04fc..098cc77d2f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/GerritResources.java @@ -54,4 +54,7 @@ public interface GerritResources extends ClientBundle { @Source("diffy.png") public ImageResource gerritAvatar(); + + @Source("draftComments.png") + public ImageResource draftComments(); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java index 2ccd48eee0..33cdfbbd20 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.java @@ -124,6 +124,7 @@ public interface ChangeConstants extends Constants { String patchSetInfoCommitter(); String patchSetInfoDownload(); String patchSetInfoParents(); + String patchSetWithDraftCommentsToolTip(); String initialCommit(); String buttonRebaseChange(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties index 4fb5b285ce..f5eb04b45f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeConstants.properties @@ -101,6 +101,7 @@ patchSetInfoAuthor = Author patchSetInfoCommitter = Committer patchSetInfoDownload = Download patchSetInfoParents = Parent(s) +patchSetWithDraftCommentsToolTip = Draft comment(s) inside initialCommit = Initial Commit buttonAbandonChangeBegin = Abandon Change diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java index 23a07822f3..9407a48e7f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java @@ -51,6 +51,7 @@ import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DisclosurePanel; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Grid; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; import com.google.gwt.user.client.ui.InlineLabel; import com.google.gwt.user.client.ui.Panel; @@ -84,7 +85,8 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel * Creates a closed complex disclosure panel for a patch set. * The patch set details are loaded when the complex disclosure panel is opened. */ - public PatchSetComplexDisclosurePanel(final PatchSet ps, boolean isOpen) { + public PatchSetComplexDisclosurePanel(final PatchSet ps, boolean isOpen, + boolean hasDraftComments) { super(Util.M.patchSetHeader(ps.getPatchSetId()), isOpen); detailCache = ChangeCache.get(ps.getId().getParentKey()).getChangeDetailCache(); changeDetail = detailCache.get(); @@ -93,6 +95,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel body = new FlowPanel(); setContent(body); + if (hasDraftComments) { + final Image draftComments = new Image(Gerrit.RESOURCES.draftComments()); + draftComments.setTitle(Util.C.patchSetWithDraftCommentsToolTip()); + getHeader().add(draftComments); + } + final GitwebLink gw = Gerrit.getGitwebLink(); final InlineLabel revtxt = new InlineLabel(ps.getRevision().get() + " "); revtxt.addStyleName(Gerrit.RESOURCES.css().patchSetRevision()); @@ -117,10 +125,6 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel addOpenHandler(this); } - if(ps.getHasDraftComments()) { - addStyleName(Gerrit.RESOURCES.css().patchSetWithDraft()); - } - } public void setDiffBaseId(PatchSet.Id diffBaseId) { diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetsBlock.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetsBlock.java index 5a6e427dfd..480518541f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetsBlock.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetsBlock.java @@ -88,7 +88,8 @@ public class PatchSetsBlock extends Composite { for (final PatchSet ps : patchSets) { final PatchSetComplexDisclosurePanel p = - new PatchSetComplexDisclosurePanel(ps, ps == currps); + new PatchSetComplexDisclosurePanel(ps, ps == currps, + detail.hasDraftComments(ps.getId())); if (diffBaseId != null) { p.setDiffBaseId(diffBaseId); if (ps == currps) { diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/draftComments.png b/gerrit-gwtui/src/main/java/com/google/gerrit/client/draftComments.png new file mode 100644 index 0000000000..31c770fdb7 Binary files /dev/null and b/gerrit-gwtui/src/main/java/com/google/gerrit/client/draftComments.png differ diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/gerrit.css b/gerrit-gwtui/src/main/java/com/google/gerrit/client/gerrit.css index 3423e1ec3c..5f16af6c03 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/gerrit.css +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/gerrit.css @@ -887,10 +887,6 @@ a:hover { font-size: 8pt; } -.patchSetWithDraft .header td { - color: #ff5555; -} - .changeScreen .gwt-DisclosurePanel .content { margin-bottom: 10px; } diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java index aeaa3bb5a8..4ad072536c 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java @@ -180,19 +180,25 @@ public class ChangeDetailFactory extends Handler { private void loadPatchSets() throws OrmException { ResultSet source = db.patchSets().byChange(changeId); List patches = new ArrayList(); + Set patchesWithDraftComments = new HashSet(); + final CurrentUser user = control.getCurrentUser(); + final Account.Id me = + user instanceof IdentifiedUser ? ((IdentifiedUser) user).getAccountId() + : null; for (PatchSet ps : source) { - final CurrentUser user = control.getCurrentUser(); - if (user instanceof IdentifiedUser) { - final Account.Id me = ((IdentifiedUser) user).getAccountId(); - ps.setHasDraftComments(db.patchComments() - .draftByPatchSetAuthor(ps.getId(), me).iterator().hasNext()); - } + final PatchSet.Id psId = ps.getId(); if (control.isPatchVisible(ps, db)) { patches.add(ps); + if (me != null + && db.patchComments().draftByPatchSetAuthor(psId, me) + .iterator().hasNext()) { + patchesWithDraftComments.add(psId); + } } - patchsetsById.put(ps.getId(), ps); + patchsetsById.put(psId, ps); } detail.setPatchSets(patches); + detail.setPatchSetsWithDraftComments(patchesWithDraftComments); } private void loadMessages() throws OrmException { diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java index 4afddfda6b..54c556dc7f 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java @@ -136,9 +136,6 @@ public final class PatchSet { @Column(id = 5) protected boolean draft; - /** Not persisted in the database */ - protected boolean hasDraftComments; - protected PatchSet() { } @@ -190,14 +187,6 @@ public final class PatchSet { return id.toRefName(); } - public boolean getHasDraftComments() { - return hasDraftComments; - } - - public void setHasDraftComments(boolean hasDraftComments) { - this.hasDraftComments = hasDraftComments; - } - @Override public String toString() { return "[PatchSet " + getId().toString() + "]";