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:
committed by
Michael Zhou
parent
2e66f80a4f
commit
207fa6e5db
@@ -1947,6 +1947,12 @@ link:rest-api-config.html#top-menu-item-info[TopMenuItemInfo] entities.
|
|||||||
|`url_aliases` |optional|
|
|`url_aliases` |optional|
|
||||||
A map of URL path pairs, where the first URL path is an alias for the
|
A map of URL path pairs, where the first URL path is an alias for the
|
||||||
second URL path.
|
second URL path.
|
||||||
|
|`email_notifications` ||
|
||||||
|
The type of email strategy to use. On `ENABLED`, the user will receive emails
|
||||||
|
from Gerrit. On `CC_ON_OWN_COMMENTS` the user will also receive emails for
|
||||||
|
their own comments. On `DISABLED` the user will not receive any email
|
||||||
|
notifications from Gerrit.
|
||||||
|
Allowed values are `ENABLED`, `CC_ON_OWN_COMMENTS`, `DISABLED`.
|
||||||
|============================================
|
|============================================
|
||||||
|
|
||||||
[[preferences-input]]
|
[[preferences-input]]
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.EmailStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
@@ -44,7 +45,6 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
p.useFlashClipboard(defaultPrefs.isUseFlashClipboard());
|
p.useFlashClipboard(defaultPrefs.isUseFlashClipboard());
|
||||||
p.downloadScheme(defaultPrefs.getDownloadUrl());
|
p.downloadScheme(defaultPrefs.getDownloadUrl());
|
||||||
p.downloadCommand(defaultPrefs.getDownloadCommand());
|
p.downloadCommand(defaultPrefs.getDownloadCommand());
|
||||||
p.copySelfOnEmail(defaultPrefs.isCopySelfOnEmails());
|
|
||||||
p.dateFormat(defaultPrefs.getDateFormat());
|
p.dateFormat(defaultPrefs.getDateFormat());
|
||||||
p.timeFormat(defaultPrefs.getTimeFormat());
|
p.timeFormat(defaultPrefs.getTimeFormat());
|
||||||
p.relativeDateInChangeTable(defaultPrefs.isRelativeDateInChangeTable());
|
p.relativeDateInChangeTable(defaultPrefs.isRelativeDateInChangeTable());
|
||||||
@@ -53,6 +53,7 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
p.muteCommonPathPrefixes(defaultPrefs.isMuteCommonPathPrefixes());
|
p.muteCommonPathPrefixes(defaultPrefs.isMuteCommonPathPrefixes());
|
||||||
p.reviewCategoryStrategy(defaultPrefs.getReviewCategoryStrategy());
|
p.reviewCategoryStrategy(defaultPrefs.getReviewCategoryStrategy());
|
||||||
p.diffView(defaultPrefs.getDiffView());
|
p.diffView(defaultPrefs.getDiffView());
|
||||||
|
p.emailStrategy(defaultPrefs.getEmailStrategy());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,9 +83,6 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
private final native String downloadCommandRaw()
|
private final native String downloadCommandRaw()
|
||||||
/*-{ return this.download_command }-*/;
|
/*-{ return this.download_command }-*/;
|
||||||
|
|
||||||
public final native boolean copySelfOnEmail()
|
|
||||||
/*-{ return this.copy_self_on_email || false }-*/;
|
|
||||||
|
|
||||||
public final DateFormat dateFormat() {
|
public final DateFormat dateFormat() {
|
||||||
String s = dateFormatRaw();
|
String s = dateFormatRaw();
|
||||||
return s != null ? DateFormat.valueOf(s) : null;
|
return s != null ? DateFormat.valueOf(s) : null;
|
||||||
@@ -125,6 +123,14 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
private final native String diffViewRaw()
|
private final native String diffViewRaw()
|
||||||
/*-{ return this.diff_view }-*/;
|
/*-{ return this.diff_view }-*/;
|
||||||
|
|
||||||
|
public final EmailStrategy emailStrategy() {
|
||||||
|
String s = emailStrategyRaw();
|
||||||
|
return s != null ? EmailStrategy.valueOf(s) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final native String emailStrategyRaw()
|
||||||
|
/*-{ return this.email_strategy }-*/;
|
||||||
|
|
||||||
public final native JsArray<TopMenuItem> my()
|
public final native JsArray<TopMenuItem> my()
|
||||||
/*-{ return this.my; }-*/;
|
/*-{ return this.my; }-*/;
|
||||||
|
|
||||||
@@ -146,9 +152,6 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
public final native void downloadCommandRaw(String d)
|
public final native void downloadCommandRaw(String d)
|
||||||
/*-{ this.download_command = d }-*/;
|
/*-{ this.download_command = d }-*/;
|
||||||
|
|
||||||
public final native void copySelfOnEmail(boolean c)
|
|
||||||
/*-{ this.copy_self_on_email = c }-*/;
|
|
||||||
|
|
||||||
public final void dateFormat(DateFormat f) {
|
public final void dateFormat(DateFormat f) {
|
||||||
dateFormatRaw(f != null ? f.toString() : null);
|
dateFormatRaw(f != null ? f.toString() : null);
|
||||||
}
|
}
|
||||||
@@ -185,6 +188,12 @@ public class AccountPreferencesInfo extends JavaScriptObject {
|
|||||||
private final native void diffViewRaw(String d)
|
private final native void diffViewRaw(String d)
|
||||||
/*-{ this.diff_view = d }-*/;
|
/*-{ this.diff_view = d }-*/;
|
||||||
|
|
||||||
|
public final void emailStrategy(EmailStrategy s) {
|
||||||
|
emailStrategyRaw(s != null ? s.toString() : null);
|
||||||
|
}
|
||||||
|
private final native void emailStrategyRaw(String s)
|
||||||
|
/*-{ this.email_strategy = s }-*/;
|
||||||
|
|
||||||
public final void setMyMenus(List<TopMenuItem> myMenus) {
|
public final void setMyMenus(List<TopMenuItem> myMenus) {
|
||||||
initMy();
|
initMy();
|
||||||
for (TopMenuItem n : myMenus) {
|
for (TopMenuItem n : myMenus) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public interface AccountConstants extends Constants {
|
|||||||
String contextWholeFile();
|
String contextWholeFile();
|
||||||
String showSiteHeader();
|
String showSiteHeader();
|
||||||
String useFlashClipboard();
|
String useFlashClipboard();
|
||||||
String copySelfOnEmails();
|
|
||||||
String reviewCategoryLabel();
|
String reviewCategoryLabel();
|
||||||
String messageShowInReviewCategoryNone();
|
String messageShowInReviewCategoryNone();
|
||||||
String messageShowInReviewCategoryName();
|
String messageShowInReviewCategoryName();
|
||||||
@@ -159,4 +158,9 @@ public interface AccountConstants extends Constants {
|
|||||||
String welcomeAgreementText();
|
String welcomeAgreementText();
|
||||||
String welcomeAgreementLater();
|
String welcomeAgreementLater();
|
||||||
String welcomeContinue();
|
String welcomeContinue();
|
||||||
|
|
||||||
|
String messageEnabled();
|
||||||
|
String messageCCMeOnMyComments();
|
||||||
|
String messageDisabled();
|
||||||
|
String emailFieldLabel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ registeredOn = Registered
|
|||||||
accountId = Account ID
|
accountId = Account ID
|
||||||
showSiteHeader = Show Site Header
|
showSiteHeader = Show Site Header
|
||||||
useFlashClipboard = Use Flash Clipboard Widget
|
useFlashClipboard = Use Flash Clipboard Widget
|
||||||
copySelfOnEmails = CC Me On Comments I Write
|
|
||||||
reviewCategoryLabel = Display In Review Category
|
reviewCategoryLabel = Display In Review Category
|
||||||
messageShowInReviewCategoryNone = None (default)
|
messageShowInReviewCategoryNone = None (default)
|
||||||
messageShowInReviewCategoryName = Show Name
|
messageShowInReviewCategoryName = Show Name
|
||||||
@@ -15,6 +14,11 @@ messageShowInReviewCategoryEmail = Show Email
|
|||||||
messageShowInReviewCategoryUsername = Show Username
|
messageShowInReviewCategoryUsername = Show Username
|
||||||
messageShowInReviewCategoryAbbrev = Show Abbreviated Name
|
messageShowInReviewCategoryAbbrev = Show Abbreviated Name
|
||||||
|
|
||||||
|
emailFieldLabel = Email Notifications:
|
||||||
|
messageEnabled = Enabled
|
||||||
|
messageCCMeOnMyComments = CC Me On Comments I Write
|
||||||
|
messageDisabled = Disabled
|
||||||
|
|
||||||
maximumPageSizeFieldLabel = Maximum Page Size:
|
maximumPageSizeFieldLabel = Maximum Page Size:
|
||||||
diffViewLabel = Diff View:
|
diffViewLabel = Diff View:
|
||||||
dateFormatLabel = Date/Time Format:
|
dateFormatLabel = Date/Time Format:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.google.gerrit.client.rpc.Natives;
|
|||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.EmailStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
@@ -50,7 +51,6 @@ import java.util.List;
|
|||||||
public class MyPreferencesScreen extends SettingsScreen {
|
public class MyPreferencesScreen extends SettingsScreen {
|
||||||
private CheckBox showSiteHeader;
|
private CheckBox showSiteHeader;
|
||||||
private CheckBox useFlashClipboard;
|
private CheckBox useFlashClipboard;
|
||||||
private CheckBox copySelfOnEmails;
|
|
||||||
private CheckBox relativeDateInChangeTable;
|
private CheckBox relativeDateInChangeTable;
|
||||||
private CheckBox sizeBarInChangeTable;
|
private CheckBox sizeBarInChangeTable;
|
||||||
private CheckBox legacycidInChangeTable;
|
private CheckBox legacycidInChangeTable;
|
||||||
@@ -60,6 +60,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private ListBox timeFormat;
|
private ListBox timeFormat;
|
||||||
private ListBox reviewCategoryStrategy;
|
private ListBox reviewCategoryStrategy;
|
||||||
private ListBox diffView;
|
private ListBox diffView;
|
||||||
|
private ListBox emailStrategy;
|
||||||
private StringListPanel myMenus;
|
private StringListPanel myMenus;
|
||||||
private Button save;
|
private Button save;
|
||||||
|
|
||||||
@@ -69,7 +70,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
|
|
||||||
showSiteHeader = new CheckBox(Util.C.showSiteHeader());
|
showSiteHeader = new CheckBox(Util.C.showSiteHeader());
|
||||||
useFlashClipboard = new CheckBox(Util.C.useFlashClipboard());
|
useFlashClipboard = new CheckBox(Util.C.useFlashClipboard());
|
||||||
copySelfOnEmails = new CheckBox(Util.C.copySelfOnEmails());
|
|
||||||
maximumPageSize = new ListBox();
|
maximumPageSize = new ListBox();
|
||||||
for (final short v : PAGESIZE_CHOICES) {
|
for (final short v : PAGESIZE_CHOICES) {
|
||||||
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
||||||
@@ -92,6 +92,20 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
Util.C.messageShowInReviewCategoryAbbrev(),
|
Util.C.messageShowInReviewCategoryAbbrev(),
|
||||||
AccountGeneralPreferences.ReviewCategoryStrategy.ABBREV.name());
|
AccountGeneralPreferences.ReviewCategoryStrategy.ABBREV.name());
|
||||||
|
|
||||||
|
emailStrategy = new ListBox();
|
||||||
|
emailStrategy.addItem(Util.C.messageEnabled(),
|
||||||
|
AccountGeneralPreferences.EmailStrategy.ENABLED.name());
|
||||||
|
emailStrategy
|
||||||
|
.addItem(
|
||||||
|
Util.C.messageCCMeOnMyComments(),
|
||||||
|
AccountGeneralPreferences.EmailStrategy.CC_ON_OWN_COMMENTS
|
||||||
|
.name());
|
||||||
|
emailStrategy
|
||||||
|
.addItem(
|
||||||
|
Util.C.messageDisabled(),
|
||||||
|
AccountGeneralPreferences.EmailStrategy.DISABLED
|
||||||
|
.name());
|
||||||
|
|
||||||
diffView = new ListBox();
|
diffView = new ListBox();
|
||||||
diffView.addItem(
|
diffView.addItem(
|
||||||
com.google.gerrit.client.changes.Util.C.sideBySide(),
|
com.google.gerrit.client.changes.Util.C.sideBySide(),
|
||||||
@@ -141,7 +155,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
|
muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
|
||||||
|
|
||||||
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
||||||
final Grid formGrid = new Grid(10 + (flashClippy ? 1 : 0), 2);
|
final Grid formGrid = new Grid(11 + (flashClippy ? 1 : 0), 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
@@ -154,10 +168,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, "");
|
|
||||||
formGrid.setWidget(row, fieldIdx, copySelfOnEmails);
|
|
||||||
row++;
|
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.reviewCategoryLabel());
|
formGrid.setText(row, labelIdx, Util.C.reviewCategoryLabel());
|
||||||
formGrid.setWidget(row, fieldIdx, reviewCategoryStrategy);
|
formGrid.setWidget(row, fieldIdx, reviewCategoryStrategy);
|
||||||
row++;
|
row++;
|
||||||
@@ -186,6 +196,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
formGrid.setWidget(row, fieldIdx, muteCommonPathPrefixes);
|
formGrid.setWidget(row, fieldIdx, muteCommonPathPrefixes);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
formGrid.setText(row, labelIdx, Util.C.emailFieldLabel());
|
||||||
|
formGrid.setWidget(row, fieldIdx, emailStrategy);
|
||||||
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
|
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
|
||||||
formGrid.setWidget(row, fieldIdx, diffView);
|
formGrid.setWidget(row, fieldIdx, diffView);
|
||||||
|
|
||||||
@@ -208,7 +222,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
final OnEditEnabler e = new OnEditEnabler(save);
|
final OnEditEnabler e = new OnEditEnabler(save);
|
||||||
e.listenTo(showSiteHeader);
|
e.listenTo(showSiteHeader);
|
||||||
e.listenTo(useFlashClipboard);
|
e.listenTo(useFlashClipboard);
|
||||||
e.listenTo(copySelfOnEmails);
|
|
||||||
e.listenTo(maximumPageSize);
|
e.listenTo(maximumPageSize);
|
||||||
e.listenTo(dateFormat);
|
e.listenTo(dateFormat);
|
||||||
e.listenTo(timeFormat);
|
e.listenTo(timeFormat);
|
||||||
@@ -218,6 +231,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
e.listenTo(muteCommonPathPrefixes);
|
e.listenTo(muteCommonPathPrefixes);
|
||||||
e.listenTo(diffView);
|
e.listenTo(diffView);
|
||||||
e.listenTo(reviewCategoryStrategy);
|
e.listenTo(reviewCategoryStrategy);
|
||||||
|
e.listenTo(emailStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -240,7 +254,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private void enable(final boolean on) {
|
private void enable(final boolean on) {
|
||||||
showSiteHeader.setEnabled(on);
|
showSiteHeader.setEnabled(on);
|
||||||
useFlashClipboard.setEnabled(on);
|
useFlashClipboard.setEnabled(on);
|
||||||
copySelfOnEmails.setEnabled(on);
|
|
||||||
maximumPageSize.setEnabled(on);
|
maximumPageSize.setEnabled(on);
|
||||||
dateFormat.setEnabled(on);
|
dateFormat.setEnabled(on);
|
||||||
timeFormat.setEnabled(on);
|
timeFormat.setEnabled(on);
|
||||||
@@ -250,12 +263,12 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
muteCommonPathPrefixes.setEnabled(on);
|
muteCommonPathPrefixes.setEnabled(on);
|
||||||
reviewCategoryStrategy.setEnabled(on);
|
reviewCategoryStrategy.setEnabled(on);
|
||||||
diffView.setEnabled(on);
|
diffView.setEnabled(on);
|
||||||
|
emailStrategy.setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(AccountPreferencesInfo p) {
|
private void display(AccountPreferencesInfo p) {
|
||||||
showSiteHeader.setValue(p.showSiteHeader());
|
showSiteHeader.setValue(p.showSiteHeader());
|
||||||
useFlashClipboard.setValue(p.useFlashClipboard());
|
useFlashClipboard.setValue(p.useFlashClipboard());
|
||||||
copySelfOnEmails.setValue(p.copySelfOnEmail());
|
|
||||||
setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.changesPerPage());
|
setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.changesPerPage());
|
||||||
setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, //
|
setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, //
|
||||||
p.dateFormat());
|
p.dateFormat());
|
||||||
@@ -271,6 +284,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
setListBox(diffView,
|
setListBox(diffView,
|
||||||
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
p.diffView());
|
p.diffView());
|
||||||
|
setListBox(emailStrategy,
|
||||||
|
AccountGeneralPreferences.EmailStrategy.ENABLED,
|
||||||
|
p.emailStrategy());
|
||||||
display(p.my());
|
display(p.my());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +353,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
AccountPreferencesInfo p = AccountPreferencesInfo.create();
|
AccountPreferencesInfo p = AccountPreferencesInfo.create();
|
||||||
p.showSiteHeader(showSiteHeader.getValue());
|
p.showSiteHeader(showSiteHeader.getValue());
|
||||||
p.useFlashClipboard(useFlashClipboard.getValue());
|
p.useFlashClipboard(useFlashClipboard.getValue());
|
||||||
p.copySelfOnEmail(copySelfOnEmails.getValue());
|
|
||||||
p.changesPerPage(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
|
p.changesPerPage(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
|
||||||
p.dateFormat(getListBox(dateFormat,
|
p.dateFormat(getListBox(dateFormat,
|
||||||
AccountGeneralPreferences.DateFormat.STD,
|
AccountGeneralPreferences.DateFormat.STD,
|
||||||
@@ -355,6 +370,8 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
p.diffView(getListBox(diffView,
|
p.diffView(getListBox(diffView,
|
||||||
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
AccountGeneralPreferences.DiffView.values()));
|
AccountGeneralPreferences.DiffView.values()));
|
||||||
|
p.emailStrategy(getListBox(emailStrategy,
|
||||||
|
EmailStrategy.ENABLED, EmailStrategy.values()));
|
||||||
|
|
||||||
List<TopMenuItem> items = new ArrayList<>();
|
List<TopMenuItem> items = new ArrayList<>();
|
||||||
for (List<String> v : myMenus.getValues()) {
|
for (List<String> v : myMenus.getValues()) {
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ public final class AccountGeneralPreferences {
|
|||||||
UNIFIED_DIFF
|
UNIFIED_DIFF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum EmailStrategy {
|
||||||
|
ENABLED,
|
||||||
|
CC_ON_OWN_COMMENTS,
|
||||||
|
DISABLED
|
||||||
|
}
|
||||||
|
|
||||||
public static enum TimeFormat {
|
public static enum TimeFormat {
|
||||||
/** 12-hour clock: 1:15 am, 2:13 pm */
|
/** 12-hour clock: 1:15 am, 2:13 pm */
|
||||||
HHMM_12("h:mm a"),
|
HHMM_12("h:mm a"),
|
||||||
@@ -120,9 +126,7 @@ public final class AccountGeneralPreferences {
|
|||||||
@Column(id = 6, length = 20, notNull = false)
|
@Column(id = 6, length = 20, notNull = false)
|
||||||
protected String downloadCommand;
|
protected String downloadCommand;
|
||||||
|
|
||||||
/** If true we CC the user on their own changes. */
|
// DELETED: id = 7 (copySelfOnEmail)
|
||||||
@Column(id = 7)
|
|
||||||
protected boolean copySelfOnEmail;
|
|
||||||
|
|
||||||
@Column(id = 8, length = 10, notNull = false)
|
@Column(id = 8, length = 10, notNull = false)
|
||||||
protected String dateFormat;
|
protected String dateFormat;
|
||||||
@@ -155,6 +159,9 @@ public final class AccountGeneralPreferences {
|
|||||||
@Column(id = 19)
|
@Column(id = 19)
|
||||||
protected boolean muteCommonPathPrefixes;
|
protected boolean muteCommonPathPrefixes;
|
||||||
|
|
||||||
|
@Column(id = 20, length = 30, notNull = false)
|
||||||
|
protected String emailStrategy;
|
||||||
|
|
||||||
public AccountGeneralPreferences() {
|
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() {
|
public boolean isShowInfoInReviewCategory() {
|
||||||
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
||||||
}
|
}
|
||||||
@@ -307,6 +306,17 @@ public final class AccountGeneralPreferences {
|
|||||||
this.diffView = diffView.name();
|
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() {
|
public boolean isSizeBarInChangeTable() {
|
||||||
return sizeBarInChangeTable;
|
return sizeBarInChangeTable;
|
||||||
}
|
}
|
||||||
@@ -336,7 +346,6 @@ public final class AccountGeneralPreferences {
|
|||||||
maximumPageSize = DEFAULT_PAGESIZE;
|
maximumPageSize = DEFAULT_PAGESIZE;
|
||||||
showSiteHeader = true;
|
showSiteHeader = true;
|
||||||
useFlashClipboard = true;
|
useFlashClipboard = true;
|
||||||
copySelfOnEmail = false;
|
|
||||||
reviewCategoryStrategy = null;
|
reviewCategoryStrategy = null;
|
||||||
downloadUrl = null;
|
downloadUrl = null;
|
||||||
downloadCommand = null;
|
downloadCommand = null;
|
||||||
@@ -347,5 +356,6 @@ public final class AccountGeneralPreferences {
|
|||||||
sizeBarInChangeTable = true;
|
sizeBarInChangeTable = true;
|
||||||
legacycidInChangeTable = false;
|
legacycidInChangeTable = false;
|
||||||
muteCommonPathPrefixes = true;
|
muteCommonPathPrefixes = true;
|
||||||
|
emailStrategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.EmailStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
@@ -104,7 +105,6 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
Boolean useFlashClipboard;
|
Boolean useFlashClipboard;
|
||||||
String downloadScheme;
|
String downloadScheme;
|
||||||
DownloadCommand downloadCommand;
|
DownloadCommand downloadCommand;
|
||||||
Boolean copySelfOnEmail;
|
|
||||||
DateFormat dateFormat;
|
DateFormat dateFormat;
|
||||||
TimeFormat timeFormat;
|
TimeFormat timeFormat;
|
||||||
Boolean relativeDateInChangeTable;
|
Boolean relativeDateInChangeTable;
|
||||||
@@ -113,6 +113,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
Boolean muteCommonPathPrefixes;
|
Boolean muteCommonPathPrefixes;
|
||||||
ReviewCategoryStrategy reviewCategoryStrategy;
|
ReviewCategoryStrategy reviewCategoryStrategy;
|
||||||
DiffView diffView;
|
DiffView diffView;
|
||||||
|
EmailStrategy emailStrategy;
|
||||||
List<TopMenu.MenuItem> my;
|
List<TopMenu.MenuItem> my;
|
||||||
Map<String, String> urlAliases;
|
Map<String, String> urlAliases;
|
||||||
|
|
||||||
@@ -124,7 +125,6 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
useFlashClipboard = p.isUseFlashClipboard() ? true : null;
|
useFlashClipboard = p.isUseFlashClipboard() ? true : null;
|
||||||
downloadScheme = p.getDownloadUrl();
|
downloadScheme = p.getDownloadUrl();
|
||||||
downloadCommand = p.getDownloadCommand();
|
downloadCommand = p.getDownloadCommand();
|
||||||
copySelfOnEmail = p.isCopySelfOnEmails() ? true : null;
|
|
||||||
dateFormat = p.getDateFormat();
|
dateFormat = p.getDateFormat();
|
||||||
timeFormat = p.getTimeFormat();
|
timeFormat = p.getTimeFormat();
|
||||||
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
||||||
@@ -133,6 +133,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
muteCommonPathPrefixes = p.isMuteCommonPathPrefixes() ? true : null;
|
muteCommonPathPrefixes = p.isMuteCommonPathPrefixes() ? true : null;
|
||||||
reviewCategoryStrategy = p.getReviewCategoryStrategy();
|
reviewCategoryStrategy = p.getReviewCategoryStrategy();
|
||||||
diffView = p.getDiffView();
|
diffView = p.getDiffView();
|
||||||
|
emailStrategy = p.getEmailStrategy();
|
||||||
}
|
}
|
||||||
loadFromAllUsers(v, allUsers);
|
loadFromAllUsers(v, allUsers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.EmailStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.TimeFormat;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
@@ -64,7 +65,6 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
public Boolean useFlashClipboard;
|
public Boolean useFlashClipboard;
|
||||||
public String downloadScheme;
|
public String downloadScheme;
|
||||||
public DownloadCommand downloadCommand;
|
public DownloadCommand downloadCommand;
|
||||||
public Boolean copySelfOnEmail;
|
|
||||||
public DateFormat dateFormat;
|
public DateFormat dateFormat;
|
||||||
public TimeFormat timeFormat;
|
public TimeFormat timeFormat;
|
||||||
public Boolean relativeDateInChangeTable;
|
public Boolean relativeDateInChangeTable;
|
||||||
@@ -73,6 +73,7 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
public Boolean muteCommonPathPrefixes;
|
public Boolean muteCommonPathPrefixes;
|
||||||
public ReviewCategoryStrategy reviewCategoryStrategy;
|
public ReviewCategoryStrategy reviewCategoryStrategy;
|
||||||
public DiffView diffView;
|
public DiffView diffView;
|
||||||
|
public EmailStrategy emailStrategy;
|
||||||
public List<TopMenu.MenuItem> my;
|
public List<TopMenu.MenuItem> my;
|
||||||
public Map<String, String> urlAliases;
|
public Map<String, String> urlAliases;
|
||||||
}
|
}
|
||||||
@@ -146,9 +147,6 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
if (i.downloadCommand != null) {
|
if (i.downloadCommand != null) {
|
||||||
p.setDownloadCommand(i.downloadCommand);
|
p.setDownloadCommand(i.downloadCommand);
|
||||||
}
|
}
|
||||||
if (i.copySelfOnEmail != null) {
|
|
||||||
p.setCopySelfOnEmails(i.copySelfOnEmail);
|
|
||||||
}
|
|
||||||
if (i.dateFormat != null) {
|
if (i.dateFormat != null) {
|
||||||
p.setDateFormat(i.dateFormat);
|
p.setDateFormat(i.dateFormat);
|
||||||
}
|
}
|
||||||
@@ -173,6 +171,9 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
if (i.diffView != null) {
|
if (i.diffView != null) {
|
||||||
p.setDiffView(i.diffView);
|
p.setDiffView(i.diffView);
|
||||||
}
|
}
|
||||||
|
if (i.emailStrategy != null) {
|
||||||
|
p.setEmailStrategy(i.emailStrategy);
|
||||||
|
}
|
||||||
|
|
||||||
db.get().accounts().update(Collections.singleton(a));
|
db.get().accounts().update(Collections.singleton(a));
|
||||||
db.get().commit();
|
db.get().commit();
|
||||||
|
|||||||
@@ -48,13 +48,14 @@ public class SetPreferences implements RestModifyView<ConfigResource, Input> {
|
|||||||
IOException, ConfigInvalidException {
|
IOException, ConfigInvalidException {
|
||||||
if (i.changesPerPage != null || i.showSiteHeader != null
|
if (i.changesPerPage != null || i.showSiteHeader != null
|
||||||
|| i.useFlashClipboard != null || i.downloadScheme != null
|
|| i.useFlashClipboard != null || i.downloadScheme != null
|
||||||
|| i.downloadCommand != null || i.copySelfOnEmail != null
|
|| i.downloadCommand != null
|
||||||
|| i.dateFormat != null || i.timeFormat != null
|
|| i.dateFormat != null || i.timeFormat != null
|
||||||
|| i.relativeDateInChangeTable != null
|
|| i.relativeDateInChangeTable != null
|
||||||
|| i.sizeBarInChangeTable != null
|
|| i.sizeBarInChangeTable != null
|
||||||
|| i.legacycidInChangeTable != null
|
|| i.legacycidInChangeTable != null
|
||||||
|| i.muteCommonPathPrefixes != null
|
|| i.muteCommonPathPrefixes != null
|
||||||
|| i.reviewCategoryStrategy != null) {
|
|| i.reviewCategoryStrategy != null
|
||||||
|
|| i.emailStrategy != null) {
|
||||||
throw new BadRequestException("unsupported option");
|
throw new BadRequestException("unsupported option");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.common.errors.EmailException;
|
import com.google.gerrit.common.errors.EmailException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.EmailStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.UserIdentity;
|
import com.google.gerrit.reviewdb.client.UserIdentity;
|
||||||
import com.google.gerrit.server.account.AccountState;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.mail.EmailHeader.AddressList;
|
import com.google.gerrit.server.mail.EmailHeader.AddressList;
|
||||||
@@ -95,28 +96,29 @@ public abstract class OutgoingEmail {
|
|||||||
if (shouldSendMessage()) {
|
if (shouldSendMessage()) {
|
||||||
if (fromId != null) {
|
if (fromId != null) {
|
||||||
final Account fromUser = args.accountCache.get(fromId).getAccount();
|
final Account fromUser = args.accountCache.get(fromId).getAccount();
|
||||||
|
EmailStrategy strategy =
|
||||||
|
fromUser.getGeneralPreferences().getEmailStrategy();
|
||||||
|
|
||||||
if (fromUser.getGeneralPreferences().isCopySelfOnEmails()) {
|
if (strategy == EmailStrategy.CC_ON_OWN_COMMENTS) {
|
||||||
// If we are impersonating a user, make sure they receive a CC of
|
// If we are impersonating a user, make sure they receive a CC of
|
||||||
// this message so they can always review and audit what we sent
|
// this message so they can always review and audit what we sent
|
||||||
// on their behalf to others.
|
// on their behalf to others.
|
||||||
//
|
//
|
||||||
add(RecipientType.CC, fromId);
|
add(RecipientType.CC, fromId);
|
||||||
|
|
||||||
} else if (rcptTo.remove(fromId)) {
|
} else if (rcptTo.remove(fromId)) {
|
||||||
// If they don't want a copy, but we queued one up anyway,
|
// If they don't want a copy, but we queued one up anyway,
|
||||||
// drop them from the recipient lists.
|
// drop them from the recipient lists.
|
||||||
//
|
//
|
||||||
final String fromEmail = fromUser.getPreferredEmail();
|
removeUser(fromUser);
|
||||||
for (Iterator<Address> i = smtpRcptTo.iterator(); i.hasNext();) {
|
}
|
||||||
if (i.next().email.equals(fromEmail)) {
|
|
||||||
i.remove();
|
// Check the preferences of all recipients. If any user has disabled
|
||||||
}
|
// his email notifications then drop him from recipients' list
|
||||||
}
|
for (Account.Id id : rcptTo) {
|
||||||
for (EmailHeader hdr : headers.values()) {
|
Account thisUser = args.accountCache.get(id).getAccount();
|
||||||
if (hdr instanceof AddressList) {
|
if (thisUser.getGeneralPreferences().getEmailStrategy()
|
||||||
((AddressList) hdr).remove(fromEmail);
|
== EmailStrategy.DISABLED) {
|
||||||
}
|
removeUser(thisUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smtpRcptTo.isEmpty()) {
|
if (smtpRcptTo.isEmpty()) {
|
||||||
@@ -476,6 +478,20 @@ public abstract class OutgoingEmail {
|
|||||||
return r.toString();
|
return r.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeUser(Account user) {
|
||||||
|
String fromEmail = user.getPreferredEmail();
|
||||||
|
for (Iterator<Address> j = smtpRcptTo.iterator(); j.hasNext();) {
|
||||||
|
if (j.next().email.equals(fromEmail)) {
|
||||||
|
j.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (EmailHeader hdr : headers.values()) {
|
||||||
|
if (hdr instanceof AddressList) {
|
||||||
|
((AddressList) hdr).remove(fromEmail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String safeToString(Object obj) {
|
private static String safeToString(Object obj) {
|
||||||
return obj != null ? obj.toString() : "";
|
return obj != null ? obj.toString() : "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
/** A version of the database schema. */
|
/** A version of the database schema. */
|
||||||
public abstract class SchemaVersion {
|
public abstract class SchemaVersion {
|
||||||
/** The current schema version. */
|
/** The current schema version. */
|
||||||
public static final Class<Schema_115> C = Schema_115.class;
|
public static final Class<Schema_116> C = Schema_116.class;
|
||||||
|
|
||||||
public static int getBinaryVersion() {
|
public static int getBinaryVersion() {
|
||||||
return guessVersion(C);
|
return guessVersion(C);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2014 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.schema;
|
||||||
|
|
||||||
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class Schema_116 extends SchemaVersion {
|
||||||
|
@Inject
|
||||||
|
Schema_116(Provider<Schema_115> prior) {
|
||||||
|
super(prior);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
|
||||||
|
ui.message("Migrate user preference copySelfOnEmail to emailStrategy");
|
||||||
|
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement()) {
|
||||||
|
stmt.executeUpdate("UPDATE accounts SET "
|
||||||
|
+ "EMAIL_STRATEGY='ENABLED' "
|
||||||
|
+ "WHERE (COPY_SELF_ON_EMAIL='N')");
|
||||||
|
stmt.executeUpdate("UPDATE accounts SET "
|
||||||
|
+ "EMAIL_STRATEGY='CC_ON_OWN_COMMENTS' "
|
||||||
|
+ "WHERE (COPY_SELF_ON_EMAIL='Y')");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user