In Conduit, let checkbox constraints self-document
Summary:
Ref T13195. Ref PHI851. Currently, checkbox constraints don't tell you what values are supported on the API page.
You can figure this out with "Inspect Element" or by viewing the source code, but just render a nice table instead.
Test Plan: {F5862969}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13195
Differential Revision: https://secure.phabricator.com/D19641
This commit is contained in:
@@ -313,6 +313,7 @@ phutil_register_library_map(array(
|
||||
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
||||
'ConduitColumnsParameterType' => 'applications/conduit/parametertype/ConduitColumnsParameterType.php',
|
||||
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
||||
'ConduitConstantDescription' => 'applications/conduit/data/ConduitConstantDescription.php',
|
||||
'ConduitEpochParameterType' => 'applications/conduit/parametertype/ConduitEpochParameterType.php',
|
||||
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
|
||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'applications/conduit/method/ConduitGetCapabilitiesConduitAPIMethod.php',
|
||||
@@ -5628,6 +5629,7 @@ phutil_register_library_map(array(
|
||||
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
||||
'ConduitColumnsParameterType' => 'ConduitParameterType',
|
||||
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'ConduitConstantDescription' => 'Phobject',
|
||||
'ConduitEpochParameterType' => 'ConduitParameterType',
|
||||
'ConduitException' => 'Exception',
|
||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
|
||||
26
src/applications/conduit/data/ConduitConstantDescription.php
Normal file
26
src/applications/conduit/data/ConduitConstantDescription.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
final class ConduitConstantDescription extends Phobject {
|
||||
|
||||
private $key;
|
||||
private $value;
|
||||
|
||||
public function setKey($key) {
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKey() {
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function setValue($value) {
|
||||
$this->value = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -190,15 +190,26 @@ EOTEXT
|
||||
$fields,
|
||||
array('ids', 'phids')) + $fields;
|
||||
|
||||
$constant_lists = array();
|
||||
|
||||
$rows = array();
|
||||
foreach ($fields as $field) {
|
||||
$key = $field->getConduitKey();
|
||||
$label = $field->getLabel();
|
||||
|
||||
$constants = $field->newConduitConstants();
|
||||
|
||||
$type_object = $field->getConduitParameterType();
|
||||
if ($type_object) {
|
||||
$type = $type_object->getTypeName();
|
||||
$description = $field->getDescription();
|
||||
if ($constants) {
|
||||
$description = array(
|
||||
$description,
|
||||
' ',
|
||||
phutil_tag('em', array(), pht('(See table below.)')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$type = null;
|
||||
$description = phutil_tag('em', array(), pht('Not supported.'));
|
||||
@@ -210,6 +221,35 @@ EOTEXT
|
||||
$type,
|
||||
$description,
|
||||
);
|
||||
|
||||
if ($constants) {
|
||||
$constant_lists[] = $this->buildRemarkup(
|
||||
pht(
|
||||
'Constants supported by the `%s` constraint:',
|
||||
'statuses'));
|
||||
|
||||
$constants_rows = array();
|
||||
foreach ($constants as $constant) {
|
||||
$constants_rows[] = array(
|
||||
$constant->getKey(),
|
||||
$constant->getValue(),
|
||||
);
|
||||
}
|
||||
|
||||
$constants_table = id(new AphrontTableView($constants_rows))
|
||||
->setHeaders(
|
||||
array(
|
||||
pht('Key'),
|
||||
pht('Value'),
|
||||
))
|
||||
->setColumnClasses(
|
||||
array(
|
||||
'pre',
|
||||
'wide',
|
||||
));
|
||||
|
||||
$constant_lists[] = $constants_table;
|
||||
}
|
||||
}
|
||||
|
||||
$table = id(new AphrontTableView($rows))
|
||||
@@ -233,7 +273,8 @@ EOTEXT
|
||||
->setCollapsed(true)
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||
->appendChild($this->buildRemarkup($info))
|
||||
->appendChild($table);
|
||||
->appendChild($table)
|
||||
->appendChild($constant_lists);
|
||||
}
|
||||
|
||||
private function buildOrderBox(
|
||||
|
||||
@@ -49,4 +49,16 @@ final class PhabricatorSearchCheckboxesField
|
||||
return new ConduitStringListParameterType();
|
||||
}
|
||||
|
||||
public function newConduitConstants() {
|
||||
$list = array();
|
||||
|
||||
foreach ($this->getOptions() as $key => $option) {
|
||||
$list[] = id(new ConduitConstantDescription())
|
||||
->setKey($key)
|
||||
->setValue($option);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -382,6 +382,10 @@ abstract class PhabricatorSearchField extends Phobject {
|
||||
return $this->enableForConduit;
|
||||
}
|
||||
|
||||
public function newConduitConstants() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/* -( Utility Methods )----------------------------------------------------- */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user