@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support "Test Plan" with modular transactions and EditEngine

Summary: Ref T11114. The only real trick here is that we respect configuration in `differential.fields`.

Test Plan: Turned plan on and off, tried to remove the plan, edited the plan.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

Differential Revision: https://secure.phabricator.com/D17048

+139 -30
+2
src/__phutil_library_map__.php
··· 554 554 'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php', 555 555 'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php', 556 556 'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php', 557 + 'DifferentialRevisionTestPlanTransaction' => 'applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php', 557 558 'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php', 558 559 'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php', 559 560 'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php', ··· 5206 5207 'DifferentialRevisionStatus' => 'Phobject', 5207 5208 'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField', 5208 5209 'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType', 5210 + 'DifferentialRevisionTestPlanTransaction' => 'DifferentialRevisionTransactionType', 5209 5211 'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField', 5210 5212 'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType', 5211 5213 'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType',
+63 -30
src/applications/differential/editor/DifferentialRevisionEditEngine.php
··· 60 60 } 61 61 62 62 protected function buildCustomEditFields($object) { 63 - return array( 64 - id(new PhabricatorTextEditField()) 65 - ->setKey('title') 66 - ->setLabel(pht('Title')) 67 - ->setIsRequired(true) 63 + 64 + $plan_required = PhabricatorEnv::getEnvConfig( 65 + 'differential.require-test-plan-field'); 66 + $plan_enabled = $this->isCustomFieldEnabled( 67 + $object, 68 + 'differential:test-plan'); 69 + 70 + $fields = array(); 71 + $fields[] = id(new PhabricatorTextEditField()) 72 + ->setKey('title') 73 + ->setLabel(pht('Title')) 74 + ->setIsRequired(true) 75 + ->setTransactionType( 76 + DifferentialRevisionTitleTransaction::TRANSACTIONTYPE) 77 + ->setDescription(pht('The title of the revision.')) 78 + ->setConduitDescription(pht('Retitle the revision.')) 79 + ->setConduitTypeDescription(pht('New revision title.')) 80 + ->setValue($object->getTitle()); 81 + 82 + $fields[] = id(new PhabricatorRemarkupEditField()) 83 + ->setKey('summary') 84 + ->setLabel(pht('Summary')) 85 + ->setTransactionType( 86 + DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE) 87 + ->setDescription(pht('The summary of the revision.')) 88 + ->setConduitDescription(pht('Change the revision summary.')) 89 + ->setConduitTypeDescription(pht('New revision summary.')) 90 + ->setValue($object->getSummary()); 91 + 92 + if ($plan_enabled) { 93 + $fields[] = id(new PhabricatorRemarkupEditField()) 94 + ->setKey('testPlan') 95 + ->setLabel(pht('Test Plan')) 96 + ->setIsRequired($plan_required) 68 97 ->setTransactionType( 69 - DifferentialRevisionTitleTransaction::TRANSACTIONTYPE) 70 - ->setDescription(pht('The title of the revision.')) 71 - ->setConduitDescription(pht('Retitle the revision.')) 72 - ->setConduitTypeDescription(pht('New revision title.')) 73 - ->setValue($object->getTitle()), 74 - id(new PhabricatorRemarkupEditField()) 75 - ->setKey('summary') 76 - ->setLabel(pht('Summary')) 77 - ->setTransactionType( 78 - DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE) 79 - ->setDescription(pht('The summary of the revision.')) 80 - ->setConduitDescription(pht('Change the revision summary.')) 81 - ->setConduitTypeDescription(pht('New revision summary.')) 82 - ->setValue($object->getSummary()), 83 - id(new PhabricatorDatasourceEditField()) 84 - ->setKey('repositoryPHID') 85 - ->setLabel(pht('Repository')) 86 - ->setDatasource(new DiffusionRepositoryDatasource()) 87 - ->setTransactionType( 88 - DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE) 89 - ->setDescription(pht('The repository the revision belongs to.')) 90 - ->setConduitDescription(pht('Change the repository for this revision.')) 91 - ->setConduitTypeDescription(pht('New repository.')) 92 - ->setSingleValue($object->getRepositoryPHID()), 93 - ); 98 + DifferentialRevisionTestPlanTransaction::TRANSACTIONTYPE) 99 + ->setDescription( 100 + pht('Actions performed to verify the behavior of the change.')) 101 + ->setConduitDescription(pht('Update the revision test plan.')) 102 + ->setConduitTypeDescription(pht('New test plan.')) 103 + ->setValue($object->getTestPlan()); 104 + } 105 + 106 + $fields[] = id(new PhabricatorDatasourceEditField()) 107 + ->setKey('repositoryPHID') 108 + ->setLabel(pht('Repository')) 109 + ->setDatasource(new DiffusionRepositoryDatasource()) 110 + ->setTransactionType( 111 + DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE) 112 + ->setDescription(pht('The repository the revision belongs to.')) 113 + ->setConduitDescription(pht('Change the repository for this revision.')) 114 + ->setConduitTypeDescription(pht('New repository.')) 115 + ->setSingleValue($object->getRepositoryPHID()); 116 + 117 + return $fields; 118 + } 119 + 120 + private function isCustomFieldEnabled(DifferentialRevision $revision, $key) { 121 + $field_list = PhabricatorCustomField::getObjectFields( 122 + $revision, 123 + PhabricatorCustomField::ROLE_EDIT); 124 + 125 + $fields = $field_list->getFields(); 126 + return isset($fields[$key]); 94 127 } 95 128 96 129 }
+74
src/applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionTestPlanTransaction 4 + extends DifferentialRevisionTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'differential.revision.testplan'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getTestPlan(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setTestPlan($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s edited the test plan for this revision.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the test plan for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function hasChangeDetailView() { 30 + return true; 31 + } 32 + 33 + public function getMailDiffSectionHeader() { 34 + return pht('CHANGES TO TEST PLAN'); 35 + } 36 + 37 + public function newChangeDetailView() { 38 + $viewer = $this->getViewer(); 39 + 40 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 41 + ->setViewer($viewer) 42 + ->setOldText($this->getOldValue()) 43 + ->setNewText($this->getNewValue()); 44 + } 45 + 46 + public function newRemarkupChanges() { 47 + $changes = array(); 48 + 49 + $changes[] = $this->newRemarkupChange() 50 + ->setOldValue($this->getOldValue()) 51 + ->setNewValue($this->getNewValue()); 52 + 53 + return $changes; 54 + } 55 + 56 + public function validateTransactions($object, array $xactions) { 57 + $errors = array(); 58 + 59 + $is_required = PhabricatorEnv::getEnvConfig( 60 + 'differential.require-test-plan-field'); 61 + 62 + if ($is_required) { 63 + if ($this->isEmptyTextTransaction($object->getTestPlan(), $xactions)) { 64 + $errors[] = $this->newRequiredError( 65 + pht( 66 + 'You must provide a test plan. Describe the actions you '. 67 + 'performed to verify the behavior of this change.')); 68 + } 69 + } 70 + 71 + return $errors; 72 + } 73 + 74 + }