mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Move Conduit rendering to SearchEngine
Summary: Ref T4986. Nothing special. Test Plan: Looked at Conduit, made a panel. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9013
This commit is contained in:
parent
684805a88a
commit
9d1cfcd8ec
2 changed files with 64 additions and 60 deletions
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorConduitListController
|
||||
extends PhabricatorConduitController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhabricatorConduitController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -23,62 +22,4 @@ final class PhabricatorConduitListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $methods,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($methods, 'ConduitAPIMethod');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$out = array();
|
||||
|
||||
$last = null;
|
||||
$list = null;
|
||||
foreach ($methods as $method) {
|
||||
$app = $method->getApplicationName();
|
||||
if ($app !== $last) {
|
||||
$last = $app;
|
||||
if ($list) {
|
||||
$out[] = $list;
|
||||
}
|
||||
$list = id(new PHUIObjectItemListView());
|
||||
|
||||
$app_object = $method->getApplication();
|
||||
if ($app_object) {
|
||||
$app_name = $app_object->getName();
|
||||
} else {
|
||||
$app_name = $app;
|
||||
}
|
||||
}
|
||||
|
||||
$method_name = $method->getAPIMethodName();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($method_name)
|
||||
->setHref($this->getApplicationURI('method/'.$method_name.'/'))
|
||||
->addAttribute($method->getMethodDescription());
|
||||
|
||||
switch ($method->getMethodStatus()) {
|
||||
case ConduitAPIMethod::METHOD_STATUS_STABLE:
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
|
||||
$item->addIcon('warning-grey', pht('Unstable'));
|
||||
$item->setBarColor('yellow');
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
|
||||
$item->addIcon('warning', pht('Deprecated'));
|
||||
$item->setBarColor('red');
|
||||
break;
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
if ($list) {
|
||||
$out[] = $list;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorConduitSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationConduit';
|
||||
}
|
||||
|
||||
public function getPageSize(PhabricatorSavedQuery $saved) {
|
||||
return PHP_INT_MAX - 1;
|
||||
}
|
||||
|
@ -135,4 +139,63 @@ final class PhabricatorConduitSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $methods,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($methods, 'ConduitAPIMethod');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$out = array();
|
||||
|
||||
$last = null;
|
||||
$list = null;
|
||||
foreach ($methods as $method) {
|
||||
$app = $method->getApplicationName();
|
||||
if ($app !== $last) {
|
||||
$last = $app;
|
||||
if ($list) {
|
||||
$out[] = $list;
|
||||
}
|
||||
$list = id(new PHUIObjectItemListView());
|
||||
|
||||
$app_object = $method->getApplication();
|
||||
if ($app_object) {
|
||||
$app_name = $app_object->getName();
|
||||
} else {
|
||||
$app_name = $app;
|
||||
}
|
||||
}
|
||||
|
||||
$method_name = $method->getAPIMethodName();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($method_name)
|
||||
->setHref($this->getApplicationURI('method/'.$method_name.'/'))
|
||||
->addAttribute($method->getMethodDescription());
|
||||
|
||||
switch ($method->getMethodStatus()) {
|
||||
case ConduitAPIMethod::METHOD_STATUS_STABLE:
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
|
||||
$item->addIcon('warning-grey', pht('Unstable'));
|
||||
$item->setBarColor('yellow');
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
|
||||
$item->addIcon('warning', pht('Deprecated'));
|
||||
$item->setBarColor('red');
|
||||
break;
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
if ($list) {
|
||||
$out[] = $list;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue