Page MenuHomePhabricator

D19403.diff
No OneTemporary

D19403.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1430,6 +1430,7 @@
'HeraldActionGroup' => 'applications/herald/action/HeraldActionGroup.php',
'HeraldActionRecord' => 'applications/herald/storage/HeraldActionRecord.php',
'HeraldAdapter' => 'applications/herald/adapter/HeraldAdapter.php',
+ 'HeraldAdapterDatasource' => 'applications/herald/typeahead/HeraldAdapterDatasource.php',
'HeraldAlwaysField' => 'applications/herald/field/HeraldAlwaysField.php',
'HeraldAnotherRuleField' => 'applications/herald/field/HeraldAnotherRuleField.php',
'HeraldApplicationActionGroup' => 'applications/herald/action/HeraldApplicationActionGroup.php',
@@ -1486,9 +1487,12 @@
'HeraldRemarkupRule' => 'applications/herald/remarkup/HeraldRemarkupRule.php',
'HeraldRule' => 'applications/herald/storage/HeraldRule.php',
'HeraldRuleAdapter' => 'applications/herald/adapter/HeraldRuleAdapter.php',
+ 'HeraldRuleAdapterField' => 'applications/herald/field/rule/HeraldRuleAdapterField.php',
'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php',
'HeraldRuleDatasource' => 'applications/herald/typeahead/HeraldRuleDatasource.php',
'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php',
+ 'HeraldRuleField' => 'applications/herald/field/rule/HeraldRuleField.php',
+ 'HeraldRuleFieldGroup' => 'applications/herald/field/rule/HeraldRuleFieldGroup.php',
'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php',
'HeraldRulePHIDType' => 'applications/herald/phid/HeraldRulePHIDType.php',
'HeraldRuleQuery' => 'applications/herald/query/HeraldRuleQuery.php',
@@ -1500,6 +1504,8 @@
'HeraldRuleTransactionComment' => 'applications/herald/storage/HeraldRuleTransactionComment.php',
'HeraldRuleTranscript' => 'applications/herald/storage/transcript/HeraldRuleTranscript.php',
'HeraldRuleTypeConfig' => 'applications/herald/config/HeraldRuleTypeConfig.php',
+ 'HeraldRuleTypeDatasource' => 'applications/herald/typeahead/HeraldRuleTypeDatasource.php',
+ 'HeraldRuleTypeField' => 'applications/herald/field/rule/HeraldRuleTypeField.php',
'HeraldRuleViewController' => 'applications/herald/controller/HeraldRuleViewController.php',
'HeraldSchemaSpec' => 'applications/herald/storage/HeraldSchemaSpec.php',
'HeraldSelectFieldValue' => 'applications/herald/value/HeraldSelectFieldValue.php',
@@ -6852,6 +6858,7 @@
'HeraldActionGroup' => 'HeraldGroup',
'HeraldActionRecord' => 'HeraldDAO',
'HeraldAdapter' => 'Phobject',
+ 'HeraldAdapterDatasource' => 'PhabricatorTypeaheadDatasource',
'HeraldAlwaysField' => 'HeraldField',
'HeraldAnotherRuleField' => 'HeraldField',
'HeraldApplicationActionGroup' => 'HeraldActionGroup',
@@ -6921,9 +6928,12 @@
'PhabricatorSubscribableInterface',
),
'HeraldRuleAdapter' => 'HeraldAdapter',
+ 'HeraldRuleAdapterField' => 'HeraldRuleField',
'HeraldRuleController' => 'HeraldController',
'HeraldRuleDatasource' => 'PhabricatorTypeaheadDatasource',
'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'HeraldRuleField' => 'HeraldField',
+ 'HeraldRuleFieldGroup' => 'HeraldFieldGroup',
'HeraldRuleListController' => 'HeraldController',
'HeraldRulePHIDType' => 'PhabricatorPHIDType',
'HeraldRuleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@@ -6935,6 +6945,8 @@
'HeraldRuleTransactionComment' => 'PhabricatorApplicationTransactionComment',
'HeraldRuleTranscript' => 'Phobject',
'HeraldRuleTypeConfig' => 'Phobject',
+ 'HeraldRuleTypeDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'HeraldRuleTypeField' => 'HeraldRuleField',
'HeraldRuleViewController' => 'HeraldController',
'HeraldSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'HeraldSelectFieldValue' => 'HeraldFieldValue',
diff --git a/src/applications/herald/field/rule/HeraldRuleAdapterField.php b/src/applications/herald/field/rule/HeraldRuleAdapterField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/rule/HeraldRuleAdapterField.php
@@ -0,0 +1,29 @@
+<?php
+
+final class HeraldRuleAdapterField
+ extends HeraldRuleField {
+
+ const FIELDCONST = 'adapter';
+
+ public function getHeraldFieldName() {
+ return pht('Content type');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $object->getContentType();
+ }
+
+ protected function getHeraldFieldStandardType() {
+ return self::STANDARD_PHID;
+ }
+
+ protected function getDatasource() {
+ return new HeraldAdapterDatasource();
+ }
+
+ protected function getDatasourceValueMap() {
+ $adapters = HeraldAdapter::getAllAdapters();
+ return mpull($adapters, 'getAdapterContentName', 'getAdapterContentType');
+ }
+
+}
diff --git a/src/applications/herald/field/rule/HeraldRuleField.php b/src/applications/herald/field/rule/HeraldRuleField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/rule/HeraldRuleField.php
@@ -0,0 +1,14 @@
+<?php
+
+abstract class HeraldRuleField
+ extends HeraldField {
+
+ public function getFieldGroupKey() {
+ return ManiphestTaskHeraldFieldGroup::FIELDGROUPKEY;
+ }
+
+ public function supportsObject($object) {
+ return ($object instanceof HeraldRule);
+ }
+
+}
diff --git a/src/applications/herald/field/rule/HeraldRuleFieldGroup.php b/src/applications/herald/field/rule/HeraldRuleFieldGroup.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/rule/HeraldRuleFieldGroup.php
@@ -0,0 +1,16 @@
+<?php
+
+final class HeraldRuleFieldGroup
+ extends HeraldFieldGroup {
+
+ const FIELDGROUPKEY = 'herald.rule';
+
+ public function getGroupLabel() {
+ return pht('Rule Fields');
+ }
+
+ protected function getGroupOrder() {
+ return 500;
+ }
+
+}
diff --git a/src/applications/herald/field/rule/HeraldRuleTypeField.php b/src/applications/herald/field/rule/HeraldRuleTypeField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/rule/HeraldRuleTypeField.php
@@ -0,0 +1,28 @@
+<?php
+
+final class HeraldRuleTypeField
+ extends HeraldRuleField {
+
+ const FIELDCONST = 'rule-type';
+
+ public function getHeraldFieldName() {
+ return pht('Rule type');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $object->getRuleType();
+ }
+
+ protected function getHeraldFieldStandardType() {
+ return self::STANDARD_PHID;
+ }
+
+ protected function getDatasource() {
+ return new HeraldRuleTypeDatasource();
+ }
+
+ protected function getDatasourceValueMap() {
+ return HeraldRuleTypeConfig::getRuleTypeMap();
+ }
+
+}
diff --git a/src/applications/herald/typeahead/HeraldAdapterDatasource.php b/src/applications/herald/typeahead/HeraldAdapterDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/typeahead/HeraldAdapterDatasource.php
@@ -0,0 +1,45 @@
+<?php
+
+final class HeraldAdapterDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Herald Adapters');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type an adapter name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorHeraldApplication';
+ }
+
+ public function loadResults() {
+ $results = $this->buildResults();
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function renderSpecialTokens(array $values) {
+ return $this->renderTokensFromResults($this->buildResults(), $values);
+ }
+
+ private function buildResults() {
+ $results = array();
+
+ $adapters = HeraldAdapter::getAllAdapters();
+ foreach ($adapters as $adapter) {
+ $value = $adapter->getAdapterContentType();
+ $name = $adapter->getAdapterContentName();
+
+ $result = id(new PhabricatorTypeaheadResult())
+ ->setPHID($value)
+ ->setName($name);
+
+ $results[$value] = $result;
+ }
+
+ return $results;
+ }
+
+}
diff --git a/src/applications/herald/typeahead/HeraldRuleTypeDatasource.php b/src/applications/herald/typeahead/HeraldRuleTypeDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/typeahead/HeraldRuleTypeDatasource.php
@@ -0,0 +1,42 @@
+<?php
+
+final class HeraldRuleTypeDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Rule Types');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a rule type...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorHeraldApplication';
+ }
+
+ public function loadResults() {
+ $results = $this->buildResults();
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function renderSpecialTokens(array $values) {
+ return $this->renderTokensFromResults($this->buildResults(), $values);
+ }
+
+ private function buildResults() {
+ $results = array();
+
+ $type_map = HeraldRuleTypeConfig::getRuleTypeMap();
+ foreach ($type_map as $type => $name) {
+ $result = id(new PhabricatorTypeaheadResult())
+ ->setPHID($type)
+ ->setName($name);
+
+ $results[$type] = $result;
+ }
+
+ return $results;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 12:46 PM (9 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6926298
Default Alt Text
D19403.diff (9 KB)

Event Timeline