2013-10-05 16:54:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialReviewersView extends AphrontView {
|
|
|
|
|
|
|
|
private $reviewers;
|
|
|
|
private $handles;
|
|
|
|
private $diff;
|
|
|
|
|
|
|
|
public function setReviewers(array $reviewers) {
|
|
|
|
assert_instances_of($reviewers, 'DifferentialReviewer');
|
|
|
|
$this->reviewers = $reviewers;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setActiveDiff(DifferentialDiff $diff) {
|
|
|
|
$this->diff = $diff;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
2013-10-07 02:08:14 +02:00
|
|
|
$viewer = $this->getUser();
|
2013-10-05 20:50:00 +02:00
|
|
|
|
2013-10-07 02:08:14 +02:00
|
|
|
$view = new PHUIStatusListView();
|
2013-10-05 16:54:42 +02:00
|
|
|
foreach ($this->reviewers as $reviewer) {
|
|
|
|
$phid = $reviewer->getReviewerPHID();
|
|
|
|
$handle = $this->handles[$phid];
|
|
|
|
|
|
|
|
// If we're missing either the diff or action information for the
|
|
|
|
// reviewer, render information as current.
|
|
|
|
$is_current = (!$this->diff) ||
|
|
|
|
(!$reviewer->getDiffID()) ||
|
|
|
|
($this->diff->getID() == $reviewer->getDiffID());
|
|
|
|
|
|
|
|
$item = new PHUIStatusItemView();
|
|
|
|
|
2013-10-07 02:08:14 +02:00
|
|
|
$item->setHighlighted($reviewer->hasAuthority($viewer));
|
2013-10-05 16:54:42 +02:00
|
|
|
|
|
|
|
switch ($reviewer->getStatus()) {
|
|
|
|
case DifferentialReviewerStatus::STATUS_ADDED:
|
2014-05-17 03:59:02 +02:00
|
|
|
$item->setIcon(
|
|
|
|
PHUIStatusItemView::ICON_OPEN,
|
|
|
|
'bluegrey',
|
|
|
|
pht('Review Requested'));
|
2013-10-05 16:54:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DifferentialReviewerStatus::STATUS_ACCEPTED:
|
|
|
|
if ($is_current) {
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_ACCEPT,
|
|
|
|
'green',
|
2013-10-05 16:54:42 +02:00
|
|
|
pht('Accepted'));
|
|
|
|
} else {
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_ACCEPT,
|
|
|
|
'dark',
|
2013-10-05 16:54:42 +02:00
|
|
|
pht('Accepted Prior Diff'));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-03-05 19:47:29 +01:00
|
|
|
case DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER:
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_ACCEPT,
|
|
|
|
'dark',
|
2014-03-05 19:47:29 +01:00
|
|
|
pht('Accepted Prior Diff'));
|
|
|
|
break;
|
|
|
|
|
2013-10-05 16:54:42 +02:00
|
|
|
case DifferentialReviewerStatus::STATUS_REJECTED:
|
|
|
|
if ($is_current) {
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_REJECT,
|
|
|
|
'red',
|
2013-10-05 16:54:42 +02:00
|
|
|
pht('Requested Changes'));
|
|
|
|
} else {
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_REJECT,
|
|
|
|
'dark',
|
2013-10-05 16:54:42 +02:00
|
|
|
pht('Requested Changes to Prior Diff'));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-03-05 19:47:29 +01:00
|
|
|
case DifferentialReviewerStatus::STATUS_REJECTED_OLDER:
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_REJECT,
|
|
|
|
'dark',
|
2014-03-05 19:47:29 +01:00
|
|
|
pht('Rejected Prior Diff'));
|
|
|
|
break;
|
|
|
|
|
2013-10-05 16:54:42 +02:00
|
|
|
case DifferentialReviewerStatus::STATUS_COMMENTED:
|
|
|
|
if ($is_current) {
|
|
|
|
$item->setIcon(
|
2014-05-17 03:59:02 +02:00
|
|
|
PHUIStatusItemView::ICON_INFO,
|
|
|
|
'bluegrey',
|
2013-10-05 16:54:42 +02:00
|
|
|
pht('Commented'));
|
|
|
|
} else {
|
|
|
|
$item->setIcon(
|
|
|
|
'info-dark',
|
|
|
|
pht('Commented Previously'));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-10-07 02:09:24 +02:00
|
|
|
case DifferentialReviewerStatus::STATUS_BLOCKING:
|
2014-05-17 03:59:02 +02:00
|
|
|
$item->setIcon(
|
|
|
|
PHUIStatusItemView::ICON_MINUS,
|
|
|
|
'red',
|
|
|
|
pht('Blocking Review'));
|
2013-10-07 02:09:24 +02:00
|
|
|
break;
|
|
|
|
|
2013-10-05 16:54:42 +02:00
|
|
|
default:
|
2014-05-17 03:59:02 +02:00
|
|
|
$item->setIcon(
|
|
|
|
PHUIStatusItemView::ICON_QUESTION,
|
|
|
|
'bluegrey',
|
|
|
|
pht('%s?', $reviewer->getStatus()));
|
2013-10-05 16:54:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$item->setTarget($handle->renderLink());
|
|
|
|
$view->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|