From 99ade500bc3ae127ca462bf555324b3551c7beaf Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 13 Dec 2015 07:43:02 -0800 Subject: [PATCH] Flesh out Conduit parmeter types for maniphest.search Summary: Ref T9964. I left a couple of these unsupported for now since they're weird in some way. Test Plan: {F1024031} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14767 --- src/__phutil_library_map__.php | 2 + .../ConduitIntListParameterType.php | 40 +++++++++++++++++++ .../query/ManiphestTaskSearchEngine.php | 14 ++++++- .../PhabricatorOwnersSearchField.php | 4 ++ .../PhabricatorSearchDatasourceField.php | 12 +++++- 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 src/applications/conduit/parametertype/ConduitIntListParameterType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bb384b09e2..8539271141 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -233,6 +233,7 @@ phutil_register_library_map(array( 'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php', 'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php', 'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php', + 'ConduitIntListParameterType' => 'applications/conduit/parametertype/ConduitIntListParameterType.php', 'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php', 'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php', 'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php', @@ -4085,6 +4086,7 @@ phutil_register_library_map(array( 'ConduitException' => 'Exception', 'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod', 'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod', + 'ConduitIntListParameterType' => 'ConduitListParameterType', 'ConduitIntParameterType' => 'ConduitListParameterType', 'ConduitListParameterType' => 'ConduitParameterType', 'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector', diff --git a/src/applications/conduit/parametertype/ConduitIntListParameterType.php b/src/applications/conduit/parametertype/ConduitIntListParameterType.php new file mode 100644 index 0000000000..a2f4c95534 --- /dev/null +++ b/src/applications/conduit/parametertype/ConduitIntListParameterType.php @@ -0,0 +1,40 @@ + $item) { + if (!is_int($item)) { + $this->raiseValidationException( + $request, + $key, + pht( + 'Expected a list of integers, but item with index "%s" is '. + 'not an integer.', + $idx)); + } + } + + return $this->validateIntList($request, $key, $list); + } + + protected function getParameterTypeName() { + return 'list'; + } + + protected function getParameterFormatDescriptions() { + return array( + pht('List of integers.'), + ); + } + + protected function getParameterExamples() { + return array( + '[123, 0, -456]', + ); + } + +} diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 1c0854218d..2165111e3d 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -48,20 +48,30 @@ final class ManiphestTaskSearchEngine id(new PhabricatorOwnersSearchField()) ->setLabel(pht('Assigned To')) ->setKey('assignedPHIDs') - ->setAliases(array('assigned')), + ->setConduitKey('assigned') + ->setAliases(array('assigned')) + ->setDescription( + pht('Search for tasks owned by a user from a list.')), id(new PhabricatorUsersSearchField()) ->setLabel(pht('Authors')) ->setKey('authorPHIDs') - ->setAliases(array('author', 'authors')), + ->setAliases(array('author', 'authors')) + ->setDescription( + pht('Search for tasks with given authors.')), id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Statuses')) ->setKey('statuses') ->setAliases(array('status')) + ->setDescription( + pht('Search for tasks with given statuses.')) ->setDatasource(new ManiphestTaskStatusFunctionDatasource()), id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Priorities')) ->setKey('priorities') ->setAliases(array('priority')) + ->setDescription( + pht('Search for tasks with given priorities.')) + ->setConduitParameterType(new ConduitIntListParameterType()) ->setDatasource(new ManiphestTaskPriorityDatasource()), id(new PhabricatorSearchTextField()) ->setLabel(pht('Contains Words')) diff --git a/src/applications/owners/searchfield/PhabricatorOwnersSearchField.php b/src/applications/owners/searchfield/PhabricatorOwnersSearchField.php index d39ed191f8..fb65341cf9 100644 --- a/src/applications/owners/searchfield/PhabricatorOwnersSearchField.php +++ b/src/applications/owners/searchfield/PhabricatorOwnersSearchField.php @@ -15,4 +15,8 @@ final class PhabricatorOwnersSearchField return new PhabricatorPeopleOwnerDatasource(); } + protected function newConduitParameterType() { + return new ConduitUserListParameterType(); + } + } diff --git a/src/applications/search/field/PhabricatorSearchDatasourceField.php b/src/applications/search/field/PhabricatorSearchDatasourceField.php index cb48b06d52..6ba322936f 100644 --- a/src/applications/search/field/PhabricatorSearchDatasourceField.php +++ b/src/applications/search/field/PhabricatorSearchDatasourceField.php @@ -4,6 +4,7 @@ final class PhabricatorSearchDatasourceField extends PhabricatorSearchTokenizerField { private $datasource; + private $conduitParameterType; protected function newDatasource() { return id(clone $this->datasource); @@ -14,8 +15,17 @@ final class PhabricatorSearchDatasourceField return $this; } + public function setConduitParameterType(ConduitParameterType $type) { + $this->conduitParameterType = $type; + return $this; + } + protected function newConduitParameterType() { - return new ConduitStringListParameterType(); + if (!$this->conduitParameterType) { + return new ConduitStringListParameterType(); + } + + return $this->conduitParameterType; } }