1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 19:02:41 +01:00
phorge-phorge/src/applications/differential/view/DifferentialRevisionDetailView.php

122 lines
3.3 KiB
PHP
Raw Normal View History

2011-01-27 23:55:52 +01:00
<?php
final class DifferentialRevisionDetailView extends AphrontView {
private $revision;
private $actions;
private $user;
private $auxiliaryFields = array();
private $diff;
2011-01-27 23:55:52 +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;
}
private function getActions() {
return $this->actions;
}
2011-01-27 23:55:52 +01:00
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
private function getUser() {
return $this->user;
}
public function setAuxiliaryFields(array $fields) {
assert_instances_of($fields, 'DifferentialFieldSpecification');
$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;
$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
foreach ($this->auxiliaryFields as $field) {
$value = $field->renderValueForRevisionView();
if (strlen($value)) {
$label = rtrim($field->renderLabelForRevisionView(), ':');
$properties->addProperty($label, $value);
}
}
$properties->setHasKeyboardShortcuts(true);
return $header->render() . $actions->render() . $properties->render();
}
private function renderHeader(DifferentialRevision $revision) {
$view = id(new PhabricatorHeaderView())
->setObjectName('D'.$revision->getID())
->setHeader($revision->getTitle());
2011-01-27 23:55:52 +01:00
$status = $revision->getStatus();
$status_name =
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
$status_color =
DifferentialRevisionStatus::getRevisionStatusTagColor($status);
$view->addTag(
id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_STATE)
->setName($status_name)
->setBackgroundColor($status_color)
);
return $view;
2011-01-27 23:55:52 +01:00
}
}