Differential D17048 Diff 41014 src/applications/differential/editor/DifferentialRevisionEditEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialRevisionEditEngine.php
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | protected function getObjectName() { | ||||
| return pht('Revision'); | return pht('Revision'); | ||||
| } | } | ||||
| protected function getObjectViewURI($object) { | protected function getObjectViewURI($object) { | ||||
| return $object->getURI(); | return $object->getURI(); | ||||
| } | } | ||||
| protected function buildCustomEditFields($object) { | protected function buildCustomEditFields($object) { | ||||
| return array( | |||||
| id(new PhabricatorTextEditField()) | $plan_required = PhabricatorEnv::getEnvConfig( | ||||
| 'differential.require-test-plan-field'); | |||||
| $plan_enabled = $this->isCustomFieldEnabled( | |||||
| $object, | |||||
| 'differential:test-plan'); | |||||
| $fields = array(); | |||||
| $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.')) | ||||
| ->setConduitTypeDescription(pht('New revision title.')) | ->setConduitTypeDescription(pht('New revision title.')) | ||||
| ->setValue($object->getTitle()), | ->setValue($object->getTitle()); | ||||
| id(new PhabricatorRemarkupEditField()) | |||||
| $fields[] = id(new PhabricatorRemarkupEditField()) | |||||
| ->setKey('summary') | ->setKey('summary') | ||||
| ->setLabel(pht('Summary')) | ->setLabel(pht('Summary')) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE) | DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE) | ||||
| ->setDescription(pht('The summary of the revision.')) | ->setDescription(pht('The summary of the revision.')) | ||||
| ->setConduitDescription(pht('Change the revision summary.')) | ->setConduitDescription(pht('Change the revision summary.')) | ||||
| ->setConduitTypeDescription(pht('New revision summary.')) | ->setConduitTypeDescription(pht('New revision summary.')) | ||||
| ->setValue($object->getSummary()), | ->setValue($object->getSummary()); | ||||
| id(new PhabricatorDatasourceEditField()) | |||||
| if ($plan_enabled) { | |||||
| $fields[] = id(new PhabricatorRemarkupEditField()) | |||||
| ->setKey('testPlan') | |||||
| ->setLabel(pht('Test Plan')) | |||||
| ->setIsRequired($plan_required) | |||||
| ->setTransactionType( | |||||
| DifferentialRevisionTestPlanTransaction::TRANSACTIONTYPE) | |||||
| ->setDescription( | |||||
| pht('Actions performed to verify the behavior of the change.')) | |||||
| ->setConduitDescription(pht('Update the revision test plan.')) | |||||
| ->setConduitTypeDescription(pht('New test plan.')) | |||||
| ->setValue($object->getTestPlan()); | |||||
| } | |||||
| $fields[] = id(new PhabricatorDatasourceEditField()) | |||||
| ->setKey('repositoryPHID') | ->setKey('repositoryPHID') | ||||
| ->setLabel(pht('Repository')) | ->setLabel(pht('Repository')) | ||||
| ->setDatasource(new DiffusionRepositoryDatasource()) | ->setDatasource(new DiffusionRepositoryDatasource()) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE) | DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE) | ||||
| ->setDescription(pht('The repository the revision belongs to.')) | ->setDescription(pht('The repository the revision belongs to.')) | ||||
| ->setConduitDescription(pht('Change the repository for this revision.')) | ->setConduitDescription(pht('Change the repository for this revision.')) | ||||
| ->setConduitTypeDescription(pht('New repository.')) | ->setConduitTypeDescription(pht('New repository.')) | ||||
| ->setSingleValue($object->getRepositoryPHID()), | ->setSingleValue($object->getRepositoryPHID()); | ||||
| ); | |||||
| return $fields; | |||||
| } | |||||
| private function isCustomFieldEnabled(DifferentialRevision $revision, $key) { | |||||
| $field_list = PhabricatorCustomField::getObjectFields( | |||||
| $revision, | |||||
| PhabricatorCustomField::ROLE_EDIT); | |||||
| $fields = $field_list->getFields(); | |||||
| return isset($fields[$key]); | |||||
| } | } | ||||
| } | } | ||||