Show and highlight assignees in change table

Change-Id: If8ec1b7f2506a9183b5af89b92eafbcb2ef26566
This commit is contained in:
Gustaf Lundh
2016-09-16 17:05:25 +02:00
parent 2605c4c9a6
commit 9c0ab72946
7 changed files with 87 additions and 5 deletions

View File

@@ -96,6 +96,10 @@ public class PageLinks {
return toChangeQuery(op("owner", fullname) + " " + status(status));
}
public static String toAssigneeQuery(String fullname) {
return toChangeQuery(op("assignee", fullname));
}
public static String toCustomDashboard(final String params) {
return "/dashboard/?" + params;
}

View File

@@ -32,6 +32,8 @@ public interface GerritCss extends CssResource {
String branchTableDeleteButton();
String branchTablePrevNextLinks();
String cAPPROVAL();
String cASSIGNEE();
String cASSIGNEDTOME();
String cLastUpdate();
String cOWNER();
String cSIZE();

View File

@@ -37,6 +37,7 @@ public interface ChangeConstants extends Constants {
String changeTableColumnSize();
String changeTableColumnStatus();
String changeTableColumnOwner();
String changeTableColumnAssignee();
String changeTableColumnProject();
String changeTableColumnBranch();
String changeTableColumnLastUpdate();

View File

@@ -18,6 +18,7 @@ changeTableColumnSubject = Subject
changeTableColumnSize = Size
changeTableColumnStatus = Status
changeTableColumnOwner = Owner
changeTableColumnAssignee = Assignee
changeTableColumnProject = Project
changeTableColumnBranch = Branch
changeTableColumnLastUpdate = Updated

View File

@@ -22,6 +22,7 @@ import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.ChangeInfo;
import com.google.gerrit.client.info.ChangeInfo.LabelInfo;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.AssigneeLinkPanel;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.NavigationTable;
@@ -49,6 +50,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class ChangeTable extends NavigationTable<ChangeInfo> {
@@ -63,11 +65,12 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
private static final int C_SUBJECT = 3;
private static final int C_STATUS = 4;
private static final int C_OWNER = 5;
private static final int C_PROJECT = 6;
private static final int C_BRANCH = 7;
private static final int C_LAST_UPDATE = 8;
private static final int C_SIZE = 9;
private static final int BASE_COLUMNS = 10;
private static final int C_ASSIGNEE = 6;
private static final int C_PROJECT = 7;
private static final int C_BRANCH = 8;
private static final int C_LAST_UPDATE = 9;
private static final int C_SIZE = 10;
private static final int BASE_COLUMNS = 11;
private final List<Section> sections;
private int columns;
@@ -90,6 +93,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
table.setText(0, C_STATUS, Util.C.changeTableColumnStatus());
table.setText(0, C_OWNER, Util.C.changeTableColumnOwner());
table.setText(0, C_ASSIGNEE, Util.C.changeTableColumnAssignee());
table.setText(0, C_PROJECT, Util.C.changeTableColumnProject());
table.setText(0, C_BRANCH, Util.C.changeTableColumnBranch());
table.setText(0, C_LAST_UPDATE, Util.C.changeTableColumnLastUpdate());
@@ -163,6 +167,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
fmt.addStyleName(row, C_SUBJECT, Gerrit.RESOURCES.css().cSUBJECT());
fmt.addStyleName(row, C_STATUS, Gerrit.RESOURCES.css().cSTATUS());
fmt.addStyleName(row, C_OWNER, Gerrit.RESOURCES.css().cOWNER());
fmt.addStyleName(row, C_ASSIGNEE, Gerrit.RESOURCES.css().cASSIGNEE());
fmt.addStyleName(row, C_LAST_UPDATE, Gerrit.RESOURCES.css().cLastUpdate());
fmt.addStyleName(row, C_SIZE, Gerrit.RESOURCES.css().cSIZE());
@@ -237,6 +242,17 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
table.setText(row, C_OWNER, "");
}
if (c.assignee() != null) {
table.setWidget(row, C_ASSIGNEE, new AssigneeLinkPanel(c.assignee()));
if (Objects.equals(c.assignee().getId(),
Gerrit.getUserAccount().getId())) {
table.getRowFormatter().addStyleName(row,
Gerrit.RESOURCES.css().cASSIGNEDTOME());
}
} else {
table.setText(row, C_ASSIGNEE, "");
}
table.setWidget(row, C_PROJECT, new ProjectLink(c.projectNameKey()));
table.setWidget(row, C_BRANCH, new BranchLink(c.projectNameKey(), c
.status(), c.branch(), c.topic()));

View File

@@ -449,6 +449,11 @@ a:hover {
white-space: nowrap;
}
.changeTable .cASSIGNEDTOME {
background: #ffe9d6 !important;
}
.changeTable .cASSIGNEE,
.changeTable .cOWNER,
.changeTable .cSTATUS {
white-space: nowrap;

View File

@@ -0,0 +1,53 @@
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.ui;
import com.google.gerrit.client.AvatarImage;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.common.PageLinks;
import com.google.gwt.user.client.ui.FlowPanel;
/** Link to any assignees accounts dashboard. */
public class AssigneeLinkPanel extends FlowPanel {
public AssigneeLinkPanel(AccountInfo info) {
addStyleName(Gerrit.RESOURCES.css().accountLinkPanel());
InlineHyperlink l =
new InlineHyperlink(FormatUtil.name(info), PageLinks.toAssigneeQuery(
assignedTo(info))) {
@Override
public void go() {
Gerrit.display(getTargetHistoryToken());
}
};
l.setTitle(FormatUtil.nameEmail(info));
add(new AvatarImage(info));
add(l);
}
public static String assignedTo(AccountInfo ai) {
if (ai.email() != null) {
return ai.email();
} else if (ai.name() != null) {
return ai.name();
} else {
return "";
}
}
}