NewAgreementScreen: Use REST API to get list of available agreements

Change-Id: I3fb4bde6e4d5c50010bd821eee61d95afd671204
This commit is contained in:
David Pursehouse
2016-08-22 23:36:00 +09:00
parent 630929fd39
commit bfc0c378bc
20 changed files with 44 additions and 35 deletions

View File

@@ -89,7 +89,7 @@ import com.google.gerrit.client.diff.Unified;
import com.google.gerrit.client.documentation.DocScreen;
import com.google.gerrit.client.editor.EditScreen;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.client.ui.Screen;

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.AgreementInfo;
import com.google.gerrit.client.info.GpgKeyInfo;
import com.google.gerrit.client.rpc.CallbackGroup;
import com.google.gerrit.client.rpc.NativeMap;

View File

@@ -1,26 +0,0 @@
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.account;
import com.google.gwt.core.client.JavaScriptObject;
public class AgreementInfo extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
public final native String description() /*-{ return this.description; }-*/;
public final native String url() /*-{ return this.url; }-*/;
protected AgreementInfo() {
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.client.account;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.info.AgreementInfo;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.FancyFlexTable;

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.info.AgreementInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.Natives;
@@ -23,7 +24,6 @@ import com.google.gerrit.client.ui.AccountScreen;
import com.google.gerrit.client.ui.OnEditEnabler;
import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -51,8 +51,8 @@ import java.util.Set;
public class NewAgreementScreen extends AccountScreen {
private final String nextToken;
private Set<String> mySigned;
private List<ContributorAgreement> available;
private ContributorAgreement current;
private List<AgreementInfo> available;
private AgreementInfo current;
private VerticalPanel radios;
@@ -87,16 +87,8 @@ public class NewAgreementScreen extends AccountScreen {
}
}});
Gerrit.SYSTEM_SVC
.contributorAgreements(new GerritCallback<List<ContributorAgreement>>() {
@Override
public void onSuccess(final List<ContributorAgreement> result) {
if (isAttached()) {
available = result;
postRPC();
}
}
});
available = Gerrit.info().auth().contributorAgreements();
postRPC();
}
@Override
@@ -163,12 +155,12 @@ public class NewAgreementScreen extends AccountScreen {
}
radios.add(hdr);
for (final ContributorAgreement cla : available) {
final RadioButton r = new RadioButton("cla_id", cla.getName());
for (final AgreementInfo cla : available) {
final RadioButton r = new RadioButton("cla_id", cla.name());
r.addStyleName(Gerrit.RESOURCES.css().contributorAgreementButton());
radios.add(r);
if (mySigned.contains(cla.getName())) {
if (mySigned.contains(cla.name())) {
r.setEnabled(false);
final Label l = new Label(Util.C.newAgreementAlreadySubmitted());
l.setStyleName(Gerrit.RESOURCES.css().contributorAgreementAlreadySubmitted());
@@ -182,8 +174,8 @@ public class NewAgreementScreen extends AccountScreen {
});
}
if (cla.getDescription() != null && !cla.getDescription().equals("")) {
final Label l = new Label(cla.getDescription());
if (cla.description() != null && !cla.description().equals("")) {
final Label l = new Label(cla.description());
l.setStyleName(Gerrit.RESOURCES.css().contributorAgreementShortDescription());
radios.add(l);
}
@@ -204,7 +196,7 @@ public class NewAgreementScreen extends AccountScreen {
}
private void doEnterAgreement() {
AccountApi.enterAgreement("self", current.getName(),
AccountApi.enterAgreement("self", current.name(),
new GerritCallback<NativeString>() {
@Override
public void onSuccess(NativeString result) {
@@ -219,9 +211,9 @@ public class NewAgreementScreen extends AccountScreen {
});
}
private void showCLA(final ContributorAgreement cla) {
private void showCLA(AgreementInfo cla) {
current = cla;
String url = cla.getAgreementUrl();
String url = cla.url();
if (url != null && url.length() > 0) {
agreementGroup.setVisible(true);
agreementHtml.setText(Gerrit.C.rpcStatusWorking());
@@ -255,7 +247,7 @@ public class NewAgreementScreen extends AccountScreen {
agreementGroup.setVisible(false);
}
finalGroup.setVisible(cla.getAutoVerify() != null);
finalGroup.setVisible(cla.autoVerifyGroup() != null);
yesIAgreeBox.setText("");
submit.setEnabled(false);
}

View File

@@ -21,8 +21,8 @@ import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupAuditEventInfo;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.FancyFlexTable;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
import com.google.gerrit.client.ui.OnEditEnabler;

View File

@@ -18,8 +18,8 @@ import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.admin;
import static com.google.gerrit.client.Dispatcher.toGroup;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.MenuScreen;
import com.google.gerrit.reviewdb.client.AccountGroup;

View File

@@ -21,7 +21,7 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.NotFoundScreen;
import com.google.gerrit.client.account.AccountCapabilities;
import com.google.gerrit.client.groups.GroupApi;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.OnEditEnabler;
import com.google.gerrit.client.ui.Screen;

View File

@@ -18,9 +18,9 @@ import static com.google.gerrit.client.admin.Util.C;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.groups.GroupList;
import com.google.gerrit.client.groups.GroupMap;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.HighlightingInlineHyperlink;
import com.google.gerrit.client.ui.NavigationTable;

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.client.change;
import com.google.gerrit.client.admin.Util;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.groups.GroupBaseInfo;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.GroupBaseInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.AccountSuggestOracle;

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.groups;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.rpc.RestApi;

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.client.groups;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;

View File

@@ -1,31 +0,0 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.groups;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.URL;
public class GroupBaseInfo extends JavaScriptObject {
public final AccountGroup.UUID getGroupUUID() {
return new AccountGroup.UUID(URL.decodeQueryString(id()));
}
public final native String id() /*-{ return this.id; }-*/;
public final native String name() /*-{ return this.name; }-*/;
protected GroupBaseInfo() {
}
}

View File

@@ -1,61 +0,0 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.groups;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.http.client.URL;
public class GroupInfo extends GroupBaseInfo {
public final AccountGroup.Id getGroupId() {
return new AccountGroup.Id(group_id());
}
public final native GroupOptionsInfo options() /*-{ return this.options; }-*/;
public final native String description() /*-{ return this.description; }-*/;
public final native String url() /*-{ return this.url; }-*/;
public final native String owner() /*-{ return this.owner; }-*/;
public final native void owner(String o) /*-{ if(o)this.owner=o; }-*/;
public final native JsArray<AccountInfo> members() /*-{ return this.members; }-*/;
public final native JsArray<GroupInfo> includes() /*-{ return this.includes; }-*/;
private native int group_id() /*-{ return this.group_id; }-*/;
private native String owner_id() /*-{ return this.owner_id; }-*/;
private native void owner_id(String o) /*-{ if(o)this.owner_id=o; }-*/;
public final AccountGroup.UUID getOwnerUUID() {
String owner = owner_id();
if (owner != null) {
return new AccountGroup.UUID(URL.decodeQueryString(owner));
}
return null;
}
public final void setOwnerUUID(AccountGroup.UUID uuid) {
owner_id(URL.encodeQueryString(uuid.get()));
}
protected GroupInfo() {
}
public static class GroupOptionsInfo extends JavaScriptObject {
public final native boolean isVisibleToAll() /*-{ return this['visible_to_all'] ? true : false; }-*/;
protected GroupOptionsInfo() {
}
}
}

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.groups;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gwt.core.client.JsArray;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.groups;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gwt.user.client.rpc.AsyncCallback;

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.client.ui;
import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.groups.GroupMap;
import com.google.gerrit.client.info.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.reviewdb.client.AccountGroup;