diff options
author | James Moger <james.moger@gitblit.com> | 2014-05-07 14:32:09 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-07 14:32:09 -0400 |
commit | 3b23dcdde4ef55927e45e56596e7023ce2cf9424 (patch) | |
tree | 0980f079007bc9c7966dda92644d606ef9bf12f6 /src/main/java/com | |
parent | 0fbf8052cc0c6272baf64d8de2d07d2cdbf3a287 (diff) | |
download | gitblit-3b23dcdde4ef55927e45e56596e7023ce2cf9424.tar.gz gitblit-3b23dcdde4ef55927e45e56596e7023ce2cf9424.zip |
Consolidate open tickets page parameters
Diffstat (limited to 'src/main/java/com')
5 files changed, 28 insertions, 23 deletions
diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index 10b21468..687f0105 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -445,6 +445,20 @@ public class WicketUtils { return new PageParameters(parameterMap);
}
+ public static PageParameters newTicketsParameters(String repositoryName, String... states) {
+ PageParameters tParams = newRepositoryParameter(repositoryName);
+ if (states != null) {
+ for (String state : states) {
+ tParams.add("status", state);
+ }
+ }
+ return tParams;
+ }
+
+ public static PageParameters newOpenTicketsParameter(String repositoryName) {
+ return newTicketsParameters(repositoryName, TicketsUI.openStatii);
+ }
+
public static String getProjectName(PageParameters params) {
return params.getString("p", "");
}
diff --git a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java index b844442a..d6f58e7b 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java @@ -66,7 +66,7 @@ public class EditMilestonePage extends RepositoryPage { RepositoryModel model = getRepositoryModel();
if (!app().tickets().isAcceptingTicketUpdates(model)) {
// ticket service is read-only
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
UserModel currentUser = GitBlitWebSession.get().getUser();
@@ -76,19 +76,19 @@ public class EditMilestonePage extends RepositoryPage { if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) {
// administration prohibited
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
oldName = WicketUtils.getObject(params);
if (StringUtils.isEmpty(oldName)) {
// milestone not specified
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
TicketMilestone tm = app().tickets().getMilestone(getRepositoryModel(), oldName);
if (tm == null) {
// milestone does not exist
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
setStatelessHint(false);
@@ -140,7 +140,7 @@ public class EditMilestonePage extends RepositoryPage { }
if (success && app().tickets().updateMilestone(getRepositoryModel(), tm, createdBy)) {
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(getRepositoryModel().name));
+ setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
} else {
// TODO error
}
@@ -151,7 +151,7 @@ public class EditMilestonePage extends RepositoryPage { @Override
public void onSubmit() {
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
};
cancel.setDefaultFormProcessing(false);
@@ -167,7 +167,7 @@ public class EditMilestonePage extends RepositoryPage { boolean notify = notificationModel.getObject();
if (app().tickets().deleteMilestone(getRepositoryModel(), oldName, createdBy, notify)) {
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
} else {
// TODO error processing
}
diff --git a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java index a9f76d3a..cc331903 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java @@ -55,7 +55,7 @@ public class NewMilestonePage extends RepositoryPage { RepositoryModel model = getRepositoryModel();
if (!app().tickets().isAcceptingTicketUpdates(model)) {
// ticket service is read-only
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
UserModel currentUser = GitBlitWebSession.get().getUser();
@@ -65,7 +65,7 @@ public class NewMilestonePage extends RepositoryPage { if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) {
// administration prohibited
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
setStatelessHint(false);
@@ -108,7 +108,7 @@ public class NewMilestonePage extends RepositoryPage { if (milestone != null) {
milestone.due = due;
app().tickets().updateMilestone(getRepositoryModel(), milestone, createdBy);
- throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(getRepositoryModel().name));
+ throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
} else {
// TODO error
}
@@ -120,7 +120,7 @@ public class NewMilestonePage extends RepositoryPage { @Override
public void onSubmit() {
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
+ setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
}
};
cancel.setDefaultFormProcessing(false);
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index 165feedf..a0c9ce01 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -60,7 +60,6 @@ import com.gitblit.models.UserModel; import com.gitblit.models.UserRepositoryPreferences;
import com.gitblit.servlet.PagesServlet;
import com.gitblit.servlet.SyndicationServlet;
-import com.gitblit.tickets.TicketIndexer.Lucene;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.BugtraqProcessor;
import com.gitblit.utils.DeepCopier;
@@ -70,7 +69,6 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.CacheControl;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.SessionlessForm;
-import com.gitblit.wicket.TicketsUI;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.LinkPanel;
import com.gitblit.wicket.panels.NavigationPanel;
@@ -202,11 +200,8 @@ public abstract class RepositoryPage extends RootPage { }
navLinks.add(new PageNavLink("gb.commits", LogPage.class, params));
navLinks.add(new PageNavLink("gb.tree", TreePage.class, params));
- if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(getRepositoryModel()) || app().tickets().hasTickets(getRepositoryModel()))) {
- PageParameters tParams = new PageParameters(params);
- for (String state : TicketsUI.openStatii) {
- tParams.add(Lucene.status.name(), state);
- }
+ if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) {
+ PageParameters tParams = WicketUtils.newOpenTicketsParameter(repositoryName);
navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams)); } navLinks.add(new PageNavLink("gb.docs", DocsPage.class, params, true));
diff --git a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java index 395200c1..ab763b8f 100644 --- a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java @@ -32,7 +32,6 @@ import com.gitblit.Constants; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; import com.gitblit.tickets.QueryResult; -import com.gitblit.tickets.TicketIndexer.Lucene; import com.gitblit.tickets.TicketLabel; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.BugtraqProcessor; @@ -77,10 +76,7 @@ public class TicketListPanel extends BasePanel { if (showRepository) { String name = StringUtils.stripDotGit(ticket.repository); - PageParameters rp = new PageParameters(WicketUtils.newRepositoryParameter(ticket.repository)); - for (String state : TicketsUI.openStatii) { - rp.add(Lucene.status.name(), state); - } + PageParameters rp = WicketUtils.newOpenTicketsParameter(ticket.repository); LinkPanel link = new LinkPanel("ticketsLink", null, name, TicketsPage.class, rp); WicketUtils.setCssBackground(link, name); item.add(link); |