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

Flesh out Conduit types for Paste search fields

Summary: Ref T9964. This fills in types and descriptions for ApplicationSearch fields in Paste.

Test Plan:
Got this nice table now:

{F1023999}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9964

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

+192 -26
+6
src/__phutil_library_map__.php
··· 228 228 'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php', 229 229 'ConduitConnectionGarbageCollector' => 'applications/conduit/garbagecollector/ConduitConnectionGarbageCollector.php', 230 230 'ConduitDeprecatedCallSetupCheck' => 'applications/conduit/check/ConduitDeprecatedCallSetupCheck.php', 231 + 'ConduitEpochParameterType' => 'applications/conduit/parametertype/ConduitEpochParameterType.php', 231 232 'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php', 232 233 'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php', 233 234 'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php', ··· 235 236 'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php', 236 237 'ConduitMethodDoesNotExistException' => 'applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php', 237 238 'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php', 239 + 'ConduitPHIDListParameterType' => 'applications/conduit/parametertype/ConduitPHIDListParameterType.php', 238 240 'ConduitParameterType' => 'applications/conduit/parametertype/ConduitParameterType.php', 239 241 'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php', 242 + 'ConduitProjectListParameterType' => 'applications/conduit/parametertype/ConduitProjectListParameterType.php', 240 243 'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php', 241 244 'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php', 242 245 'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php', ··· 4074 4077 'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod', 4075 4078 'ConduitConnectionGarbageCollector' => 'PhabricatorGarbageCollector', 4076 4079 'ConduitDeprecatedCallSetupCheck' => 'PhabricatorSetupCheck', 4080 + 'ConduitEpochParameterType' => 'ConduitListParameterType', 4077 4081 'ConduitException' => 'Exception', 4078 4082 'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod', 4079 4083 'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod', ··· 4081 4085 'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector', 4082 4086 'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException', 4083 4087 'ConduitMethodNotFoundException' => 'ConduitException', 4088 + 'ConduitPHIDListParameterType' => 'ConduitListParameterType', 4084 4089 'ConduitParameterType' => 'Phobject', 4085 4090 'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod', 4091 + 'ConduitProjectListParameterType' => 'ConduitListParameterType', 4086 4092 'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod', 4087 4093 'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 4088 4094 'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
+37
src/applications/conduit/parametertype/ConduitEpochParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitEpochParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $value = parent::getParameterValue($request, $key); 8 + 9 + if (!is_int($value)) { 10 + $this->raiseValidationException( 11 + $request, 12 + $key, 13 + pht('Expected integer, got something else.')); 14 + } 15 + 16 + return $value; 17 + } 18 + 19 + protected function getParameterTypeName() { 20 + return 'epoch'; 21 + } 22 + 23 + protected function getParameterFormatDescriptions() { 24 + return array( 25 + pht('Epoch timestamp, as an integer.'), 26 + ); 27 + } 28 + 29 + protected function getParameterExamples() { 30 + return array( 31 + '["PHID-PROJ-1111"]', 32 + '["backend"]', 33 + '["PHID-PROJ-2222", "frontend"]', 34 + ); 35 + } 36 + 37 + }
+17 -1
src/applications/conduit/parametertype/ConduitListParameterType.php
··· 4 4 extends ConduitParameterType { 5 5 6 6 protected function getParameterValue(array $request, $key) { 7 - $value = parent::getParameterValue(); 7 + $value = parent::getParameterValue($request, $key); 8 8 9 9 if (!is_array($value)) { 10 10 $this->raiseValidationException( ··· 28 28 } 29 29 30 30 return $value; 31 + } 32 + 33 + protected function validateStringList(array $request, $key, array $list) { 34 + foreach ($list as $idx => $item) { 35 + if (!is_string($item)) { 36 + $this->raiseValidationException( 37 + $request, 38 + $key, 39 + pht( 40 + 'Expected a list of strings, but item with index "%s" is '. 41 + 'not a string.', 42 + $idx)); 43 + } 44 + } 45 + 46 + return $list; 31 47 } 32 48 33 49 protected function getParameterDefault() {
+27
src/applications/conduit/parametertype/ConduitPHIDListParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitPHIDListParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $list = parent::getParameterValue($request, $key); 8 + return $this->validateStringList($request, $key, $list); 9 + } 10 + 11 + protected function getParameterTypeName() { 12 + return 'list<phid>'; 13 + } 14 + 15 + protected function getParameterFormatDescriptions() { 16 + return array( 17 + pht('List of PHIDs.'), 18 + ); 19 + } 20 + 21 + protected function getParameterExamples() { 22 + return array( 23 + '["PHID-WXYZ-1111", "PHID-WXYZ-2222"]', 24 + ); 25 + } 26 + 27 + }
+34
src/applications/conduit/parametertype/ConduitProjectListParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitProjectListParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $list = parent::getParameterValue($request, $key); 8 + $list = $this->validateStringList($request, $key, $list); 9 + return id(new PhabricatorProjectPHIDResolver()) 10 + ->setViewer($this->getViewer()) 11 + ->resolvePHIDs($list); 12 + } 13 + 14 + protected function getParameterTypeName() { 15 + return 'list<project>'; 16 + } 17 + 18 + protected function getParameterFormatDescriptions() { 19 + return array( 20 + pht('List of project PHIDs.'), 21 + pht('List of project tags.'), 22 + pht('List with a mixture of PHIDs and tags.'), 23 + ); 24 + } 25 + 26 + protected function getParameterExamples() { 27 + return array( 28 + '["PHID-PROJ-1111"]', 29 + '["backend"]', 30 + '["PHID-PROJ-2222", "frontend"]', 31 + ); 32 + } 33 + 34 + }
+2 -15
src/applications/conduit/parametertype/ConduitStringListParameterType.php
··· 4 4 extends ConduitListParameterType { 5 5 6 6 protected function getParameterValue(array $request, $key) { 7 - $list = parent::getParameterValue(); 8 - 9 - foreach ($list as $idx => $item) { 10 - if (!is_string($item)) { 11 - $this->raiseValidationException( 12 - $request, 13 - $key, 14 - pht( 15 - 'Expected a list of strings, but item with index "%s" is '. 16 - 'not a string.', 17 - $idx)); 18 - } 19 - } 20 - 21 - return $list; 7 + $list = parent::getParameterValue($request, $key); 8 + return $this->validateStringList($request, $key, $list); 22 9 } 23 10 24 11 protected function getParameterTypeName() {
+2 -1
src/applications/conduit/parametertype/ConduitUserListParameterType.php
··· 4 4 extends ConduitListParameterType { 5 5 6 6 protected function getParameterValue(array $request, $key) { 7 - $list = parent::getParameterValue(); 7 + $list = parent::getParameterValue($request, $key); 8 + $list = $this->validateStringList($request, $key, $list); 8 9 return id(new PhabricatorUserPHIDResolver()) 9 10 ->setViewer($this->getViewer()) 10 11 ->resolvePHIDs($list);
+14 -4
src/applications/paste/query/PhabricatorPasteSearchEngine.php
··· 48 48 ->setAliases(array('authors')) 49 49 ->setKey('authorPHIDs') 50 50 ->setConduitKey('authors') 51 - ->setLabel(pht('Authors')), 51 + ->setLabel(pht('Authors')) 52 + ->setDescription( 53 + pht('Search for pastes with specific authors.')), 52 54 id(new PhabricatorSearchStringListField()) 53 55 ->setKey('languages') 54 - ->setLabel(pht('Languages')), 56 + ->setLabel(pht('Languages')) 57 + ->setDescription( 58 + pht('Search for pastes highlighted in specific languages.')), 55 59 id(new PhabricatorSearchDateField()) 56 60 ->setKey('createdStart') 57 - ->setLabel(pht('Created After')), 61 + ->setLabel(pht('Created After')) 62 + ->setDescription( 63 + pht('Search for pastes created after a given time.')), 58 64 id(new PhabricatorSearchDateField()) 59 65 ->setKey('createdEnd') 60 - ->setLabel(pht('Created Before')), 66 + ->setLabel(pht('Created Before')) 67 + ->setDescription( 68 + pht('Search for pastes created before a given time.')), 61 69 id(new PhabricatorSearchCheckboxesField()) 62 70 ->setKey('statuses') 63 71 ->setLabel(pht('Status')) 72 + ->setDescription( 73 + pht('Search for archived or active pastes.')) 64 74 ->setOptions( 65 75 id(new PhabricatorPaste()) 66 76 ->getStatusNameMap()),
+3 -1
src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
··· 42 42 ->setKey('projectPHIDs') 43 43 ->setConduitKey('projects') 44 44 ->setAliases(array('project', 'projects')) 45 - ->setLabel(pht('Projects')); 45 + ->setLabel(pht('Projects')) 46 + ->setDescription( 47 + pht('Search for objects associated with given projects.')); 46 48 47 49 return $fields; 48 50 }
+4
src/applications/project/searchfield/PhabricatorProjectSearchField.php
··· 47 47 48 48 } 49 49 50 + protected function newConduitParameterType() { 51 + return new ConduitProjectListParameterType(); 52 + } 53 + 50 54 }
+1 -2
src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
··· 160 160 $type_object = $field->getConduitParameterType(); 161 161 if ($type_object) { 162 162 $type = '`'.$type_object->getTypeName().'`'; 163 - // TODO: Support generating and surfacing this information. 164 - $description = pht('TODO'); 163 + $description = $field->getDescription(); 165 164 } else { 166 165 $type = ''; 167 166 $description = '//'.pht('Not Supported').'//';
+4
src/applications/search/field/PhabricatorSearchDateField.php
··· 38 38 return PhabricatorTime::parseLocalTime($value, $this->getViewer()); 39 39 } 40 40 41 + protected function newConduitParameterType() { 42 + return new ConduitEpochParameterType(); 43 + } 44 + 41 45 }
+25
src/applications/search/field/PhabricatorSearchField.php
··· 16 16 private $label; 17 17 private $aliases = array(); 18 18 private $errors = array(); 19 + private $description; 19 20 20 21 21 22 /* -( Configuring Fields )------------------------------------------------- */ ··· 160 161 } 161 162 162 163 return $this->getKey(); 164 + } 165 + 166 + 167 + /** 168 + * Set a human-readable description for this field. 169 + * 170 + * @param string Human-readable description. 171 + * @return this 172 + * @task config 173 + */ 174 + public function setDescription($description) { 175 + $this->description = $description; 176 + return $this; 177 + } 178 + 179 + 180 + /** 181 + * Get this field's human-readable description. 182 + * 183 + * @return string|null Human-readable description. 184 + * @task config 185 + */ 186 + public function getDescription() { 187 + return $this->description; 163 188 } 164 189 165 190
+6
src/applications/search/field/PhabricatorSearchSubscribersField.php
··· 18 18 return new PhabricatorMetaMTAMailableFunctionDatasource(); 19 19 } 20 20 21 + protected function newConduitParameterType() { 22 + // TODO: Ideally, this should eventually be a "Subscribers" type which 23 + // accepts projects as well. 24 + return new ConduitUserListParameterType(); 25 + } 26 + 21 27 }
+3 -1
src/applications/spaces/engineextension/PhabricatorSpacesSearchEngineExtension.php
··· 30 30 ->setKey('spacePHIDs') 31 31 ->setConduitKey('spaces') 32 32 ->setAliases(array('space', 'spaces')) 33 - ->setLabel(pht('Spaces')); 33 + ->setLabel(pht('Spaces')) 34 + ->setDescription( 35 + pht('Search for objects in certain spaces.')); 34 36 } 35 37 36 38 return $fields;
+4
src/applications/spaces/searchfield/PhabricatorSpacesSearchField.php
··· 40 40 return $phids; 41 41 } 42 42 43 + protected function newConduitParameterType() { 44 + return new ConduitPHIDListParameterType(); 45 + } 46 + 43 47 }
+3 -1
src/applications/subscriptions/engineextension/PhabricatorSubscriptionsSearchEngineExtension.php
··· 43 43 ->setLabel(pht('Subscribers')) 44 44 ->setKey('subscriberPHIDs') 45 45 ->setConduitKey('subscribers') 46 - ->setAliases(array('subscriber', 'subscribers')); 46 + ->setAliases(array('subscriber', 'subscribers')) 47 + ->setDescription( 48 + pht('Search for objects with certain subscribers.')); 47 49 48 50 return $fields; 49 51 }