ChangeScreen2: mark patch sets with draft comments in revision list
Bug: Issue 2072 Change-Id: I10294b78cd3d832b5b64b146286f9368e12fa87b
This commit is contained in:
parent
a92fc47ef4
commit
17d0d337aa
@ -171,6 +171,12 @@ default. Optional fields are:
|
||||
* `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`: parse and output all header fields from the
|
||||
@ -3138,6 +3144,9 @@ The `RevisionInfo` entity contains information about a patch set.
|
||||
|===========================
|
||||
|Field Name ||Description
|
||||
|`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.
|
||||
|`fetch` ||
|
||||
Information about how to fetch this patch set. The fetch information is
|
||||
|
@ -43,7 +43,10 @@ public enum ListChangesOption {
|
||||
CURRENT_ACTIONS(10),
|
||||
|
||||
/** Set the reviewed boolean for the caller. */
|
||||
REVIEWED(11);
|
||||
REVIEWED(11),
|
||||
|
||||
/** Include draft comments for the caller. */
|
||||
DRAFT_COMMENTS(12);
|
||||
|
||||
private final int value;
|
||||
|
||||
|
@ -25,4 +25,5 @@ interface Constants extends com.google.gwt.i18n.client.Constants {
|
||||
String date();
|
||||
String author();
|
||||
String draft();
|
||||
String draftCommentsTooltip();
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ ps = PS
|
||||
commit = Commit
|
||||
date = Date
|
||||
author = Author
|
||||
draft = (DRAFT)
|
||||
draft = (DRAFT)
|
||||
draftCommentsTooltip = Draft comment(s) inside
|
||||
|
@ -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.FlexTable;
|
||||
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.Widget;
|
||||
import com.google.gwt.user.client.ui.impl.HyperlinkImpl;
|
||||
@ -94,6 +95,7 @@ class RevisionsBox extends Composite {
|
||||
String current();
|
||||
String legacy_id();
|
||||
String commit();
|
||||
String draft_comment();
|
||||
}
|
||||
|
||||
private final Change.Id changeId;
|
||||
@ -115,8 +117,9 @@ class RevisionsBox extends Composite {
|
||||
if (!loaded) {
|
||||
RestApi call = ChangeApi.detail(changeId.get());
|
||||
ChangeList.addOptions(call, EnumSet.of(
|
||||
ListChangesOption.ALL_COMMITS,
|
||||
ListChangesOption.ALL_REVISIONS,
|
||||
ListChangesOption.ALL_COMMITS));
|
||||
ListChangesOption.DRAFT_COMMENTS));
|
||||
call.get(new AsyncCallback<ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeInfo result) {
|
||||
@ -178,6 +181,15 @@ class RevisionsBox extends Composite {
|
||||
if (r.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.openTd()
|
||||
|
@ -56,6 +56,13 @@ limitations under the License.
|
||||
.commit {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.draft_comment {
|
||||
margin: 0 2px 0 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel styleName='{style.revisionBox}'>
|
||||
<g:ScrollPanel styleName='{style.scroll}'>
|
||||
|
@ -203,6 +203,7 @@ public class ChangeInfo extends JavaScriptObject {
|
||||
public final native int _number() /*-{ return this._number; }-*/;
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
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 void set_commit(CommitInfo c) /*-{ this.commit = c; }-*/;
|
||||
|
||||
|
@ -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.DETAILED_ACCOUNTS;
|
||||
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.MESSAGES;
|
||||
import static com.google.gerrit.common.changes.ListChangesOption.REVIEWED;
|
||||
@ -834,6 +835,18 @@ public class ChangeJson {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -936,6 +949,7 @@ public class ChangeJson {
|
||||
static class RevisionInfo {
|
||||
private transient boolean isCurrent;
|
||||
Boolean draft;
|
||||
Boolean hasDraftComments;
|
||||
int _number;
|
||||
Map<String, FetchInfo> fetch;
|
||||
CommitInfo commit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user