Add table control that shows labels as rows and users as columns
Add a new option for a control that renders the labels/approvals as a
table with one row per label and reviewers as columns.
Change-Id: I062b6e11d3771ff505b760cc7be5e07fe5fc4bf2
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/labelui/LabelUi.java b/src/main/java/com/googlesource/gerrit/plugins/labelui/LabelUi.java
index 32ff7fa..918f96c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/labelui/LabelUi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/labelui/LabelUi.java
@@ -15,5 +15,5 @@
package com.googlesource.gerrit.plugins.labelui;
public enum LabelUi {
- DEFAULT, USER_LABEL_TABLE
+ DEFAULT, LABEL_USER_TABLE, USER_LABEL_TABLE
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/labelui/client/LabelPanel.java b/src/main/java/com/googlesource/gerrit/plugins/labelui/client/LabelPanel.java
index 76fc72c..3890648 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/labelui/client/LabelPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/labelui/client/LabelPanel.java
@@ -67,6 +67,9 @@
ChangeInfo change =
panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
switch (result.ui()) {
+ case LABEL_USER_TABLE:
+ displayLabelUserTable(change);
+ break;
case USER_LABEL_TABLE:
displayUserLabelTable(change);
break;
@@ -83,6 +86,39 @@
});
}
+ private void displayLabelUserTable(ChangeInfo change) {
+ Set<String> labelNames = getLabelNames(change);
+ Map<String, AccountInfo> users = getUserMap(labelNames, change);
+ Map<Integer, VotableInfo> votable = votable(change);
+ Grid g = createGrid(labelNames.size() + 1, users.size() + 1);
+
+ int i = 1;
+ for (AccountInfo account : users.values()) {
+ g.setWidget(0, i, createUserWidget(account));
+ i++;
+ }
+
+ i = 1;
+ for (String labelName : labelNames) {
+ g.setWidget(i, 0, createLabelLabel(change.label(labelName)));
+
+ int j = 1;
+ for (AccountInfo account : users.values()) {
+ LabelInfo label = change.label(labelName);
+ ApprovalInfo ai = label.forUser(account._accountId());
+ g.setWidget(i, j, createLabelValueWidget(label, ai));
+
+ if (!votable.get(account._accountId()).isVotable(labelName)) {
+ formatNonVotable(g, i, j);
+ }
+ j++;
+ }
+ i++;
+ }
+
+ add(g);
+ }
+
private void displayUserLabelTable(ChangeInfo change) {
Set<String> labelNames = getLabelNames(change);
Map<String, AccountInfo> users = getUserMap(labelNames, change);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/labelui/client/PreferencesInfo.java b/src/main/java/com/googlesource/gerrit/plugins/labelui/client/PreferencesInfo.java
index d764ef2..76ab746 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/labelui/client/PreferencesInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/labelui/client/PreferencesInfo.java
@@ -18,7 +18,7 @@
public class PreferencesInfo extends JavaScriptObject {
public static enum LabelUi {
- DEFAULT, USER_LABEL_TABLE
+ DEFAULT, LABEL_USER_TABLE, USER_LABEL_TABLE
}
public static PreferencesInfo create() {
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
index 511b6d6..117ae7d 100644
--- a/src/main/resources/Documentation/about.md
+++ b/src/main/resources/Documentation/about.md
@@ -12,6 +12,13 @@
![DefaultApprovalsScreenshot](images/default-approvals.png)
+### `LABEL_USER_TABLE`
+
+Renders the labels/approvals as a table with one row per label and
+users as columns:
+
+![ApprovalTableScreenshot](images/label-user-table.png)
+
### `USER_LABEL_TABLE`
Renders the labels/approvals as a table with one row per user and
diff --git a/src/main/resources/Documentation/images/label-user-table.png b/src/main/resources/Documentation/images/label-user-table.png
new file mode 100644
index 0000000..c313fec
--- /dev/null
+++ b/src/main/resources/Documentation/images/label-user-table.png
Binary files differ
diff --git a/src/main/resources/Documentation/images/preferences.png b/src/main/resources/Documentation/images/preferences.png
index 3ab252e..d804f7a 100644
--- a/src/main/resources/Documentation/images/preferences.png
+++ b/src/main/resources/Documentation/images/preferences.png
Binary files differ
diff --git a/src/main/resources/Documentation/rest-api-accounts.md b/src/main/resources/Documentation/rest-api-accounts.md
index bc69c71..3265b13 100644
--- a/src/main/resources/Documentation/rest-api-accounts.md
+++ b/src/main/resources/Documentation/rest-api-accounts.md
@@ -68,7 +68,7 @@
* _ui_: The control that should be displayed on the change screen to
render the labels/approvals. Possible values are `DEFAULT` and
- `USER_LABEL_TABLE`.
+ `LABEL_USER_TABLE`, `USER_LABEL_TABLE`.
SEE ALSO
--------