Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/view/DifferentialRevisionDetailView.php
| <?php | <?php | ||||
| final class DifferentialRevisionDetailView extends AphrontView { | final class DifferentialRevisionDetailView extends AphrontView { | ||||
| private $revision; | private $revision; | ||||
| private $actions; | private $actions; | ||||
| private $auxiliaryFields = array(); | private $customFields; | ||||
| private $diff; | private $diff; | ||||
| private $uri; | private $uri; | ||||
| public function setURI($uri) { | public function setURI($uri) { | ||||
| $this->uri = $uri; | $this->uri = $uri; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getURI() { | public function getURI() { | ||||
| Show All 16 Lines | final class DifferentialRevisionDetailView extends AphrontView { | ||||
| public function setActions(array $actions) { | public function setActions(array $actions) { | ||||
| $this->actions = $actions; | $this->actions = $actions; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| private function getActions() { | private function getActions() { | ||||
| return $this->actions; | return $this->actions; | ||||
| } | } | ||||
| public function setAuxiliaryFields(array $fields) { | public function setCustomFields(PhabricatorCustomFieldList $list) { | ||||
| assert_instances_of($fields, 'DifferentialFieldSpecification'); | $this->customFields = $list; | ||||
| $this->auxiliaryFields = $fields; | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function render() { | public function render() { | ||||
| $this->requireResource('differential-core-view-css'); | $this->requireResource('differential-core-view-css'); | ||||
| $revision = $this->revision; | $revision = $this->revision; | ||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| $header = $this->renderHeader($revision); | $header = $this->renderHeader($revision); | ||||
| $actions = id(new PhabricatorActionListView()) | $actions = id(new PhabricatorActionListView()) | ||||
| ->setUser($user) | ->setUser($user) | ||||
| ->setObject($revision) | ->setObject($revision) | ||||
| ->setObjectURI($this->getURI()); | ->setObjectURI($this->getURI()); | ||||
| foreach ($this->getActions() as $action) { | foreach ($this->getActions() as $action) { | ||||
| $obj = id(new PhabricatorActionView()) | $actions->addAction($action); | ||||
| ->setIcon(idx($action, 'icon', 'edit')) | |||||
| ->setName($action['name']) | |||||
| ->setHref(idx($action, 'href')) | |||||
| ->setWorkflow(idx($action, 'sigil') == 'workflow') | |||||
| ->setRenderAsForm(!empty($action['instant'])) | |||||
| ->setUser($user) | |||||
| ->setDisabled(idx($action, 'disabled', false)); | |||||
| $actions->addAction($obj); | |||||
| } | } | ||||
| $properties = id(new PHUIPropertyListView()) | $properties = id(new PHUIPropertyListView()) | ||||
| ->setUser($user) | ->setUser($user) | ||||
| ->setObject($revision); | ->setObject($revision); | ||||
| $status = $revision->getStatus(); | $status = $revision->getStatus(); | ||||
| $local_vcs = $this->getDiff()->getSourceControlSystem(); | $local_vcs = $this->getDiff()->getSourceControlSystem(); | ||||
| Show All 20 Lines | if ($status == ArcanistDifferentialRevisionStatus::ACCEPTED) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if ($next_step) { | if ($next_step) { | ||||
| $next_step = phutil_tag('tt', array(), $next_step); | $next_step = phutil_tag('tt', array(), $next_step); | ||||
| $properties->addProperty(pht('Next Step'), $next_step); | $properties->addProperty(pht('Next Step'), $next_step); | ||||
| } | } | ||||
| foreach ($this->auxiliaryFields as $field) { | |||||
| $value = $field->renderValueForRevisionView(); | |||||
| if ($value !== null) { | |||||
| $label = rtrim($field->renderLabelForRevisionView(), ':'); | |||||
| $properties->addProperty($label, $value); | |||||
| } | |||||
| } | |||||
| $properties->setHasKeyboardShortcuts(true); | $properties->setHasKeyboardShortcuts(true); | ||||
| $properties->setActionList($actions); | $properties->setActionList($actions); | ||||
| $properties->invokeWillRenderEvent(); | $field_list = $this->customFields; | ||||
| if ($field_list) { | |||||
| if (strlen($revision->getSummary())) { | $field_list->appendFieldsToPropertyList( | ||||
| $properties->addSectionHeader( | $revision, | ||||
| pht('Summary'), | $user, | ||||
| PHUIPropertyListView::ICON_SUMMARY); | $properties); | ||||
| $properties->addTextContent( | |||||
| PhabricatorMarkupEngine::renderOneObject( | |||||
| id(new PhabricatorMarkupOneOff()) | |||||
| ->setPreserveLinebreaks(true) | |||||
| ->setContent($revision->getSummary()), | |||||
| 'default', | |||||
| $user)); | |||||
| } | |||||
| if (strlen($revision->getTestPlan())) { | |||||
| $properties->addSectionHeader( | |||||
| pht('Test Plan'), | |||||
| PHUIPropertyListView::ICON_TESTPLAN); | |||||
| $properties->addTextContent( | |||||
| PhabricatorMarkupEngine::renderOneObject( | |||||
| id(new PhabricatorMarkupOneOff()) | |||||
| ->setPreserveLinebreaks(true) | |||||
| ->setContent($revision->getTestPlan()), | |||||
| 'default', | |||||
| $user)); | |||||
| } | } | ||||
| $object_box = id(new PHUIObjectBoxView()) | $object_box = id(new PHUIObjectBoxView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->addPropertyList($properties); | ->addPropertyList($properties); | ||||
| return $object_box; | return $object_box; | ||||
| } | } | ||||
| Show All 29 Lines | |||||