Visualize sizes of changes in change tables and user dashboards
Add a new column to change tables and user dashboards in which the size of a change is visualized by a colored bar. For small changes a short green bar is shown, for medium sized changes a middle sized yellow bar is shown and large changes have a full red bar. Visualizing the change sizes gives a hint to the reviewers about how complex a change is and how long it will take to review it. For contributors the visualization of the change size may be a motivation to split large changes into smaller pieces which will speed up the review process. How many changed lines are considered as a large change is configurable. Change-Id: I88497b8aea00047d93ad7d079eecc5e1052187d2 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
committed by
Shawn Pearce
parent
4bb665eb8b
commit
662e55f6af
@@ -40,6 +40,7 @@ public interface ChangeConstants extends Constants {
|
||||
String allMergedChanges();
|
||||
|
||||
String changeTableColumnSubject();
|
||||
String changeTableColumnSize();
|
||||
String changeTableColumnStatus();
|
||||
String changeTableColumnOwner();
|
||||
String changeTableColumnReviewers();
|
||||
|
||||
@@ -20,6 +20,7 @@ allAbandonedChanges = All abandoned changes
|
||||
allMergedChanges = All merged changes
|
||||
|
||||
changeTableColumnSubject = Subject
|
||||
changeTableColumnSize = Size
|
||||
changeTableColumnStatus = Status
|
||||
changeTableColumnOwner = Owner
|
||||
changeTableColumnReviewers = Reviewers
|
||||
|
||||
@@ -85,6 +85,8 @@ public class ChangeInfo extends JavaScriptObject {
|
||||
public final native String topic() /*-{ return this.topic; }-*/;
|
||||
public final native String change_id() /*-{ return this.change_id; }-*/;
|
||||
public final native boolean mergeable() /*-{ return this.mergeable; }-*/;
|
||||
public final native int insertions() /*-{ return this.insertions; }-*/;
|
||||
public final native int deletions() /*-{ return this.deletions; }-*/;
|
||||
private final native String statusRaw() /*-{ return this.status; }-*/;
|
||||
public final native String subject() /*-{ return this.subject; }-*/;
|
||||
public final native AccountInfo owner() /*-{ return this.owner; }-*/;
|
||||
|
||||
@@ -69,4 +69,6 @@ public interface ChangeMessages extends Messages {
|
||||
String years0MonthsAgo(long years, String yearLabel);
|
||||
String yearsMonthsAgo(long years, String yearLabel, long months,
|
||||
String monthLabel);
|
||||
|
||||
String insertionsAndDeletions(int insertions, int deletions);
|
||||
}
|
||||
|
||||
@@ -51,3 +51,5 @@ monthsAgo = {0} months ago
|
||||
years0MonthsAgo = {0} {1} ago
|
||||
yearsMonthsAgo = {0} {1}, {2} {3} ago
|
||||
yearsAgo = {0} years ago
|
||||
|
||||
insertionsAndDeletions = +{0}, -{1}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.InlineLabel;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
@@ -48,12 +49,13 @@ import java.util.List;
|
||||
public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
private static final int C_STAR = 1;
|
||||
private static final int C_SUBJECT = 2;
|
||||
private static final int C_STATUS = 3;
|
||||
private static final int C_OWNER = 4;
|
||||
private static final int C_PROJECT = 5;
|
||||
private static final int C_BRANCH = 6;
|
||||
private static final int C_LAST_UPDATE = 7;
|
||||
private static final int BASE_COLUMNS = 8;
|
||||
private static final int C_SIZE = 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 BASE_COLUMNS = 9;
|
||||
|
||||
private final List<Section> sections;
|
||||
private int columns;
|
||||
@@ -71,6 +73,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
sections = new ArrayList<Section>();
|
||||
table.setText(0, C_STAR, "");
|
||||
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
|
||||
table.setText(0, C_SIZE, Util.C.changeTableColumnSize());
|
||||
table.setText(0, C_STATUS, Util.C.changeTableColumnStatus());
|
||||
table.setText(0, C_OWNER, Util.C.changeTableColumnOwner());
|
||||
table.setText(0, C_PROJECT, Util.C.changeTableColumnProject());
|
||||
@@ -137,6 +140,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
fmt.addStyleName(row, i, Gerrit.RESOURCES.css().dataCell());
|
||||
}
|
||||
fmt.addStyleName(row, C_SUBJECT, Gerrit.RESOURCES.css().cSUBJECT());
|
||||
fmt.addStyleName(row, C_SIZE, Gerrit.RESOURCES.css().cSIZE());
|
||||
fmt.addStyleName(row, C_OWNER, Gerrit.RESOURCES.css().cOWNER());
|
||||
fmt.addStyleName(row, C_LAST_UPDATE, Gerrit.RESOURCES.css().cLastUpdate());
|
||||
for (int i = BASE_COLUMNS; i < columns; i++) {
|
||||
@@ -197,6 +201,8 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
String subject = Util.cropSubject(c.subject());
|
||||
table.setWidget(row, C_SUBJECT, new TableChangeLink(subject, c));
|
||||
|
||||
table.setWidget(row, C_SIZE, getSizeWidget(c));
|
||||
|
||||
Change.Status status = c.status();
|
||||
if (status != Change.Status.NEW) {
|
||||
table.setText(row, C_STATUS, Util.toLongString(status));
|
||||
@@ -296,6 +302,32 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
setRowItem(row, c);
|
||||
}
|
||||
|
||||
private static Widget getSizeWidget(ChangeInfo c) {
|
||||
int largeChangeSize = Gerrit.getConfig().getLargeChangeSize();
|
||||
int changedLines = c.insertions() + c.deletions();
|
||||
int p = 100;
|
||||
if (changedLines < largeChangeSize) {
|
||||
p = Math.round(changedLines * 100 / largeChangeSize);
|
||||
}
|
||||
|
||||
int width = Math.max(2, 70 * p / 100);
|
||||
int red = p > 50 ? 255 : (int) Math.round((p) * 5.12);
|
||||
int green = p < 50 ? 255 : (int) Math.round(256 - (p - 50) * 5.12);
|
||||
String bg = "#" + toHex(red) + toHex(green) + "00";
|
||||
|
||||
SimplePanel panel = new SimplePanel();
|
||||
panel.setStyleName(Gerrit.RESOURCES.css().changeSize());
|
||||
panel.setWidth(width + "px");
|
||||
panel.getElement().getStyle().setBackgroundColor(bg);
|
||||
panel.setTitle(Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static String toHex(int i) {
|
||||
String hex = Integer.toHexString(i);
|
||||
return hex.length() == 1 ? "0" + hex : hex;
|
||||
}
|
||||
|
||||
public void addSection(final Section s) {
|
||||
assert s.parent == null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user