mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 09:58:24 +01:00
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:
parent
a20f0674a9
commit
5a38b75f16
5 changed files with 86 additions and 1 deletions
|
@ -313,6 +313,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
||||||
'ConduitColumnsParameterType' => 'applications/conduit/parametertype/ConduitColumnsParameterType.php',
|
'ConduitColumnsParameterType' => 'applications/conduit/parametertype/ConduitColumnsParameterType.php',
|
||||||
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
|
||||||
|
'ConduitConstantDescription' => 'applications/conduit/data/ConduitConstantDescription.php',
|
||||||
'ConduitEpochParameterType' => 'applications/conduit/parametertype/ConduitEpochParameterType.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',
|
||||||
|
@ -5628,6 +5629,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
||||||
'ConduitColumnsParameterType' => 'ConduitParameterType',
|
'ConduitColumnsParameterType' => 'ConduitParameterType',
|
||||||
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
|
'ConduitConstantDescription' => 'Phobject',
|
||||||
'ConduitEpochParameterType' => 'ConduitParameterType',
|
'ConduitEpochParameterType' => 'ConduitParameterType',
|
||||||
'ConduitException' => 'Exception',
|
'ConduitException' => 'Exception',
|
||||||
'ConduitGetCapabilitiesConduitAPIMethod' => 'ConduitAPIMethod',
|
'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,
|
$fields,
|
||||||
array('ids', 'phids')) + $fields;
|
array('ids', 'phids')) + $fields;
|
||||||
|
|
||||||
|
$constant_lists = array();
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$key = $field->getConduitKey();
|
$key = $field->getConduitKey();
|
||||||
$label = $field->getLabel();
|
$label = $field->getLabel();
|
||||||
|
|
||||||
|
$constants = $field->newConduitConstants();
|
||||||
|
|
||||||
$type_object = $field->getConduitParameterType();
|
$type_object = $field->getConduitParameterType();
|
||||||
if ($type_object) {
|
if ($type_object) {
|
||||||
$type = $type_object->getTypeName();
|
$type = $type_object->getTypeName();
|
||||||
$description = $field->getDescription();
|
$description = $field->getDescription();
|
||||||
|
if ($constants) {
|
||||||
|
$description = array(
|
||||||
|
$description,
|
||||||
|
' ',
|
||||||
|
phutil_tag('em', array(), pht('(See table below.)')),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$type = null;
|
$type = null;
|
||||||
$description = phutil_tag('em', array(), pht('Not supported.'));
|
$description = phutil_tag('em', array(), pht('Not supported.'));
|
||||||
|
@ -210,6 +221,35 @@ EOTEXT
|
||||||
$type,
|
$type,
|
||||||
$description,
|
$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))
|
$table = id(new AphrontTableView($rows))
|
||||||
|
@ -233,7 +273,8 @@ EOTEXT
|
||||||
->setCollapsed(true)
|
->setCollapsed(true)
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
->appendChild($this->buildRemarkup($info))
|
->appendChild($this->buildRemarkup($info))
|
||||||
->appendChild($table);
|
->appendChild($table)
|
||||||
|
->appendChild($constant_lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildOrderBox(
|
private function buildOrderBox(
|
||||||
|
|
|
@ -49,4 +49,16 @@ final class PhabricatorSearchCheckboxesField
|
||||||
return new ConduitStringListParameterType();
|
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;
|
return $this->enableForConduit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newConduitConstants() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Utility Methods )----------------------------------------------------- */
|
/* -( Utility Methods )----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue