Show "File n of N" in diff views
This allows the reviewer to see how many files are still left to review and how many are already done. Change-Id: Id89eb7c85a557708d5de7bf1447747661eb1e3a1 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -36,4 +36,6 @@ public interface GerritMessages extends Messages {
|
||||
String cannotDownloadPlugin(String scriptPath);
|
||||
|
||||
String parentUpdateFailed(String message);
|
||||
|
||||
String fileCount(int fileNumber, int fileCount);
|
||||
}
|
||||
|
||||
@@ -17,3 +17,5 @@ pluginFailed = Plugin "{0}" failed to load
|
||||
cannotDownloadPlugin = Cannot load plugin from {0}
|
||||
|
||||
parentUpdateFailed = Setting parent project failed: {0}
|
||||
|
||||
fileCount = File {0} of {1}
|
||||
|
||||
@@ -74,6 +74,8 @@ public class Header extends Composite {
|
||||
@UiField CheckBox reviewed;
|
||||
@UiField Element project;
|
||||
@UiField Element filePath;
|
||||
@UiField Element fileNumber;
|
||||
@UiField Element fileCount;
|
||||
|
||||
@UiField Element noDiff;
|
||||
@UiField FlowPanel linkPanel;
|
||||
@@ -143,6 +145,9 @@ public class Header extends Composite {
|
||||
public void onSuccess(NativeMap<FileInfo> result) {
|
||||
JsArray<FileInfo> files = result.values();
|
||||
FileInfo.sortFileInfoByPath(files);
|
||||
fileNumber.setInnerText(
|
||||
Integer.toString(Natives.asList(files).indexOf(result.get(path)) + 1));
|
||||
fileCount.setInnerText(Integer.toString(files.length()));
|
||||
int index = 0; // TODO: Maybe use patchIndex.
|
||||
for (int i = 0; i < files.length(); i++) {
|
||||
if (path.equals(files.get(i).path())) {
|
||||
|
||||
@@ -34,6 +34,11 @@ limitations under the License.
|
||||
.path {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.fileCount {
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
bottom: 4px;
|
||||
}
|
||||
.navigation {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -69,6 +74,9 @@ limitations under the License.
|
||||
<div class='{style.navigation}'>
|
||||
<span ui:field='noDiff' class='{style.nodiff}'><ui:msg>No Differences</ui:msg></span>
|
||||
<g:FlowPanel ui:field='linkPanel' styleName='{style.linkPanel}'/>
|
||||
<span class='{style.fileCount}'>
|
||||
<ui:msg>File <span ui:field='fileNumber'/> of <span ui:field='fileCount'/></ui:msg>
|
||||
</span>
|
||||
<x:InlineHyperlink ui:field='prev' styleName='{res.style.goPrev}'/>
|
||||
<x:InlineHyperlink ui:field='up'
|
||||
styleName='{res.style.goUp}'
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||
@@ -35,7 +36,7 @@ import java.util.List;
|
||||
class NavLinks extends Composite {
|
||||
public enum Nav {
|
||||
PREV (0, '[', PatchUtil.C.previousFileHelp(), 0),
|
||||
NEXT (3, ']', PatchUtil.C.nextFileHelp(), 1);
|
||||
NEXT (4, ']', PatchUtil.C.nextFileHelp(), 1);
|
||||
|
||||
public int col; // Table Cell column to display link in
|
||||
public int key; // key code shortcut to activate link
|
||||
@@ -59,7 +60,7 @@ class NavLinks extends Composite {
|
||||
NavLinks(KeyCommandSet kcs, PatchSet.Id forPatch) {
|
||||
patchSetId = forPatch;
|
||||
keys = kcs;
|
||||
table = new Grid(1, 4);
|
||||
table = new Grid(1, 5);
|
||||
initWidget(table);
|
||||
|
||||
final CellFormatter fmt = table.getCellFormatter();
|
||||
@@ -68,6 +69,7 @@ class NavLinks extends Composite {
|
||||
fmt.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
|
||||
fmt.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
fmt.setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
fmt.setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
|
||||
final ChangeLink up = new ChangeLink("", patchSetId);
|
||||
SafeHtml.set(up, SafeHtml.asis(Util.C.upToChangeIconLink()));
|
||||
@@ -77,6 +79,10 @@ class NavLinks extends Composite {
|
||||
void display(int patchIndex, PatchTable fileList,
|
||||
List<InlineHyperlink> links, List<WebLinkInfo> webLinks) {
|
||||
if (fileList != null) {
|
||||
Label fileCountLabel =
|
||||
new Label(Gerrit.M.fileCount(patchIndex + 1, fileList.size()));
|
||||
fileCountLabel.setStyleName(Gerrit.RESOURCES.css().nowrap());
|
||||
table.setWidget(0, 3, fileCountLabel);
|
||||
setupNav(Nav.PREV, fileList.getPreviousPatchLink(patchIndex));
|
||||
setupNav(Nav.NEXT, fileList.getNextPatchLink(patchIndex));
|
||||
} else {
|
||||
|
||||
@@ -102,6 +102,10 @@ class PatchTable extends Composite {
|
||||
return i != null ? i : -1;
|
||||
}
|
||||
|
||||
int size() {
|
||||
return patchMap.size();
|
||||
}
|
||||
|
||||
private Map<Patch.Key, Integer> patchMap() {
|
||||
if (patchMap == null) {
|
||||
patchMap = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user