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

Add "Content type" and "Rule type" fields to Herald rules for Herald rules

Summary:
Depends on D19400. Ref T13130. Currently, when you write Herald rules about other Herald rules, you can't pick a rule type or content type, so there's no way to get notified about edits to just global rules (which is the primary driving use case).

Add a "Content type" field to let the rule match rules that affect revisions, tasks, commits, etc.

Add a "Rule type" field to let the rule match global, personal, or object rules.

Test Plan:
- Wrote a global rule for other rules about global Herald rules:

{F5540307}

{F5540308}

- Ran it against itself which matched:

{F5540309}

- Ran it against another rule (not a global rule about Herald rules), which did not match:

{F5540311}

- Also reviewed the fields in those transcripts in more detail to make sure they were extracting matching correctly.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13130

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

+186
+12
src/__phutil_library_map__.php
··· 1430 1430 'HeraldActionGroup' => 'applications/herald/action/HeraldActionGroup.php', 1431 1431 'HeraldActionRecord' => 'applications/herald/storage/HeraldActionRecord.php', 1432 1432 'HeraldAdapter' => 'applications/herald/adapter/HeraldAdapter.php', 1433 + 'HeraldAdapterDatasource' => 'applications/herald/typeahead/HeraldAdapterDatasource.php', 1433 1434 'HeraldAlwaysField' => 'applications/herald/field/HeraldAlwaysField.php', 1434 1435 'HeraldAnotherRuleField' => 'applications/herald/field/HeraldAnotherRuleField.php', 1435 1436 'HeraldApplicationActionGroup' => 'applications/herald/action/HeraldApplicationActionGroup.php', ··· 1486 1487 'HeraldRemarkupRule' => 'applications/herald/remarkup/HeraldRemarkupRule.php', 1487 1488 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', 1488 1489 'HeraldRuleAdapter' => 'applications/herald/adapter/HeraldRuleAdapter.php', 1490 + 'HeraldRuleAdapterField' => 'applications/herald/field/rule/HeraldRuleAdapterField.php', 1489 1491 'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php', 1490 1492 'HeraldRuleDatasource' => 'applications/herald/typeahead/HeraldRuleDatasource.php', 1491 1493 'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php', 1494 + 'HeraldRuleField' => 'applications/herald/field/rule/HeraldRuleField.php', 1495 + 'HeraldRuleFieldGroup' => 'applications/herald/field/rule/HeraldRuleFieldGroup.php', 1492 1496 'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php', 1493 1497 'HeraldRulePHIDType' => 'applications/herald/phid/HeraldRulePHIDType.php', 1494 1498 'HeraldRuleQuery' => 'applications/herald/query/HeraldRuleQuery.php', ··· 1500 1504 'HeraldRuleTransactionComment' => 'applications/herald/storage/HeraldRuleTransactionComment.php', 1501 1505 'HeraldRuleTranscript' => 'applications/herald/storage/transcript/HeraldRuleTranscript.php', 1502 1506 'HeraldRuleTypeConfig' => 'applications/herald/config/HeraldRuleTypeConfig.php', 1507 + 'HeraldRuleTypeDatasource' => 'applications/herald/typeahead/HeraldRuleTypeDatasource.php', 1508 + 'HeraldRuleTypeField' => 'applications/herald/field/rule/HeraldRuleTypeField.php', 1503 1509 'HeraldRuleViewController' => 'applications/herald/controller/HeraldRuleViewController.php', 1504 1510 'HeraldSchemaSpec' => 'applications/herald/storage/HeraldSchemaSpec.php', 1505 1511 'HeraldSelectFieldValue' => 'applications/herald/value/HeraldSelectFieldValue.php', ··· 6852 6858 'HeraldActionGroup' => 'HeraldGroup', 6853 6859 'HeraldActionRecord' => 'HeraldDAO', 6854 6860 'HeraldAdapter' => 'Phobject', 6861 + 'HeraldAdapterDatasource' => 'PhabricatorTypeaheadDatasource', 6855 6862 'HeraldAlwaysField' => 'HeraldField', 6856 6863 'HeraldAnotherRuleField' => 'HeraldField', 6857 6864 'HeraldApplicationActionGroup' => 'HeraldActionGroup', ··· 6921 6928 'PhabricatorSubscribableInterface', 6922 6929 ), 6923 6930 'HeraldRuleAdapter' => 'HeraldAdapter', 6931 + 'HeraldRuleAdapterField' => 'HeraldRuleField', 6924 6932 'HeraldRuleController' => 'HeraldController', 6925 6933 'HeraldRuleDatasource' => 'PhabricatorTypeaheadDatasource', 6926 6934 'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor', 6935 + 'HeraldRuleField' => 'HeraldField', 6936 + 'HeraldRuleFieldGroup' => 'HeraldFieldGroup', 6927 6937 'HeraldRuleListController' => 'HeraldController', 6928 6938 'HeraldRulePHIDType' => 'PhabricatorPHIDType', 6929 6939 'HeraldRuleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', ··· 6935 6945 'HeraldRuleTransactionComment' => 'PhabricatorApplicationTransactionComment', 6936 6946 'HeraldRuleTranscript' => 'Phobject', 6937 6947 'HeraldRuleTypeConfig' => 'Phobject', 6948 + 'HeraldRuleTypeDatasource' => 'PhabricatorTypeaheadDatasource', 6949 + 'HeraldRuleTypeField' => 'HeraldRuleField', 6938 6950 'HeraldRuleViewController' => 'HeraldController', 6939 6951 'HeraldSchemaSpec' => 'PhabricatorConfigSchemaSpec', 6940 6952 'HeraldSelectFieldValue' => 'HeraldFieldValue',
+29
src/applications/herald/field/rule/HeraldRuleAdapterField.php
··· 1 + <?php 2 + 3 + final class HeraldRuleAdapterField 4 + extends HeraldRuleField { 5 + 6 + const FIELDCONST = 'adapter'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Content type'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $object->getContentType(); 14 + } 15 + 16 + protected function getHeraldFieldStandardType() { 17 + return self::STANDARD_PHID; 18 + } 19 + 20 + protected function getDatasource() { 21 + return new HeraldAdapterDatasource(); 22 + } 23 + 24 + protected function getDatasourceValueMap() { 25 + $adapters = HeraldAdapter::getAllAdapters(); 26 + return mpull($adapters, 'getAdapterContentName', 'getAdapterContentType'); 27 + } 28 + 29 + }
+14
src/applications/herald/field/rule/HeraldRuleField.php
··· 1 + <?php 2 + 3 + abstract class HeraldRuleField 4 + extends HeraldField { 5 + 6 + public function getFieldGroupKey() { 7 + return ManiphestTaskHeraldFieldGroup::FIELDGROUPKEY; 8 + } 9 + 10 + public function supportsObject($object) { 11 + return ($object instanceof HeraldRule); 12 + } 13 + 14 + }
+16
src/applications/herald/field/rule/HeraldRuleFieldGroup.php
··· 1 + <?php 2 + 3 + final class HeraldRuleFieldGroup 4 + extends HeraldFieldGroup { 5 + 6 + const FIELDGROUPKEY = 'herald.rule'; 7 + 8 + public function getGroupLabel() { 9 + return pht('Rule Fields'); 10 + } 11 + 12 + protected function getGroupOrder() { 13 + return 500; 14 + } 15 + 16 + }
+28
src/applications/herald/field/rule/HeraldRuleTypeField.php
··· 1 + <?php 2 + 3 + final class HeraldRuleTypeField 4 + extends HeraldRuleField { 5 + 6 + const FIELDCONST = 'rule-type'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Rule type'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $object->getRuleType(); 14 + } 15 + 16 + protected function getHeraldFieldStandardType() { 17 + return self::STANDARD_PHID; 18 + } 19 + 20 + protected function getDatasource() { 21 + return new HeraldRuleTypeDatasource(); 22 + } 23 + 24 + protected function getDatasourceValueMap() { 25 + return HeraldRuleTypeConfig::getRuleTypeMap(); 26 + } 27 + 28 + }
+45
src/applications/herald/typeahead/HeraldAdapterDatasource.php
··· 1 + <?php 2 + 3 + final class HeraldAdapterDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Herald Adapters'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type an adapter name...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorHeraldApplication'; 16 + } 17 + 18 + public function loadResults() { 19 + $results = $this->buildResults(); 20 + return $this->filterResultsAgainstTokens($results); 21 + } 22 + 23 + protected function renderSpecialTokens(array $values) { 24 + return $this->renderTokensFromResults($this->buildResults(), $values); 25 + } 26 + 27 + private function buildResults() { 28 + $results = array(); 29 + 30 + $adapters = HeraldAdapter::getAllAdapters(); 31 + foreach ($adapters as $adapter) { 32 + $value = $adapter->getAdapterContentType(); 33 + $name = $adapter->getAdapterContentName(); 34 + 35 + $result = id(new PhabricatorTypeaheadResult()) 36 + ->setPHID($value) 37 + ->setName($name); 38 + 39 + $results[$value] = $result; 40 + } 41 + 42 + return $results; 43 + } 44 + 45 + }
+42
src/applications/herald/typeahead/HeraldRuleTypeDatasource.php
··· 1 + <?php 2 + 3 + final class HeraldRuleTypeDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Rule Types'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type a rule type...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorHeraldApplication'; 16 + } 17 + 18 + public function loadResults() { 19 + $results = $this->buildResults(); 20 + return $this->filterResultsAgainstTokens($results); 21 + } 22 + 23 + protected function renderSpecialTokens(array $values) { 24 + return $this->renderTokensFromResults($this->buildResults(), $values); 25 + } 26 + 27 + private function buildResults() { 28 + $results = array(); 29 + 30 + $type_map = HeraldRuleTypeConfig::getRuleTypeMap(); 31 + foreach ($type_map as $type => $name) { 32 + $result = id(new PhabricatorTypeaheadResult()) 33 + ->setPHID($type) 34 + ->setName($name); 35 + 36 + $results[$type] = $result; 37 + } 38 + 39 + return $results; 40 + } 41 + 42 + }