mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
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
This commit is contained in:
parent
1b325a0a89
commit
0282ce74ab
17 changed files with 192 additions and 26 deletions
|
@ -228,6 +228,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
||||||
'ConduitConnectionGarbageCollector' => 'applications/conduit/garbagecollector/ConduitConnectionGarbageCollector.php',
|
'ConduitConnectionGarbageCollector' => 'applications/conduit/garbagecollector/ConduitConnectionGarbageCollector.php',
|
||||||
'ConduitDeprecatedCallSetupCheck' => 'applications/conduit/check/ConduitDeprecatedCallSetupCheck.php',
|
'ConduitDeprecatedCallSetupCheck' => 'applications/conduit/check/ConduitDeprecatedCallSetupCheck.php',
|
||||||
|
'ConduitEpochParameterType' => 'applications/conduit/parametertype/ConduitEpochParameterType.php',
|
||||||
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
|
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
|
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
|
||||||
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
|
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
|
||||||
|
@ -235,8 +236,10 @@ phutil_register_library_map(array(
|
||||||
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
|
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
|
||||||
'ConduitMethodDoesNotExistException' => 'applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php',
|
'ConduitMethodDoesNotExistException' => 'applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php',
|
||||||
'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php',
|
'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php',
|
||||||
|
'ConduitPHIDListParameterType' => 'applications/conduit/parametertype/ConduitPHIDListParameterType.php',
|
||||||
'ConduitParameterType' => 'applications/conduit/parametertype/ConduitParameterType.php',
|
'ConduitParameterType' => 'applications/conduit/parametertype/ConduitParameterType.php',
|
||||||
'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php',
|
'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php',
|
||||||
|
'ConduitProjectListParameterType' => 'applications/conduit/parametertype/ConduitProjectListParameterType.php',
|
||||||
'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php',
|
'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php',
|
||||||
'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php',
|
'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php',
|
||||||
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
||||||
|
@ -4074,6 +4077,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ConduitConnectionGarbageCollector' => 'PhabricatorGarbageCollector',
|
'ConduitConnectionGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
'ConduitDeprecatedCallSetupCheck' => 'PhabricatorSetupCheck',
|
'ConduitDeprecatedCallSetupCheck' => 'PhabricatorSetupCheck',
|
||||||
|
'ConduitEpochParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitException' => 'Exception',
|
'ConduitException' => 'Exception',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
@ -4081,8 +4085,10 @@ phutil_register_library_map(array(
|
||||||
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException',
|
'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException',
|
||||||
'ConduitMethodNotFoundException' => 'ConduitException',
|
'ConduitMethodNotFoundException' => 'ConduitException',
|
||||||
|
'ConduitPHIDListParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitParameterType' => 'Phobject',
|
'ConduitParameterType' => 'Phobject',
|
||||||
'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
'ConduitProjectListParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||||
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitEpochParameterType
|
||||||
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(array $request, $key) {
|
||||||
|
$value = parent::getParameterValue($request, $key);
|
||||||
|
|
||||||
|
if (!is_int($value)) {
|
||||||
|
$this->raiseValidationException(
|
||||||
|
$request,
|
||||||
|
$key,
|
||||||
|
pht('Expected integer, got something else.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'epoch';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('Epoch timestamp, as an integer.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'["PHID-PROJ-1111"]',
|
||||||
|
'["backend"]',
|
||||||
|
'["PHID-PROJ-2222", "frontend"]',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ abstract class ConduitListParameterType
|
||||||
extends ConduitParameterType {
|
extends ConduitParameterType {
|
||||||
|
|
||||||
protected function getParameterValue(array $request, $key) {
|
protected function getParameterValue(array $request, $key) {
|
||||||
$value = parent::getParameterValue();
|
$value = parent::getParameterValue($request, $key);
|
||||||
|
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
$this->raiseValidationException(
|
$this->raiseValidationException(
|
||||||
|
@ -30,6 +30,22 @@ abstract class ConduitListParameterType
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function validateStringList(array $request, $key, array $list) {
|
||||||
|
foreach ($list as $idx => $item) {
|
||||||
|
if (!is_string($item)) {
|
||||||
|
$this->raiseValidationException(
|
||||||
|
$request,
|
||||||
|
$key,
|
||||||
|
pht(
|
||||||
|
'Expected a list of strings, but item with index "%s" is '.
|
||||||
|
'not a string.',
|
||||||
|
$idx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getParameterDefault() {
|
protected function getParameterDefault() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitPHIDListParameterType
|
||||||
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(array $request, $key) {
|
||||||
|
$list = parent::getParameterValue($request, $key);
|
||||||
|
return $this->validateStringList($request, $key, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'list<phid>';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('List of PHIDs.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'["PHID-WXYZ-1111", "PHID-WXYZ-2222"]',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitProjectListParameterType
|
||||||
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(array $request, $key) {
|
||||||
|
$list = parent::getParameterValue($request, $key);
|
||||||
|
$list = $this->validateStringList($request, $key, $list);
|
||||||
|
return id(new PhabricatorProjectPHIDResolver())
|
||||||
|
->setViewer($this->getViewer())
|
||||||
|
->resolvePHIDs($list);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'list<project>';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('List of project PHIDs.'),
|
||||||
|
pht('List of project tags.'),
|
||||||
|
pht('List with a mixture of PHIDs and tags.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'["PHID-PROJ-1111"]',
|
||||||
|
'["backend"]',
|
||||||
|
'["PHID-PROJ-2222", "frontend"]',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,21 +4,8 @@ final class ConduitStringListParameterType
|
||||||
extends ConduitListParameterType {
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
protected function getParameterValue(array $request, $key) {
|
protected function getParameterValue(array $request, $key) {
|
||||||
$list = parent::getParameterValue();
|
$list = parent::getParameterValue($request, $key);
|
||||||
|
return $this->validateStringList($request, $key, $list);
|
||||||
foreach ($list as $idx => $item) {
|
|
||||||
if (!is_string($item)) {
|
|
||||||
$this->raiseValidationException(
|
|
||||||
$request,
|
|
||||||
$key,
|
|
||||||
pht(
|
|
||||||
'Expected a list of strings, but item with index "%s" is '.
|
|
||||||
'not a string.',
|
|
||||||
$idx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getParameterTypeName() {
|
protected function getParameterTypeName() {
|
||||||
|
|
|
@ -4,7 +4,8 @@ final class ConduitUserListParameterType
|
||||||
extends ConduitListParameterType {
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
protected function getParameterValue(array $request, $key) {
|
protected function getParameterValue(array $request, $key) {
|
||||||
$list = parent::getParameterValue();
|
$list = parent::getParameterValue($request, $key);
|
||||||
|
$list = $this->validateStringList($request, $key, $list);
|
||||||
return id(new PhabricatorUserPHIDResolver())
|
return id(new PhabricatorUserPHIDResolver())
|
||||||
->setViewer($this->getViewer())
|
->setViewer($this->getViewer())
|
||||||
->resolvePHIDs($list);
|
->resolvePHIDs($list);
|
||||||
|
|
|
@ -48,19 +48,29 @@ final class PhabricatorPasteSearchEngine
|
||||||
->setAliases(array('authors'))
|
->setAliases(array('authors'))
|
||||||
->setKey('authorPHIDs')
|
->setKey('authorPHIDs')
|
||||||
->setConduitKey('authors')
|
->setConduitKey('authors')
|
||||||
->setLabel(pht('Authors')),
|
->setLabel(pht('Authors'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for pastes with specific authors.')),
|
||||||
id(new PhabricatorSearchStringListField())
|
id(new PhabricatorSearchStringListField())
|
||||||
->setKey('languages')
|
->setKey('languages')
|
||||||
->setLabel(pht('Languages')),
|
->setLabel(pht('Languages'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for pastes highlighted in specific languages.')),
|
||||||
id(new PhabricatorSearchDateField())
|
id(new PhabricatorSearchDateField())
|
||||||
->setKey('createdStart')
|
->setKey('createdStart')
|
||||||
->setLabel(pht('Created After')),
|
->setLabel(pht('Created After'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for pastes created after a given time.')),
|
||||||
id(new PhabricatorSearchDateField())
|
id(new PhabricatorSearchDateField())
|
||||||
->setKey('createdEnd')
|
->setKey('createdEnd')
|
||||||
->setLabel(pht('Created Before')),
|
->setLabel(pht('Created Before'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for pastes created before a given time.')),
|
||||||
id(new PhabricatorSearchCheckboxesField())
|
id(new PhabricatorSearchCheckboxesField())
|
||||||
->setKey('statuses')
|
->setKey('statuses')
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for archived or active pastes.'))
|
||||||
->setOptions(
|
->setOptions(
|
||||||
id(new PhabricatorPaste())
|
id(new PhabricatorPaste())
|
||||||
->getStatusNameMap()),
|
->getStatusNameMap()),
|
||||||
|
|
|
@ -42,7 +42,9 @@ final class PhabricatorProjectsSearchEngineExtension
|
||||||
->setKey('projectPHIDs')
|
->setKey('projectPHIDs')
|
||||||
->setConduitKey('projects')
|
->setConduitKey('projects')
|
||||||
->setAliases(array('project', 'projects'))
|
->setAliases(array('project', 'projects'))
|
||||||
->setLabel(pht('Projects'));
|
->setLabel(pht('Projects'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for objects associated with given projects.'));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,8 @@ final class PhabricatorProjectSearchField
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return new ConduitProjectListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,7 @@ EOTEXT
|
||||||
$type_object = $field->getConduitParameterType();
|
$type_object = $field->getConduitParameterType();
|
||||||
if ($type_object) {
|
if ($type_object) {
|
||||||
$type = '`'.$type_object->getTypeName().'`';
|
$type = '`'.$type_object->getTypeName().'`';
|
||||||
// TODO: Support generating and surfacing this information.
|
$description = $field->getDescription();
|
||||||
$description = pht('TODO');
|
|
||||||
} else {
|
} else {
|
||||||
$type = '';
|
$type = '';
|
||||||
$description = '//'.pht('Not Supported').'//';
|
$description = '//'.pht('Not Supported').'//';
|
||||||
|
|
|
@ -38,4 +38,8 @@ final class PhabricatorSearchDateField
|
||||||
return PhabricatorTime::parseLocalTime($value, $this->getViewer());
|
return PhabricatorTime::parseLocalTime($value, $this->getViewer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return new ConduitEpochParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ abstract class PhabricatorSearchField extends Phobject {
|
||||||
private $label;
|
private $label;
|
||||||
private $aliases = array();
|
private $aliases = array();
|
||||||
private $errors = array();
|
private $errors = array();
|
||||||
|
private $description;
|
||||||
|
|
||||||
|
|
||||||
/* -( Configuring Fields )------------------------------------------------- */
|
/* -( Configuring Fields )------------------------------------------------- */
|
||||||
|
@ -163,6 +164,30 @@ abstract class PhabricatorSearchField extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a human-readable description for this field.
|
||||||
|
*
|
||||||
|
* @param string Human-readable description.
|
||||||
|
* @return this
|
||||||
|
* @task config
|
||||||
|
*/
|
||||||
|
public function setDescription($description) {
|
||||||
|
$this->description = $description;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this field's human-readable description.
|
||||||
|
*
|
||||||
|
* @return string|null Human-readable description.
|
||||||
|
* @task config
|
||||||
|
*/
|
||||||
|
public function getDescription() {
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Handling Errors )---------------------------------------------------- */
|
/* -( Handling Errors )---------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,4 +18,10 @@ final class PhabricatorSearchSubscribersField
|
||||||
return new PhabricatorMetaMTAMailableFunctionDatasource();
|
return new PhabricatorMetaMTAMailableFunctionDatasource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
// TODO: Ideally, this should eventually be a "Subscribers" type which
|
||||||
|
// accepts projects as well.
|
||||||
|
return new ConduitUserListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ final class PhabricatorSpacesSearchEngineExtension
|
||||||
->setKey('spacePHIDs')
|
->setKey('spacePHIDs')
|
||||||
->setConduitKey('spaces')
|
->setConduitKey('spaces')
|
||||||
->setAliases(array('space', 'spaces'))
|
->setAliases(array('space', 'spaces'))
|
||||||
->setLabel(pht('Spaces'));
|
->setLabel(pht('Spaces'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for objects in certain spaces.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
|
@ -40,4 +40,8 @@ final class PhabricatorSpacesSearchField
|
||||||
return $phids;
|
return $phids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return new ConduitPHIDListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,9 @@ final class PhabricatorSubscriptionsSearchEngineExtension
|
||||||
->setLabel(pht('Subscribers'))
|
->setLabel(pht('Subscribers'))
|
||||||
->setKey('subscriberPHIDs')
|
->setKey('subscriberPHIDs')
|
||||||
->setConduitKey('subscribers')
|
->setConduitKey('subscribers')
|
||||||
->setAliases(array('subscriber', 'subscribers'));
|
->setAliases(array('subscriber', 'subscribers'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for objects with certain subscribers.'));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue