Differential D17053 Diff 41022 src/applications/differential/editor/DifferentialRevisionEditEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialRevisionEditEngine.php
| <?php | <?php | ||||
| final class DifferentialRevisionEditEngine | final class DifferentialRevisionEditEngine | ||||
| extends PhabricatorEditEngine { | extends PhabricatorEditEngine { | ||||
| private $diff; | |||||
| const ENGINECONST = 'differential.revision'; | const ENGINECONST = 'differential.revision'; | ||||
| public function getEngineName() { | public function getEngineName() { | ||||
| return pht('Revisions'); | return pht('Revisions'); | ||||
| } | } | ||||
| public function getSummaryHeader() { | public function getSummaryHeader() { | ||||
| return pht('Configure Revision Forms'); | return pht('Configure Revision Forms'); | ||||
| Show All 14 Lines | final class DifferentialRevisionEditEngine | ||||
| protected function newEditableObject() { | protected function newEditableObject() { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| return DifferentialRevision::initializeNewRevision($viewer); | return DifferentialRevision::initializeNewRevision($viewer); | ||||
| } | } | ||||
| protected function newObjectQuery() { | protected function newObjectQuery() { | ||||
| return id(new DifferentialRevisionQuery()) | return id(new DifferentialRevisionQuery()) | ||||
| ->needActiveDiffs(true) | |||||
| ->needReviewerStatus(true); | ->needReviewerStatus(true); | ||||
| } | } | ||||
| protected function getObjectCreateTitleText($object) { | protected function getObjectCreateTitleText($object) { | ||||
| return pht('Create New Revision'); | return pht('Create New Revision'); | ||||
| } | } | ||||
| protected function getObjectEditTitleText($object) { | protected function getObjectEditTitleText($object) { | ||||
| return pht('Edit Revision: %s', $object->getTitle()); | $monogram = $object->getMonogram(); | ||||
| $title = $object->getTitle(); | |||||
| $diff = $this->getDiff(); | |||||
| if ($diff) { | |||||
| return pht('Update Revision %s: %s', $monogram, $title); | |||||
| } else { | |||||
| return pht('Edit Revision %s: %s', $monogram, $title); | |||||
| } | |||||
| } | } | ||||
| protected function getObjectEditShortText($object) { | protected function getObjectEditShortText($object) { | ||||
| return $object->getMonogram(); | return $object->getMonogram(); | ||||
| } | } | ||||
| protected function getObjectCreateShortText() { | protected function getObjectCreateShortText() { | ||||
| return pht('Create Revision'); | return pht('Create Revision'); | ||||
| } | } | ||||
| protected function getObjectName() { | protected function getObjectName() { | ||||
| return pht('Revision'); | return pht('Revision'); | ||||
| } | } | ||||
| protected function getObjectViewURI($object) { | protected function getObjectViewURI($object) { | ||||
| return $object->getURI(); | return $object->getURI(); | ||||
| } | } | ||||
| public function setDiff(DifferentialDiff $diff) { | |||||
| $this->diff = $diff; | |||||
| return $this; | |||||
| } | |||||
| public function getDiff() { | |||||
| return $this->diff; | |||||
| } | |||||
| protected function buildCustomEditFields($object) { | protected function buildCustomEditFields($object) { | ||||
| $plan_required = PhabricatorEnv::getEnvConfig( | $plan_required = PhabricatorEnv::getEnvConfig( | ||||
| 'differential.require-test-plan-field'); | 'differential.require-test-plan-field'); | ||||
| $plan_enabled = $this->isCustomFieldEnabled( | $plan_enabled = $this->isCustomFieldEnabled( | ||||
| $object, | $object, | ||||
| 'differential:test-plan'); | 'differential:test-plan'); | ||||
| $diff = $this->getDiff(); | |||||
| if ($diff) { | |||||
| $diff_phid = $diff->getPHID(); | |||||
| } else { | |||||
| $diff_phid = null; | |||||
| } | |||||
| $is_update = ($diff && $object->getID()); | |||||
| $fields = array(); | $fields = array(); | ||||
| $fields[] = id(new PhabricatorHandlesEditField()) | |||||
| ->setKey('update') | |||||
| ->setLabel(pht('Update Diff')) | |||||
| ->setDescription(pht('New diff to create or update the revision with.')) | |||||
| ->setConduitDescription(pht('Create or update a revision with a diff.')) | |||||
| ->setConduitTypeDescription(pht('PHID of the diff.')) | |||||
| ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) | |||||
| ->setHandleParameterType(new AphrontPHIDListHTTPParameterType()) | |||||
| ->setSingleValue($diff_phid) | |||||
| ->setIsReorderable(false) | |||||
| ->setIsDefaultable(false) | |||||
| ->setIsInvisible(true) | |||||
| ->setIsLockable(false); | |||||
| if ($is_update) { | |||||
| $fields[] = id(new PhabricatorInstructionsEditField()) | |||||
| ->setKey('update.help') | |||||
| ->setValue(pht('Describe the updates you have made to the diff.')); | |||||
| $fields[] = id(new PhabricatorCommentEditField()) | |||||
| ->setKey('update.comment') | |||||
| ->setLabel(pht('Comment')) | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) | |||||
| ->setIsWebOnly(true) | |||||
| ->setDescription(pht('Comments providing context for the update.')); | |||||
| $fields[] = id(new PhabricatorSubmitEditField()) | |||||
| ->setKey('update.submit') | |||||
| ->setValue($this->getObjectEditButtonText($object)); | |||||
| $fields[] = id(new PhabricatorDividerEditField()) | |||||
| ->setKey('update.note'); | |||||
| } | |||||
| $fields[] = id(new PhabricatorTextEditField()) | $fields[] = id(new PhabricatorTextEditField()) | ||||
| ->setKey('title') | ->setKey('title') | ||||
| ->setLabel(pht('Title')) | ->setLabel(pht('Title')) | ||||
| ->setIsRequired(true) | ->setIsRequired(true) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| DifferentialRevisionTitleTransaction::TRANSACTIONTYPE) | DifferentialRevisionTitleTransaction::TRANSACTIONTYPE) | ||||
| ->setDescription(pht('The title of the revision.')) | ->setDescription(pht('The title of the revision.')) | ||||
| ->setConduitDescription(pht('Retitle the revision.')) | ->setConduitDescription(pht('Retitle the revision.')) | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||