NewAgreementScreen: Use REST API to enter new agreement
Change-Id: Ibd3ae40799a13425ff78ef9590318c8b6c152fe6
This commit is contained in:
		 David Pursehouse
					David Pursehouse
				
			
				
					committed by
					
						 Edwin Kempin
						Edwin Kempin
					
				
			
			
				
	
			
			
			 Edwin Kempin
						Edwin Kempin
					
				
			
						parent
						
							8aa92dfb34
						
					
				
				
					commit
					240e2c6d2f
				
			| @@ -211,6 +211,14 @@ public class AccountApi { | ||||
|     new RestApi("/accounts/").id(account).view("password.http").delete(cb); | ||||
|   } | ||||
|  | ||||
|   /** Enter a contributor agreement */ | ||||
|   public static void enterAgreement(String account, String name, | ||||
|       AsyncCallback<NativeString> cb) { | ||||
|     AgreementInput in = AgreementInput.create(); | ||||
|     in.name(name); | ||||
|     new RestApi("/accounts/").id(account).view("agreements").put(in, cb); | ||||
|   } | ||||
|  | ||||
|   private static JsArray<ProjectWatchInfo> projectWatchArrayFromSet( | ||||
|       Set<ProjectWatchInfo> set) { | ||||
|     JsArray<ProjectWatchInfo> jsArray = JsArray.createArray().cast(); | ||||
| @@ -220,6 +228,17 @@ public class AccountApi { | ||||
|     return jsArray; | ||||
|   } | ||||
|  | ||||
|   private static class AgreementInput extends JavaScriptObject { | ||||
|     final native void name(String n) /*-{ if(n)this.name=n; }-*/; | ||||
|  | ||||
|     static AgreementInput create() { | ||||
|       return createObject().cast(); | ||||
|     } | ||||
|  | ||||
|     protected AgreementInput() { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   private static class HttpPasswordInput extends JavaScriptObject { | ||||
|     final native void generate(boolean g) /*-{ if(g)this.generate=g; }-*/; | ||||
|  | ||||
|   | ||||
| @@ -17,6 +17,7 @@ package com.google.gerrit.client.account; | ||||
| import com.google.gerrit.client.ErrorDialog; | ||||
| import com.google.gerrit.client.Gerrit; | ||||
| import com.google.gerrit.client.rpc.GerritCallback; | ||||
| import com.google.gerrit.client.rpc.NativeString; | ||||
| import com.google.gerrit.client.ui.AccountScreen; | ||||
| import com.google.gerrit.client.ui.OnEditEnabler; | ||||
| import com.google.gerrit.client.ui.SmallHeading; | ||||
| @@ -41,7 +42,6 @@ import com.google.gwt.user.client.ui.Panel; | ||||
| import com.google.gwt.user.client.ui.RadioButton; | ||||
| import com.google.gwt.user.client.ui.VerticalPanel; | ||||
| import com.google.gwtexpui.globalkey.client.NpTextBox; | ||||
| import com.google.gwtjsonrpc.common.VoidResult; | ||||
|  | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| @@ -199,15 +199,15 @@ public class NewAgreementScreen extends AccountScreen { | ||||
|   } | ||||
|  | ||||
|   private void doEnterAgreement() { | ||||
|     Util.ACCOUNT_SEC.enterAgreement(current.getName(), | ||||
|         new GerritCallback<VoidResult>() { | ||||
|     AccountApi.enterAgreement("self", current.getName(), | ||||
|         new GerritCallback<NativeString>() { | ||||
|           @Override | ||||
|           public void onSuccess(final VoidResult result) { | ||||
|           public void onSuccess(NativeString result) { | ||||
|             Gerrit.display(nextToken); | ||||
|           } | ||||
|  | ||||
|           @Override | ||||
|           public void onFailure(final Throwable caught) { | ||||
|           public void onFailure(Throwable caught) { | ||||
|             yesIAgreeBox.setText(""); | ||||
|             super.onFailure(caught); | ||||
|           } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user