<body>
<wicket:extend>
<div class="container">
- <div class="markdown" style="padding: 10px 0px 5px 0px;" wicket:id="myTicketsMessage">[my tickets message]</div>
-
<table class="tickets">
- <span wicket:id="headerContent"></span>
+ <thead>
+ <tr>
+ <th class="left">
+ <img style="vertical-align: middle;" src="git-black-16x16.png"/>
+ <wicket:message key="gb.repository">Repository</wicket:message>
+ </th>
+ <th class="hidden-phone" colspan='2'><span><wicket:message key="gb.ticket">Ticket</wicket:message></span></th>
+ <th class="hidden-tablet hidden-phone"><span><wicket:message key="gb.status">Status</wicket:message></span></th>
+ <th class="hidden-tablet hidden-phone right"><span><wicket:message key="gb.responsible">Responsible</wicket:message></span></th>
+ </tr>
+ </thead>
<tbody>
- <tr wicket:id="row">
- <span wicket:id="rowContent"></span>
- </tr>
- </tbody>
+ <tr wicket:id="row">
+ <td class="left" style="padding-left:3px;">
+ <b><span class="repositorySwatch" wicket:id="repositorySwatch"></span></b>
+ <span style="padding-left:3px;" wicket:id="repositoryName">[repository name]</span>
+ </td>
+ <td class="hidden-phone">
+ <span wicket:id="ticketIcon">[ticket icon]</span>
+ <span class="list" wicket:id="ticketTitle">[ticket title]</span>
+ <span style="color:#888;"> (#<span wicket:id="ticketNumber">[ticket number]</span>)</span>
+ </td>
+ <td><span class="badge badge-info" wicket:id="ticketVotes"></span></td>
+ <td><span wicket:id="ticketStatus"></span></td>
+ <td class="hidden-tablet hidden-phone author right"><span wicket:id="ticketResponsibleImg"></span><span wicket:id="ticketResponsible">[ticket responsible]</span></td>
+ </tr>
+ </tbody>
</table>
-
- <wicket:fragment wicket:id="ticketsHeader">
- <tr>
- <th class="left">
- <img style="vertical-align: middle;" src="git-black-16x16.png"/>
- <wicket:message key="gb.repository">Repository</wicket:message>
- </th>
- <th class="hidden-phone" ><span><wicket:message key="gb.ticket">Ticket</wicket:message></span></th>
- <th class="hidden-phone" ><span><wicket:message key="gb.description">Description</wicket:message></span></th>
- <th class="hidden-tablet hidden-phone right"><span><wicket:message key="gb.responsible">Responsible</wicket:message></span></th>
- </tr>
- </wicket:fragment>
-
- <wicket:fragment wicket:id="ticketRow">
- <td class="left" style="padding-left:3px;">
- <b><span class="repositorySwatch" wicket:id="repositorySwatch"></span></b>
- <span style="padding-left:3px;" wicket:id="repositoryName">[repository name]</span>
- </td>
- <td class="hidden-phone"><span class="list" wicket:id="ticketName">[ticket name]</span></td>
- <td class="hidden-phone"><span class="list" wicket:id="ticketDescription">[ticket description]</span></td>
- <td class="hidden-tablet hidden-phone author right"><span wicket:id="ticketResponsible">[ticket responsible]</span></td>
- </wicket:fragment>
</div>
</wicket:extend>
</body>
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) {
}
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<TicketModel> returnedTickets = tickets.getTickets(null);
- List<TicketModel> yourTickets = new ArrayList<TicketModel>();
-
- 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<QueryResult> results = tickets.queryFor(qb.build(), 0, 0, Lucene.updated.name(), true);
- final ListDataProvider<TicketModel> dp = new ListDataProvider<TicketModel>(yourTickets);
+ final ListDataProvider<QueryResult> dp = new ListDataProvider<QueryResult>(results);
- DataView<TicketModel> dataView = new DataView<TicketModel>("row", dp) {
+ DataView<QueryResult> dataView = new DataView<QueryResult>("row", dp) {
private static final long serialVersionUID = 1L;
@Override
- protected void populateItem(Item<TicketModel> 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<QueryResult> 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<? extends BasePage> 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;
+ }
}