2011-01-27 23:55:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionDetailView extends AphrontView {
|
|
|
|
|
|
|
|
private $revision;
|
|
|
|
private $actions;
|
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
|
|
|
|
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) {
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$properties->addProperty('Next Step', $next_step);
|
2012-12-11 23:59:27 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|