diff options
author | Stefan Beller <sbeller@google.com> | 2016-05-31 14:43:36 -0700 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2016-06-01 06:40:46 +0000 |
commit | 4b989b977e4168769fc6e7a0da762fbafa95d647 (patch) | |
tree | 786c916480691e8b29c283b85f1d815011db3cf3 | |
parent | 43fe38183b99b0104ed0e40ed5c5e548305b113b (diff) |
Submit: Give another error message when the change itself has problems
Andrew reported that he saw the disabled submit button and the hover
text saying "See the 'Submitted Together' tab for problems specially
see 78110" while looking at 78110 already and it confused him.
This introduces a custom error message when the error message is generated
by the change that the user is looking at. The root cause, which is
inconsistency with other UI elements ("Ready to submit") is not fixed
in this change. This will be less confusing as listing the same change
in a list of changes though.
Change-Id: I585a243f04dc19a6ea0247baa08b63dca09449f1
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java index bda348dbce..65c9dff259 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java @@ -95,6 +95,8 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>, "This change depends on other hidden changes which are not ready"; private static final String CLICK_FAILURE_TOOLTIP = "Clicking the button would fail"; + private static final String CHANGE_UNMERGEABLE = + "Problems with integrating this change"; private static final String CHANGES_NOT_MERGEABLE = "See the \"Submitted Together\" tab for problems, specifically see: "; @@ -222,12 +224,13 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>, } /** + * @param cd the change the user is currently looking at * @param cs set of changes to be submitted at once * @param identifiedUser the user who is checking to submit * @return a reason why any of the changes is not submittable or null */ - private String problemsForSubmittingChangeset( - ChangeSet cs, IdentifiedUser identifiedUser) { + private String problemsForSubmittingChangeset(ChangeData cd, ChangeSet cs, + IdentifiedUser identifiedUser) { try { @SuppressWarnings("resource") ReviewDb db = dbProvider.get(); @@ -249,6 +252,11 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>, if (unmergeable == null) { return CLICK_FAILURE_TOOLTIP; } else if (!unmergeable.isEmpty()) { + for (ChangeData c : unmergeable) { + if (c.change().getKey().equals(cd.change().getKey())) { + return CHANGE_UNMERGEABLE; + } + } return CHANGES_NOT_MERGEABLE + Joiner.on(", ").join( Iterables.transform(unmergeable, new Function<ChangeData, String>() { @@ -326,8 +334,8 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>, && !Strings.isNullOrEmpty(topic) && topicSize > 1; - String submitProblems = problemsForSubmittingChangeset(cs, - resource.getUser()); + String submitProblems = + problemsForSubmittingChangeset(cd, cs, resource.getUser()); Boolean enabled; try { |