ChangeScreen2: mark patch sets with draft comments in revision list

Bug: Issue 2072
Change-Id: I10294b78cd3d832b5b64b146286f9368e12fa87b
This commit is contained in:
David Ostrovsky
2013-09-30 21:36:09 +02:00
committed by David Pursehouse
parent a92fc47ef4
commit 17d0d337aa
8 changed files with 51 additions and 3 deletions

View File

@@ -171,6 +171,12 @@ default. Optional fields are:
* `ALL_REVISIONS`: describe all revisions, not just current. * `ALL_REVISIONS`: describe all revisions, not just current.
-- --
[[draft_comments]]
--
* `DRAFT_COMMENTS`: include the `has_draft_comments` field for
revisions. Only valid when the `CURRENT_REVISION` or `ALL_REVISIONS`
option is selected.
[[current-commit]] [[current-commit]]
-- --
* `CURRENT_COMMIT`: parse and output all header fields from the * `CURRENT_COMMIT`: parse and output all header fields from the
@@ -3138,6 +3144,9 @@ The `RevisionInfo` entity contains information about a patch set.
|=========================== |===========================
|Field Name ||Description |Field Name ||Description
|`draft` |not set if `false`|Whether the patch set is a draft. |`draft` |not set if `false`|Whether the patch set is a draft.
|`has_draft_comments` |not set if `false`|Whether the patch
set has one or more draft comments by the calling user. Only set if
link:#draft_comments[draft comments] is requested.
|`_number` ||The patch set number. |`_number` ||The patch set number.
|`fetch` || |`fetch` ||
Information about how to fetch this patch set. The fetch information is Information about how to fetch this patch set. The fetch information is

View File

@@ -43,7 +43,10 @@ public enum ListChangesOption {
CURRENT_ACTIONS(10), CURRENT_ACTIONS(10),
/** Set the reviewed boolean for the caller. */ /** Set the reviewed boolean for the caller. */
REVIEWED(11); REVIEWED(11),
/** Include draft comments for the caller. */
DRAFT_COMMENTS(12);
private final int value; private final int value;

View File

@@ -25,4 +25,5 @@ interface Constants extends com.google.gwt.i18n.client.Constants {
String date(); String date();
String author(); String author();
String draft(); String draft();
String draftCommentsTooltip();
} }

View File

@@ -8,3 +8,4 @@ commit = Commit
date = Date date = Date
author = Author author = Author
draft = (DRAFT) draft = (DRAFT)
draftCommentsTooltip = Draft comment(s) inside

View File

@@ -41,6 +41,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ImageResourceRenderer;
import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.impl.HyperlinkImpl; import com.google.gwt.user.client.ui.impl.HyperlinkImpl;
@@ -94,6 +95,7 @@ class RevisionsBox extends Composite {
String current(); String current();
String legacy_id(); String legacy_id();
String commit(); String commit();
String draft_comment();
} }
private final Change.Id changeId; private final Change.Id changeId;
@@ -115,8 +117,9 @@ class RevisionsBox extends Composite {
if (!loaded) { if (!loaded) {
RestApi call = ChangeApi.detail(changeId.get()); RestApi call = ChangeApi.detail(changeId.get());
ChangeList.addOptions(call, EnumSet.of( ChangeList.addOptions(call, EnumSet.of(
ListChangesOption.ALL_COMMITS,
ListChangesOption.ALL_REVISIONS, ListChangesOption.ALL_REVISIONS,
ListChangesOption.ALL_COMMITS)); ListChangesOption.DRAFT_COMMENTS));
call.get(new AsyncCallback<ChangeInfo>() { call.get(new AsyncCallback<ChangeInfo>() {
@Override @Override
public void onSuccess(ChangeInfo result) { public void onSuccess(ChangeInfo result) {
@@ -178,6 +181,15 @@ class RevisionsBox extends Composite {
if (r.draft()) { if (r.draft()) {
sb.append(" ").append(Resources.C.draft()); sb.append(" ").append(Resources.C.draft());
} }
if (r.has_draft_comments()) {
sb.append(" ")
.openSpan()
.addStyleName(style.draft_comment())
.setAttribute("title", Resources.C.draftCommentsTooltip())
.append(new ImageResourceRenderer()
.render(Gerrit.RESOURCES.draftComments()))
.closeSpan();
}
sb.closeTd(); sb.closeTd();
sb.openTd() sb.openTd()

View File

@@ -56,6 +56,13 @@ limitations under the License.
.commit { .commit {
font-family: monospace; font-family: monospace;
} }
.draft_comment {
margin: 0 2px 0 0;
width: 16px;
height: 16px;
vertical-align: bottom;
}
</ui:style> </ui:style>
<g:HTMLPanel styleName='{style.revisionBox}'> <g:HTMLPanel styleName='{style.revisionBox}'>
<g:ScrollPanel styleName='{style.scroll}'> <g:ScrollPanel styleName='{style.scroll}'>

View File

@@ -203,6 +203,7 @@ public class ChangeInfo extends JavaScriptObject {
public final native int _number() /*-{ return this._number; }-*/; public final native int _number() /*-{ return this._number; }-*/;
public final native String name() /*-{ return this.name; }-*/; public final native String name() /*-{ return this.name; }-*/;
public final native boolean draft() /*-{ return this.draft || false; }-*/; public final native boolean draft() /*-{ return this.draft || false; }-*/;
public final native boolean has_draft_comments() /*-{ return this.has_draft_comments || false; }-*/;
public final native CommitInfo commit() /*-{ return this.commit; }-*/; public final native CommitInfo commit() /*-{ return this.commit; }-*/;
public final native void set_commit(CommitInfo c) /*-{ this.commit = c; }-*/; public final native void set_commit(CommitInfo c) /*-{ this.commit = c; }-*/;

View File

@@ -23,6 +23,7 @@ import static com.google.gerrit.common.changes.ListChangesOption.CURRENT_FILES;
import static com.google.gerrit.common.changes.ListChangesOption.CURRENT_REVISION; import static com.google.gerrit.common.changes.ListChangesOption.CURRENT_REVISION;
import static com.google.gerrit.common.changes.ListChangesOption.DETAILED_ACCOUNTS; import static com.google.gerrit.common.changes.ListChangesOption.DETAILED_ACCOUNTS;
import static com.google.gerrit.common.changes.ListChangesOption.DETAILED_LABELS; import static com.google.gerrit.common.changes.ListChangesOption.DETAILED_LABELS;
import static com.google.gerrit.common.changes.ListChangesOption.DRAFT_COMMENTS;
import static com.google.gerrit.common.changes.ListChangesOption.LABELS; import static com.google.gerrit.common.changes.ListChangesOption.LABELS;
import static com.google.gerrit.common.changes.ListChangesOption.MESSAGES; import static com.google.gerrit.common.changes.ListChangesOption.MESSAGES;
import static com.google.gerrit.common.changes.ListChangesOption.REVIEWED; import static com.google.gerrit.common.changes.ListChangesOption.REVIEWED;
@@ -834,6 +835,18 @@ public class ChangeJson {
out.actions.put(d.getId(), new ActionInfo(d)); out.actions.put(d.getId(), new ActionInfo(d));
} }
} }
if (has(DRAFT_COMMENTS)
&& userProvider.get().isIdentifiedUser()) {
IdentifiedUser user = (IdentifiedUser)userProvider.get();
out.hasDraftComments =
db.get().patchComments()
.draftByPatchSetAuthor(in.getId(), user.getAccountId())
.iterator().hasNext()
? true
: null;
}
return out; return out;
} }
@@ -936,6 +949,7 @@ public class ChangeJson {
static class RevisionInfo { static class RevisionInfo {
private transient boolean isCurrent; private transient boolean isCurrent;
Boolean draft; Boolean draft;
Boolean hasDraftComments;
int _number; int _number;
Map<String, FetchInfo> fetch; Map<String, FetchInfo> fetch;
CommitInfo commit; CommitInfo commit;