Add account setting for defaulting new changes to WIP
Create change online dialog wasn't extended in this change to respect new added work-in-progress account setting to initialize the checkbox accordingly. In PolyGerrit UI the WIP Change checkbox is shown and could be set if needed, in GWT UI the work-in-progress flag is always set implicitly. Feature: Issue 8866 Change-Id: Ibf537436841b755c946a6c329100f94a22774f68
This commit is contained in:
parent
9690994111
commit
821c5321d2
|
@ -827,6 +827,12 @@ commands that need to be copied frequently, such as the Change-Ids, commit IDs
|
||||||
and download commands. Note that this option is only shown if the Flash plugin
|
and download commands. Note that this option is only shown if the Flash plugin
|
||||||
is available and the JavaScript Clipboard API is unavailable.
|
is available and the JavaScript Clipboard API is unavailable.
|
||||||
|
|
||||||
|
- [[work-in-progress-by-default]]`Set new changes work-in-progress`:
|
||||||
|
+
|
||||||
|
Whether new changes are uploaded as work-in-progress per default. This
|
||||||
|
preference just sets the default; the behavior can still be overridden using a
|
||||||
|
link:user-upload.html#wip[push option].
|
||||||
|
|
||||||
[[my-menu]]
|
[[my-menu]]
|
||||||
In addition it is possible to customize the menu entries of the `My`
|
In addition it is possible to customize the menu entries of the `My`
|
||||||
menu. This can be used to make the navigation to frequently used
|
menu. This can be used to make the navigation to frequently used
|
||||||
|
|
|
@ -1249,6 +1249,7 @@ any account.
|
||||||
"review_category_strategy": "ABBREV",
|
"review_category_strategy": "ABBREV",
|
||||||
"mute_common_path_prefixes": true,
|
"mute_common_path_prefixes": true,
|
||||||
"publish_comments_on_push": true,
|
"publish_comments_on_push": true,
|
||||||
|
"work_in_progress_by_default": true,
|
||||||
"default_base_for_merges": "FIRST_PARENT",
|
"default_base_for_merges": "FIRST_PARENT",
|
||||||
"my": [
|
"my": [
|
||||||
{
|
{
|
||||||
|
@ -1355,6 +1356,7 @@ link:#preferences-info[PreferencesInfo] entity.
|
||||||
"review_category_strategy": "NAME",
|
"review_category_strategy": "NAME",
|
||||||
"diff_view": "SIDE_BY_SIDE",
|
"diff_view": "SIDE_BY_SIDE",
|
||||||
"publish_comments_on_push": true,
|
"publish_comments_on_push": true,
|
||||||
|
"work_in_progress_by_default": true,
|
||||||
"mute_common_path_prefixes": true,
|
"mute_common_path_prefixes": true,
|
||||||
"my": [
|
"my": [
|
||||||
{
|
{
|
||||||
|
@ -2645,6 +2647,9 @@ Allowed values are `AUTO_MERGE` and `FIRST_PARENT`.
|
||||||
|`publish_comments_on_push` |not set if `false`|
|
|`publish_comments_on_push` |not set if `false`|
|
||||||
Whether to link:user-upload.html#publish-comments[publish draft comments] on
|
Whether to link:user-upload.html#publish-comments[publish draft comments] on
|
||||||
push by default.
|
push by default.
|
||||||
|
|`work_in_progress_by_default` |not set if `false`|
|
||||||
|
Whether to link:user-upload.html#wip[set work-in-progress] on
|
||||||
|
push or on create changes online by default.
|
||||||
|============================================
|
|============================================
|
||||||
|
|
||||||
[[preferences-input]]
|
[[preferences-input]]
|
||||||
|
|
|
@ -309,6 +309,11 @@ flag from a change on push, explicitly specify the `ready` option:
|
||||||
Only change owners, project owners and site administrators can specify
|
Only change owners, project owners and site administrators can specify
|
||||||
`work-in-progress` and `ready` options on push.
|
`work-in-progress` and `ready` options on push.
|
||||||
|
|
||||||
|
The default for this option can be set as a
|
||||||
|
link:intro-user.html#work-in-progress-by-default[user preference]. If the
|
||||||
|
preference is set so the default behavior is to create `work-in-progress`
|
||||||
|
changes, this can be overridden with the `ready` option.
|
||||||
|
|
||||||
[[message]]
|
[[message]]
|
||||||
==== Message
|
==== Message
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,14 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.PushOneCommit;
|
import com.google.gerrit.acceptance.PushOneCommit;
|
||||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||||
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.common.ChangeInput;
|
import com.google.gerrit.extensions.common.ChangeInput;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -38,6 +40,14 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
project2 = createProject("project-2", project1);
|
project2 = createProject("project-2", project1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
setApiUser(admin);
|
||||||
|
GeneralPreferencesInfo prefs = gApi.accounts().id(admin.id.get()).getPreferences();
|
||||||
|
prefs.workInProgressByDefault = false;
|
||||||
|
gApi.accounts().id(admin.id.get()).setPreferences(prefs);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createChangeWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
public void createChangeWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
||||||
ChangeInfo info =
|
ChangeInfo info =
|
||||||
|
@ -52,6 +62,13 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
assertThat(gApi.changes().create(input).get().workInProgress).isTrue();
|
assertThat(gApi.changes().create(input).get().workInProgress).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createChangeWithWorkInProgressByDefaultForUserEnabled() throws Exception {
|
||||||
|
setWorkInProgressByDefaultForUser();
|
||||||
|
ChangeInput input = new ChangeInput(project2.get(), "master", "empty change");
|
||||||
|
assertThat(gApi.changes().create(input).get().workInProgress).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createChangeBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
public void createChangeBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||||
setWorkInProgressByDefaultForProject(project2);
|
setWorkInProgressByDefaultForProject(project2);
|
||||||
|
@ -60,6 +77,14 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
assertThat(gApi.changes().create(input).get().workInProgress).isNull();
|
assertThat(gApi.changes().create(input).get().workInProgress).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createChangeBypassWorkInProgressByDefaultForUserEnabled() throws Exception {
|
||||||
|
setWorkInProgressByDefaultForUser();
|
||||||
|
ChangeInput input = new ChangeInput(project2.get(), "master", "empty change");
|
||||||
|
input.workInProgress = false;
|
||||||
|
assertThat(gApi.changes().create(input).get().workInProgress).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createChangeWithWorkInProgressByDefaultForProjectInherited() throws Exception {
|
public void createChangeWithWorkInProgressByDefaultForProjectInherited() throws Exception {
|
||||||
setWorkInProgressByDefaultForProject(project1);
|
setWorkInProgressByDefaultForProject(project1);
|
||||||
|
@ -74,6 +99,12 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isTrue();
|
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void pushWithWorkInProgressByDefaultForUserEnabled() throws Exception {
|
||||||
|
setWorkInProgressByDefaultForUser();
|
||||||
|
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pushBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
public void pushBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||||
setWorkInProgressByDefaultForProject(project2);
|
setWorkInProgressByDefaultForProject(project2);
|
||||||
|
@ -82,6 +113,14 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
.isFalse();
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void pushBypassWorkInProgressByDefaultForUserEnabled() throws Exception {
|
||||||
|
setWorkInProgressByDefaultForUser();
|
||||||
|
assertThat(
|
||||||
|
createChange(project2, "refs/for/master%ready").getChange().change().isWorkInProgress())
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pushWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
public void pushWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
||||||
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isFalse();
|
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isFalse();
|
||||||
|
@ -99,6 +138,12 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||||
gApi.projects().name(p.get()).config(input);
|
gApi.projects().name(p.get()).config(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setWorkInProgressByDefaultForUser() throws Exception {
|
||||||
|
GeneralPreferencesInfo prefs = gApi.accounts().id(admin.id.get()).getPreferences();
|
||||||
|
prefs.workInProgressByDefault = true;
|
||||||
|
gApi.accounts().id(admin.id.get()).setPreferences(prefs);
|
||||||
|
}
|
||||||
|
|
||||||
private PushOneCommit.Result createChange(Project.NameKey p) throws Exception {
|
private PushOneCommit.Result createChange(Project.NameKey p) throws Exception {
|
||||||
return createChange(p, "refs/for/master");
|
return createChange(p, "refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||||
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
||||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||||
import com.google.gerrit.extensions.client.ReviewerState;
|
import com.google.gerrit.extensions.client.ReviewerState;
|
||||||
|
@ -950,6 +951,30 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||||
assertThat(sender).notSent();
|
assertThat(sender).notSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createWipChangeWithWorkInProgressByDefaultForUser() throws Exception {
|
||||||
|
// Make sure owner user is created
|
||||||
|
StagedChange sc = stageReviewableChange();
|
||||||
|
// All was cleaned already
|
||||||
|
assertThat(sender).notSent();
|
||||||
|
|
||||||
|
// Toggle workInProgress flag for owner
|
||||||
|
GeneralPreferencesInfo prefs = gApi.accounts().id(sc.owner.id.get()).getPreferences();
|
||||||
|
prefs.workInProgressByDefault = true;
|
||||||
|
gApi.accounts().id(sc.owner.id.get()).setPreferences(prefs);
|
||||||
|
|
||||||
|
// Create another change without notification that should be wip
|
||||||
|
StagedPreChange spc = stagePreChange("refs/for/master");
|
||||||
|
Truth.assertThat(gApi.changes().id(spc.changeId).get().workInProgress).isTrue();
|
||||||
|
assertThat(sender).notSent();
|
||||||
|
|
||||||
|
// Clean up workInProgressByDefault by owner
|
||||||
|
prefs = gApi.accounts().id(sc.owner.id.get()).getPreferences();
|
||||||
|
Truth.assertThat(prefs.workInProgressByDefault).isTrue();
|
||||||
|
prefs.workInProgressByDefault = false;
|
||||||
|
gApi.accounts().id(sc.owner.id.get()).setPreferences(prefs);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createReviewableChangeWithNotifyOwnerReviewers() throws Exception {
|
public void createReviewableChangeWithNotifyOwnerReviewers() throws Exception {
|
||||||
stagePreChange("refs/for/master%notify=OWNER_REVIEWERS");
|
stagePreChange("refs/for/master%notify=OWNER_REVIEWERS");
|
||||||
|
|
|
@ -158,6 +158,7 @@ public class GeneralPreferencesInfo {
|
||||||
public EmailFormat emailFormat;
|
public EmailFormat emailFormat;
|
||||||
public DefaultBase defaultBaseForMerges;
|
public DefaultBase defaultBaseForMerges;
|
||||||
public Boolean publishCommentsOnPush;
|
public Boolean publishCommentsOnPush;
|
||||||
|
public Boolean workInProgressByDefault;
|
||||||
|
|
||||||
public boolean isShowInfoInReviewCategory() {
|
public boolean isShowInfoInReviewCategory() {
|
||||||
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
||||||
|
@ -227,6 +228,7 @@ public class GeneralPreferencesInfo {
|
||||||
p.signedOffBy = false;
|
p.signedOffBy = false;
|
||||||
p.defaultBaseForMerges = DefaultBase.FIRST_PARENT;
|
p.defaultBaseForMerges = DefaultBase.FIRST_PARENT;
|
||||||
p.publishCommentsOnPush = false;
|
p.publishCommentsOnPush = false;
|
||||||
|
p.workInProgressByDefault = false;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,9 @@ public class GeneralPreferences extends JavaScriptObject {
|
||||||
public final native boolean
|
public final native boolean
|
||||||
publishCommentsOnPush() /*-{ return this.publish_comments_on_push || false }-*/;
|
publishCommentsOnPush() /*-{ return this.publish_comments_on_push || false }-*/;
|
||||||
|
|
||||||
|
public final native boolean
|
||||||
|
workInProgressByDefault() /*-{ return this.work_in_progress_by_default || false }-*/;
|
||||||
|
|
||||||
public final native JsArray<TopMenuItem> my() /*-{ return this.my; }-*/;
|
public final native JsArray<TopMenuItem> my() /*-{ return this.my; }-*/;
|
||||||
|
|
||||||
public final native void changesPerPage(int n) /*-{ this.changes_per_page = n }-*/;
|
public final native void changesPerPage(int n) /*-{ this.changes_per_page = n }-*/;
|
||||||
|
@ -230,6 +233,9 @@ public class GeneralPreferences extends JavaScriptObject {
|
||||||
public final native void publishCommentsOnPush(
|
public final native void publishCommentsOnPush(
|
||||||
boolean p) /*-{ this.publish_comments_on_push = p }-*/;
|
boolean p) /*-{ this.publish_comments_on_push = p }-*/;
|
||||||
|
|
||||||
|
public final native void workInProgressByDefault(
|
||||||
|
boolean p) /*-{ this.work_in_progress_by_default = p }-*/;
|
||||||
|
|
||||||
public final void setMyMenus(List<TopMenuItem> myMenus) {
|
public final void setMyMenus(List<TopMenuItem> myMenus) {
|
||||||
initMy();
|
initMy();
|
||||||
for (TopMenuItem n : myMenus) {
|
for (TopMenuItem n : myMenus) {
|
||||||
|
|
|
@ -69,6 +69,8 @@ public interface AccountConstants extends Constants {
|
||||||
|
|
||||||
String publishCommentsOnPush();
|
String publishCommentsOnPush();
|
||||||
|
|
||||||
|
String workInProgressByDefault();
|
||||||
|
|
||||||
String myMenu();
|
String myMenu();
|
||||||
|
|
||||||
String myMenuInfo();
|
String myMenuInfo();
|
||||||
|
|
|
@ -39,6 +39,7 @@ showLegacycidInChangeTable = Show Change Number In Changes Table
|
||||||
muteCommonPathPrefixes = Mute Common Path Prefixes In File List
|
muteCommonPathPrefixes = Mute Common Path Prefixes In File List
|
||||||
signedOffBy = Insert Signed-off-by Footer For Inline Edit Changes
|
signedOffBy = Insert Signed-off-by Footer For Inline Edit Changes
|
||||||
publishCommentsOnPush = Publish Draft Comments When a Change Is Updated by Push
|
publishCommentsOnPush = Publish Draft Comments When a Change Is Updated by Push
|
||||||
|
workInProgressByDefault = Set all new changes work-in-progress by default
|
||||||
myMenu = My Menu
|
myMenu = My Menu
|
||||||
myMenuInfo = \
|
myMenuInfo = \
|
||||||
Menu items for the 'My' top level menu. \
|
Menu items for the 'My' top level menu. \
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
private CheckBox muteCommonPathPrefixes;
|
private CheckBox muteCommonPathPrefixes;
|
||||||
private CheckBox signedOffBy;
|
private CheckBox signedOffBy;
|
||||||
private CheckBox publishCommentsOnPush;
|
private CheckBox publishCommentsOnPush;
|
||||||
|
private CheckBox workInProgressByDefault;
|
||||||
private ListBox maximumPageSize;
|
private ListBox maximumPageSize;
|
||||||
private ListBox dateFormat;
|
private ListBox dateFormat;
|
||||||
private ListBox timeFormat;
|
private ListBox timeFormat;
|
||||||
|
@ -163,9 +164,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
|
muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
|
||||||
signedOffBy = new CheckBox(Util.C.signedOffBy());
|
signedOffBy = new CheckBox(Util.C.signedOffBy());
|
||||||
publishCommentsOnPush = new CheckBox(Util.C.publishCommentsOnPush());
|
publishCommentsOnPush = new CheckBox(Util.C.publishCommentsOnPush());
|
||||||
|
workInProgressByDefault = new CheckBox(Util.C.workInProgressByDefault());
|
||||||
|
|
||||||
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
|
||||||
final Grid formGrid = new Grid(15 + (flashClippy ? 1 : 0), 2);
|
final Grid formGrid = new Grid(16 + (flashClippy ? 1 : 0), 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
@ -229,6 +231,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
formGrid.setWidget(row, fieldIdx, publishCommentsOnPush);
|
formGrid.setWidget(row, fieldIdx, publishCommentsOnPush);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
formGrid.setText(row, labelIdx, "");
|
||||||
|
formGrid.setWidget(row, fieldIdx, workInProgressByDefault);
|
||||||
|
row++;
|
||||||
|
|
||||||
if (flashClippy) {
|
if (flashClippy) {
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
formGrid.setWidget(row, fieldIdx, useFlashClipboard);
|
formGrid.setWidget(row, fieldIdx, useFlashClipboard);
|
||||||
|
@ -264,6 +270,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
e.listenTo(muteCommonPathPrefixes);
|
e.listenTo(muteCommonPathPrefixes);
|
||||||
e.listenTo(signedOffBy);
|
e.listenTo(signedOffBy);
|
||||||
e.listenTo(publishCommentsOnPush);
|
e.listenTo(publishCommentsOnPush);
|
||||||
|
e.listenTo(workInProgressByDefault);
|
||||||
e.listenTo(diffView);
|
e.listenTo(diffView);
|
||||||
e.listenTo(reviewCategoryStrategy);
|
e.listenTo(reviewCategoryStrategy);
|
||||||
e.listenTo(emailStrategy);
|
e.listenTo(emailStrategy);
|
||||||
|
@ -303,6 +310,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
muteCommonPathPrefixes.setEnabled(on);
|
muteCommonPathPrefixes.setEnabled(on);
|
||||||
signedOffBy.setEnabled(on);
|
signedOffBy.setEnabled(on);
|
||||||
publishCommentsOnPush.setEnabled(on);
|
publishCommentsOnPush.setEnabled(on);
|
||||||
|
workInProgressByDefault.setEnabled(on);
|
||||||
reviewCategoryStrategy.setEnabled(on);
|
reviewCategoryStrategy.setEnabled(on);
|
||||||
diffView.setEnabled(on);
|
diffView.setEnabled(on);
|
||||||
emailStrategy.setEnabled(on);
|
emailStrategy.setEnabled(on);
|
||||||
|
@ -329,6 +337,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
muteCommonPathPrefixes.setValue(p.muteCommonPathPrefixes());
|
muteCommonPathPrefixes.setValue(p.muteCommonPathPrefixes());
|
||||||
signedOffBy.setValue(p.signedOffBy());
|
signedOffBy.setValue(p.signedOffBy());
|
||||||
publishCommentsOnPush.setValue(p.publishCommentsOnPush());
|
publishCommentsOnPush.setValue(p.publishCommentsOnPush());
|
||||||
|
workInProgressByDefault.setValue(p.workInProgressByDefault());
|
||||||
setListBox(
|
setListBox(
|
||||||
reviewCategoryStrategy,
|
reviewCategoryStrategy,
|
||||||
GeneralPreferencesInfo.ReviewCategoryStrategy.NONE,
|
GeneralPreferencesInfo.ReviewCategoryStrategy.NONE,
|
||||||
|
@ -421,6 +430,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
||||||
p.muteCommonPathPrefixes(muteCommonPathPrefixes.getValue());
|
p.muteCommonPathPrefixes(muteCommonPathPrefixes.getValue());
|
||||||
p.signedOffBy(signedOffBy.getValue());
|
p.signedOffBy(signedOffBy.getValue());
|
||||||
p.publishCommentsOnPush(publishCommentsOnPush.getValue());
|
p.publishCommentsOnPush(publishCommentsOnPush.getValue());
|
||||||
|
p.workInProgressByDefault(workInProgressByDefault.getValue());
|
||||||
p.reviewCategoryStrategy(
|
p.reviewCategoryStrategy(
|
||||||
getListBox(
|
getListBox(
|
||||||
reviewCategoryStrategy, ReviewCategoryStrategy.NONE, ReviewCategoryStrategy.values()));
|
reviewCategoryStrategy, ReviewCategoryStrategy.NONE, ReviewCategoryStrategy.values()));
|
||||||
|
|
|
@ -188,11 +188,6 @@ public class CreateChange
|
||||||
throw new MethodNotAllowedException("private changes are disabled");
|
throw new MethodNotAllowedException("private changes are disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isWorkInProgress =
|
|
||||||
input.workInProgress == null
|
|
||||||
? rsrc.getProjectState().isWorkInProgressByDefault()
|
|
||||||
: input.workInProgress;
|
|
||||||
|
|
||||||
contributorAgreements.check(rsrc.getNameKey(), rsrc.getUser());
|
contributorAgreements.check(rsrc.getNameKey(), rsrc.getUser());
|
||||||
|
|
||||||
Project.NameKey project = rsrc.getNameKey();
|
Project.NameKey project = rsrc.getNameKey();
|
||||||
|
@ -243,6 +238,12 @@ public class CreateChange
|
||||||
AccountState account = accountCache.get(me.getAccountId());
|
AccountState account = accountCache.get(me.getAccountId());
|
||||||
GeneralPreferencesInfo info = account.getAccount().getGeneralPreferencesInfo();
|
GeneralPreferencesInfo info = account.getAccount().getGeneralPreferencesInfo();
|
||||||
|
|
||||||
|
boolean isWorkInProgress =
|
||||||
|
input.workInProgress == null
|
||||||
|
? rsrc.getProjectState().isWorkInProgressByDefault()
|
||||||
|
|| MoreObjects.firstNonNull(info.workInProgressByDefault, false)
|
||||||
|
: input.workInProgress;
|
||||||
|
|
||||||
// Add a Change-Id line if there isn't already one
|
// Add a Change-Id line if there isn't already one
|
||||||
String commitMessage = subject;
|
String commitMessage = subject;
|
||||||
if (ChangeIdUtil.indexOfChangeId(commitMessage, "\n") == -1) {
|
if (ChangeIdUtil.indexOfChangeId(commitMessage, "\n") == -1) {
|
||||||
|
|
|
@ -2154,7 +2154,9 @@ class ReceiveCommits {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
magicBranch.workInProgress =
|
magicBranch.workInProgress =
|
||||||
projectCache.get(project.getNameKey()).isWorkInProgressByDefault();
|
projectCache.get(project.getNameKey()).isWorkInProgressByDefault()
|
||||||
|
|| firstNonNull(
|
||||||
|
user.getAccount().getGeneralPreferencesInfo().workInProgressByDefault, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOps(BatchUpdate bu) throws RestApiException {
|
private void addOps(BatchUpdate bu) throws RestApiException {
|
||||||
|
|
|
@ -190,6 +190,16 @@ limitations under the License.
|
||||||
on-change="_handlePublishCommentsOnPushChanged">
|
on-change="_handlePublishCommentsOnPushChanged">
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<span class="title">Set new changes to "work in progress" by default</span>
|
||||||
|
<span class="value">
|
||||||
|
<input
|
||||||
|
id="workInProgressByDefault"
|
||||||
|
type="checkbox"
|
||||||
|
checked$="[[_localPrefs.work_in_progress_by_default]]"
|
||||||
|
on-change="_handleWorkInProgressByDefault">
|
||||||
|
</span>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<span class="title">
|
<span class="title">
|
||||||
Insert Signed-off-by Footer For Inline Edit Changes
|
Insert Signed-off-by Footer For Inline Edit Changes
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
'diff_view',
|
'diff_view',
|
||||||
'expand_inline_diffs',
|
'expand_inline_diffs',
|
||||||
'publish_comments_on_push',
|
'publish_comments_on_push',
|
||||||
|
'work_in_progress_by_default',
|
||||||
'signed_off_by',
|
'signed_off_by',
|
||||||
'email_format',
|
'email_format',
|
||||||
];
|
];
|
||||||
|
@ -265,6 +266,11 @@
|
||||||
this.$.publishCommentsOnPush.checked);
|
this.$.publishCommentsOnPush.checked);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_handleWorkInProgressByDefault() {
|
||||||
|
this.set('_localPrefs.work_in_progress_by_default',
|
||||||
|
this.$.workInProgressByDefault.checked);
|
||||||
|
},
|
||||||
|
|
||||||
_handleInsertSignedOff() {
|
_handleInsertSignedOff() {
|
||||||
this.set('_localPrefs.signed_off_by', this.$.insertSignedOff.checked);
|
this.set('_localPrefs.signed_off_by', this.$.insertSignedOff.checked);
|
||||||
},
|
},
|
||||||
|
|
|
@ -172,6 +172,9 @@ limitations under the License.
|
||||||
.firstElementChild.checked, false);
|
.firstElementChild.checked, false);
|
||||||
assert.equal(valueOf('Publish comments on push', 'preferences')
|
assert.equal(valueOf('Publish comments on push', 'preferences')
|
||||||
.firstElementChild.checked, false);
|
.firstElementChild.checked, false);
|
||||||
|
assert.equal(valueOf(
|
||||||
|
'Set new changes to "work in progress" by default', 'preferences')
|
||||||
|
.firstElementChild.checked, false);
|
||||||
assert.equal(valueOf(
|
assert.equal(valueOf(
|
||||||
'Insert Signed-off-by Footer For Inline Edit Changes', 'preferences')
|
'Insert Signed-off-by Footer For Inline Edit Changes', 'preferences')
|
||||||
.firstElementChild.checked, false);
|
.firstElementChild.checked, false);
|
||||||
|
@ -232,6 +235,30 @@ limitations under the License.
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('set new changes work-in-progress', done => {
|
||||||
|
const newChangesWorkInProgress =
|
||||||
|
valueOf('Set new changes to "work in progress" by default',
|
||||||
|
'preferences').firstElementChild;
|
||||||
|
MockInteractions.tap(newChangesWorkInProgress);
|
||||||
|
|
||||||
|
assert.isFalse(element._menuChanged);
|
||||||
|
assert.isTrue(element._prefsChanged);
|
||||||
|
|
||||||
|
stub('gr-rest-api-interface', {
|
||||||
|
savePreferences(prefs) {
|
||||||
|
assert.equal(prefs.work_in_progress_by_default, true);
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save the change.
|
||||||
|
element._handleSavePreferences().then(() => {
|
||||||
|
assert.isFalse(element._prefsChanged);
|
||||||
|
assert.isFalse(element._menuChanged);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('diff preferences', done => {
|
test('diff preferences', done => {
|
||||||
// Rendered with the expected preferences selected.
|
// Rendered with the expected preferences selected.
|
||||||
assert.equal(valueOf('Context', 'diffPreferences')
|
assert.equal(valueOf('Context', 'diffPreferences')
|
||||||
|
|
Loading…
Reference in New Issue