3 final class DifferentialReviewersView
extends AphrontView
{
9 public function setReviewers(array $reviewers) {
10 assert_instances_of($reviewers, 'DifferentialReviewer');
11 $this->reviewers
= $reviewers;
15 public function setHandles(array $handles) {
16 assert_instances_of($handles, 'PhabricatorObjectHandle');
17 $this->handles
= $handles;
21 public function setActiveDiff(DifferentialDiff
$diff) {
26 public function render() {
27 $viewer = $this->getUser();
28 $reviewers = $this->reviewers
;
30 $handles = $this->handles
;
32 $view = new PHUIStatusListView();
34 // Move resigned reviewers to the bottom.
37 foreach ($reviewers as $key => $reviewer) {
38 if ($reviewer->isResigned()) {
39 $tail[$key] = $reviewer;
41 $head[$key] = $reviewer;
45 PhabricatorPolicyFilterSet
::loadHandleViewCapabilities(
50 $reviewers = $head +
$tail;
51 foreach ($reviewers as $reviewer) {
52 $phid = $reviewer->getReviewerPHID();
53 $handle = $handles[$phid];
55 $action_phid = $reviewer->getLastActionDiffPHID();
56 $is_current_action = $this->isCurrent($action_phid);
57 $is_voided = (bool)$reviewer->getVoidedPHID();
59 $comment_phid = $reviewer->getLastCommentDiffPHID();
60 $is_current_comment = $this->isCurrent($comment_phid);
62 $item = new PHUIStatusItemView();
64 $item->setHighlighted($reviewer->hasAuthority($viewer));
66 // If someone other than the reviewer acted on the reviewer's behalf,
67 // show who is responsible for the current state. This is usually a
68 // user accepting for a package or project.
69 $authority_phid = $reviewer->getLastActorPHID();
70 if ($authority_phid && ($authority_phid !== $phid)) {
71 $authority_name = $viewer->renderHandle($authority_phid)
74 $authority_name = null;
77 switch ($reviewer->getReviewerStatus()) {
78 case DifferentialReviewerStatus
::STATUS_ADDED
:
80 if ($is_current_comment) {
83 $label = pht('Commented');
85 $icon = 'fa-comment-o';
87 $label = pht('Commented Previously');
90 $icon = PHUIStatusItemView
::ICON_OPEN
;
92 $label = pht('Review Requested');
96 case DifferentialReviewerStatus
::STATUS_ACCEPTED
:
97 if ($is_current_action && !$is_voided) {
98 $icon = PHUIStatusItemView
::ICON_ACCEPT
;
100 if ($authority_name !== null) {
101 $label = pht('Accepted (by %s)', $authority_name);
103 $label = pht('Accepted');
106 $icon = 'fa-check-circle-o';
109 if (!$is_current_action && $is_voided) {
110 // The reviewer accepted the revision, but later the author
111 // used "Request Review" to request an updated review.
112 $label = pht('Accepted Earlier');
113 } else if ($authority_name !== null) {
114 $label = pht('Accepted Prior Diff (by %s)', $authority_name);
116 $label = pht('Accepted Prior Diff');
121 case DifferentialReviewerStatus
::STATUS_REJECTED
:
122 if ($is_current_action) {
123 $icon = PHUIStatusItemView
::ICON_REJECT
;
125 if ($authority_name !== null) {
126 $label = pht('Requested Changes (by %s)', $authority_name);
128 $label = pht('Requested Changes');
131 $icon = 'fa-times-circle-o';
133 if ($authority_name !== null) {
135 'Requested Changes to Prior Diff (by %s)',
138 $label = pht('Requested Changes to Prior Diff');
143 case DifferentialReviewerStatus
::STATUS_BLOCKING
:
144 $icon = PHUIStatusItemView
::ICON_MINUS
;
146 $label = pht('Blocking Review');
149 case DifferentialReviewerStatus
::STATUS_RESIGNED
:
152 $label = pht('Resigned');
156 $icon = PHUIStatusItemView
::ICON_QUESTION
;
158 $label = pht('Unknown ("%s")', $reviewer->getReviewerStatus());
163 $item->setIcon($icon, $color, $label);
165 $handle->renderHovercardLink(
169 if ($reviewer->isPackage()) {
170 if (!$reviewer->getChangesets()) {
171 $item->setNote(pht('(Owns No Changed Paths)'));
175 if ($handle->hasCapabilities()) {
176 if (!$handle->hasViewCapability($diff)) {
178 ->setIcon('fa-eye-slash', 'red')
179 ->setNote(pht('No View Permission'))
184 $view->addItem($item);
190 private function isCurrent($action_phid) {
199 $diff_phid = $this->diff
->getPHID();
204 if ($diff_phid == $action_phid) {