Add a dropdown to control email notifications on user preference page

Add a dropdown 'Email Notifications' in the user preferences to allow
users to control their email notifications.

On selecting 'Disabled' user will not receive any email notifications
from Gerrit.

Remove the checkbox 'CC Me On Comments I write' and add it to the new
dropdown. Functionality remains the same as the original checkbox.

Options in the dropdown are:

1. Enabled
2. CC On Own Comments
3. Disabled

Feature: Issue 989
Change-Id: If40d0d34f39415d5c64ccaa5803fc6321bddd322
This commit is contained in:
Mani Chandel
2014-07-08 17:13:12 +05:30
committed by Michael Zhou
parent 2e66f80a4f
commit 207fa6e5db
12 changed files with 165 additions and 53 deletions

View File

@@ -76,6 +76,12 @@ public final class AccountGeneralPreferences {
UNIFIED_DIFF
}
public static enum EmailStrategy {
ENABLED,
CC_ON_OWN_COMMENTS,
DISABLED
}
public static enum TimeFormat {
/** 12-hour clock: 1:15 am, 2:13 pm */
HHMM_12("h:mm a"),
@@ -120,9 +126,7 @@ public final class AccountGeneralPreferences {
@Column(id = 6, length = 20, notNull = false)
protected String downloadCommand;
/** If true we CC the user on their own changes. */
@Column(id = 7)
protected boolean copySelfOnEmail;
// DELETED: id = 7 (copySelfOnEmail)
@Column(id = 8, length = 10, notNull = false)
protected String dateFormat;
@@ -155,6 +159,9 @@ public final class AccountGeneralPreferences {
@Column(id = 19)
protected boolean muteCommonPathPrefixes;
@Column(id = 20, length = 30, notNull = false)
protected String emailStrategy;
public AccountGeneralPreferences() {
}
@@ -242,14 +249,6 @@ public final class AccountGeneralPreferences {
}
}
public boolean isCopySelfOnEmails() {
return copySelfOnEmail;
}
public void setCopySelfOnEmails(boolean includeSelfOnEmail) {
copySelfOnEmail = includeSelfOnEmail;
}
public boolean isShowInfoInReviewCategory() {
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
}
@@ -307,6 +306,17 @@ public final class AccountGeneralPreferences {
this.diffView = diffView.name();
}
public EmailStrategy getEmailStrategy() {
if (emailStrategy == null) {
return EmailStrategy.ENABLED;
}
return EmailStrategy.valueOf(emailStrategy);
}
public void setEmailStrategy(EmailStrategy strategy) {
this.emailStrategy = strategy.name();
}
public boolean isSizeBarInChangeTable() {
return sizeBarInChangeTable;
}
@@ -336,7 +346,6 @@ public final class AccountGeneralPreferences {
maximumPageSize = DEFAULT_PAGESIZE;
showSiteHeader = true;
useFlashClipboard = true;
copySelfOnEmail = false;
reviewCategoryStrategy = null;
downloadUrl = null;
downloadCommand = null;
@@ -347,5 +356,6 @@ public final class AccountGeneralPreferences {
sizeBarInChangeTable = true;
legacycidInChangeTable = false;
muteCommonPathPrefixes = true;
emailStrategy = null;
}
}