From 0fe5ccc88dfba15e3688cc40e91b1328c0862271 Mon Sep 17 00:00:00 2001 From: Pravin Sethia Date: Mon, 29 Jul 2013 12:35:35 +0530 Subject: [PATCH 1/2] fix: NoOp score not displayed for open changes Score for NoBlock/NoOp category doesn't get displayed for open changes on All --> Open or My --> Changes. For such category, none of the label flags i.e. recommended, liked, approved or rejected flags are set for open changes. Further, abandoned and merged change display different images for same score e.g. If a -1 has been assigned, Abandoned change displays a "X" whereas a Merged change displays "-1". A Merged can be rejected for a NoBlock or NoOp category type. Bug: Issue 2056 Change-Id: I29cfa02f4a43ef6be1cb94614ed75b979a84f7af (cherry picked from commit e88304abce3ceb9c7b93040363c4db3219459b0a) --- .../gerrit/server/change/ChangeJson.java | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java index 3592bbf6f4..13704ed1d4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java @@ -352,7 +352,13 @@ public class ChangeJson { continue; } if (standard) { - setRecommendedAndDisliked(cd, type, e.getValue()); + for (PatchSetApproval psa : cd.currentApprovals(db)) { + if (type.matches(psa)) { + short val = psa.getValue(); + Account.Id accountId = psa.getAccountId(); + setLabelScores(type, e.getValue(), val, accountId); + } + } } if (detailed) { setLabelValues(type, e.getValue()); @@ -396,36 +402,32 @@ public class ChangeJson { return labels; } - private void setRecommendedAndDisliked(ChangeData cd, LabelType type, - LabelInfo label) throws OrmException { + private void setLabelScores(LabelType type, + LabelInfo label, short score, Account.Id accountId) + throws OrmException { if (label.approved != null || label.rejected != null) { return; } if (type.getMin() == null || type.getMax() == null) { - // Unknown or misconfigured type can't have intermediate scores. + // Can't set score for unknown or misconfigured type. return; } - short min = type.getMin().getValue(); - short max = type.getMax().getValue(); - if (-1 <= min && max <= 1) { - // Types with a range of -1..+1 can't have intermediate scores. - return; - } - - for (PatchSetApproval psa : cd.currentApprovals(db)) { - short val = psa.getValue(); - if (val != 0 && min < val && val < max && type.matches(psa)) { - if (0 < val) { - label.recommended = accountLoader.get(psa.getAccountId()); - label.value = val != 1 ? val : null; - } else { - label.disliked = accountLoader.get(psa.getAccountId()); - label.value = val != -1 ? val : null; - } + if (score != 0) { + if (score == type.getMax().getValue()) { + label.approved = accountLoader.get(accountId); + } else if (score == type.getMin().getValue()) { + label.rejected = accountLoader.get(accountId); + } else if (score > 0) { + label.recommended = accountLoader.get(accountId); + label.value = score; + } else if (score < 0) { + label.disliked = accountLoader.get(accountId); + label.value = score; } } + return; } @@ -536,22 +538,11 @@ public class ChangeJson { } LabelInfo li = labels.get(type.getName()); - if (!standard || li.approved != null || li.rejected != null) { + if (!standard) { continue; } - if (val == type.getMax().getValue()) { - li.approved = accountLoader.get(accountId); - } else if (val == type.getMin().getValue() - // A merged change can't have been rejected. - && cd.getChange().getStatus() != Status.MERGED) { - li.rejected = accountLoader.get(accountId); - } else if (val > 0) { - li.recommended = accountLoader.get(accountId); - li.value = val; - } else if (val < 0) { - li.disliked = accountLoader.get(accountId); - li.value = val; - } + + setLabelScores(type, li, val, accountId); } } return labels; From 4cc99757c07f792446f459fdd36fa0581f863244 Mon Sep 17 00:00:00 2001 From: Bruce Zu Date: Thu, 29 Aug 2013 15:17:08 +0800 Subject: [PATCH 2/2] Fix: RepoCommandLink's text is wrong The title of the "repo download" link was mistakenly set to "checkout" during refactoring in commit cbc629f4f4ce6bd9071a540cb026ef8a9d53382c. Change it to the correct "repo download" title. Bug: Issue 2093 Change-Id: I4c30d0fedf56942f741edbbfaa7505052e5e370c --- .../com/google/gerrit/client/download/DownloadCommandLink.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadCommandLink.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadCommandLink.java index c5c68db1b7..7a477fabab 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadCommandLink.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadCommandLink.java @@ -86,7 +86,7 @@ public abstract class DownloadCommandLink extends Anchor implements ClickHandler String projectName; String ref; public RepoCommandLink(String project, String ref) { - super(DownloadCommand.REPO_DOWNLOAD, "checkout"); + super(DownloadCommand.REPO_DOWNLOAD, "repo download"); this.projectName = project; this.ref = ref; }