Rewrite GWT UI to use project name in addition to numeric change ID
This change adapts the GWT UI to recognize a project name in the URL alongside the numeric change ID and integrate it into all REST API calls made on /changes. This is an effort towards having the project in all REST API calls to /changes which will make routing Gerrit requests easier. On top, it doesn't require secondary index lookups for trivial calls like /detail. In contrast to the original proposal, changes will be served at /c/project-name/+/123 instead of /p/project-name/+c/1234. This is to stay more consistent with the REST API which serves all changes at /changes instead of /projects. The only difference between the UI and the API is now that the UI uses '/+/' as a delimiter while the API uses '~'. In addition project names in the API need to be URL encoded. This enables us to use the new change id that includes the project also in a later part of the URL. In the UI, this isn't needed and at the same time we want to maximize the readability of URLs which is done by the two differences noted above. If a user uses a URL without the project (/c/123), we retrieve the project upon the first API call and rewrite the URL. All instances of Project.NameKey and String project are marked @Nullable where they can actually be null. In the API layer they are consistently marked @Nullable to reflect the current status of the backend. That is, a project can optionally be provided. This might be changed to a more strict policy at a later stage. Change-Id: Ie3feee2e3b3e3b91b8d646d0326b7ada6134a0f9
This commit is contained in:
@@ -39,7 +39,7 @@ public class ChangeGlue {
|
||||
}
|
||||
|
||||
public static void onAction(ChangeInfo change, ActionInfo action, ActionButton button) {
|
||||
RestApi api = ChangeApi.change(change.legacyId().get()).view(action.id());
|
||||
RestApi api = ChangeApi.change(change.project(), change.legacyId().get()).view(action.id());
|
||||
JavaScriptObject f = get(action.id());
|
||||
if (f != null) {
|
||||
ActionContext c = ActionContext.create(api);
|
||||
|
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
class DefaultActions {
|
||||
static void invoke(ChangeInfo change, ActionInfo action, RestApi api) {
|
||||
invoke(action, api, callback(PageLinks.toChange(change.legacyId())));
|
||||
invoke(action, api, callback(PageLinks.toChange(change.projectNameKey(), change.legacyId())));
|
||||
}
|
||||
|
||||
static void invoke(Project.NameKey project, ActionInfo action, RestApi api) {
|
||||
|
@@ -25,7 +25,7 @@ import com.google.gwt.core.client.JavaScriptObject;
|
||||
public class EditGlue {
|
||||
public static void onAction(
|
||||
ChangeInfo change, EditInfo edit, ActionInfo action, ActionButton button) {
|
||||
RestApi api = ChangeApi.edit(change.legacyId().get()).view(action.id());
|
||||
RestApi api = ChangeApi.edit(change.project(), change.legacyId().get()).view(action.id());
|
||||
|
||||
JavaScriptObject f = get(action.id());
|
||||
if (f != null) {
|
||||
|
@@ -25,7 +25,9 @@ import com.google.gwt.core.client.JavaScriptObject;
|
||||
public class RevisionGlue {
|
||||
public static void onAction(
|
||||
ChangeInfo change, RevisionInfo revision, ActionInfo action, ActionButton button) {
|
||||
RestApi api = ChangeApi.revision(change.legacyId().get(), revision.name()).view(action.id());
|
||||
RestApi api =
|
||||
ChangeApi.revision(change.project(), change.legacyId().get(), revision.name())
|
||||
.view(action.id());
|
||||
|
||||
JavaScriptObject f = get(action.id());
|
||||
if (f != null) {
|
||||
|
Reference in New Issue
Block a user