From: James Moger Date: Tue, 22 Apr 2014 01:55:48 +0000 (-0400) Subject: Revisions demonstrating the direction I'd like this to go X-Git-Tag: v1.6.0~98^2~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e1fa9b763cadcdc44943f805aba83698acafa613;p=gitblit.git Revisions demonstrating the direction I'd like this to go --- diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html index 5d11fbbb..063e7511 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html @@ -7,38 +7,35 @@
-
[my tickets message]
- - + + + + + + + + - - - - + + + + + + + +
+ + Repository + TicketStatusResponsible
+ + [repository name] + + [ticket icon] + [ticket title] + (#[ticket number]) + [ticket responsible]
- - - - - - Repository - - Ticket - Description - Responsible - - - - - - - [repository name] - - [ticket name] - [ticket description] - [ticket responsible] -
diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java index 6cd80a3f..2c57a051 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -1,41 +1,41 @@ package com.gitblit.wicket.pages; -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import org.apache.wicket.Component; +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.markup.repeater.data.ListDataProvider; + import com.gitblit.models.RepositoryModel; -import com.gitblit.models.UserModel; import com.gitblit.models.TicketModel; +import com.gitblit.models.UserModel; +import com.gitblit.models.TicketModel.Status; +import com.gitblit.models.TicketModel.Type; import com.gitblit.tickets.ITicketService; +import com.gitblit.tickets.QueryBuilder; +import com.gitblit.tickets.QueryResult; +import com.gitblit.tickets.TicketIndexer.Lucene; +import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.panels.GravatarImage; import com.gitblit.wicket.panels.LinkPanel; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.markup.repeater.data.IDataProvider; -import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.apache.wicket.model.IModel; -import org.apache.wicket.Component; -import org.apache.wicket.PageParameters; - public class MyTicketsPage extends RootPage { - public MyTicketsPage(PageParameters params) + public MyTicketsPage() { - this(); + this(null); } - public MyTicketsPage() + public MyTicketsPage(PageParameters params) { super(); - setupPage("", ""); + setupPage("", getString("gb.mytickets")); UserModel currentUser = GitBlitWebSession.get().getUser(); if (currentUser == null) { @@ -43,75 +43,156 @@ public class MyTicketsPage extends RootPage { } String username = currentUser.getName(); - // TODO - Recover the Welcome message - String message = "Welcome on GitBlit"; - this.add(new Label("myTicketsMessage", message)); - - Fragment fragment = new Fragment("headerContent", "ticketsHeader", this); - add(fragment); + QueryBuilder qb = QueryBuilder + .q(Lucene.createdby.matches(username)) + .or(Lucene.responsible.matches(username)) + .or(Lucene.watchedby.matches(username)); ITicketService tickets = GitBlitWebApp.get().tickets(); - List returnedTickets = tickets.getTickets(null); - List yourTickets = new ArrayList(); - - for(int i = 0; i < returnedTickets.size(); i++) - { - TicketModel ticket = returnedTickets.get(i); - if(ticket.isOpen()) - { - if(ticket.isResponsible(username) || ticket.isAuthor(username) - || ticket.isVoter(username) || ticket.isWatching(username)) - { - yourTickets.add(ticket); - } - } - } + List results = tickets.queryFor(qb.build(), 0, 0, Lucene.updated.name(), true); - final ListDataProvider dp = new ListDataProvider(yourTickets); + final ListDataProvider dp = new ListDataProvider(results); - DataView dataView = new DataView("row", dp) { + DataView dataView = new DataView("row", dp) { private static final long serialVersionUID = 1L; @Override - protected void populateItem(Item item) { - TicketModel ticketModel = item.getModelObject(); - RepositoryModel repository = app().repositories().getRepositoryModel(ticketModel.repository); - - Fragment row = new Fragment("rowContent", "ticketRow", this); - item.add(row); + protected void populateItem(Item item) { + QueryResult ticket = item.getModelObject(); + RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository); - Component swatch; - if(repository.isBare) - { - swatch = new Label("repositorySwatch", " ").setEscapeModelStrings(false); - } - else - { - swatch = new Label("repositorySwatch", "!"); - WicketUtils.setHtmlTooltip(swatch, getString("gb.workingCopyWarning")); - } + Component swatch = new Label("repositorySwatch", " ").setEscapeModelStrings(false); WicketUtils.setCssBackground(swatch, repository.toString()); - row.add(swatch); + item.add(swatch); - PageParameters pp = WicketUtils.newRepositoryParameter(repository.name); - Class linkPage; - if (repository.hasCommits) { - // repository has content - linkPage = SummaryPage.class; - } else { - // new/empty repository OR proposed repository - linkPage = EmptyRepositoryPage.class; - } + PageParameters rp = WicketUtils.newRepositoryParameter(ticket.repository); + PageParameters tp = WicketUtils.newObjectParameter(ticket.repository, "" + ticket.number); + item.add(new LinkPanel("repositoryName", "list", StringUtils.stripDotGit(ticket.repository), SummaryPage.class, rp)); - String ticketUrl = app().tickets().getTicketUrl(ticketModel); + item.add(getStateIcon("ticketIcon", ticket.type, ticket.status)); + item.add(new Label("ticketNumber", "" + ticket.number)); + item.add(new LinkPanel("ticketTitle", "list", ticket.title, TicketsPage.class, tp)); + + // votes indicator + Label v = new Label("ticketVotes", "" + ticket.votesCount); + WicketUtils.setHtmlTooltip(v, getString("gb.votes")); + item.add(v.setVisible(ticket.votesCount > 0)); + + Label ticketStatus = new Label("ticketStatus", ticket.status.toString()); + String statusClass = getStatusClass(ticket.status); + WicketUtils.setCssClass(ticketStatus, statusClass); + item.add(ticketStatus); - row.add(new LinkPanel("repositoryName", "list", repository.name, linkPage, pp)); - row.add(new LinkPanel("ticketName", "list", ticketModel.title, ticketUrl)); - row.add(new LinkPanel("ticketDescription", "list", ticketModel.body, ticketUrl)); - row.add(new Label("ticketResponsible", ticketModel.responsible)); + UserModel responsible = app().users().getUserModel(ticket.responsible); + if (responsible == null) { + if (ticket.responsible == null) { + item.add(new Label("ticketResponsibleImg").setVisible(false)); + } else { + item.add(new GravatarImage("ticketResponsibleImg", ticket.responsible, ticket.responsible, null, 16, true)); + } + item.add(new Label("ticketResponsible", ticket.responsible)); + } else { + item.add(new GravatarImage("ticketResponsibleImg", responsible, null, 16, true)); + item.add(new LinkPanel("ticketResponsible", null, responsible.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(ticket.responsible))); + } } }; add(dataView); } + + protected Label getStateIcon(String wicketId, TicketModel ticket) { + return getStateIcon(wicketId, ticket.type, ticket.status); + } + + protected Label getStateIcon(String wicketId, Type type, Status state) { + Label label = new Label(wicketId); + if (type == null) { + type = Type.defaultType; + } + switch (type) { + case Proposal: + WicketUtils.setCssClass(label, "fa fa-code-fork"); + break; + case Bug: + WicketUtils.setCssClass(label, "fa fa-bug"); + break; + case Enhancement: + WicketUtils.setCssClass(label, "fa fa-magic"); + break; + case Question: + WicketUtils.setCssClass(label, "fa fa-question"); + break; + default: + // standard ticket + WicketUtils.setCssClass(label, "fa fa-ticket"); + } + WicketUtils.setHtmlTooltip(label, getTypeState(type, state)); + return label; + } + + protected String getTypeState(Type type, Status state) { + return state.toString() + " " + type.toString(); + } + + protected String getLozengeClass(Status status, boolean subtle) { + if (status == null) { + status = Status.New; + } + String css = ""; + switch (status) { + case Declined: + case Duplicate: + case Invalid: + case Wontfix: + case Abandoned: + css = "aui-lozenge-error"; + break; + case Fixed: + case Merged: + case Resolved: + css = "aui-lozenge-success"; + break; + case New: + css = "aui-lozenge-complete"; + break; + case On_Hold: + css = "aui-lozenge-current"; + break; + default: + css = ""; + break; + } + + return "aui-lozenge" + (subtle ? " aui-lozenge-subtle": "") + (css.isEmpty() ? "" : " ") + css; + } + + protected String getStatusClass(Status status) { + String css = ""; + switch (status) { + case Declined: + case Duplicate: + case Invalid: + case Wontfix: + case Abandoned: + css = "resolution-error"; + break; + case Fixed: + case Merged: + case Resolved: + css = "resolution-success"; + break; + case New: + css = "resolution-complete"; + break; + case On_Hold: + css = "resolution-current"; + break; + default: + css = ""; + break; + } + + return "resolution" + (css.isEmpty() ? "" : " ") + css; + } }