mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-09 19:08:40 +02:00
Flesh out Conduit parameter types for Owners + CustomFields
Summary: Ref T9964. Fill in more parameter types and descriptions. (No date support yet since it's a bit more involved.) Test Plan: {F1024022} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14766
This commit is contained in:
parent
0282ce74ab
commit
663dce5029
20 changed files with 196 additions and 7 deletions
|
@ -223,6 +223,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPIRequest' => 'applications/conduit/protocol/ConduitAPIRequest.php',
|
'ConduitAPIRequest' => 'applications/conduit/protocol/ConduitAPIRequest.php',
|
||||||
'ConduitAPIResponse' => 'applications/conduit/protocol/ConduitAPIResponse.php',
|
'ConduitAPIResponse' => 'applications/conduit/protocol/ConduitAPIResponse.php',
|
||||||
'ConduitApplicationNotInstalledException' => 'applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php',
|
'ConduitApplicationNotInstalledException' => 'applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php',
|
||||||
|
'ConduitBoolParameterType' => 'applications/conduit/parametertype/ConduitBoolParameterType.php',
|
||||||
'ConduitCall' => 'applications/conduit/call/ConduitCall.php',
|
'ConduitCall' => 'applications/conduit/call/ConduitCall.php',
|
||||||
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
||||||
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
||||||
|
@ -232,6 +233,7 @@ phutil_register_library_map(array(
|
||||||
'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',
|
||||||
|
'ConduitIntParameterType' => 'applications/conduit/parametertype/ConduitIntParameterType.php',
|
||||||
'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php',
|
'ConduitListParameterType' => 'applications/conduit/parametertype/ConduitListParameterType.php',
|
||||||
'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',
|
||||||
|
@ -244,6 +246,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php',
|
'ConduitResultSearchEngineExtension' => 'applications/conduit/query/ConduitResultSearchEngineExtension.php',
|
||||||
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
||||||
'ConduitStringListParameterType' => 'applications/conduit/parametertype/ConduitStringListParameterType.php',
|
'ConduitStringListParameterType' => 'applications/conduit/parametertype/ConduitStringListParameterType.php',
|
||||||
|
'ConduitStringParameterType' => 'applications/conduit/parametertype/ConduitStringParameterType.php',
|
||||||
'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php',
|
'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php',
|
||||||
'ConduitUserListParameterType' => 'applications/conduit/parametertype/ConduitUserListParameterType.php',
|
'ConduitUserListParameterType' => 'applications/conduit/parametertype/ConduitUserListParameterType.php',
|
||||||
'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php',
|
'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php',
|
||||||
|
@ -4072,6 +4075,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPIRequest' => 'Phobject',
|
'ConduitAPIRequest' => 'Phobject',
|
||||||
'ConduitAPIResponse' => 'Phobject',
|
'ConduitAPIResponse' => 'Phobject',
|
||||||
'ConduitApplicationNotInstalledException' => 'ConduitMethodNotFoundException',
|
'ConduitApplicationNotInstalledException' => 'ConduitMethodNotFoundException',
|
||||||
|
'ConduitBoolParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitCall' => 'Phobject',
|
'ConduitCall' => 'Phobject',
|
||||||
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
||||||
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
@ -4081,6 +4085,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitException' => 'Exception',
|
'ConduitException' => 'Exception',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
'ConduitIntParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitListParameterType' => 'ConduitParameterType',
|
'ConduitListParameterType' => 'ConduitParameterType',
|
||||||
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException',
|
'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException',
|
||||||
|
@ -4093,6 +4098,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
'ConduitResultSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||||
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
||||||
'ConduitStringListParameterType' => 'ConduitListParameterType',
|
'ConduitStringListParameterType' => 'ConduitListParameterType',
|
||||||
|
'ConduitStringParameterType' => 'ConduitListParameterType',
|
||||||
'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector',
|
'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||||
'ConduitUserListParameterType' => 'ConduitListParameterType',
|
'ConduitUserListParameterType' => 'ConduitListParameterType',
|
||||||
'ConpherenceColumnViewController' => 'ConpherenceController',
|
'ConpherenceColumnViewController' => 'ConpherenceController',
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitBoolParameterType
|
||||||
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(array $request, $key) {
|
||||||
|
$value = parent::getParameterValue($request, $key);
|
||||||
|
|
||||||
|
if (!is_bool($value)) {
|
||||||
|
$this->raiseValidationException(
|
||||||
|
$request,
|
||||||
|
$key,
|
||||||
|
pht('Expected boolean (true or false), got something else.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'bool';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('A boolean.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'true',
|
||||||
|
'false',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,14 @@ final class ConduitEpochParameterType
|
||||||
$this->raiseValidationException(
|
$this->raiseValidationException(
|
||||||
$request,
|
$request,
|
||||||
$key,
|
$key,
|
||||||
pht('Expected integer, got something else.'));
|
pht('Expected epoch timestamp as integer, got something else.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value <= 0) {
|
||||||
|
$this->raiseValidationException(
|
||||||
|
$request,
|
||||||
|
$key,
|
||||||
|
pht('Epoch timestamp must be larger than 0, got %d.', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -28,9 +35,7 @@ final class ConduitEpochParameterType
|
||||||
|
|
||||||
protected function getParameterExamples() {
|
protected function getParameterExamples() {
|
||||||
return array(
|
return array(
|
||||||
'["PHID-PROJ-1111"]',
|
'1450019509',
|
||||||
'["backend"]',
|
|
||||||
'["PHID-PROJ-2222", "frontend"]',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitIntParameterType
|
||||||
|
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 'int';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('An integer.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'123',
|
||||||
|
'0',
|
||||||
|
'-345',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ConduitStringParameterType
|
||||||
|
extends ConduitListParameterType {
|
||||||
|
|
||||||
|
protected function getParameterValue(array $request, $key) {
|
||||||
|
$value = parent::getParameterValue($request, $key);
|
||||||
|
|
||||||
|
if (!is_string($value)) {
|
||||||
|
$this->raiseValidationException(
|
||||||
|
$request,
|
||||||
|
$key,
|
||||||
|
pht('Expected string, got something else.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterTypeName() {
|
||||||
|
return 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterFormatDescriptions() {
|
||||||
|
return array(
|
||||||
|
pht('A string.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getParameterExamples() {
|
||||||
|
return array(
|
||||||
|
'"papaya"',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,19 +21,29 @@ final class PhabricatorOwnersPackageSearchEngine
|
||||||
->setLabel(pht('Authority'))
|
->setLabel(pht('Authority'))
|
||||||
->setKey('authorityPHIDs')
|
->setKey('authorityPHIDs')
|
||||||
->setAliases(array('authority', 'authorities'))
|
->setAliases(array('authority', 'authorities'))
|
||||||
|
->setConduitKey('owners')
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for packages with specific owners.'))
|
||||||
->setDatasource(new PhabricatorProjectOrUserDatasource()),
|
->setDatasource(new PhabricatorProjectOrUserDatasource()),
|
||||||
id(new PhabricatorSearchDatasourceField())
|
id(new PhabricatorSearchDatasourceField())
|
||||||
->setLabel(pht('Repositories'))
|
->setLabel(pht('Repositories'))
|
||||||
->setKey('repositoryPHIDs')
|
->setKey('repositoryPHIDs')
|
||||||
|
->setConduitKey('repositories')
|
||||||
->setAliases(array('repository', 'repositories'))
|
->setAliases(array('repository', 'repositories'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for packages by included repositories.'))
|
||||||
->setDatasource(new DiffusionRepositoryDatasource()),
|
->setDatasource(new DiffusionRepositoryDatasource()),
|
||||||
id(new PhabricatorSearchStringListField())
|
id(new PhabricatorSearchStringListField())
|
||||||
->setLabel(pht('Paths'))
|
->setLabel(pht('Paths'))
|
||||||
->setKey('paths')
|
->setKey('paths')
|
||||||
->setAliases(array('path')),
|
->setAliases(array('path'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for packages affecting specific paths.')),
|
||||||
id(new PhabricatorSearchCheckboxesField())
|
id(new PhabricatorSearchCheckboxesField())
|
||||||
->setKey('statuses')
|
->setKey('statuses')
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Search for active or archived packages.'))
|
||||||
->setOptions(
|
->setOptions(
|
||||||
id(new PhabricatorOwnersPackage())
|
id(new PhabricatorOwnersPackage())
|
||||||
->getStatusNameMap()),
|
->getStatusNameMap()),
|
||||||
|
|
|
@ -196,13 +196,13 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
$head_builtin = pht('Builtin Order');
|
$head_builtin = pht('Builtin Order');
|
||||||
$head_description = pht('Description');
|
$head_label = pht('Label');
|
||||||
$head_columns = pht('Columns');
|
$head_columns = pht('Columns');
|
||||||
|
|
||||||
$orders = $query->getBuiltinOrders();
|
$orders = $query->getBuiltinOrders();
|
||||||
|
|
||||||
$table = array();
|
$table = array();
|
||||||
$table[] = "| {$head_builtin} | {$head_description} | {$head_columns} |";
|
$table[] = "| {$head_builtin} | {$head_label} | {$head_columns} |";
|
||||||
$table[] = '|-----------------|---------------------|-----------------|';
|
$table[] = '|-----------------|---------------------|-----------------|';
|
||||||
foreach ($orders as $key => $order) {
|
foreach ($orders as $key => $order) {
|
||||||
$name = $order['name'];
|
$name = $order['name'];
|
||||||
|
@ -310,6 +310,10 @@ These are the fields available on this object type:
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$head_key = pht('Key');
|
||||||
|
$head_type = pht('Type');
|
||||||
|
$head_description = pht('Description');
|
||||||
|
|
||||||
$specs = $engine->getAllConduitFieldSpecifications();
|
$specs = $engine->getAllConduitFieldSpecifications();
|
||||||
|
|
||||||
$table = array();
|
$table = array();
|
||||||
|
|
|
@ -63,4 +63,12 @@ final class PhabricatorSearchCustomFieldProxyField
|
||||||
$this->getValue());
|
$this->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDescription() {
|
||||||
|
return $this->getCustomField()->getFieldDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return $this->getCustomField()->getConduitSearchParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,8 @@ final class PhabricatorSearchDatasourceField
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitParameterType() {
|
||||||
|
return new ConduitStringListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1337,6 +1337,17 @@ abstract class PhabricatorCustomField extends Phobject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConduitSearchParameterType() {
|
||||||
|
return $this->newConduitSearchParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
if ($this->proxy) {
|
||||||
|
return $this->proxy->newConduitSearchParameterType();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Herald )------------------------------------------------------------- */
|
/* -( Herald )------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -463,4 +463,5 @@ abstract class PhabricatorStandardCustomField
|
||||||
return $this->getFieldValue();
|
return $this->getFieldValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,7 @@ final class PhabricatorStandardCustomFieldBool
|
||||||
return new AphrontBoolHTTPParameterType();
|
return new AphrontBoolHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
return new ConduitBoolParameterType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,4 +197,9 @@ final class PhabricatorStandardCustomFieldDate
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
// TODO: Build a new "pair<epoch|null, epoch|null>" type or similar.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,8 @@ final class PhabricatorStandardCustomFieldHeader
|
||||||
return $this->getFieldName();
|
return $this->getFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAppearInApplicationSearch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,5 +116,8 @@ final class PhabricatorStandardCustomFieldInt
|
||||||
return new AphrontIntHTTPParameterType();
|
return new AphrontIntHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
return new ConduitIntParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,4 +84,7 @@ final class PhabricatorStandardCustomFieldLink
|
||||||
return new AphrontStringHTTPParameterType();
|
return new AphrontStringHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
return new ConduitStringListParameterType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,5 +99,8 @@ final class PhabricatorStandardCustomFieldRemarkup
|
||||||
return new AphrontStringHTTPParameterType();
|
return new AphrontStringHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAppearInApplicationSearch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,4 +140,7 @@ final class PhabricatorStandardCustomFieldSelect
|
||||||
return new AphrontSelectHTTPParameterType();
|
return new AphrontSelectHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
return new ConduitStringListParameterType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,4 +67,8 @@ final class PhabricatorStandardCustomFieldText
|
||||||
return new AphrontStringHTTPParameterType();
|
return new AphrontStringHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAppearInApplicationSearch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,8 @@ final class PhabricatorStandardCustomFieldUsers
|
||||||
return new AphrontUserListHTTPParameterType();
|
return new AphrontUserListHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newConduitSearchParameterType() {
|
||||||
|
return new ConduitUserListParameterType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue