]> source.dussan.org Git - gitblit.git/commitdiff
Conditionally hide the propose patchset instructions
authorJames Moger <james.moger@gitblit.com>
Fri, 7 Mar 2014 19:28:12 +0000 (14:28 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 7 Mar 2014 19:28:12 +0000 (14:28 -0500)
There are a few scenarios where a ticket without a patchset should not
display propose instructions.

1. the ticket is resolved
2. the repository is configured to reject new patchsets or is read-only
3. the server is configured to reject new patchsets

src/main/java/com/gitblit/wicket/pages/TicketPage.java

index 69f4fe7a94805ee8e3994baa623ac8c07300733a..4be9e69f3cde025e5dfa5f3b126df1d2950112be 100644 (file)
@@ -731,15 +731,22 @@ public class TicketPage extends TicketBasePage {
                 *  PATCHSET TAB\r
                 */\r
                if (currentPatchset == null) {\r
-                       // no patchset yet, show propose fragment\r
-                       String repoUrl = getRepositoryUrl(user, repository);\r
-                       Fragment changeIdFrag = new Fragment("patchset", "proposeFragment", this);\r
-                       changeIdFrag.add(new Label("proposeInstructions", MarkdownUtils.transformMarkdown(getString("gb.proposeInstructions"))).setEscapeModelStrings(false));\r
-                       changeIdFrag.add(new Label("ptWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Barnum")));\r
-                       changeIdFrag.add(new Label("ptWorkflowSteps", getProposeWorkflow("propose_pt.md", repoUrl, ticket.number)).setEscapeModelStrings(false));\r
-                       changeIdFrag.add(new Label("gitWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Git")));\r
-                       changeIdFrag.add(new Label("gitWorkflowSteps", getProposeWorkflow("propose_git.md", repoUrl, ticket.number)).setEscapeModelStrings(false));\r
-                       add(changeIdFrag);\r
+                       // no patchset available\r
+                       if (ticket.isOpen() && app().tickets().isAcceptingNewPatchsets(repository)) {\r
+                               // ticket & repo will accept a proposal patchset\r
+                               // show the instructions for proposing a patchset\r
+                               String repoUrl = getRepositoryUrl(user, repository);\r
+                               Fragment changeIdFrag = new Fragment("patchset", "proposeFragment", this);\r
+                               changeIdFrag.add(new Label("proposeInstructions", MarkdownUtils.transformMarkdown(getString("gb.proposeInstructions"))).setEscapeModelStrings(false));\r
+                               changeIdFrag.add(new Label("ptWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Barnum")));\r
+                               changeIdFrag.add(new Label("ptWorkflowSteps", getProposeWorkflow("propose_pt.md", repoUrl, ticket.number)).setEscapeModelStrings(false));\r
+                               changeIdFrag.add(new Label("gitWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Git")));\r
+                               changeIdFrag.add(new Label("gitWorkflowSteps", getProposeWorkflow("propose_git.md", repoUrl, ticket.number)).setEscapeModelStrings(false));\r
+                               add(changeIdFrag);\r
+                       } else {\r
+                               // ticket is resolved OR repository is rejecting new patchsets\r
+                               add(new Label("patchset").setVisible(false));\r
+                       }\r
                } else {\r
                        // show current patchset\r
                        Fragment patchsetFrag = new Fragment("patchset", "patchsetFragment", this);\r