Modernize URLs to be shorter and consistent
Instead of using http://site/#change,1234 we now use a slightly more common looking http://site/#/c/1234 URL to link to a change. It is also quite a bit shorter than the old format, using up less space in the address bar. Files within a patch set are now denoted below the change, as in http://site/#/c/1234/1/src/module/foo.c making it easier to jump directly to a specific file, or to just see the structure of the current view. Whenever possible the old URLs continue to work by redirecting to the equivalent new URL. We plan to keep the old URLs alive, as many issue tracking systems have direct links based on the old URL format and these links should not be invalidated. This change also fixes the dynamic redirects of http://site/1234 and http://site/r/deadbeef to jump directly to the corresponding change if there is exactly one possible URL. This avoids the ugly interim redirect to http://site/#/q/1234,n,z when the server can compute what the correct location should be on its own. Entities that have multiple views suffix the URL with ",view-name" to indicate which view the user wants to see. For files the default view is the side-by-side view and does not have a suffix, while the unified patch view has a suffix of ",unified", for example: http://site/#/c/1234/1/src/module/foo.c,unified. Project admin panels use a similar view suffix to denote which of the tabs on the left menu is currently open, with the main info tab being the default with no suffix. Change-Id: I2bac7ef1b2638fb08df2659b8373960eadec205a
This commit is contained in:
@@ -24,38 +24,38 @@ import com.google.gerrit.reviewdb.Change.Status;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
|
||||
public class PageLinks {
|
||||
public static final String SETTINGS = "settings";
|
||||
public static final String SETTINGS_PREFERENCES = "settings,preferences";
|
||||
public static final String SETTINGS_SSHKEYS = "settings,ssh-keys";
|
||||
public static final String SETTINGS_HTTP_PASSWORD = "settings,http-password";
|
||||
public static final String SETTINGS_WEBIDENT = "settings,web-identities";
|
||||
public static final String SETTINGS_MYGROUPS = "settings,group-memberships";
|
||||
public static final String SETTINGS_AGREEMENTS = "settings,agreements";
|
||||
public static final String SETTINGS_CONTACT = "settings,contact";
|
||||
public static final String SETTINGS_PROJECTS = "settings,projects";
|
||||
public static final String SETTINGS_NEW_AGREEMENT = "settings,new-agreement";
|
||||
public static final String REGISTER = "register";
|
||||
public static final String SETTINGS = "/settings/";
|
||||
public static final String SETTINGS_PREFERENCES = "/settings/preferences";
|
||||
public static final String SETTINGS_SSHKEYS = "/settings/ssh-keys";
|
||||
public static final String SETTINGS_HTTP_PASSWORD = "/settings/http-password";
|
||||
public static final String SETTINGS_WEBIDENT = "/settings/web-identities";
|
||||
public static final String SETTINGS_MYGROUPS = "/settings/group-memberships";
|
||||
public static final String SETTINGS_AGREEMENTS = "/settings/agreements";
|
||||
public static final String SETTINGS_CONTACT = "/settings/contact";
|
||||
public static final String SETTINGS_PROJECTS = "/settings/projects";
|
||||
public static final String SETTINGS_NEW_AGREEMENT = "/settings/new-agreement";
|
||||
public static final String REGISTER = "/register";
|
||||
|
||||
public static final String TOP = "n,z";
|
||||
|
||||
public static final String MINE = "mine";
|
||||
public static final String ADMIN_GROUPS = "admin,groups";
|
||||
public static final String ADMIN_PROJECTS = "admin,projects";
|
||||
public static final String MINE = "/";
|
||||
public static final String ADMIN_GROUPS = "/admin/groups/";
|
||||
public static final String ADMIN_PROJECTS = "/admin/projects/";
|
||||
|
||||
public static String toChange(final ChangeInfo c) {
|
||||
return toChange(c.getId());
|
||||
}
|
||||
|
||||
public static String toChange(final Change.Id c) {
|
||||
return "change," + c.toString();
|
||||
return "/c/" + c + "/";
|
||||
}
|
||||
|
||||
public static String toChange(final PatchSet.Id ps) {
|
||||
return "change," + ps.getParentKey().toString() + ",patchset=" + ps.get();
|
||||
return "/c/" + ps.getParentKey() + "/" + ps.get();
|
||||
}
|
||||
|
||||
public static String toProjectAcceess(final Project.NameKey p) {
|
||||
return "admin,project," + p.get() + ",access";
|
||||
return "/admin/projects/" + p.get() + ",access";
|
||||
}
|
||||
|
||||
public static String toAccountDashboard(final AccountInfo acct) {
|
||||
@@ -63,11 +63,16 @@ public class PageLinks {
|
||||
}
|
||||
|
||||
public static String toAccountDashboard(final Account.Id acct) {
|
||||
return "dashboard," + acct.toString();
|
||||
return "/dashboard/" + acct.toString();
|
||||
}
|
||||
|
||||
public static String toChangeQuery(final String query) {
|
||||
return "q," + KeyUtil.encode(query) + "," + TOP;
|
||||
return toChangeQuery(query, TOP);
|
||||
}
|
||||
|
||||
public static String toChangeQuery(String query, String page) {
|
||||
query = KeyUtil.encode(query).replaceAll("%3[Aa]", ":");
|
||||
return "/q/" + query + "," + page;
|
||||
}
|
||||
|
||||
public static String projectQuery(Project.NameKey proj, Status status) {
|
||||
|
||||
Reference in New Issue
Block a user