Show the number of drafts the user has on a patch
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -27,6 +27,7 @@ public interface ChangeMessages extends Messages {
|
||||
String repoDownload(String project, int change, int ps);
|
||||
|
||||
String patchTableComments(@PluralCount int count);
|
||||
String patchTableDrafts(@PluralCount int count);
|
||||
|
||||
String messageWrittenOn(String date);
|
||||
|
||||
|
@@ -10,6 +10,9 @@ repoDownload = repo download {0} {1}/{2}
|
||||
patchTableComments[one] = 1 comment
|
||||
patchTableComments = {0} comments
|
||||
|
||||
patchTableDrafts[one] = 1 draft
|
||||
patchTableDrafts = {0} drafts
|
||||
|
||||
messageWrittenOn = on {0}
|
||||
|
||||
renamedFrom = renamed from {0}
|
||||
|
@@ -142,12 +142,19 @@ public class PatchTable extends FancyFlexTable<Patch> {
|
||||
|
||||
table.clearCell(row, C_DELTA);
|
||||
|
||||
final int cnt = patch.getCommentCount();
|
||||
if (cnt == 0) {
|
||||
table.clearCell(row, C_COMMENTS);
|
||||
} else {
|
||||
table.setText(row, C_COMMENTS, Util.M.patchTableComments(cnt));
|
||||
final StringBuilder commentStr = new StringBuilder();
|
||||
if (patch.getCommentCount() > 0) {
|
||||
commentStr.append(Util.M.patchTableComments(patch.getCommentCount()));
|
||||
}
|
||||
if (patch.getDraftCount() > 0) {
|
||||
if (commentStr.length() > 0) {
|
||||
commentStr.append(", ");
|
||||
}
|
||||
commentStr.append("<span class=\"Drafts\">");
|
||||
commentStr.append(Util.M.patchTableDrafts(patch.getDraftCount()));
|
||||
commentStr.append("</span>");
|
||||
}
|
||||
table.setHTML(row, C_COMMENTS, commentStr.toString());
|
||||
|
||||
if (patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
||||
table.setWidget(row, C_DIFF + 0, new SideBySide(Util.C
|
||||
|
@@ -14,13 +14,17 @@
|
||||
|
||||
package com.google.gerrit.client.data;
|
||||
|
||||
import com.google.gerrit.client.reviewdb.Account;
|
||||
import com.google.gerrit.client.reviewdb.Patch;
|
||||
import com.google.gerrit.client.reviewdb.PatchLineComment;
|
||||
import com.google.gerrit.client.reviewdb.PatchSet;
|
||||
import com.google.gerrit.client.reviewdb.PatchSetInfo;
|
||||
import com.google.gerrit.client.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.client.rpc.Common;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PatchSetDetail {
|
||||
protected PatchSet patchSet;
|
||||
@@ -34,6 +38,25 @@ public class PatchSetDetail {
|
||||
patchSet = ps;
|
||||
info = db.patchSetInfo().get(patchSet.getId());
|
||||
patches = db.patches().byPatchSet(patchSet.getId()).toList();
|
||||
|
||||
final Account.Id me = Common.getAccountId();
|
||||
if (me != null) {
|
||||
// If we are signed in, compute the number of draft comments by the
|
||||
// current user on each of these patch files. This way the can more
|
||||
// quickly locate where they have pending drafts, and review them.
|
||||
//
|
||||
final List<PatchLineComment> comments =
|
||||
db.patchComments().draft(ps.getId(), me).toList();
|
||||
if (!comments.isEmpty()) {
|
||||
final Map<Patch.Key, Patch> byKey = db.patches().toMap(patches);
|
||||
for (final PatchLineComment c : comments) {
|
||||
final Patch p = byKey.get(c.getKey().getParentKey());
|
||||
if (p != null) {
|
||||
p.setDraftCount(p.getDraftCount() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PatchSet getPatchSet() {
|
||||
|
@@ -134,6 +134,9 @@ public final class Patch {
|
||||
@Column
|
||||
protected int nbrComments;
|
||||
|
||||
/** Number of drafts by the current user; not persisted in the datastore. */
|
||||
protected int nbrDrafts;
|
||||
|
||||
/**
|
||||
* Original if {@link #changeType} is {@link ChangeType#COPIED} or
|
||||
* {@link ChangeType#RENAMED}.
|
||||
@@ -162,6 +165,14 @@ public final class Patch {
|
||||
nbrComments = n;
|
||||
}
|
||||
|
||||
public int getDraftCount() {
|
||||
return nbrDrafts;
|
||||
}
|
||||
|
||||
public void setDraftCount(final int n) {
|
||||
nbrDrafts = n;
|
||||
}
|
||||
|
||||
public ChangeType getChangeType() {
|
||||
return ChangeType.forCode(changeType);
|
||||
}
|
||||
|
@@ -181,6 +181,9 @@
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.gerrit-ChangeTable .CommentCell span.Drafts {
|
||||
color: #ff5555;
|
||||
}
|
||||
|
||||
.gerrit-ChangeTable .FilePathCell {
|
||||
white-space: nowrap;
|
||||
|
Reference in New Issue
Block a user