diff --git a/src/applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php b/src/applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php index 672aeb822f..53aa040560 100644 --- a/src/applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php @@ -27,9 +27,24 @@ final class DifferentialProjectReviewersFieldSpecification 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()) ->setReviewers($reviewers) - ->setHandles($this->getLoadedHandles()); + ->setHandles($this->getLoadedHandles()) + ->setHighlightPHIDs($highlight); $diff = $this->getRevision()->loadActiveDiff(); if ($diff) { diff --git a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php index 5ec9fb2614..f7fcf2056c 100644 --- a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php @@ -33,6 +33,7 @@ final class DifferentialReviewersFieldSpecification $view = id(new DifferentialReviewersView()) ->setReviewers($reviewers) + ->setHighlightPHIDs(array($this->getUser()->getPHID())) ->setHandles($this->getLoadedHandles()); $diff = $this->getRevision()->loadActiveDiff(); diff --git a/src/applications/differential/view/DifferentialReviewersView.php b/src/applications/differential/view/DifferentialReviewersView.php index b731054285..851af0afaa 100644 --- a/src/applications/differential/view/DifferentialReviewersView.php +++ b/src/applications/differential/view/DifferentialReviewersView.php @@ -5,6 +5,7 @@ final class DifferentialReviewersView extends AphrontView { private $reviewers; private $handles; private $diff; + private $highlightPHIDs = array(); public function setReviewers(array $reviewers) { assert_instances_of($reviewers, 'DifferentialReviewer'); @@ -23,9 +24,16 @@ final class DifferentialReviewersView extends AphrontView { return $this; } + public function setHighlightPHIDs(array $phids) { + $this->highlightPHIDs = $phids; + return $this; + } + public function render() { $view = new PHUIStatusListView(); + $highlighted = array_fuse($this->highlightPHIDs); + foreach ($this->reviewers as $reviewer) { $phid = $reviewer->getReviewerPHID(); $handle = $this->handles[$phid]; @@ -38,6 +46,9 @@ final class DifferentialReviewersView extends AphrontView { $item = new PHUIStatusItemView(); + if (isset($highlighted[$phid])) { + $item->setHighlighted(true); + } switch ($reviewer->getStatus()) { case DifferentialReviewerStatus::STATUS_ADDED: