Merge "Highlight 'Reply' button in blue color when there are draft comments"

This commit is contained in:
David Pursehouse 2015-04-30 08:45:10 +00:00 committed by Gerrit Code Review
commit 79d17aa007
3 changed files with 18 additions and 1 deletions

View File

@ -113,6 +113,7 @@ public class ChangeScreen extends Screen {
String label_need();
String replyBox();
String selected();
String highlight();
String hashtagName();
}
@ -131,6 +132,7 @@ public class ChangeScreen extends Screen {
private String base;
private String revision;
private ChangeInfo changeInfo;
private boolean hasDraftComments;
private CommentLinkProcessor commentLinkProcessor;
private EditInfo edit;
@ -300,6 +302,9 @@ public class ChangeScreen extends Screen {
.openDiv()
.append(Gerrit.getConfig().getReplyLabel())
.closeDiv());
if (hasDraftComments) {
reply.setStyleName(style.highlight());
}
reply.setVisible(true);
}
}
@ -932,6 +937,7 @@ public class ChangeScreen extends Screen {
@Override
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
r.add(result);
hasDraftComments = !result.isEmpty();
}
@Override
@ -1143,7 +1149,7 @@ public class ChangeScreen extends Screen {
initRevisionsAction(info, revision, actionMap);
if (Gerrit.isSignedIn()) {
replyAction = new ReplyAction(info, revision,
replyAction = new ReplyAction(info, revision, hasDraftComments,
style, commentLinkProcessor, reply, quickApprove);
}
history.set(commentLinkProcessor, replyAction, changeId, info);

View File

@ -33,6 +33,7 @@ import com.google.gwtexpui.user.client.PluginSafePopupPanel;
class ReplyAction {
private final PatchSet.Id psId;
private final String revision;
private final boolean hasDraftComments;
private final ChangeScreen.Style style;
private final CommentLinkProcessor clp;
private final Widget replyButton;
@ -47,6 +48,7 @@ class ReplyAction {
ReplyAction(
ChangeInfo info,
String revision,
boolean hasDraftComments,
ChangeScreen.Style style,
CommentLinkProcessor clp,
Widget replyButton,
@ -55,6 +57,7 @@ class ReplyAction {
info.legacy_id(),
info.revisions().get(revision)._number());
this.revision = revision;
this.hasDraftComments = hasDraftComments;
this.style = style;
this.clp = clp;
this.replyButton = replyButton;
@ -111,11 +114,15 @@ class ReplyAction {
public void onClose(CloseEvent<PopupPanel> event) {
if (popup == p) {
popup = null;
if (hasDraftComments || replyBox.hasMessage()) {
replyButton.setStyleName(style.highlight());
}
}
}
});
p.add(replyBox);
Window.scrollTo(0, 0);
replyButton.removeStyleName(style.highlight());
p.showRelativeTo(replyButton);
GlobalKey.dialog(p);
popup = p;

View File

@ -180,6 +180,10 @@ class ReplyBox extends Composite {
postReview();
}
boolean hasMessage() {
return !message.getText().trim().isEmpty();
}
private void postReview() {
in.message(message.getText().trim());
in.prePost();