]> source.dussan.org Git - gitblit.git/commitdiff
Allow integration (mergeTo) branch to be changed in edit ticket
authorJames Moger <james.moger@gitblit.com>
Wed, 5 Mar 2014 15:56:34 +0000 (10:56 -0500)
committerJames Moger <james.moger@gitblit.com>
Wed, 5 Mar 2014 16:42:34 +0000 (11:42 -0500)
src/main/java/com/gitblit/wicket/pages/EditTicketPage.html
src/main/java/com/gitblit/wicket/pages/EditTicketPage.java

index 5d8f6829890c0cd9729b37a6cf1b645084d5ffa7..424eece3a1aa59222e3944ca1af5a162755395e8 100644 (file)
@@ -41,6 +41,7 @@
                        <tr><th><wicket:message key="gb.type"></wicket:message><span style="color:red;">*</span></th><td class="edit"><select class="input-large" wicket:id="type"></select></td></tr>\r
                        <tr wicket:id="responsible"></tr>\r
                        <tr wicket:id="milestone"></tr>\r
+                       <tr wicket:id="mergeto"></tr>\r
                </table>\r
        </div>\r
        </div>  \r
@@ -62,5 +63,9 @@
        <th><wicket:message key="gb.milestone"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="milestone"></select></td>\r
 </wicket:fragment>\r
 \r
+<wicket:fragment wicket:id="mergeToFragment">\r
+       <th><wicket:message key="gb.mergeTo"></wicket:message></th><td class="edit"><select class="input-large" wicket:id="mergeto"></select></td>\r
+</wicket:fragment>\r
+\r
 </wicket:extend>\r
 </html>
\ No newline at end of file
index 5446dde30d8be775663b20b42770f336ef67db1c..aad1d6fe344f00015d8e87b1540ce123b81e4ea0 100644 (file)
@@ -31,7 +31,9 @@ import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.model.IModel;\r
 import org.apache.wicket.model.Model;\r
+import org.eclipse.jgit.lib.Repository;\r
 \r
+import com.gitblit.Constants;\r
 import com.gitblit.Constants.AccessPermission;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.TicketModel;\r
@@ -68,6 +70,8 @@ public class EditTicketPage extends RepositoryPage {
 \r
        private IModel<String> topicModel;\r
 \r
+       private IModel<String> mergeToModel;\r
+\r
        private IModel<TicketResponsible> responsibleModel;\r
 \r
        private IModel<TicketMilestone> milestoneModel;\r
@@ -105,6 +109,7 @@ public class EditTicketPage extends RepositoryPage {
                topicModel = Model.of(ticket.topic == null ? "" : ticket.topic);\r
                responsibleModel = Model.of();\r
                milestoneModel = Model.of();\r
+               mergeToModel = Model.of(ticket.mergeTo == null ? "" : ticket.mergeTo);\r
 \r
                setStatelessHint(false);\r
                setOutputMarkupId(true);\r
@@ -174,6 +179,13 @@ public class EditTicketPage extends RepositoryPage {
                                        }\r
                                }\r
 \r
+                               String mergeTo = mergeToModel.getObject();\r
+                               if ((StringUtils.isEmpty(ticket.mergeTo) && !StringUtils.isEmpty(mergeTo))\r
+                                               || (!StringUtils.isEmpty(mergeTo) && !mergeTo.equals(ticket.mergeTo))) {\r
+                                       // integration branch change\r
+                                       change.setField(Field.mergeTo, mergeTo);\r
+                               }\r
+\r
                                if (change.hasFieldChanges()) {\r
                                        if (!ticket.isWatching(createdBy)) {\r
                                                change.watch(createdBy);\r
@@ -258,10 +270,27 @@ public class EditTicketPage extends RepositoryPage {
 \r
                        milestone.add(new DropDownChoice<TicketMilestone>("milestone", milestoneModel, milestones));\r
                        form.add(milestone.setVisible(!milestones.isEmpty()));\r
+\r
+                       // mergeTo (integration branch)\r
+                       List<String> branches = new ArrayList<String>();\r
+                       for (String branch : getRepositoryModel().getLocalBranches()) {\r
+                               // exclude ticket branches\r
+                               if (!branch.startsWith(Constants.R_TICKET)) {\r
+                                       branches.add(Repository.shortenRefName(branch));\r
+                               }\r
+                       }\r
+                       branches.remove(Repository.shortenRefName(getRepositoryModel().HEAD));\r
+                       branches.add(0, Repository.shortenRefName(getRepositoryModel().HEAD));\r
+\r
+                       Fragment mergeto = new Fragment("mergeto", "mergeToFragment", this);\r
+                       mergeto.add(new DropDownChoice<String>("mergeto", mergeToModel, branches));\r
+                       form.add(mergeto.setVisible(!branches.isEmpty()));\r
+\r
                } else {\r
                        // user does not have permission to assign milestone or responsible\r
                        form.add(new Label("responsible").setVisible(false));\r
                        form.add(new Label("milestone").setVisible(false));\r
+                       form.add(new Label("mergeto").setVisible(false));\r
                }\r
 \r
                form.add(new Button("update"));\r
@@ -275,7 +304,6 @@ public class EditTicketPage extends RepositoryPage {
                };\r
                cancel.setDefaultFormProcessing(false);\r
                form.add(cancel);\r
-\r
        }\r
 \r
        @Override\r