Add key commands to mark patch as reviewed
Add a key command to toggle the reviewed flag for a patch.
In addition add another key command to mark the patch as reviewed and
navigate to the next unreviewed patch. This is the same streamlined
workflow as implemented by 1481c2ed1a.
Bug: issue 1510
Change-Id: I322814cde19921ea424990f701d52b6fb040168b
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -48,6 +48,9 @@ public interface PatchConstants extends Constants {
|
||||
String fileList();
|
||||
String expandComment();
|
||||
|
||||
String toggleReviewed();
|
||||
String markAsReviewedAndGoToNext();
|
||||
|
||||
String commentEditorSet();
|
||||
String commentInsert();
|
||||
String commentSaveDraft();
|
||||
|
||||
@@ -30,6 +30,9 @@ commentNext = Next comment
|
||||
fileList = Browse files in patch set
|
||||
expandComment = Expand or collapse comment
|
||||
|
||||
toggleReviewed = Toggle the reviewed flag
|
||||
markAsReviewedAndGoToNext = Mark patch as reviewed and go to next unreviewed patch
|
||||
|
||||
commentEditorSet = Comment Editing
|
||||
commentInsert = Create a new inline comment
|
||||
commentSaveDraft = Save draft comment
|
||||
|
||||
@@ -25,8 +25,8 @@ 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.InlineHyperlink;
|
||||
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;
|
||||
@@ -112,6 +112,7 @@ public abstract class PatchScreen extends Screen implements
|
||||
|
||||
private CheckBox reviewedCheckBox;
|
||||
private FlowPanel reviewedPanel;
|
||||
private InlineHyperlink reviewedLink;
|
||||
private HistoryTable historyTable;
|
||||
private FlowPanel topPanel;
|
||||
private FlowPanel contentPanel;
|
||||
@@ -131,7 +132,9 @@ public abstract class PatchScreen extends Screen implements
|
||||
|
||||
/** Keys that cause an action on this screen */
|
||||
private KeyCommandSet keysNavigation;
|
||||
private KeyCommandSet keysAction;
|
||||
private HandlerRegistration regNavigation;
|
||||
private HandlerRegistration regAction;
|
||||
private boolean intralineFailure;
|
||||
|
||||
/**
|
||||
@@ -193,13 +196,6 @@ public abstract class PatchScreen extends Screen implements
|
||||
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();
|
||||
@@ -212,25 +208,20 @@ public abstract class PatchScreen extends Screen implements
|
||||
|
||||
if (nextUnreviewedPatchIndex > -1) {
|
||||
// Create invisible patch link to change page
|
||||
final PatchLink reviewedLink =
|
||||
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();
|
||||
}
|
||||
});
|
||||
reviewedLink = new ChangeLink("", patchKey.getParentKey());
|
||||
}
|
||||
reviewedAnchor.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
setReviewedByCurrentUser(true);
|
||||
reviewedLink.go();
|
||||
}
|
||||
});
|
||||
|
||||
return reviewedAnchor;
|
||||
}
|
||||
@@ -310,6 +301,14 @@ public abstract class PatchScreen extends Screen implements
|
||||
keysNavigation.add(new UpToChangeCommand(patchKey.getParentKey(), 0, 'u'));
|
||||
keysNavigation.add(new FileListCmd(0, 'f', PatchUtil.C.fileList()));
|
||||
|
||||
if (Gerrit.isSignedIn()) {
|
||||
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
|
||||
keysAction
|
||||
.add(new ToggleReviewedCmd(0, 'm', PatchUtil.C.toggleReviewed()));
|
||||
keysAction.add(new MarkAsReviewedAndGoToNextCmd(0, 'M', PatchUtil.C
|
||||
.markAsReviewedAndGoToNext()));
|
||||
}
|
||||
|
||||
historyTable = new HistoryTable(this);
|
||||
|
||||
commitMessageBlock = new CommitMessageBlock();
|
||||
@@ -393,6 +392,10 @@ public abstract class PatchScreen extends Screen implements
|
||||
regNavigation.removeHandler();
|
||||
regNavigation = null;
|
||||
}
|
||||
if (regAction != null) {
|
||||
regAction.removeHandler();
|
||||
regAction = null;
|
||||
}
|
||||
super.onUnload();
|
||||
}
|
||||
|
||||
@@ -405,6 +408,13 @@ public abstract class PatchScreen extends Screen implements
|
||||
regNavigation = null;
|
||||
}
|
||||
regNavigation = GlobalKey.add(this, keysNavigation);
|
||||
if (regAction != null) {
|
||||
regAction.removeHandler();
|
||||
regAction = null;
|
||||
}
|
||||
if (keysAction != null) {
|
||||
regAction = GlobalKey.add(this, keysAction);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract AbstractPatchContentTable createContentTable();
|
||||
@@ -603,4 +613,31 @@ public abstract class PatchScreen extends Screen implements
|
||||
p.open();
|
||||
}
|
||||
}
|
||||
|
||||
public class ToggleReviewedCmd extends KeyCommand {
|
||||
public ToggleReviewedCmd(int mask, int key, String help) {
|
||||
super(mask, key, help);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyPress(final KeyPressEvent event) {
|
||||
final boolean isReviewed = !reviewedCheckBox.getValue();
|
||||
reviewedCheckBox.setValue(isReviewed);
|
||||
setReviewedByCurrentUser(isReviewed);
|
||||
}
|
||||
}
|
||||
|
||||
public class MarkAsReviewedAndGoToNextCmd extends KeyCommand {
|
||||
public MarkAsReviewedAndGoToNextCmd(int mask, int key, String help) {
|
||||
super(mask, key, help);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyPress(final KeyPressEvent event) {
|
||||
if (reviewedLink != null) {
|
||||
setReviewedByCurrentUser(true);
|
||||
reviewedLink.go();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user