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

Give Herald rules a standard "Hnnn" object name

Summary: Allow Herald rules to be referred to with `H123`, etc., like other object types are. Herald rules now have proper PHIDs and an increasingly prominent role in triggering application actions. Although I suspect users will rarely use `H123` in Remarkup to mention rules, this can simplify some of the interfaces which relate objects across systems.

Test Plan: Looked at various interfaces and saw `H123` names. Mentioned `H123` in remarkup.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+68 -10
+2
src/__phutil_library_map__.php
··· 758 758 'HeraldPholioMockAdapter' => 'applications/herald/adapter/HeraldPholioMockAdapter.php', 759 759 'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php', 760 760 'HeraldRecursiveConditionsException' => 'applications/herald/engine/exception/HeraldRecursiveConditionsException.php', 761 + 'HeraldRemarkupRule' => 'applications/herald/remarkup/HeraldRemarkupRule.php', 761 762 'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php', 762 763 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', 763 764 'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php', ··· 3181 3182 'HeraldPholioMockAdapter' => 'HeraldAdapter', 3182 3183 'HeraldPreCommitRefAdapter' => 'HeraldAdapter', 3183 3184 'HeraldRecursiveConditionsException' => 'Exception', 3185 + 'HeraldRemarkupRule' => 'PhabricatorRemarkupRuleObject', 3184 3186 'HeraldRule' => 3185 3187 array( 3186 3188 0 => 'HeraldDAO',
+6
src/applications/herald/application/PhabricatorApplicationHerald.php
··· 30 30 return self::GROUP_ORGANIZATION; 31 31 } 32 32 33 + public function getRemarkupRules() { 34 + return array( 35 + new HeraldRemarkupRule(), 36 + ); 37 + } 38 + 33 39 public function getRoutes() { 34 40 return array( 35 41 '/herald/' => array(
+1 -1
src/applications/herald/controller/HeraldRuleListController.php
··· 41 41 $id = $rule->getID(); 42 42 43 43 $item = id(new PHUIObjectItemView()) 44 - ->setObjectName(pht('Rule %s', $rule->getID())) 44 + ->setObjectName("H{$id}") 45 45 ->setHeader($rule->getName()) 46 46 ->setHref($this->getApplicationURI("rule/{$id}/")); 47 47
+3 -1
src/applications/herald/controller/HeraldRuleViewController.php
··· 41 41 $actions = $this->buildActionView($rule); 42 42 $properties = $this->buildPropertyView($rule, $actions); 43 43 44 + $id = $rule->getID(); 45 + 44 46 $crumbs = $this->buildApplicationCrumbs(); 45 47 $crumbs->addCrumb( 46 48 id(new PhabricatorCrumbView()) 47 - ->setName(pht('Rule %d', $rule->getID()))); 49 + ->setName("H{$id}")); 48 50 49 51 $object_box = id(new PHUIObjectBoxView()) 50 52 ->setHeader($header)
+3 -1
src/applications/herald/engine/HeraldEngine.php
··· 368 368 $name = $rule->getName(); 369 369 $id = $rule->getID(); 370 370 $effect->setReason( 371 - 'Conditions were met for Herald rule "'.$name.'" (#'.$id.').'); 371 + pht( 372 + 'Conditions were met for %s', 373 + "H{$id} {$name}")); 372 374 373 375 $effects[] = $effect; 374 376 }
+31 -1
src/applications/herald/phid/HeraldPHIDTypeRule.php
··· 35 35 $id = $rule->getID(); 36 36 $name = $rule->getName(); 37 37 38 - $handle->setName($name); 38 + $handle->setName("H{$id}"); 39 + $handle->setFullName("H{$id} {$name}"); 39 40 $handle->setURI("/herald/rule/{$id}/"); 40 41 } 42 + } 43 + 44 + public function canLoadNamedObject($name) { 45 + return preg_match('/^H\d*[1-9]\d*$/i', $name); 46 + } 47 + 48 + public function loadNamedObjects( 49 + PhabricatorObjectQuery $query, 50 + array $names) { 51 + 52 + $id_map = array(); 53 + foreach ($names as $name) { 54 + $id = (int)substr($name, 1); 55 + $id_map[$id][] = $name; 56 + } 57 + 58 + $objects = id(new HeraldRuleQuery()) 59 + ->setViewer($query->getViewer()) 60 + ->withIDs(array_keys($id_map)) 61 + ->execute(); 62 + 63 + $results = array(); 64 + foreach ($objects as $id => $object) { 65 + foreach (idx($id_map, $id, array()) as $name) { 66 + $results[$name] = $object; 67 + } 68 + } 69 + 70 + return $results; 41 71 } 42 72 43 73 }
+18
src/applications/herald/remarkup/HeraldRemarkupRule.php
··· 1 + <?php 2 + 3 + final class HeraldRemarkupRule 4 + extends PhabricatorRemarkupRuleObject { 5 + 6 + protected function getObjectNamePrefix() { 7 + return 'H'; 8 + } 9 + 10 + protected function loadObjects(array $ids) { 11 + $viewer = $this->getEngine()->getConfig('viewer'); 12 + return id(new HeraldRuleQuery()) 13 + ->setViewer($viewer) 14 + ->withIDs($ids) 15 + ->execute(); 16 + } 17 + 18 + }
+4 -6
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
··· 232 232 } 233 233 if ($status == PhabricatorAuditStatusConstants::AUDIT_REQUIRED) { 234 234 $reasons[] = pht( 235 - 'Herald Rule #%d "%s" Triggered Audit', 236 - $id, 237 - $rule_name); 235 + '%s Triggered Audit', 236 + "H{$id} {$rule_name}"); 238 237 } else { 239 238 $reasons[] = pht( 240 - 'Herald Rule #%d "%s" Triggered CC', 241 - $id, 242 - $rule_name); 239 + '%s Triggered CC', 240 + "H{$id} {$rule_name}"); 243 241 } 244 242 } 245 243