Add streamlined workflow to patch screen

Added a link next to the "Reviewed" checkbox that marks the current
patch reviewed and goes to the next unreviewed patch.

Change-Id: I3d52fd2875e1910e76d1593ca57f4a9fdd732ee2
This commit is contained in:
Keunhong Park
2012-05-29 11:13:18 -06:00
parent 7e8d9b3ed9
commit 1481c2ed1a
4 changed files with 85 additions and 16 deletions

View File

@@ -233,7 +233,7 @@ public class PatchTable extends Composite {
* @param before A string to display at the beginning of the href text
* @param after A string to display at the end of the href text
*/
private PatchLink createLink(int index, PatchScreen.Type patchType,
public PatchLink createLink(int index, PatchScreen.Type patchType,
SafeHtml before, SafeHtml after) {
Patch patch = patchList.get(index);

View File

@@ -60,7 +60,8 @@ public interface PatchConstants extends Constants {
String previousFileHelp();
String nextFileHelp();
String reviewed();
String reviewedAnd();
String next();
String download();
String buttonReplyDone();

View File

@@ -42,7 +42,8 @@ whitespaceIGNORE_ALL_SPACE=All
previousFileHelp = Previous file
nextFileHelp = Next file
reviewed = Reviewed
reviewedAnd = Reviewed &
next = next
download = (Download)
fileTypeSymlink = Type: Symbolic Link

View File

@@ -20,10 +20,13 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.RpcStatus;
import com.google.gerrit.client.changes.CommitMessageBlock;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.changes.PatchTable.PatchValidator;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
import com.google.gerrit.client.ui.PatchLink;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.data.PatchScript;
import com.google.gerrit.common.data.PatchSetDetail;
@@ -34,17 +37,22 @@ import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwtexpui.globalkey.client.GlobalKey;
import com.google.gwtexpui.globalkey.client.KeyCommand;
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
import com.google.gwtexpui.safehtml.client.SafeHtml;
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
import com.google.gwtjsonrpc.common.VoidResult;
public abstract class PatchScreen extends Screen implements
@@ -102,7 +110,8 @@ public abstract class PatchScreen extends Screen implements
protected PatchScriptSettingsPanel settingsPanel;
protected TopView topView;
private CheckBox reviewed;
private CheckBox reviewedCheckBox;
private FlowPanel reviewedPanel;
private HistoryTable historyTable;
private FlowPanel topPanel;
private FlowPanel contentPanel;
@@ -143,14 +152,7 @@ public abstract class PatchScreen extends Screen implements
idSideB = id.getParentKey();
this.patchIndex = patchIndex;
reviewed = new CheckBox(Util.C.reviewed());
reviewed.addValueChangeHandler(
new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
setReviewedByCurrentUser(event.getValue());
}
});
createReviewedPanel();
prefs = fileList != null ? fileList.getPreferences() :
new ListenableAccountDiffPreference();
@@ -168,6 +170,71 @@ public abstract class PatchScreen extends Screen implements
settingsPanel = new PatchScriptSettingsPanel(prefs);
}
private void createReviewedPanel(){
reviewedPanel = new FlowPanel();
reviewedCheckBox = new CheckBox(PatchUtil.C.reviewedAnd() + " ");
reviewedCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
setReviewedByCurrentUser(event.getValue());
}
});
reviewedPanel.add(reviewedCheckBox);
reviewedPanel.add(getReviewedAnchor());
}
private Anchor getReviewedAnchor() {
SafeHtmlBuilder text = new SafeHtmlBuilder();
text.append(PatchUtil.C.next());
text.append(SafeHtml.asis(Util.C.nextPatchLinkIcon()));
Anchor reviewedAnchor = new Anchor("");
SafeHtml.set(reviewedAnchor, text);
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
setReviewedByCurrentUser(true);
}
});
final PatchValidator unreviewedValidator = new PatchValidator() {
public boolean isValid(Patch patch) {
return !patch.isReviewedByCurrentUser();
}
};
int nextUnreviewedPatchIndex =
fileList.getNextPatch(patchIndex, true, unreviewedValidator,
fileList.PREFERENCE_VALIDATOR);
if (nextUnreviewedPatchIndex > -1) {
// Create invisible patch link to change page
final PatchLink reviewedLink =
fileList.createLink(nextUnreviewedPatchIndex, getPatchScreenType(),
null, null);
reviewedLink.setText("");
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
reviewedLink.go();
}
});
} else {
final ChangeLink upLink = new ChangeLink("", patchKey.getParentKey());
reviewedAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
upLink.go();
}
});
}
return reviewedAnchor;
}
@Override
public void notifyDraftDelta(int delta) {
lastScript = null;
@@ -180,9 +247,9 @@ public abstract class PatchScreen extends Screen implements
private void update(AccountDiffPreference dp) {
// Did the user just turn on auto-review?
if (!reviewed.getValue() && prefs.getOld().isManualReview()
if (!reviewedCheckBox.getValue() && prefs.getOld().isManualReview()
&& !dp.isManualReview()) {
reviewed.setValue(true);
reviewedCheckBox.setValue(true);
setReviewedByCurrentUser(true);
}
@@ -236,7 +303,7 @@ public abstract class PatchScreen extends Screen implements
super.onInitUI();
if (Gerrit.isSignedIn()) {
setTitleFarEast(reviewed);
setTitleFarEast(reviewedPanel);
}
keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
@@ -464,7 +531,7 @@ public abstract class PatchScreen extends Screen implements
}
}
}
reviewed.setValue(isReviewed);
reviewedCheckBox.setValue(isReviewed);
}
intralineFailure = isFirst && script.hasIntralineFailure();