summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2010-11-15 12:06:42 -0800
committerShawn O. Pearce <sop@google.com>2010-11-15 12:06:42 -0800
commit6819cef106101cfd7921a257c215b6676fb736b0 (patch)
tree18cf2e2794b478d7cbb966e3f1111d67fda58863
parent887bc2d59f51cbcad286b892a1204a8f18650300 (diff)
Fix crossed notify toggles for project watches
The submit and new changes buttons were cross-wired, causing the one to impact the other's value. Fix that, and while we are at it clarify the names involved so there is less confusion going on. Change-Id: Ie1b082e35b7a95913a7feb92739f79220a24a983 Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchesTable.java11
-rw-r--r--gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountProjectWatch.java54
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java3
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java3
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/mail/MergedSender.java3
5 files changed, 33 insertions, 41 deletions
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchesTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchesTable.java
index be808fa57e..b3bd0cbec8 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchesTable.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchesTable.java
@@ -134,9 +134,9 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
table.setWidget(row, 1, new CheckBox());
table.setWidget(row, 2, fp);
- addNotifyButton(AccountProjectWatch.Type.NEW_CHANGES, info, row, 3);
- addNotifyButton(AccountProjectWatch.Type.COMMENTS, info, row, 4);
- addNotifyButton(AccountProjectWatch.Type.SUBMITS, info, row, 5);
+ addNotifyButton(AccountProjectWatch.NotifyType.NEW_CHANGES, info, row, 3);
+ addNotifyButton(AccountProjectWatch.NotifyType.ALL_COMMENTS, info, row, 4);
+ addNotifyButton(AccountProjectWatch.NotifyType.SUBMITTED_CHANGES, info, row, 5);
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().iconCell());
@@ -148,7 +148,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
setRowItem(row, info);
}
- protected void addNotifyButton(final AccountProjectWatch.Type type,
+ protected void addNotifyButton(final AccountProjectWatch.NotifyType type,
final AccountProjectWatchInfo info, final int row, final int col) {
final CheckBox cbox = new CheckBox();
@@ -157,13 +157,16 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
public void onClick(final ClickEvent event) {
final boolean oldVal = info.getWatch().isNotify(type);
info.getWatch().setNotify(type, cbox.getValue());
+ cbox.setEnabled(false);
Util.ACCOUNT_SVC.updateProjectWatch(info.getWatch(),
new GerritCallback<VoidResult>() {
public void onSuccess(final VoidResult result) {
+ cbox.setEnabled(true);
}
@Override
public void onFailure(final Throwable caught) {
+ cbox.setEnabled(true);
info.getWatch().setNotify(type, oldVal);
cbox.setValue(oldVal);
super.onFailure(caught);
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountProjectWatch.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountProjectWatch.java
index 6713d8f8f6..c18ae823cd 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountProjectWatch.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/AccountProjectWatch.java
@@ -21,8 +21,8 @@ import com.google.gwtorm.client.StringKey;
/** An {@link Account} interested in a {@link Project}. */
public final class AccountProjectWatch {
- public enum Type {
- NEW_CHANGES, SUBMITS, COMMENTS
+ public enum NotifyType {
+ NEW_CHANGES, ALL_COMMENTS, SUBMITTED_CHANGES
}
public static final String FILTER_ALL = "*";
@@ -124,46 +124,32 @@ public final class AccountProjectWatch {
return FILTER_ALL.equals(key.filter.get()) ? null : key.filter.get();
}
- public boolean isNotifyNewChanges() {
- return notifyNewChanges;
- }
-
- public void setNotifyNewChanges(final boolean a) {
- notifyNewChanges = a;
- }
-
- public boolean isNotifyAllComments() {
- return notifyAllComments;
- }
-
- public void setNotifyAllComments(final boolean a) {
- notifyAllComments = a;
- }
-
- public boolean isNotifySubmittedChanges() {
- return notifySubmittedChanges;
- }
+ public boolean isNotify(final NotifyType type) {
+ switch (type) {
+ case NEW_CHANGES:
+ return notifyNewChanges;
- public void setNotifySubmittedChanges(final boolean a) {
- notifySubmittedChanges = a;
- }
+ case ALL_COMMENTS:
+ return notifyAllComments;
- public boolean isNotify(final Type type) {
- switch(type) {
- case NEW_CHANGES: return notifySubmittedChanges;
- case SUBMITS: return notifyNewChanges;
- case COMMENTS: return notifyAllComments;
+ case SUBMITTED_CHANGES:
+ return notifySubmittedChanges;
}
return false;
}
- public void setNotify(final Type type, final boolean v) {
- switch(type) {
- case NEW_CHANGES: notifySubmittedChanges = v;
+ public void setNotify(final NotifyType type, final boolean v) {
+ switch (type) {
+ case NEW_CHANGES:
+ notifyNewChanges = v;
break;
- case SUBMITS: notifyNewChanges = v;
+
+ case ALL_COMMENTS:
+ notifyAllComments = v;
break;
- case COMMENTS: notifyAllComments = v;
+
+ case SUBMITTED_CHANGES:
+ notifySubmittedChanges = v;
break;
}
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
index 71712af953..0377291b26 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
@@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.PatchSet;
import com.google.gerrit.reviewdb.PatchSetApproval;
import com.google.gerrit.reviewdb.PatchSetInfo;
import com.google.gerrit.reviewdb.StarredChange;
+import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListEntry;
@@ -299,7 +300,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
// BCC anyone else who has interest in this project's changes
//
for (final AccountProjectWatch w : getWatches()) {
- if (w.isNotifyAllComments()) {
+ if (w.isNotify(NotifyType.ALL_COMMENTS)) {
add(RecipientType.BCC, w.getAccountId());
}
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
index 18bfe976c7..c14ff1b747 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
@@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.AccountGroupMember;
import com.google.gerrit.reviewdb.AccountProjectWatch;
import com.google.gerrit.reviewdb.Change;
+import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
import com.google.gerrit.server.ssh.SshInfo;
import com.google.gwtorm.client.OrmException;
import com.google.inject.Inject;
@@ -61,7 +62,7 @@ public class CreateChangeSender extends NewChangeSender {
// BCC anyone who has interest in this project's changes
//
for (final AccountProjectWatch w : getWatches()) {
- if (w.isNotifyNewChanges()) {
+ if (w.isNotify(NotifyType.NEW_CHANGES)) {
if (owners.contains(w.getAccountId())) {
add(RecipientType.TO, w.getAccountId());
} else {
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/MergedSender.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/MergedSender.java
index 40f479075f..b2a1c4433f 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/MergedSender.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/MergedSender.java
@@ -23,6 +23,7 @@ import com.google.gerrit.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.Branch;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.PatchSetApproval;
+import com.google.gerrit.reviewdb.AccountProjectWatch.NotifyType;
import com.google.gwtorm.client.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -149,7 +150,7 @@ public class MergedSender extends ReplyToChangeSender {
// BCC anyone else who has interest in this project's changes
//
for (final AccountProjectWatch w : getWatches()) {
- if (w.isNotifySubmittedChanges()) {
+ if (w.isNotify(NotifyType.SUBMITTED_CHANGES)) {
add(RecipientType.BCC, w.getAccountId());
}
}