Merge "Adapt ProjectInfoScreen to use the REST API"
This commit is contained in:
@@ -18,6 +18,7 @@ import com.google.gwt.core.client.JavaScriptObject;
|
|||||||
|
|
||||||
public class ProjectAccessInfo extends JavaScriptObject {
|
public class ProjectAccessInfo extends JavaScriptObject {
|
||||||
public final native boolean canAddRefs() /*-{ return this.can_add ? true : false; }-*/;
|
public final native boolean canAddRefs() /*-{ return this.can_add ? true : false; }-*/;
|
||||||
|
public final native boolean isOwner() /*-{ return this.is_owner ? true : false; }-*/;
|
||||||
|
|
||||||
protected ProjectAccessInfo() {
|
protected ProjectAccessInfo() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,18 @@
|
|||||||
package com.google.gerrit.client.admin;
|
package com.google.gerrit.client.admin;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.access.AccessMap;
|
||||||
|
import com.google.gerrit.client.access.ProjectAccessInfo;
|
||||||
import com.google.gerrit.client.download.DownloadPanel;
|
import com.google.gerrit.client.download.DownloadPanel;
|
||||||
|
import com.google.gerrit.client.projects.ConfigInfo;
|
||||||
|
import com.google.gerrit.client.projects.ConfigInfo.InheritedBooleanInfo;
|
||||||
|
import com.google.gerrit.client.projects.ProjectApi;
|
||||||
|
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||||
import com.google.gerrit.client.ui.SmallHeading;
|
import com.google.gerrit.client.ui.SmallHeading;
|
||||||
import com.google.gerrit.common.data.ProjectDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
import com.google.gerrit.reviewdb.client.InheritedBoolean;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||||
@@ -39,9 +43,8 @@ import com.google.gwtexpui.globalkey.client.NpTextArea;
|
|||||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||||
|
|
||||||
public class ProjectInfoScreen extends ProjectScreen {
|
public class ProjectInfoScreen extends ProjectScreen {
|
||||||
private String projectName;
|
private boolean isOwner;
|
||||||
private Project project;
|
private Project.NameKey parent;
|
||||||
private ProjectDetail projectDetail;
|
|
||||||
|
|
||||||
private LabeledWidgetsGrid grid;
|
private LabeledWidgetsGrid grid;
|
||||||
|
|
||||||
@@ -63,7 +66,6 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
|
|
||||||
public ProjectInfoScreen(final Project.NameKey toShow) {
|
public ProjectInfoScreen(final Project.NameKey toShow) {
|
||||||
super(toShow);
|
super(toShow);
|
||||||
projectName = toShow.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,7 +80,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(new ProjectDownloadPanel(projectName, true));
|
add(new ProjectDownloadPanel(getProjectKey().get(), true));
|
||||||
|
|
||||||
initDescription();
|
initDescription();
|
||||||
grid = new LabeledWidgetsGrid();
|
grid = new LabeledWidgetsGrid();
|
||||||
@@ -91,44 +93,49 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
@Override
|
@Override
|
||||||
protected void onLoad() {
|
protected void onLoad() {
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
Util.PROJECT_SVC.projectDetail(getProjectKey(),
|
|
||||||
new ScreenLoadCallback<ProjectDetail>(this) {
|
Project.NameKey project = getProjectKey();
|
||||||
public void preDisplay(final ProjectDetail result) {
|
CallbackGroup cbg = new CallbackGroup();
|
||||||
enableForm(result.canModifyAgreements,
|
AccessMap.get(project,
|
||||||
result.canModifyDescription, result.canModifyMergeType, result.canModifyState,
|
cbg.add(new GerritCallback<ProjectAccessInfo>() {
|
||||||
result.canModifyMaxObjectSizeLimit);
|
@Override
|
||||||
saveProject.setVisible(
|
public void onSuccess(ProjectAccessInfo result) {
|
||||||
result.canModifyAgreements ||
|
isOwner = result.isOwner();
|
||||||
result.canModifyDescription ||
|
enableForm();
|
||||||
result.canModifyMergeType ||
|
saveProject.setVisible(isOwner);
|
||||||
result.canModifyState);
|
}
|
||||||
|
}));
|
||||||
|
ProjectApi.getParent(project,
|
||||||
|
cbg.add(new GerritCallback<Project.NameKey>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Project.NameKey result) {
|
||||||
|
parent = result;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
ProjectApi.getConfig(project,
|
||||||
|
cbg.addFinal(new ScreenLoadCallback<ConfigInfo>(this) {
|
||||||
|
@Override
|
||||||
|
public void preDisplay(ConfigInfo result) {
|
||||||
display(result);
|
display(result);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
savedPanel = INFO;
|
savedPanel = INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableForm() {
|
private void enableForm() {
|
||||||
if (projectDetail != null) {
|
enableForm(isOwner);
|
||||||
enableForm(projectDetail.canModifyAgreements,
|
|
||||||
projectDetail.canModifyDescription,
|
|
||||||
projectDetail.canModifyMergeType,
|
|
||||||
projectDetail.canModifyState,
|
|
||||||
projectDetail.canModifyMaxObjectSizeLimit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableForm(final boolean canModifyAgreements,
|
private void enableForm(boolean isOwner) {
|
||||||
final boolean canModifyDescription, final boolean canModifyMergeType,
|
submitType.setEnabled(isOwner);
|
||||||
final boolean canModifyState, final boolean canModifyMaxObjectSizeLimit) {
|
state.setEnabled(isOwner);
|
||||||
submitType.setEnabled(canModifyMergeType);
|
contentMerge.setEnabled(isOwner);
|
||||||
state.setEnabled(canModifyState);
|
descTxt.setEnabled(isOwner);
|
||||||
contentMerge.setEnabled(canModifyMergeType);
|
contributorAgreements.setEnabled(isOwner);
|
||||||
descTxt.setEnabled(canModifyDescription);
|
signedOffBy.setEnabled(isOwner);
|
||||||
contributorAgreements.setEnabled(canModifyAgreements);
|
requireChangeID.setEnabled(isOwner);
|
||||||
signedOffBy.setEnabled(canModifyAgreements);
|
maxObjectSizeLimit.setEnabled(isOwner);
|
||||||
requireChangeID.setEnabled(canModifyMergeType);
|
|
||||||
maxObjectSizeLimit.setEnabled(canModifyMaxObjectSizeLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDescription() {
|
private void initDescription() {
|
||||||
@@ -199,9 +206,9 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
if (SubmitType.FAST_FORWARD_ONLY.equals(Project.SubmitType
|
if (SubmitType.FAST_FORWARD_ONLY.equals(Project.SubmitType
|
||||||
.valueOf(submitType.getValue(submitType.getSelectedIndex())))) {
|
.valueOf(submitType.getValue(submitType.getSelectedIndex())))) {
|
||||||
contentMerge.setEnabled(false);
|
contentMerge.setEnabled(false);
|
||||||
final InheritedBoolean inheritedBoolean = new InheritedBoolean();
|
InheritedBooleanInfo b = InheritedBooleanInfo.create();
|
||||||
inheritedBoolean.setValue(InheritableBoolean.FALSE);
|
b.setConfiguredValue(InheritableBoolean.FALSE);
|
||||||
setBool(contentMerge, inheritedBoolean);
|
setBool(contentMerge, b);
|
||||||
} else {
|
} else {
|
||||||
contentMerge.setEnabled(submitType.isEnabled());
|
contentMerge.setEnabled(submitType.isEnabled());
|
||||||
}
|
}
|
||||||
@@ -246,18 +253,18 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBool(ListBox box, InheritedBoolean inheritedBoolean) {
|
private void setBool(ListBox box, InheritedBooleanInfo inheritedBoolean) {
|
||||||
int inheritedIndex = -1;
|
int inheritedIndex = -1;
|
||||||
for (int i = 0; i < box.getItemCount(); i++) {
|
for (int i = 0; i < box.getItemCount(); i++) {
|
||||||
if (box.getValue(i).startsWith(InheritableBoolean.INHERIT.name())) {
|
if (box.getValue(i).startsWith(InheritableBoolean.INHERIT.name())) {
|
||||||
inheritedIndex = i;
|
inheritedIndex = i;
|
||||||
}
|
}
|
||||||
if (box.getValue(i).startsWith(inheritedBoolean.value.name())) {
|
if (box.getValue(i).startsWith(inheritedBoolean.configured_value().name())) {
|
||||||
box.setSelectedIndex(i);
|
box.setSelectedIndex(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inheritedIndex >= 0) {
|
if (inheritedIndex >= 0) {
|
||||||
if (project.getParent(Gerrit.getConfig().getWildProject()) == null) {
|
if (parent.equals(Gerrit.getConfig().getWildProject())) {
|
||||||
if (box.getSelectedIndex() == inheritedIndex) {
|
if (box.getSelectedIndex() == inheritedIndex) {
|
||||||
for (int i = 0; i < box.getItemCount(); i++) {
|
for (int i = 0; i < box.getItemCount(); i++) {
|
||||||
if (box.getValue(i).equals(InheritableBoolean.FALSE.name())) {
|
if (box.getValue(i).equals(InheritableBoolean.FALSE.name())) {
|
||||||
@@ -269,7 +276,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
box.removeItem(inheritedIndex);
|
box.removeItem(inheritedIndex);
|
||||||
} else {
|
} else {
|
||||||
box.setItemText(inheritedIndex, InheritableBoolean.INHERIT.name() + " ("
|
box.setItemText(inheritedIndex, InheritableBoolean.INHERIT.name() + " ("
|
||||||
+ inheritedBoolean.inheritedValue + ")");
|
+ inheritedBoolean.inherited_value() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,53 +293,38 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||||||
return InheritableBoolean.INHERIT;
|
return InheritableBoolean.INHERIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(final ProjectDetail result) {
|
void display(ConfigInfo result) {
|
||||||
project = result.project;
|
descTxt.setText(result.description());
|
||||||
|
setBool(contributorAgreements, result.use_contributor_agreements());
|
||||||
descTxt.setText(project.getDescription());
|
setBool(signedOffBy, result.use_signed_off_by());
|
||||||
setBool(contributorAgreements, result.useContributorAgreements);
|
setBool(contentMerge, result.use_content_merge());
|
||||||
setBool(signedOffBy, result.useSignedOffBy);
|
setBool(requireChangeID, result.require_change_id());
|
||||||
setBool(contentMerge, result.useContentMerge);
|
setSubmitType(result.submit_type());
|
||||||
setBool(requireChangeID, result.requireChangeID);
|
setState(result.state());
|
||||||
setSubmitType(project.getSubmitType());
|
maxObjectSizeLimit.setText(result.max_object_size_limit().configured_value());
|
||||||
setState(project.getState());
|
|
||||||
maxObjectSizeLimit.setText(project.getMaxObjectSizeLimit());
|
|
||||||
|
|
||||||
saveProject.setEnabled(false);
|
saveProject.setEnabled(false);
|
||||||
|
|
||||||
projectDetail = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSave() {
|
private void doSave() {
|
||||||
project.setDescription(descTxt.getText().trim());
|
enableForm(false);
|
||||||
project.setUseContributorAgreements(getBool(contributorAgreements));
|
ProjectApi.setConfig(getProjectKey(), descTxt.getText().trim(),
|
||||||
project.setUseSignedOffBy(getBool(signedOffBy));
|
getBool(contributorAgreements), getBool(contentMerge),
|
||||||
project.setUseContentMerge(getBool(contentMerge));
|
getBool(signedOffBy), getBool(requireChangeID),
|
||||||
project.setRequireChangeID(getBool(requireChangeID));
|
maxObjectSizeLimit.getText().trim(),
|
||||||
project.setMaxObjectSizeLimit(maxObjectSizeLimit.getText().trim());
|
Project.SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
|
||||||
if (submitType.getSelectedIndex() >= 0) {
|
Project.State.valueOf(state.getValue(state.getSelectedIndex())),
|
||||||
project.setSubmitType(Project.SubmitType.valueOf(submitType
|
new GerritCallback<ConfigInfo>() {
|
||||||
.getValue(submitType.getSelectedIndex())));
|
@Override
|
||||||
}
|
public void onSuccess(ConfigInfo result) {
|
||||||
if (state.getSelectedIndex() >= 0) {
|
enableForm();
|
||||||
project.setState(Project.State.valueOf(state
|
|
||||||
.getValue(state.getSelectedIndex())));
|
|
||||||
}
|
|
||||||
|
|
||||||
enableForm(false, false, false, false, false);
|
|
||||||
|
|
||||||
Util.PROJECT_SVC.changeProjectSettings(project,
|
|
||||||
new GerritCallback<ProjectDetail>() {
|
|
||||||
public void onSuccess(final ProjectDetail result) {
|
|
||||||
enableForm(result.canModifyAgreements,
|
|
||||||
result.canModifyDescription, result.canModifyMergeType, result.canModifyState,
|
|
||||||
result.canModifyMaxObjectSizeLimit);
|
|
||||||
display(result);
|
display(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
super.onFailure(caught);
|
|
||||||
enableForm();
|
enableForm();
|
||||||
|
super.onFailure(caught);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
package com.google.gerrit.client.projects;
|
package com.google.gerrit.client.projects;
|
||||||
|
|
||||||
import com.google.gerrit.client.rpc.NativeMap;
|
import com.google.gerrit.client.rpc.NativeMap;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwtexpui.safehtml.client.FindReplace;
|
import com.google.gwtexpui.safehtml.client.FindReplace;
|
||||||
@@ -26,6 +28,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConfigInfo extends JavaScriptObject {
|
public class ConfigInfo extends JavaScriptObject {
|
||||||
|
public final native String description()
|
||||||
|
/*-{ return this.description }-*/;
|
||||||
|
|
||||||
public final native InheritedBooleanInfo require_change_id()
|
public final native InheritedBooleanInfo require_change_id()
|
||||||
/*-{ return this.require_change_id; }-*/;
|
/*-{ return this.require_change_id; }-*/;
|
||||||
|
|
||||||
@@ -38,6 +43,24 @@ public class ConfigInfo extends JavaScriptObject {
|
|||||||
public final native InheritedBooleanInfo use_signed_off_by()
|
public final native InheritedBooleanInfo use_signed_off_by()
|
||||||
/*-{ return this.use_signed_off_by; }-*/;
|
/*-{ return this.use_signed_off_by; }-*/;
|
||||||
|
|
||||||
|
public final SubmitType submit_type() {
|
||||||
|
return SubmitType.valueOf(submit_typeRaw());
|
||||||
|
}
|
||||||
|
private final native String submit_typeRaw()
|
||||||
|
/*-{ return this.submit_type }-*/;
|
||||||
|
|
||||||
|
public final Project.State state() {
|
||||||
|
if (stateRaw() == null) {
|
||||||
|
return Project.State.ACTIVE;
|
||||||
|
}
|
||||||
|
return Project.State.valueOf(stateRaw());
|
||||||
|
}
|
||||||
|
private final native String stateRaw()
|
||||||
|
/*-{ return this.state }-*/;
|
||||||
|
|
||||||
|
public final native MaxObjectSizeLimitInfo max_object_size_limit()
|
||||||
|
/*-{ return this.max_object_size_limit; }-*/;
|
||||||
|
|
||||||
private final native NativeMap<CommentLinkInfo> commentlinks0()
|
private final native NativeMap<CommentLinkInfo> commentlinks0()
|
||||||
/*-{ return this.commentlinks; }-*/;
|
/*-{ return this.commentlinks; }-*/;
|
||||||
final List<FindReplace> commentlinks() {
|
final List<FindReplace> commentlinks() {
|
||||||
@@ -75,6 +98,10 @@ public class ConfigInfo extends JavaScriptObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class InheritedBooleanInfo extends JavaScriptObject {
|
public static class InheritedBooleanInfo extends JavaScriptObject {
|
||||||
|
public static InheritedBooleanInfo create() {
|
||||||
|
return (InheritedBooleanInfo) createObject();
|
||||||
|
}
|
||||||
|
|
||||||
public final native boolean value()
|
public final native boolean value()
|
||||||
/*-{ return this.value ? true : false; }-*/;
|
/*-{ return this.value ? true : false; }-*/;
|
||||||
|
|
||||||
@@ -87,7 +114,22 @@ public class ConfigInfo extends JavaScriptObject {
|
|||||||
private final native String configured_valueRaw()
|
private final native String configured_valueRaw()
|
||||||
/*-{ return this.configured_value }-*/;
|
/*-{ return this.configured_value }-*/;
|
||||||
|
|
||||||
|
public final void setConfiguredValue(InheritableBoolean v) {
|
||||||
|
setConfiguredValueRaw(v.name());
|
||||||
|
}
|
||||||
|
public final native void setConfiguredValueRaw(String v)
|
||||||
|
/*-{ if(v)this.configured_value=v; }-*/;
|
||||||
|
|
||||||
protected InheritedBooleanInfo() {
|
protected InheritedBooleanInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MaxObjectSizeLimitInfo extends JavaScriptObject {
|
||||||
|
public final native String value() /*-{ return this.value; }-*/;
|
||||||
|
public final native String inherited_value() /*-{ return this.inherited_value; }-*/;
|
||||||
|
public final native String configured_value() /*-{ return this.configured_value }-*/;
|
||||||
|
|
||||||
|
protected MaxObjectSizeLimitInfo() {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ package com.google.gerrit.client.projects;
|
|||||||
|
|
||||||
import com.google.gerrit.client.VoidResult;
|
import com.google.gerrit.client.VoidResult;
|
||||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||||
|
import com.google.gerrit.client.rpc.NativeString;
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
import com.google.gerrit.client.rpc.RestApi;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
@@ -38,18 +41,17 @@ public class ProjectApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new branch */
|
/** Create a new branch */
|
||||||
public static void createBranch(Project.NameKey projectName, String ref,
|
public static void createBranch(Project.NameKey name, String ref,
|
||||||
String revision, AsyncCallback<BranchInfo> cb) {
|
String revision, AsyncCallback<BranchInfo> cb) {
|
||||||
BranchInput input = BranchInput.create();
|
BranchInput input = BranchInput.create();
|
||||||
input.setRevision(revision);
|
input.setRevision(revision);
|
||||||
new RestApi("/projects/").id(projectName.get()).view("branches").id(ref)
|
project(name).view("branches").id(ref).ifNoneMatch().put(input, cb);
|
||||||
.ifNoneMatch().put(input, cb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retrieve all visible branches of the project */
|
/** Retrieve all visible branches of the project */
|
||||||
public static void getBranches(Project.NameKey projectName,
|
public static void getBranches(Project.NameKey name,
|
||||||
AsyncCallback<JsArray<BranchInfo>> cb) {
|
AsyncCallback<JsArray<BranchInfo>> cb) {
|
||||||
new RestApi("/projects/").id(projectName.get()).view("branches").get(cb);
|
project(name).view("branches").get(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,11 +61,11 @@ public class ProjectApi {
|
|||||||
* callbacks' {@code onFailure} method is invoked. In a failure case it can be
|
* callbacks' {@code onFailure} method is invoked. In a failure case it can be
|
||||||
* that still some of the branches were successfully deleted.
|
* that still some of the branches were successfully deleted.
|
||||||
*/
|
*/
|
||||||
public static void deleteBranches(Project.NameKey projectName,
|
public static void deleteBranches(Project.NameKey name,
|
||||||
Set<String> refs, AsyncCallback<VoidResult> cb) {
|
Set<String> refs, AsyncCallback<VoidResult> cb) {
|
||||||
CallbackGroup group = new CallbackGroup();
|
CallbackGroup group = new CallbackGroup();
|
||||||
for (String ref : refs) {
|
for (String ref : refs) {
|
||||||
new RestApi("/projects/").id(projectName.get()).view("branches").id(ref)
|
project(name).view("branches").id(ref)
|
||||||
.delete(group.add(cb));
|
.delete(group.add(cb));
|
||||||
cb = CallbackGroup.emptyCallback();
|
cb = CallbackGroup.emptyCallback();
|
||||||
}
|
}
|
||||||
@@ -72,7 +74,61 @@ public class ProjectApi {
|
|||||||
|
|
||||||
public static void getConfig(Project.NameKey name,
|
public static void getConfig(Project.NameKey name,
|
||||||
AsyncCallback<ConfigInfo> cb) {
|
AsyncCallback<ConfigInfo> cb) {
|
||||||
new RestApi("/projects/").id(name.get()).view("config").get(cb);
|
project(name).view("config").get(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setConfig(Project.NameKey name, String description,
|
||||||
|
InheritableBoolean useContributorAgreements,
|
||||||
|
InheritableBoolean useContentMerge, InheritableBoolean useSignedOffBy,
|
||||||
|
InheritableBoolean requireChangeId, String maxObjectSizeLimit,
|
||||||
|
SubmitType submitType, Project.State state, AsyncCallback<ConfigInfo> cb) {
|
||||||
|
ConfigInput in = ConfigInput.create();
|
||||||
|
in.setDescription(description);
|
||||||
|
in.setUseContributorAgreements(useContributorAgreements);
|
||||||
|
in.setUseContentMerge(useContentMerge);
|
||||||
|
in.setUseSignedOffBy(useSignedOffBy);
|
||||||
|
in.setRequireChangeId(requireChangeId);
|
||||||
|
in.setMaxObjectSizeLimit(maxObjectSizeLimit);
|
||||||
|
in.setSubmitType(submitType);
|
||||||
|
in.setState(state);
|
||||||
|
project(name).view("config").put(in, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getParent(Project.NameKey name,
|
||||||
|
final AsyncCallback<Project.NameKey> cb) {
|
||||||
|
project(name).view("parent").get(
|
||||||
|
new AsyncCallback<NativeString>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(NativeString result) {
|
||||||
|
cb.onSuccess(new Project.NameKey(result.asString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
cb.onFailure(caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getDescription(Project.NameKey name,
|
||||||
|
AsyncCallback<NativeString> cb) {
|
||||||
|
project(name).view("description").get(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDescription(Project.NameKey name, String description,
|
||||||
|
AsyncCallback<NativeString> cb) {
|
||||||
|
RestApi call = project(name).view("description");
|
||||||
|
if (description != null && !description.isEmpty()) {
|
||||||
|
DescriptionInput input = DescriptionInput.create();
|
||||||
|
input.setDescription(description);
|
||||||
|
call.put(input, cb);
|
||||||
|
} else {
|
||||||
|
call.delete(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RestApi project(Project.NameKey name) {
|
||||||
|
return new RestApi("/projects/").id(name.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ProjectInput extends JavaScriptObject {
|
private static class ProjectInput extends JavaScriptObject {
|
||||||
@@ -92,6 +148,57 @@ public class ProjectApi {
|
|||||||
final native void setCreateEmptyCommit(boolean cc) /*-{ if(cc)this.create_empty_commit=cc; }-*/;
|
final native void setCreateEmptyCommit(boolean cc) /*-{ if(cc)this.create_empty_commit=cc; }-*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ConfigInput extends JavaScriptObject {
|
||||||
|
static ConfigInput create() {
|
||||||
|
return (ConfigInput) createObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ConfigInput() {
|
||||||
|
}
|
||||||
|
|
||||||
|
final native void setDescription(String d)
|
||||||
|
/*-{ if(d)this.description=d; }-*/;
|
||||||
|
|
||||||
|
final void setUseContributorAgreements(InheritableBoolean v) {
|
||||||
|
setUseContributorAgreementsRaw(v.name());
|
||||||
|
}
|
||||||
|
private final native void setUseContributorAgreementsRaw(String v)
|
||||||
|
/*-{ if(v)this.use_contributor_agreements=v; }-*/;
|
||||||
|
|
||||||
|
final void setUseContentMerge(InheritableBoolean v) {
|
||||||
|
setUseContentMergeRaw(v.name());
|
||||||
|
}
|
||||||
|
private final native void setUseContentMergeRaw(String v)
|
||||||
|
/*-{ if(v)this.use_content_merge=v; }-*/;
|
||||||
|
|
||||||
|
final void setUseSignedOffBy(InheritableBoolean v) {
|
||||||
|
setUseSignedOffByRaw(v.name());
|
||||||
|
}
|
||||||
|
private final native void setUseSignedOffByRaw(String v)
|
||||||
|
/*-{ if(v)this.use_signed_off_by=v; }-*/;
|
||||||
|
|
||||||
|
final void setRequireChangeId(InheritableBoolean v) {
|
||||||
|
setRequireChangeIdRaw(v.name());
|
||||||
|
}
|
||||||
|
private final native void setRequireChangeIdRaw(String v)
|
||||||
|
/*-{ if(v)this.require_change_id=v; }-*/;
|
||||||
|
|
||||||
|
final native void setMaxObjectSizeLimit(String l)
|
||||||
|
/*-{ if(l)this.max_object_size_limit=l; }-*/;
|
||||||
|
|
||||||
|
final void setSubmitType(SubmitType t) {
|
||||||
|
setSubmitTypeRaw(t.name());
|
||||||
|
}
|
||||||
|
private final native void setSubmitTypeRaw(String t)
|
||||||
|
/*-{ if(t)this.submit_type=t; }-*/;
|
||||||
|
|
||||||
|
final void setState(Project.State s) {
|
||||||
|
setStateRaw(s.name());
|
||||||
|
}
|
||||||
|
private final native void setStateRaw(String s)
|
||||||
|
/*-{ if(s)this.state=s; }-*/;
|
||||||
|
}
|
||||||
|
|
||||||
private static class BranchInput extends JavaScriptObject {
|
private static class BranchInput extends JavaScriptObject {
|
||||||
static BranchInput create() {
|
static BranchInput create() {
|
||||||
return (BranchInput) createObject();
|
return (BranchInput) createObject();
|
||||||
@@ -102,4 +209,15 @@ public class ProjectApi {
|
|||||||
|
|
||||||
final native void setRevision(String r) /*-{ if(r)this.revision=r; }-*/;
|
final native void setRevision(String r) /*-{ if(r)this.revision=r; }-*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class DescriptionInput extends JavaScriptObject {
|
||||||
|
static DescriptionInput create() {
|
||||||
|
return (DescriptionInput) createObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DescriptionInput() {
|
||||||
|
}
|
||||||
|
|
||||||
|
final native void setDescription(String d) /*-{ if(d)this.description=d; }-*/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user