Allow to propose changes to access rights through code review

Users that are able to upload changes for code review for the
refs/meta/config branch can now propose changes to the project access
rights through code review directly from the ProjectAccessScreen.

When editing the project access rights there will be a new button
'Save for Review' which will create a new change for the access
rights modifications. Project owners are automatically added as
reviewer to this change. If a project owner agrees to the access rights
modifications he can simply approve and submit the change.

Change-Id: Ica40ce3f57726bdb897e01783cc6da10f1d392cc
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Gustaf Lundh <gustaf.lundh@sonymobile.com>
Signed-off-by: Ulrik Sjölin <ulrik.sjolin@sonyericsson.com>
This commit is contained in:
Edwin Kempin
2012-05-09 02:07:28 +02:00
parent 895d18b7f2
commit 5aa9a2c98d
26 changed files with 492 additions and 199 deletions

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.ProjectAccess;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
@@ -78,6 +79,9 @@ public class ProjectAccessScreen extends ProjectScreen {
@UiField
Button commit;
@UiField
Button review;
private Driver driver;
private ProjectAccess access;
@@ -111,8 +115,8 @@ public class ProjectAccessScreen extends ProjectScreen {
private void displayReadOnly(ProjectAccess access) {
this.access = access;
accessEditor.setEditing(false);
UIObject.setVisible(editTools, !access.getOwnerOf().isEmpty());
edit.setEnabled(!access.getOwnerOf().isEmpty());
UIObject.setVisible(editTools, !access.getOwnerOf().isEmpty() || access.canUpload());
edit.setEnabled(!access.getOwnerOf().isEmpty() || access.canUpload());
cancel1.setVisible(false);
UIObject.setVisible(commitTools, false);
driver.edit(access);
@@ -125,6 +129,8 @@ public class ProjectAccessScreen extends ProjectScreen {
edit.setEnabled(false);
cancel1.setVisible(true);
UIObject.setVisible(commitTools, true);
commit.setVisible(!access.getOwnerOf().isEmpty());
review.setVisible(access.canUpload());
accessEditor.setEditing(true);
driver.edit(access);
}
@@ -180,6 +186,9 @@ public class ProjectAccessScreen extends ProjectScreen {
for (final String diff : diffs) {
error.add(new Label(diff));
}
if (access.canUpload()) {
error.add(new Label(Gerrit.C.projectAccessProposeForReviewHint()));
}
}
}
@@ -211,9 +220,52 @@ public class ProjectAccessScreen extends ProjectScreen {
});
}
@UiHandler("review")
void onReview(ClickEvent event) {
final ProjectAccess access = driver.flush();
if (driver.hasErrors()) {
Window.alert(Util.C.errorsMustBeFixed());
return;
}
String message = commitMessage.getText().trim();
if ("".equals(message)) {
message = null;
}
enable(false);
Util.PROJECT_SVC.reviewProjectAccess( //
getProjectKey(), //
access.getRevision(), //
message, //
access.getLocal(), //
new GerritCallback<Change.Id>() {
@Override
public void onSuccess(Change.Id changeId) {
enable(true);
commitMessage.setText("");
error.clear();
if (changeId != null) {
Gerrit.display(PageLinks.toChange(changeId));
} else {
displayReadOnly(access);
}
}
@Override
public void onFailure(Throwable caught) {
error.clear();
enable(true);
super.onFailure(caught);
}
});
}
private void enable(boolean enabled) {
commitMessage.setEnabled(enabled);
commit.setEnabled(enabled);
commit.setEnabled(enabled ? !access.getOwnerOf().isEmpty() : false);
review.setEnabled(enabled ? access.canUpload() : false);
cancel1.setEnabled(enabled);
cancel2.setEnabled(enabled);
}