New mute-label allows for temporarily unhighlighting changes in dashboard

If the "mute/<patchset_id>"-star is set by a user, and <patchset_id>
matches the current patch set, the change is always reported as "reviewed"
in the ChangeInfo.

This allows users to "de-highlight" changes in a dashboard until a new
patchset is uploaded.

The ChangeInfo muted-field will show if the change is currently in a
mute-state.

Change-Id: I83085033ff99d7b0ce1fe834fabfad5956db90ae
This commit is contained in:
Gustaf Lundh 2017-04-27 14:56:31 +02:00
parent aca5d89120
commit e011d93ba6
5 changed files with 27 additions and 1 deletions

View File

@ -61,6 +61,19 @@ request. They can then decide to remove the ignore star.
The ignore star is represented by the special star label 'ignore'. The ignore star is represented by the special star label 'ignore'.
[[mute-star]]
== Mute Star
If the "mute/<patchset_id>"-star is set by a user, and <patchset_id>
matches the current patch set, the change is always reported as "reviewed"
in the ChangeInfo.
This allows users to "de-highlight" changes in a dashboard until a new
patchset has been uploaded.
The ChangeInfo muted-field will show if the change is currently in a
mute state.
[[query-stars]] [[query-stars]]
== Query Stars == Query Stars

View File

@ -36,6 +36,7 @@ public class ChangeInfo {
public Timestamp updated; public Timestamp updated;
public Timestamp submitted; public Timestamp submitted;
public Boolean starred; public Boolean starred;
public Boolean muted;
public Collection<String> stars; public Collection<String> stars;
public Boolean reviewed; public Boolean reviewed;
public SubmitType submitType; public SubmitType submitType;

View File

@ -136,6 +136,8 @@ public class ChangeInfo extends JavaScriptObject {
public final native boolean starred() /*-{ return this.starred ? true : false; }-*/; public final native boolean starred() /*-{ return this.starred ? true : false; }-*/;
public final native boolean muted() /*-{ return this.muted ? true : false; }-*/;
public final native boolean reviewed() /*-{ return this.reviewed ? true : false; }-*/; public final native boolean reviewed() /*-{ return this.reviewed ? true : false; }-*/;
public final native boolean isPrivate() /*-{ return this.is_private ? true : false; }-*/; public final native boolean isPrivate() /*-{ return this.is_private ? true : false; }-*/;

View File

@ -147,6 +147,7 @@ public class StarredChangesUtil {
public static final String DEFAULT_LABEL = "star"; public static final String DEFAULT_LABEL = "star";
public static final String IGNORE_LABEL = "ignore"; public static final String IGNORE_LABEL = "ignore";
public static final String MUTE_LABEL = "mute";
public static final ImmutableSortedSet<String> DEFAULT_LABELS = public static final ImmutableSortedSet<String> DEFAULT_LABELS =
ImmutableSortedSet.of(DEFAULT_LABEL); ImmutableSortedSet.of(DEFAULT_LABEL);

View File

@ -514,6 +514,11 @@ public class ChangeJson {
if (user.isIdentifiedUser()) { if (user.isIdentifiedUser()) {
Collection<String> stars = cd.stars(user.getAccountId()); Collection<String> stars = cd.stars(user.getAccountId());
out.starred = stars.contains(StarredChangesUtil.DEFAULT_LABEL) ? true : null; out.starred = stars.contains(StarredChangesUtil.DEFAULT_LABEL) ? true : null;
out.muted =
stars.contains(
StarredChangesUtil.MUTE_LABEL + "/" + cd.currentPatchSet().getPatchSetId())
? true
: null;
if (!stars.isEmpty()) { if (!stars.isEmpty()) {
out.stars = stars; out.stars = stars;
} }
@ -521,8 +526,12 @@ public class ChangeJson {
if (in.getStatus().isOpen() && has(REVIEWED) && user.isIdentifiedUser()) { if (in.getStatus().isOpen() && has(REVIEWED) && user.isIdentifiedUser()) {
Account.Id accountId = user.getAccountId(); Account.Id accountId = user.getAccountId();
if (out.muted != null) {
out.reviewed = true;
} else {
out.reviewed = cd.reviewedBy().contains(accountId) ? true : null; out.reviewed = cd.reviewedBy().contains(accountId) ? true : null;
} }
}
out.labels = labelsFor(perm, ctl, cd, has(LABELS), has(DETAILED_LABELS)); out.labels = labelsFor(perm, ctl, cd, has(LABELS), has(DETAILED_LABELS));
out.submitted = getSubmittedOn(cd); out.submitted = getSubmittedOn(cd);