From d1f12af94b21a04c3cf96caf1ab83c4bdf552236 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 09 Feb 2012 17:48:11 -0500 Subject: [PATCH] Reversed the order of buttons on all forms so that default is submit --- src/com/gitblit/wicket/pages/SendProposalPage.java | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/com/gitblit/wicket/pages/SendProposalPage.java b/src/com/gitblit/wicket/pages/SendProposalPage.java index ea91f1b..a7fcadc 100644 --- a/src/com/gitblit/wicket/pages/SendProposalPage.java +++ b/src/com/gitblit/wicket/pages/SendProposalPage.java @@ -26,6 +26,7 @@ import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.CompoundPropertyModel; +import com.gitblit.Constants.FederationProposalResult; import com.gitblit.GitBlit; import com.gitblit.models.FederationProposal; import com.gitblit.models.RepositoryModel; @@ -36,7 +37,7 @@ import com.gitblit.wicket.panels.RepositoriesPanel; @RequiresAdminRole -public class SendProposalPage extends BasePage { +public class SendProposalPage extends RootSubPage { public String myUrl; @@ -47,7 +48,7 @@ public SendProposalPage(PageParameters params) { super(params); - setupPage("", getString("gb.sendProposal")); + setupPage(getString("gb.sendProposal"), ""); setStatelessHint(true); final String token = WicketUtils.getToken(params); @@ -78,17 +79,44 @@ error("Please enter a destination url for your proposal!"); return; } - + // build new proposal FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token); proposal.url = myUrl; proposal.message = message; try { - if (FederationUtils.propose(destinationUrl, proposal)) { - info(MessageFormat.format("Proposal successfully received by {0}.", destinationUrl)); + FederationProposalResult res = FederationUtils + .propose(destinationUrl, proposal); + switch (res) { + case ACCEPTED: + info(MessageFormat.format("Proposal successfully received by {0}.", + destinationUrl)); setResponsePage(RepositoriesPage.class); - } else { - error(MessageFormat.format("Sorry, {0} rejected your proposal.", destinationUrl)); + break; + case NO_POKE: + error(MessageFormat.format( + "Sorry, {0} could not find a Gitblit instance at {1}.", + destinationUrl, myUrl)); + break; + case NO_PROPOSALS: + error(MessageFormat.format( + "Sorry, {0} is not accepting proposals at this time.", + destinationUrl)); + break; + case FEDERATION_DISABLED: + error(MessageFormat + .format("Sorry, {0} is not configured to federate with any Gitblit instances.", + destinationUrl)); + break; + case MISSING_DATA: + error(MessageFormat.format("Sorry, {0} did not receive any proposal data!", + destinationUrl)); + break; + case ERROR: + error(MessageFormat.format( + "Sorry, {0} reports that an unexpected error occurred!", + destinationUrl)); + break; } } catch (Exception e) { if (!StringUtils.isEmpty(e.getMessage())) { @@ -111,7 +139,7 @@ @Override public void onSubmit() { - setResponsePage(RepositoriesPage.class); + setResponsePage(FederationPage.class); } }; cancel.setDefaultFormProcessing(false); @@ -120,8 +148,8 @@ List<RepositoryModel> repositories = new ArrayList<RepositoryModel>( proposal.repositories.values()); - RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositories", false, - repositories, getAccessRestrictions()); + RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false, + repositories, false, getAccessRestrictions()); add(repositoriesPanel); } } -- Gitblit v1.9.1