Add frontend code for email format user preference
This change adds all required frontend code for both GWT UI and Polygerrit as well as docs for the user preferenced introduced by Change I190644732. Feature: Issue 5349 Change-Id: I94353380fbd5208cebb7fe8946fb4c4100c8d054
This commit is contained in:
@@ -644,6 +644,20 @@ on comments that you write yourself.
|
|||||||
+
|
+
|
||||||
Email notifications are disabled.
|
Email notifications are disabled.
|
||||||
|
|
||||||
|
- [[email-format]]`Email Format`:
|
||||||
|
+
|
||||||
|
This setting controls the email format Gerrit sends. Note that this
|
||||||
|
setting has no effect if the administrator has disabled HTML emails
|
||||||
|
for the Gerrit instance.
|
||||||
|
+
|
||||||
|
** `Plaintext Only`:
|
||||||
|
+
|
||||||
|
Email notifications contain only plaintext content.
|
||||||
|
+
|
||||||
|
** `HTML and Plaintext`:
|
||||||
|
+
|
||||||
|
Email notifications contain both HTML and plaintext content.
|
||||||
|
|
||||||
- [[default-base-for-merges]]`Default Base For Merges`:
|
- [[default-base-for-merges]]`Default Base For Merges`:
|
||||||
+
|
+
|
||||||
This setting controls which base should be pre-selected in the
|
This setting controls which base should be pre-selected in the
|
||||||
|
@@ -22,6 +22,7 @@ import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DateFormat;
|
|||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DefaultBase;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DefaultBase;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DownloadCommand;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DownloadCommand;
|
||||||
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailFormat;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.ReviewCategoryStrategy;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.ReviewCategoryStrategy;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.TimeFormat;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.TimeFormat;
|
||||||
@@ -52,6 +53,7 @@ public class GeneralPreferences extends JavaScriptObject {
|
|||||||
p.legacycidInChangeTable(d.legacycidInChangeTable);
|
p.legacycidInChangeTable(d.legacycidInChangeTable);
|
||||||
p.muteCommonPathPrefixes(d.muteCommonPathPrefixes);
|
p.muteCommonPathPrefixes(d.muteCommonPathPrefixes);
|
||||||
p.signedOffBy(d.signedOffBy);
|
p.signedOffBy(d.signedOffBy);
|
||||||
|
p.emailFormat(d.emailFormat);
|
||||||
p.reviewCategoryStrategy(d.getReviewCategoryStrategy());
|
p.reviewCategoryStrategy(d.getReviewCategoryStrategy());
|
||||||
p.diffView(d.getDiffView());
|
p.diffView(d.getDiffView());
|
||||||
p.emailStrategy(d.emailStrategy);
|
p.emailStrategy(d.emailStrategy);
|
||||||
@@ -132,6 +134,13 @@ public class GeneralPreferences extends JavaScriptObject {
|
|||||||
|
|
||||||
private native String emailStrategyRaw() /*-{ return this.email_strategy }-*/;
|
private native String emailStrategyRaw() /*-{ return this.email_strategy }-*/;
|
||||||
|
|
||||||
|
public final EmailFormat emailFormat() {
|
||||||
|
String s = emailFormatRaw();
|
||||||
|
return s != null ? EmailFormat.valueOf(s) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private native String emailFormatRaw() /*-{ return this.email_format }-*/;
|
||||||
|
|
||||||
public final DefaultBase defaultBaseForMerges() {
|
public final DefaultBase defaultBaseForMerges() {
|
||||||
String s = defaultBaseForMergesRaw();
|
String s = defaultBaseForMergesRaw();
|
||||||
return s != null ? DefaultBase.valueOf(s) : null;
|
return s != null ? DefaultBase.valueOf(s) : null;
|
||||||
@@ -203,6 +212,12 @@ public class GeneralPreferences extends JavaScriptObject {
|
|||||||
|
|
||||||
private native void emailStrategyRaw(String s) /*-{ this.email_strategy = s }-*/;
|
private native void emailStrategyRaw(String s) /*-{ this.email_strategy = s }-*/;
|
||||||
|
|
||||||
|
public final void emailFormat(EmailFormat f) {
|
||||||
|
emailFormatRaw(f != null ? f.toString() : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void emailFormatRaw(String s) /*-{ this.email_format = s }-*/;
|
||||||
|
|
||||||
public final void defaultBaseForMerges(DefaultBase b) {
|
public final void defaultBaseForMerges(DefaultBase b) {
|
||||||
defaultBaseForMergesRaw(b != null ? b.toString() : null);
|
defaultBaseForMergesRaw(b != null ? b.toString() : null);
|
||||||
}
|
}
|
||||||
|
@@ -287,6 +287,12 @@ public interface AccountConstants extends Constants {
|
|||||||
|
|
||||||
String emailFieldLabel();
|
String emailFieldLabel();
|
||||||
|
|
||||||
|
String emailFormatFieldLabel();
|
||||||
|
|
||||||
|
String messagePlaintextOnly();
|
||||||
|
|
||||||
|
String messageHtmlPlaintext();
|
||||||
|
|
||||||
String defaultBaseForMerges();
|
String defaultBaseForMerges();
|
||||||
|
|
||||||
String autoMerge();
|
String autoMerge();
|
||||||
|
@@ -19,6 +19,10 @@ messageCCMeOnMyComments = Every Comment
|
|||||||
messageEnabled = Only Comments Left By Others
|
messageEnabled = Only Comments Left By Others
|
||||||
messageDisabled = None
|
messageDisabled = None
|
||||||
|
|
||||||
|
emailFormatFieldLabel = Email Format:
|
||||||
|
messagePlaintextOnly = Plaintext Only
|
||||||
|
messageHtmlPlaintext = HTML and Plaintext
|
||||||
|
|
||||||
defaultBaseForMerges = Default Base For Merges:
|
defaultBaseForMerges = Default Base For Merges:
|
||||||
autoMerge = Auto Merge
|
autoMerge = Auto Merge
|
||||||
firstParent = First Parent
|
firstParent = First Parent
|
||||||
|
@@ -61,6 +61,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private ListBox reviewCategoryStrategy;
|
private ListBox reviewCategoryStrategy;
|
||||||
private ListBox diffView;
|
private ListBox diffView;
|
||||||
private ListBox emailStrategy;
|
private ListBox emailStrategy;
|
||||||
|
private ListBox emailFormat;
|
||||||
private ListBox defaultBaseForMerges;
|
private ListBox defaultBaseForMerges;
|
||||||
private StringListPanel myMenus;
|
private StringListPanel myMenus;
|
||||||
private Button save;
|
private Button save;
|
||||||
@@ -102,6 +103,12 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
emailStrategy.addItem(
|
emailStrategy.addItem(
|
||||||
Util.C.messageDisabled(), GeneralPreferencesInfo.EmailStrategy.DISABLED.name());
|
Util.C.messageDisabled(), GeneralPreferencesInfo.EmailStrategy.DISABLED.name());
|
||||||
|
|
||||||
|
emailFormat = new ListBox();
|
||||||
|
emailFormat.addItem(
|
||||||
|
Util.C.messagePlaintextOnly(), GeneralPreferencesInfo.EmailFormat.PLAINTEXT.name());
|
||||||
|
emailFormat.addItem(
|
||||||
|
Util.C.messageHtmlPlaintext(), GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT.name());
|
||||||
|
|
||||||
defaultBaseForMerges = new ListBox();
|
defaultBaseForMerges = new ListBox();
|
||||||
defaultBaseForMerges.addItem(
|
defaultBaseForMerges.addItem(
|
||||||
Util.C.autoMerge(), GeneralPreferencesInfo.DefaultBase.AUTO_MERGE.name());
|
Util.C.autoMerge(), GeneralPreferencesInfo.DefaultBase.AUTO_MERGE.name());
|
||||||
@@ -157,7 +164,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
signedOffBy = new CheckBox(Util.C.signedOffBy());
|
signedOffBy = new CheckBox(Util.C.signedOffBy());
|
||||||
|
|
||||||
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
||||||
final Grid formGrid = new Grid(13 + (flashClippy ? 1 : 0), 2);
|
final Grid formGrid = new Grid(14 + (flashClippy ? 1 : 0), 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
@@ -177,6 +184,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
formGrid.setWidget(row, fieldIdx, emailStrategy);
|
formGrid.setWidget(row, fieldIdx, emailStrategy);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
formGrid.setText(row, labelIdx, Util.C.emailFormatFieldLabel());
|
||||||
|
formGrid.setWidget(row, fieldIdx, emailFormat);
|
||||||
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.defaultBaseForMerges());
|
formGrid.setText(row, labelIdx, Util.C.defaultBaseForMerges());
|
||||||
formGrid.setWidget(row, fieldIdx, defaultBaseForMerges);
|
formGrid.setWidget(row, fieldIdx, defaultBaseForMerges);
|
||||||
row++;
|
row++;
|
||||||
@@ -250,6 +261,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
e.listenTo(diffView);
|
e.listenTo(diffView);
|
||||||
e.listenTo(reviewCategoryStrategy);
|
e.listenTo(reviewCategoryStrategy);
|
||||||
e.listenTo(emailStrategy);
|
e.listenTo(emailStrategy);
|
||||||
|
e.listenTo(emailFormat);
|
||||||
e.listenTo(defaultBaseForMerges);
|
e.listenTo(defaultBaseForMerges);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +299,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
reviewCategoryStrategy.setEnabled(on);
|
reviewCategoryStrategy.setEnabled(on);
|
||||||
diffView.setEnabled(on);
|
diffView.setEnabled(on);
|
||||||
emailStrategy.setEnabled(on);
|
emailStrategy.setEnabled(on);
|
||||||
|
emailFormat.setEnabled(on);
|
||||||
defaultBaseForMerges.setEnabled(on);
|
defaultBaseForMerges.setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +327,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
p.reviewCategoryStrategy());
|
p.reviewCategoryStrategy());
|
||||||
setListBox(diffView, GeneralPreferencesInfo.DiffView.SIDE_BY_SIDE, p.diffView());
|
setListBox(diffView, GeneralPreferencesInfo.DiffView.SIDE_BY_SIDE, p.diffView());
|
||||||
setListBox(emailStrategy, GeneralPreferencesInfo.EmailStrategy.ENABLED, p.emailStrategy());
|
setListBox(emailStrategy, GeneralPreferencesInfo.EmailStrategy.ENABLED, p.emailStrategy());
|
||||||
|
setListBox(emailFormat, GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT, p.emailFormat());
|
||||||
setListBox(
|
setListBox(
|
||||||
defaultBaseForMerges,
|
defaultBaseForMerges,
|
||||||
GeneralPreferencesInfo.DefaultBase.FIRST_PARENT,
|
GeneralPreferencesInfo.DefaultBase.FIRST_PARENT,
|
||||||
@@ -414,6 +428,12 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
GeneralPreferencesInfo.EmailStrategy.ENABLED,
|
GeneralPreferencesInfo.EmailStrategy.ENABLED,
|
||||||
GeneralPreferencesInfo.EmailStrategy.values()));
|
GeneralPreferencesInfo.EmailStrategy.values()));
|
||||||
|
|
||||||
|
p.emailFormat(
|
||||||
|
getListBox(
|
||||||
|
emailFormat,
|
||||||
|
GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT,
|
||||||
|
GeneralPreferencesInfo.EmailFormat.values()));
|
||||||
|
|
||||||
p.defaultBaseForMerges(
|
p.defaultBaseForMerges(
|
||||||
getListBox(
|
getListBox(
|
||||||
defaultBaseForMerges,
|
defaultBaseForMerges,
|
||||||
|
@@ -174,6 +174,17 @@ limitations under the License.
|
|||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
|
<section hidden$="[[!_localPrefs.email_format]]">
|
||||||
|
<span class="title">Email Format</span>
|
||||||
|
<span class="value">
|
||||||
|
<select
|
||||||
|
is="gr-select"
|
||||||
|
bind-value="{{_localPrefs.email_format}}">
|
||||||
|
<option value="HTML_PLAINTEXT">HTML and Plaintext</option>
|
||||||
|
<option value="PLAINTEXT">Plaintext Only</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<span class="title">Diff View</span>
|
<span class="title">Diff View</span>
|
||||||
<span class="value">
|
<span class="value">
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
'email_strategy',
|
'email_strategy',
|
||||||
'diff_view',
|
'diff_view',
|
||||||
'expand_inline_diffs',
|
'expand_inline_diffs',
|
||||||
|
'email_format',
|
||||||
];
|
];
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
|
@@ -85,6 +85,7 @@ limitations under the License.
|
|||||||
time_format: 'HHMM_12',
|
time_format: 'HHMM_12',
|
||||||
diff_view: 'UNIFIED_DIFF',
|
diff_view: 'UNIFIED_DIFF',
|
||||||
email_strategy: 'ENABLED',
|
email_strategy: 'ENABLED',
|
||||||
|
email_format: 'HTML_PLAINTEXT',
|
||||||
|
|
||||||
my: [
|
my: [
|
||||||
{url: '/first/url', name: 'first name', target: '_blank'},
|
{url: '/first/url', name: 'first name', target: '_blank'},
|
||||||
@@ -162,6 +163,8 @@ limitations under the License.
|
|||||||
.lastElementChild.bindValue, preferences.time_format);
|
.lastElementChild.bindValue, preferences.time_format);
|
||||||
assert.equal(valueOf('Email Notifications', 'preferences')
|
assert.equal(valueOf('Email Notifications', 'preferences')
|
||||||
.firstElementChild.bindValue, preferences.email_strategy);
|
.firstElementChild.bindValue, preferences.email_strategy);
|
||||||
|
assert.equal(valueOf('Email Format', 'preferences')
|
||||||
|
.firstElementChild.bindValue, preferences.email_format);
|
||||||
assert.equal(valueOf('Diff View', 'preferences')
|
assert.equal(valueOf('Diff View', 'preferences')
|
||||||
.firstElementChild.bindValue, preferences.diff_view);
|
.firstElementChild.bindValue, preferences.diff_view);
|
||||||
assert.equal(valueOf('Expand Inline Diffs', 'preferences')
|
assert.equal(valueOf('Expand Inline Diffs', 'preferences')
|
||||||
|
Reference in New Issue
Block a user