Modernize most Conduit console interfaces
Summary:
Ref T603. Ref T2625.
Long chain of "doing the right thing" here: I want to clean this up, so I can clean up the Conduit logs, so I can add a setup issue for deprecated method calls, so I can remove deprecated methods, so I can get rid of `DifferentialRevisionListData`, so I can make Differntial policy-aware.
Adds modern infrastructure and UI to all of the Conduit interfaces (except only partially for the logs, that will be the next diff).
Test Plan:
{F48201}
{F48202}
{F48203}
{F48204}
{F48206}
This will get further updates in the next diff:
{F48205}
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T603, T2625
Differential Revision: https://secure.phabricator.com/D6331
This commit is contained in:
@@ -5,122 +5,27 @@
|
||||
*/
|
||||
abstract class PhabricatorConduitController extends PhabricatorController {
|
||||
|
||||
private $filter;
|
||||
protected $showSideNav;
|
||||
protected function buildSideNavView() {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
$page = $this->buildStandardPageView();
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
$page->setApplicationName('Conduit');
|
||||
$page->setBaseURI('/conduit/');
|
||||
$page->setTitle(idx($data, 'title'));
|
||||
$page->setGlyph("\xE2\x87\xB5");
|
||||
id(new PhabricatorConduitSearchEngine())
|
||||
->setViewer($viewer)
|
||||
->addNavigationItems($nav->getMenu());
|
||||
|
||||
if ($this->showSideNav()) {
|
||||
$nav->addLabel('Logs');
|
||||
$nav->addFilter('log', pht('Call Logs'));
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI('/conduit/'));
|
||||
$method_filters = $this->getMethodFilters();
|
||||
foreach ($method_filters as $group => $methods) {
|
||||
$nav->addLabel($group);
|
||||
foreach ($methods as $method) {
|
||||
$method_name = $method['full_name'];
|
||||
$nav->selectFilter(null);
|
||||
|
||||
$display_name = $method_name;
|
||||
switch ($method['status']) {
|
||||
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
|
||||
$display_name = '('.$display_name.')';
|
||||
break;
|
||||
}
|
||||
|
||||
$nav->addFilter('method/'.$method_name,
|
||||
$display_name);
|
||||
}
|
||||
}
|
||||
$nav->selectFilter($this->getFilter());
|
||||
$nav->appendChild($view);
|
||||
$body = $nav;
|
||||
} else {
|
||||
$body = $view;
|
||||
}
|
||||
$page->appendChild($body);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
return $response->setContent($page->render());
|
||||
return $nav;
|
||||
}
|
||||
|
||||
private function getFilter() {
|
||||
return $this->filter;
|
||||
protected function buildApplicationMenu() {
|
||||
return $this->buildSideNavView()->getMenu();
|
||||
}
|
||||
|
||||
protected function setFilter($filter) {
|
||||
$this->filter = $filter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function showSideNav() {
|
||||
return $this->showSideNav !== false;
|
||||
}
|
||||
|
||||
protected function setShowSideNav($show_side_nav) {
|
||||
$this->showSideNav = $show_side_nav;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getAllMethodImplementationClasses() {
|
||||
$classes = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('ConduitAPIMethod')
|
||||
->setType('class')
|
||||
->setConcreteOnly(true)
|
||||
->selectSymbolsWithoutLoading();
|
||||
|
||||
return array_values(ipull($classes, 'name'));
|
||||
}
|
||||
|
||||
protected function getMethodFilters() {
|
||||
$classes = $this->getAllMethodImplementationClasses();
|
||||
$method_names = array();
|
||||
foreach ($classes as $method_class) {
|
||||
$method_name = ConduitAPIMethod::getAPIMethodNameFromClassName(
|
||||
$method_class);
|
||||
$group_name = head(explode('.', $method_name));
|
||||
|
||||
$method_object = newv($method_class, array());
|
||||
|
||||
$application = $method_object->getApplication();
|
||||
if ($application && !$application->isInstalled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = $method_object->getMethodStatus();
|
||||
|
||||
$key = sprintf(
|
||||
'%02d %s %s',
|
||||
$this->getOrderForMethodStatus($status),
|
||||
$group_name,
|
||||
$method_name);
|
||||
|
||||
$method_names[$key] = array(
|
||||
'full_name' => $method_name,
|
||||
'group_name' => $group_name,
|
||||
'status' => $status,
|
||||
'description' => $method_object->getMethodDescription(),
|
||||
);
|
||||
}
|
||||
ksort($method_names);
|
||||
$method_names = igroup($method_names, 'group_name');
|
||||
ksort($method_names);
|
||||
|
||||
return $method_names;
|
||||
}
|
||||
|
||||
private function getOrderForMethodStatus($status) {
|
||||
$map = array(
|
||||
ConduitAPIMethod::METHOD_STATUS_STABLE => 0,
|
||||
ConduitAPIMethod::METHOD_STATUS_UNSTABLE => 1,
|
||||
ConduitAPIMethod::METHOD_STATUS_DEPRECATED => 2,
|
||||
);
|
||||
return idx($map, $status, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user