Add branch actions to Projects > Branches view
Enumerate any RestViews which implement UiAction for BranchResource and generate buttons for these in the web UI. This allows the Codenvy plugin to contribute an Edit button next to each branch. Change-Id: Iaa95ccf560036b928066684a4ca33b6b27b08ab6
This commit is contained in:
@@ -18,6 +18,7 @@ import com.google.gerrit.client.actions.ActionButton;
|
||||
import com.google.gerrit.client.actions.ActionInfo;
|
||||
import com.google.gerrit.client.changes.ChangeInfo;
|
||||
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
||||
import com.google.gerrit.client.projects.BranchInfo;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
@@ -136,6 +137,7 @@ public class ActionContext extends JavaScriptObject {
|
||||
final native void set(ActionInfo a) /*-{ this.action=a; }-*/;
|
||||
final native void set(ChangeInfo c) /*-{ this.change=c; }-*/;
|
||||
final native void set(Project.NameKey p) /*-{ this.project=p; }-*/;
|
||||
final native void set(BranchInfo b) /*-{ this.branch=b }-*/;
|
||||
final native void set(RevisionInfo r) /*-{ this.revision=r; }-*/;
|
||||
|
||||
final native void button(ActionButton b) /*-{ this._b=b; }-*/;
|
||||
|
@@ -43,6 +43,7 @@ public class ApiGlue {
|
||||
change_actions: {},
|
||||
revision_actions: {},
|
||||
project_actions: {},
|
||||
branch_actions: {},
|
||||
|
||||
getPluginName: @com.google.gerrit.client.api.ApiGlue::getPluginName(),
|
||||
injectCss: @com.google.gwt.dom.client.StyleInjector::inject(Ljava/lang/String;),
|
||||
@@ -71,6 +72,7 @@ public class ApiGlue {
|
||||
if ('change' == t) this.change_actions[i]=c;
|
||||
else if ('revision' == t) this.revision_actions[i]=c;
|
||||
else if ('project' == t) this.project_actions[i]=c;
|
||||
else if ('branch' == t) this.branch_actions[i]=c;
|
||||
else if ('screen' == t) _screen(p,t,c);
|
||||
},
|
||||
screen: function(r,c){this._screen(this.getPluginName(),r,c)},
|
||||
|
@@ -16,18 +16,40 @@ package com.google.gerrit.client.api;
|
||||
|
||||
import com.google.gerrit.client.actions.ActionButton;
|
||||
import com.google.gerrit.client.actions.ActionInfo;
|
||||
import com.google.gerrit.client.projects.BranchInfo;
|
||||
import com.google.gerrit.client.projects.ProjectApi;
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class ProjectGlue {
|
||||
public static void onAction(
|
||||
Project.NameKey project,
|
||||
BranchInfo branch,
|
||||
ActionInfo action,
|
||||
ActionButton button) {
|
||||
RestApi api = ProjectApi.project(project)
|
||||
.view("branches").id(branch.ref())
|
||||
.view(action.id());
|
||||
JavaScriptObject f = branchAction(action.id());
|
||||
if (f != null) {
|
||||
ActionContext c = ActionContext.create(api);
|
||||
c.set(action);
|
||||
c.set(project);
|
||||
c.set(branch);
|
||||
c.button(button);
|
||||
ApiGlue.invoke(f, c);
|
||||
} else {
|
||||
DefaultActions.invoke(project, action, api);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onAction(
|
||||
Project.NameKey project,
|
||||
ActionInfo action,
|
||||
ActionButton button) {
|
||||
RestApi api = ProjectApi.project(project).view(action.id());
|
||||
JavaScriptObject f = get(action.id());
|
||||
JavaScriptObject f = projectAction(action.id());
|
||||
if (f != null) {
|
||||
ActionContext c = ActionContext.create(api);
|
||||
c.set(action);
|
||||
@@ -39,10 +61,14 @@ public class ProjectGlue {
|
||||
}
|
||||
}
|
||||
|
||||
private static final native JavaScriptObject get(String id) /*-{
|
||||
private static final native JavaScriptObject projectAction(String id) /*-{
|
||||
return $wnd.Gerrit.project_actions[id];
|
||||
}-*/;
|
||||
|
||||
private static final native JavaScriptObject branchAction(String id) /*-{
|
||||
return $wnd.Gerrit.branch_actions[id];
|
||||
}-*/;
|
||||
|
||||
private ProjectGlue() {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user