ChangeScreen: reword submit button for single change topics

When `change.submitWholeTopic` is enabled and a topic is set for a change,
we always rendered the submit button with "Submit whole topic". This is
confusing when having only one change in the topic, which can easily happen
when a user wants to revert just one change which was merged as part of a
larger topic before. Then the revert commit keeps the topic, but it's just
one change in the topic.

To avoid user confusion when having just one change in the topic, do not
display it as a submission of the whole topic, but rather treat it as a
change without topic.

The change for one change in a topic has been adapted to reflect the new
behavior. This does not worsen the test situation as there are still
	revisionActionsTwoChangeChangesInTopic
	revisionActionsTwoChangeChangesInTopicReady
which test the point of having the whole topic enabled.

Change-Id: Ic97400a05749d9db4a03eb512a52c84f43403a83
This commit is contained in:
Stefan Beller
2015-02-23 10:53:45 -08:00
committed by David Pursehouse
parent 2fcfde15c8
commit 619af2aaca
2 changed files with 17 additions and 15 deletions

View File

@@ -53,15 +53,9 @@ public class ActionsIT extends AbstractDaemonTest {
approve(changeId);
Map<String, ActionInfo> actions = getActions(changeId);
commonActionsAssertions(actions);
if (isSubmitWholeTopicEnabled()) {
ActionInfo info = actions.get("submit");
assertThat(info.enabled).isTrue();
assertThat(info.label).isEqualTo("Submit whole topic");
assertThat(info.method).isEqualTo("POST");
assertThat(info.title).isEqualTo("Submit all 1 changes of the same topic");
} else {
noSubmitWholeTopicAssertions(actions);
}
// We want to treat a single change in a topic not as a whole topic,
// so regardless of how submitWholeTopic is configured:
noSubmitWholeTopicAssertions(actions);
}
@Test

View File

@@ -290,13 +290,13 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
.setTitle("")
.setVisible(false);
}
List<ChangeData> changesByTopic = null;
if (submitWholeTopic && !Strings.isNullOrEmpty(topic)) {
List<ChangeData> changesByTopic = null;
try {
changesByTopic = queryProvider.get().byTopicOpen(topic);
} catch (OrmException e) {
throw new OrmRuntimeException(e);
}
changesByTopic = getChangesByTopic(topic);
}
if (submitWholeTopic
&& !Strings.isNullOrEmpty(topic)
&& changesByTopic.size() > 1) {
Map<String, String> params = ImmutableMap.of(
"topicSize", String.valueOf(changesByTopic.size()));
String topicProblems = problemsForSubmittingChanges(changesByTopic,
@@ -665,6 +665,14 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
return config.getBoolean("change", null, "submitWholeTopic" , false);
}
private List<ChangeData> getChangesByTopic(String topic) {
try {
return queryProvider.get().byTopicOpen(topic);
} catch (OrmException e) {
throw new OrmRuntimeException(e);
}
}
public static class CurrentRevision implements
RestModifyView<ChangeResource, SubmitInput> {
private final Provider<ReviewDb> dbProvider;