MyAgreementsScreen: Use REST API to get agreements
The "status" column is removed. With the new REST API, the agreement is either signed or not. Change-Id: I2235675c88d35c719ae922832f5308fea13cc56b
This commit is contained in:
committed by
David Pursehouse
parent
78ee73822f
commit
c22142958e
@@ -288,6 +288,12 @@ public class AccountApi {
|
|||||||
.post(GpgKeysInput.delete(fingerprints), cb);
|
.post(GpgKeysInput.delete(fingerprints), cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** List contributor agreements */
|
||||||
|
public static void getAgreements(String account,
|
||||||
|
AsyncCallback<JsArray<AgreementInfo>> cb) {
|
||||||
|
new RestApi("/accounts/").id(account).view("agreements").get(cb);
|
||||||
|
}
|
||||||
|
|
||||||
private static class GpgKeysInput extends JavaScriptObject {
|
private static class GpgKeysInput extends JavaScriptObject {
|
||||||
static GpgKeysInput add(String key) {
|
static GpgKeysInput add(String key) {
|
||||||
return createWithAdd(Natives.arrayOf(key));
|
return createWithAdd(Natives.arrayOf(key));
|
||||||
|
|||||||
@@ -141,11 +141,8 @@ public interface AccountConstants extends Constants {
|
|||||||
String errorDialogTitleRegisterNewEmail();
|
String errorDialogTitleRegisterNewEmail();
|
||||||
|
|
||||||
String newAgreement();
|
String newAgreement();
|
||||||
String agreementStatus();
|
|
||||||
String agreementName();
|
String agreementName();
|
||||||
String agreementDescription();
|
String agreementDescription();
|
||||||
String agreementStatus_EXPIRED();
|
|
||||||
String agreementStatus_VERIFIED();
|
|
||||||
|
|
||||||
String newAgreementSelectTypeHeading();
|
String newAgreementSelectTypeHeading();
|
||||||
String newAgreementNoneAvailable();
|
String newAgreementNoneAvailable();
|
||||||
|
|||||||
@@ -151,10 +151,7 @@ errorDialogTitleRegisterNewEmail = Email Registration Failed
|
|||||||
|
|
||||||
|
|
||||||
newAgreement = New Contributor Agreement
|
newAgreement = New Contributor Agreement
|
||||||
agreementStatus = Status
|
|
||||||
agreementName = Name
|
agreementName = Name
|
||||||
agreementStatus_EXPIRED = Expired
|
|
||||||
agreementStatus_VERIFIED = Verified
|
|
||||||
agreementDescription = Description
|
agreementDescription = Description
|
||||||
|
|
||||||
newAgreementSelectTypeHeading = Select an agreement type:
|
newAgreementSelectTypeHeading = Select an agreement type:
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// 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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,14 +16,17 @@ package com.google.gerrit.client.account;
|
|||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
|
import com.google.gerrit.client.rpc.Natives;
|
||||||
import com.google.gerrit.client.ui.FancyFlexTable;
|
import com.google.gerrit.client.ui.FancyFlexTable;
|
||||||
import com.google.gerrit.client.ui.Hyperlink;
|
import com.google.gerrit.client.ui.Hyperlink;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.data.AgreementInfo;
|
|
||||||
import com.google.gerrit.common.data.ContributorAgreement;
|
import com.google.gerrit.common.data.ContributorAgreement;
|
||||||
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MyAgreementsScreen extends SettingsScreen {
|
public class MyAgreementsScreen extends SettingsScreen {
|
||||||
private AgreementTable agreements;
|
private AgreementTable agreements;
|
||||||
|
|
||||||
@@ -39,71 +42,54 @@ public class MyAgreementsScreen extends SettingsScreen {
|
|||||||
@Override
|
@Override
|
||||||
protected void onLoad() {
|
protected void onLoad() {
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
Util.ACCOUNT_SVC.myAgreements(new ScreenLoadCallback<AgreementInfo>(this) {
|
AccountApi.getAgreements(
|
||||||
|
"self", new ScreenLoadCallback<JsArray<AgreementInfo>>(this) {
|
||||||
@Override
|
@Override
|
||||||
public void preDisplay(final AgreementInfo result) {
|
public void preDisplay(JsArray<AgreementInfo> result) {
|
||||||
agreements.display(result);
|
agreements.display(Natives.asList(result));
|
||||||
}
|
}});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AgreementTable extends FancyFlexTable<ContributorAgreement> {
|
private static class AgreementTable extends FancyFlexTable<ContributorAgreement> {
|
||||||
AgreementTable() {
|
AgreementTable() {
|
||||||
table.setWidth("");
|
table.setWidth("");
|
||||||
table.setText(0, 1, Util.C.agreementStatus());
|
table.setText(0, 1, Util.C.agreementName());
|
||||||
table.setText(0, 2, Util.C.agreementName());
|
table.setText(0, 2, Util.C.agreementDescription());
|
||||||
table.setText(0, 3, Util.C.agreementDescription());
|
|
||||||
|
|
||||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||||
for (int c = 1; c < 4; c++) {
|
for (int c = 1; c < 3; c++) {
|
||||||
fmt.addStyleName(0, c, Gerrit.RESOURCES.css().dataHeader());
|
fmt.addStyleName(0, c, Gerrit.RESOURCES.css().dataHeader());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(final AgreementInfo result) {
|
void display(List<AgreementInfo> result) {
|
||||||
while (1 < table.getRowCount()) {
|
while (1 < table.getRowCount()) {
|
||||||
table.removeRow(table.getRowCount() - 1);
|
table.removeRow(table.getRowCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String k : result.accepted) {
|
for (AgreementInfo info : result) {
|
||||||
addOne(result, k);
|
addOne(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addOne(final AgreementInfo info, final String k) {
|
void addOne(AgreementInfo info) {
|
||||||
final int row = table.getRowCount();
|
int row = table.getRowCount();
|
||||||
table.insertRow(row);
|
table.insertRow(row);
|
||||||
applyDataRowStyle(row);
|
applyDataRowStyle(row);
|
||||||
|
|
||||||
final ContributorAgreement cla = info.agreements.get(k);
|
String url = info.url();
|
||||||
final String statusName;
|
if (url != null && url.length() > 0) {
|
||||||
if (cla == null) {
|
Anchor a = new Anchor(info.name(), url);
|
||||||
statusName = Util.C.agreementStatus_EXPIRED();
|
a.setTarget("_blank");
|
||||||
|
table.setWidget(row, 1, a);
|
||||||
} else {
|
} else {
|
||||||
statusName = Util.C.agreementStatus_VERIFIED();
|
table.setText(row, 1, info.name());
|
||||||
}
|
}
|
||||||
table.setText(row, 1, statusName);
|
table.setText(row, 2, info.description());
|
||||||
|
FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||||
if (cla == null) {
|
for (int c = 1; c < 3; c++) {
|
||||||
table.setText(row, 2, "");
|
|
||||||
table.setText(row, 3, "");
|
|
||||||
} else {
|
|
||||||
final String url = cla.getAgreementUrl();
|
|
||||||
if (url != null && url.length() > 0) {
|
|
||||||
final Anchor a = new Anchor(cla.getName(), url);
|
|
||||||
a.setTarget("_blank");
|
|
||||||
table.setWidget(row, 2, a);
|
|
||||||
} else {
|
|
||||||
table.setText(row, 2, cla.getName());
|
|
||||||
}
|
|
||||||
table.setText(row, 3, cla.getDescription());
|
|
||||||
}
|
|
||||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
|
||||||
for (int c = 1; c < 4; c++) {
|
|
||||||
fmt.addStyleName(row, c, Gerrit.RESOURCES.css().dataCell());
|
fmt.addStyleName(row, c, Gerrit.RESOURCES.css().dataCell());
|
||||||
}
|
}
|
||||||
|
|
||||||
setRowItem(row, cla);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user