2011-01-27 23:55:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionDetailView extends AphrontView {
|
|
|
|
|
|
|
|
private $revision;
|
|
|
|
private $actions;
|
2011-04-13 03:17:43 +02:00
|
|
|
private $user;
|
2011-08-10 22:46:01 +02:00
|
|
|
private $auxiliaryFields = array();
|
2012-12-11 23:59:27 +01:00
|
|
|
private $diff;
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
public function setDiff(DifferentialDiff $diff) {
|
|
|
|
$this->diff = $diff;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function getDiff() {
|
|
|
|
return $this->diff;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRevision(DifferentialRevision $revision) {
|
2011-01-27 23:55:52 +01:00
|
|
|
$this->revision = $revision;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setActions(array $actions) {
|
|
|
|
$this->actions = $actions;
|
|
|
|
return $this;
|
|
|
|
}
|
2012-12-11 23:59:27 +01:00
|
|
|
private function getActions() {
|
|
|
|
return $this->actions;
|
|
|
|
}
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
public function setUser(PhabricatorUser $user) {
|
2011-04-13 03:17:43 +02:00
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
|
|
}
|
2012-12-11 23:59:27 +01:00
|
|
|
private function getUser() {
|
|
|
|
return $this->user;
|
|
|
|
}
|
2011-04-13 03:17:43 +02:00
|
|
|
|
2011-08-10 22:46:01 +02:00
|
|
|
public function setAuxiliaryFields(array $fields) {
|
2012-04-04 01:35:35 +02:00
|
|
|
assert_instances_of($fields, 'DifferentialFieldSpecification');
|
2011-08-10 22:46:01 +02:00
|
|
|
$this->auxiliaryFields = $fields;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-01-27 23:55:52 +01:00
|
|
|
public function render() {
|
|
|
|
|
|
|
|
require_celerity_resource('differential-core-view-css');
|
|
|
|
|
|
|
|
$revision = $this->revision;
|
2012-12-11 23:59:27 +01:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
|
|
$header = $this->renderHeader($revision);
|
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
->setUser($user)
|
|
|
|
->setObject($revision);
|
|
|
|
foreach ($this->getActions() as $action) {
|
|
|
|
$obj = id(new PhabricatorActionView())
|
|
|
|
->setIcon(idx($action, 'icon', 'edit'))
|
|
|
|
->setName($action['name'])
|
|
|
|
->setHref(idx($action, 'href'))
|
|
|
|
->setWorkflow(idx($action, 'sigil') == 'workflow')
|
|
|
|
->setUser($user)
|
|
|
|
->setDisabled(idx($action, 'disabled', false));
|
|
|
|
$actions->addAction($obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
$properties = new PhabricatorPropertyListView();
|
|
|
|
$status = $revision->getStatus();
|
|
|
|
$local_vcs = $this->getDiff()->getSourceControlSystem();
|
|
|
|
|
|
|
|
$next_step = null;
|
|
|
|
if ($status == ArcanistDifferentialRevisionStatus::ACCEPTED) {
|
|
|
|
switch ($local_vcs) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
|
|
|
$next_step = '<tt>arc land</tt>';
|
|
|
|
break;
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
$next_step = '<tt>arc commit</tt>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($next_step) {
|
|
|
|
$properties->addProperty('Next Step:', $next_step);
|
|
|
|
}
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2011-08-10 22:46:01 +02:00
|
|
|
foreach ($this->auxiliaryFields as $field) {
|
|
|
|
$value = $field->renderValueForRevisionView();
|
2011-12-17 01:31:02 +01:00
|
|
|
if (strlen($value)) {
|
2012-03-30 23:12:10 +02:00
|
|
|
$label = rtrim($field->renderLabelForRevisionView(), ':');
|
2012-12-11 23:59:27 +01:00
|
|
|
$properties->addProperty($label, $value);
|
2011-08-10 22:46:01 +02:00
|
|
|
}
|
|
|
|
}
|
2012-12-11 23:59:27 +01:00
|
|
|
$properties->setHasKeyboardShortcuts(true);
|
2011-08-10 22:46:01 +02:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
return $header->render() . $actions->render() . $properties->render();
|
|
|
|
}
|
2011-02-20 21:50:28 +01:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
private function renderHeader(DifferentialRevision $revision) {
|
|
|
|
$view = id(new PhabricatorHeaderView())
|
|
|
|
->setObjectName('D'.$revision->getID())
|
|
|
|
->setHeader($revision->getTitle());
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
$status = $revision->getStatus();
|
|
|
|
$status_name =
|
|
|
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
|
|
|
|
$status_color =
|
|
|
|
DifferentialRevisionStatus::getRevisionStatusTagColor($status);
|
2012-03-30 23:12:10 +02:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
$view->addTag(
|
|
|
|
id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE)
|
|
|
|
->setName($status_name)
|
|
|
|
->setBackgroundColor($status_color)
|
|
|
|
);
|
2012-03-30 23:12:10 +02:00
|
|
|
|
2012-12-11 23:59:27 +01:00
|
|
|
return $view;
|
2011-01-27 23:55:52 +01:00
|
|
|
}
|
|
|
|
}
|