@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.

Update rendering of policy edit transactions in Applications

Summary:
Ref T13411. Since circa D19829, transactions have rendered policy changes in a modern way, notably making "Custom Policy" clickable to show the policy rules.

Edit transactions in Applications still use a separate, older approach to render policies. This produces policy renderings which don't use modern quoting rules and don't link in a modern way.

Make Applications use the same rendering code that other transactions (like normal edit/view edits) use.

Test Plan: Edited policies in Applications, saw more useful transactions in the log. Clicked "Custom Policy" in the transaction log and got a useful explanation of the policy.

Maniphest Tasks: T13411

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

+9 -38
+8 -38
src/applications/meta/xactions/PhabricatorApplicationPolicyChangeTransaction.php
··· 52 52 } 53 53 54 54 public function getTitle() { 55 - $old = $this->renderApplicationPolicy($this->getOldValue()); 56 - $new = $this->renderApplicationPolicy($this->getNewValue()); 57 - 58 55 return pht( 59 - '%s changed the "%s" policy from "%s" to "%s".', 56 + '%s changed the %s policy from %s to %s.', 60 57 $this->renderAuthor(), 61 58 $this->renderCapability(), 62 - $old, 63 - $new); 59 + $this->renderOldPolicy(), 60 + $this->renderNewPolicy()); 64 61 } 65 62 66 63 public function getTitleForFeed() { ··· 68 65 $new = $this->renderApplicationPolicy($this->getNewValue()); 69 66 70 67 return pht( 71 - '%s changed the "%s" policy for application %s from "%s" to "%s".', 68 + '%s changed the %s policy for application %s from %s to %s.', 72 69 $this->renderAuthor(), 73 70 $this->renderCapability(), 74 71 $this->renderObject(), 75 - $old, 76 - $new); 72 + $this->renderOldPolicy(), 73 + $this->renderNewPolicy()); 77 74 } 78 75 79 76 public function validateTransactions($object, array $xactions) { ··· 165 162 return $errors; 166 163 } 167 164 168 - private function renderApplicationPolicy($name) { 169 - $policies = $this->getAllPolicies(); 170 - if (empty($policies[$name])) { 171 - // Not a standard policy, check for a custom policy. 172 - $policy = id(new PhabricatorPolicyQuery()) 173 - ->setViewer($this->getViewer()) 174 - ->withPHIDs(array($name)) 175 - ->executeOne(); 176 - $policies[$name] = $policy; 177 - } 178 - 179 - $policy = idx($policies, $name); 180 - return $this->renderValue($policy->getFullName()); 181 - } 182 - 183 - private function getAllPolicies() { 184 - if (!$this->policies) { 185 - $viewer = $this->getViewer(); 186 - $application = $this->getObject(); 187 - $this->policies = id(new PhabricatorPolicyQuery()) 188 - ->setViewer($viewer) 189 - ->setObject($application) 190 - ->execute(); 191 - } 192 - 193 - return $this->policies; 194 - } 195 - 196 165 private function renderCapability() { 197 166 $application = $this->getObject(); 198 167 $capability = $this->getCapabilityName(); 199 - return $application->getCapabilityLabel($capability); 168 + $label = $application->getCapabilityLabel($capability); 169 + return $this->renderValue($label); 200 170 } 201 171 202 172 private function getCapabilityName() {
+1
src/applications/transactions/controller/PhabricatorApplicationTransactionValueController.php
··· 33 33 case PhabricatorTransactions::TYPE_EDIT_POLICY: 34 34 case PhabricatorTransactions::TYPE_JOIN_POLICY: 35 35 case PhabricatorRepositoryPushPolicyTransaction::TRANSACTIONTYPE: 36 + case PhabricatorApplicationPolicyChangeTransaction::TRANSACTIONTYPE: 36 37 break; 37 38 default: 38 39 return new Aphront404Response();