mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Highlight reviews the viewer is responsible for in Differential
Summary: Ref T1279. No logical changes, but cosmetically highlight stuff you have authority for, like we do in Diffusion. Test Plan: See screenshot. Reviewers: chad, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1279 Differential Revision: https://secure.phabricator.com/D7237
This commit is contained in:
parent
4c0ec01ce5
commit
c80a4f51c1
3 changed files with 28 additions and 1 deletions
|
@ -27,9 +27,24 @@ final class DifferentialProjectReviewersFieldSpecification
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$highlight = array();
|
||||||
|
if ($this->getUser()->getPHID() != $this->getRevision()->getAuthorPHID()) {
|
||||||
|
// Determine which of these projects the viewer is a member of, so we can
|
||||||
|
// highlight them. (If the viewer is the author, skip this since they
|
||||||
|
// can't review.)
|
||||||
|
$phids = mpull($reviewers, 'getReviewerPHID');
|
||||||
|
$projects = id(new PhabricatorProjectQuery())
|
||||||
|
->setViewer($this->getUser())
|
||||||
|
->withPHIDs($phids)
|
||||||
|
->withMemberPHIDs(array($this->getUser()->getPHID()))
|
||||||
|
->execute();
|
||||||
|
$highlight = mpull($projects, 'getPHID');
|
||||||
|
}
|
||||||
|
|
||||||
$view = id(new DifferentialReviewersView())
|
$view = id(new DifferentialReviewersView())
|
||||||
->setReviewers($reviewers)
|
->setReviewers($reviewers)
|
||||||
->setHandles($this->getLoadedHandles());
|
->setHandles($this->getLoadedHandles())
|
||||||
|
->setHighlightPHIDs($highlight);
|
||||||
|
|
||||||
$diff = $this->getRevision()->loadActiveDiff();
|
$diff = $this->getRevision()->loadActiveDiff();
|
||||||
if ($diff) {
|
if ($diff) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ final class DifferentialReviewersFieldSpecification
|
||||||
|
|
||||||
$view = id(new DifferentialReviewersView())
|
$view = id(new DifferentialReviewersView())
|
||||||
->setReviewers($reviewers)
|
->setReviewers($reviewers)
|
||||||
|
->setHighlightPHIDs(array($this->getUser()->getPHID()))
|
||||||
->setHandles($this->getLoadedHandles());
|
->setHandles($this->getLoadedHandles());
|
||||||
|
|
||||||
$diff = $this->getRevision()->loadActiveDiff();
|
$diff = $this->getRevision()->loadActiveDiff();
|
||||||
|
|
|
@ -5,6 +5,7 @@ final class DifferentialReviewersView extends AphrontView {
|
||||||
private $reviewers;
|
private $reviewers;
|
||||||
private $handles;
|
private $handles;
|
||||||
private $diff;
|
private $diff;
|
||||||
|
private $highlightPHIDs = array();
|
||||||
|
|
||||||
public function setReviewers(array $reviewers) {
|
public function setReviewers(array $reviewers) {
|
||||||
assert_instances_of($reviewers, 'DifferentialReviewer');
|
assert_instances_of($reviewers, 'DifferentialReviewer');
|
||||||
|
@ -23,9 +24,16 @@ final class DifferentialReviewersView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHighlightPHIDs(array $phids) {
|
||||||
|
$this->highlightPHIDs = $phids;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$view = new PHUIStatusListView();
|
$view = new PHUIStatusListView();
|
||||||
|
|
||||||
|
$highlighted = array_fuse($this->highlightPHIDs);
|
||||||
|
|
||||||
foreach ($this->reviewers as $reviewer) {
|
foreach ($this->reviewers as $reviewer) {
|
||||||
$phid = $reviewer->getReviewerPHID();
|
$phid = $reviewer->getReviewerPHID();
|
||||||
$handle = $this->handles[$phid];
|
$handle = $this->handles[$phid];
|
||||||
|
@ -38,6 +46,9 @@ final class DifferentialReviewersView extends AphrontView {
|
||||||
|
|
||||||
$item = new PHUIStatusItemView();
|
$item = new PHUIStatusItemView();
|
||||||
|
|
||||||
|
if (isset($highlighted[$phid])) {
|
||||||
|
$item->setHighlighted(true);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($reviewer->getStatus()) {
|
switch ($reviewer->getStatus()) {
|
||||||
case DifferentialReviewerStatus::STATUS_ADDED:
|
case DifferentialReviewerStatus::STATUS_ADDED:
|
||||||
|
|
Loading…
Reference in a new issue