Fix side-by-side / unified navigation links

Now that toSideBySide() explicitly redirects to SideBySide, use
toPatch() instead when appropriate.

Change-Id: Id8839c2b66f5ea39f7998ea8230e8ca0c5613d8f
This commit is contained in:
Michael Zhou
2016-03-27 13:18:58 -04:00
parent 83e36d7425
commit 8d1e9c46fe
4 changed files with 17 additions and 11 deletions

View File

@@ -107,8 +107,18 @@ import com.google.gwtexpui.user.client.UserAgent;
import com.google.gwtorm.client.KeyUtil; import com.google.gwtorm.client.KeyUtil;
public class Dispatcher { public class Dispatcher {
public static String toPatch(PatchSet.Id diffBase,
PatchSet.Id revision, String fileName) {
return toPatch("", diffBase, revision, fileName, null, 0);
}
public static String toPatch(PatchSet.Id diffBase,
PatchSet.Id revision, String fileName, DisplaySide side, int line) {
return toPatch("", diffBase, revision, fileName, side, line);
}
public static String toSideBySide(PatchSet.Id diffBase, Patch.Key id) { public static String toSideBySide(PatchSet.Id diffBase, Patch.Key id) {
return toPatch("", diffBase, id); return toPatch("sidebyside", diffBase, id);
} }
public static String toSideBySide(PatchSet.Id diffBase, public static String toSideBySide(PatchSet.Id diffBase,
@@ -116,11 +126,6 @@ public class Dispatcher {
return toPatch("sidebyside", diffBase, revision, fileName, null, 0); return toPatch("sidebyside", diffBase, revision, fileName, null, 0);
} }
public static String toSideBySide(PatchSet.Id diffBase,
PatchSet.Id revision, String fileName, DisplaySide side, int line) {
return toPatch("sidebyside", diffBase, revision, fileName, side, line);
}
public static String toUnified(PatchSet.Id diffBase, public static String toUnified(PatchSet.Id diffBase,
PatchSet.Id revision, String fileName) { PatchSet.Id revision, String fileName) {
return toPatch("unified", diffBase, revision, fileName, null, 0); return toPatch("unified", diffBase, revision, fileName, null, 0);
@@ -472,7 +477,7 @@ public class Dispatcher {
} }
if ("".equals(panel) || /* DEPRECATED URL */"cm".equals(panel)) { if ("".equals(panel) || /* DEPRECATED URL */"cm".equals(panel)) {
if (preferUnified() || (UserAgent.isPortrait() && UserAgent.isMobile())) { if (preferUnified()) {
unified(token, baseId, id, side, line); unified(token, baseId, id, side, line);
} else { } else {
codemirror(token, baseId, id, side, line, false); codemirror(token, baseId, id, side, line, false);
@@ -491,7 +496,8 @@ public class Dispatcher {
} }
private static boolean preferUnified() { private static boolean preferUnified() {
return DiffView.UNIFIED_DIFF.equals(Gerrit.getUserPreferences().diffView()); return DiffView.UNIFIED_DIFF.equals(Gerrit.getUserPreferences().diffView())
|| (UserAgent.isPortrait() && UserAgent.isMobile());
} }
private static void unified(final String token, final PatchSet.Id baseId, private static void unified(final String token, final PatchSet.Id baseId,

View File

@@ -49,6 +49,6 @@ class FileComments extends Composite {
} }
private static String url(PatchSet.Id ps, CommentInfo info) { private static String url(PatchSet.Id ps, CommentInfo info) {
return Dispatcher.toSideBySide(null, ps, info.path()); return Dispatcher.toPatch(null, ps, info.path());
} }
} }

View File

@@ -284,7 +284,7 @@ public class FileTable extends FlowPanel {
return info.binary() return info.binary()
? Dispatcher.toUnified(base, curr, info.path()) ? Dispatcher.toUnified(base, curr, info.path())
: mode == Mode.REVIEW : mode == Mode.REVIEW
? Dispatcher.toSideBySide(base, curr, info.path()) ? Dispatcher.toPatch(base, curr, info.path())
: Dispatcher.toEditScreen(curr, info.path()); : Dispatcher.toEditScreen(curr, info.path());
} }

View File

@@ -88,7 +88,7 @@ class LineComment extends Composite {
} }
private static String url(PatchSet.Id ps, CommentInfo info) { private static String url(PatchSet.Id ps, CommentInfo info) {
return Dispatcher.toSideBySide(null, ps, info.path(), return Dispatcher.toPatch(null, ps, info.path(),
info.side() == Side.PARENT ? DisplaySide.A : DisplaySide.B, info.side() == Side.PARENT ? DisplaySide.A : DisplaySide.B,
info.line()); info.line());
} }