1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

Conduit -- kill tabs

Summary:
this has a single side nav now.   added a Utilites section below the methods
which houses Logs and Token.

On logs I ended up deleting this whole concept of "view" and the existing side
nav -- I think there were plans to add a way to filter down to subset of the
conduit calls.  For logs, I envision that being a separate first class tool when
/ if we think we need additional complexity.

On token I made the form FULL so it was like the rest of the views in this page.

Test Plan:
looks good!   clicked on a few methods and it worked!  clicked on the
logs and they were there!  clicked on the pager within the logs and it worked!
checked out the token page and it looked good too.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T631

Differential Revision: https://secure.phabricator.com/D1499
This commit is contained in:
Bob Trahan 2012-01-26 12:47:23 -08:00
parent 76dac260e7
commit 5caf9fb6da
8 changed files with 106 additions and 112 deletions

View file

@ -83,7 +83,7 @@ class AphrontDefaultApplicationConfiguration
=> 'PhabricatorPeopleProfileController',
'/conduit/' => array(
'$' => 'PhabricatorConduitConsoleController',
'method/(?P<method>[^/]+)$' => 'PhabricatorConduitConsoleController',
'method/(?P<method>[^/]+)/$' => 'PhabricatorConduitConsoleController',
'log/$' => 'PhabricatorConduitLogController',
'log/view/(?P<view>[^/]+)/$' => 'PhabricatorConduitLogController',
'token/$' => 'PhabricatorConduitTokenController',

View file

@ -1,7 +1,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,29 +21,105 @@
*/
abstract class PhabricatorConduitController extends PhabricatorController {
private $filter;
protected $showSideNav;
public function buildStandardPageResponse($view, array $data) {
$doclink = PhabricatorEnv::getDoclink(
'article/Conduit_Technical_Documentation.html'
);
$page = $this->buildStandardPageView();
$page->setApplicationName('Conduit');
$page->setBaseURI('/conduit/');
$page->setTitle(idx($data, 'title'));
$page->setTabs(
array(
'console' => array(
'href' => '/conduit/',
'name' => 'Console',
),
'logs' => array(
'href' => '/conduit/log/',
'name' => 'Logs',
),
),
idx($data, 'tab'));
$page->setGlyph("\xE2\x87\xB5");
$page->appendChild($view);
$page->setTabs(array(
'help' => array(
'href' => $doclink,
'name' => 'Help')
), null);
if ($this->showSideNav()) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/conduit/'));
$first_filter = null;
$method_filters = $this->getMethodFilters();
foreach ($method_filters as $group => $methods) {
$nav->addLabel($group);
foreach ($methods as $method) {
$method_name = $method['full_name'];
$nav->addFilter('method/'.$method_name,
$method_name);
if (!$first_filter) {
$first_filter = 'method/'.$method_name;
}
}
$nav->addSpacer();
}
$nav->addLabel('Utilities');
$nav->addFilter('log', 'Logs');
$nav->addFilter('token', 'Token');
$nav->selectFilter($this->getFilter(), $first_filter);
$nav->appendChild($view);
$body = $nav;
} else {
$body = $view;
}
$page->appendChild($body);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
private function getFilter() {
return $this->filter;
}
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'));
}
private function getMethodFilters() {
$classes = $this->getAllMethodImplementationClasses();
$method_names = array();
foreach ($classes as $method_class) {
$method_name = ConduitAPIMethod::getAPIMethodNameFromClassName(
$method_class);
$parts = explode('.', $method_name);
$method_names[] = array(
'full_name' => $method_name,
'group_name' => reset($parts),
);
}
$method_names = igroup($method_names, 'group_name');
ksort($method_names);
return $method_names;
}
}

View file

@ -8,7 +8,12 @@
phutil_require_module('phabricator', 'aphront/response/webpage');
phutil_require_module('phabricator', 'applications/base/controller/base');
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
phutil_require_module('phutil', 'parser/uri');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');

View file

@ -36,6 +36,7 @@ class PhabricatorConduitConsoleController
if (empty($methods[$this->method])) {
$this->method = key($methods);
}
$this->setFilter('method/'.$this->method);
$method_class = $methods[$this->method];
PhutilSymbolLoader::loadClass($method_class);
@ -108,62 +109,13 @@ class PhabricatorConduitConsoleController
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
$view = new AphrontSideNavView();
foreach ($this->buildNavItems() as $item) {
$view->addNavItem($item);
}
$view->appendChild($panel);
return $this->buildStandardPageResponse(
array($view),
array($panel),
array(
'title' => 'Conduit Console',
'tab' => 'console',
));
}
private function buildNavItems() {
$classes = $this->getAllMethodImplementationClasses();
$method_names = array();
foreach ($classes as $method_class) {
$method_name = ConduitAPIMethod::getAPIMethodNameFromClassName(
$method_class);
$parts = explode('.', $method_name);
$method_names[] = array(
'full_name' => $method_name,
'group_name' => reset($parts),
);
}
$method_names = igroup($method_names, 'group_name');
ksort($method_names);
$items = array();
foreach ($method_names as $group => $methods) {
$items[] = phutil_render_tag(
'a',
array(
),
phutil_escape_html($group));
foreach ($methods as $method) {
$method_name = $method['full_name'];
$selected = ($method_name == $this->method);
$items[] = phutil_render_tag(
'a',
array(
'class' => $selected ? 'aphront-side-nav-selected' : null,
'href' => '/conduit/method/'.$method_name,
),
phutil_escape_html($method_name));
}
$items[] = '<hr />';
}
// Pop off the last '<hr />'.
array_pop($items);
return $items;
}
private function getAllMethods() {
$classes = $this->getAllMethodImplementationClasses();
$methods = array();
@ -173,15 +125,4 @@ class PhabricatorConduitConsoleController
}
return $methods;
}
private function getAllMethodImplementationClasses() {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass('ConduitAPIMethod')
->setType('class')
->setConcreteOnly(true)
->selectSymbolsWithoutLoading();
return array_values(ipull($classes, 'name'));
}
}

View file

@ -15,7 +15,6 @@ phutil_require_module('phabricator', 'view/form/control/static');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'symbols');

View file

@ -1,7 +1,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,37 +21,9 @@
*/
class PhabricatorConduitLogController extends PhabricatorConduitController {
private $view;
public function willProcessRequest(array $data) {
$this->view = idx($data, 'view');
}
public function processRequest() {
$request = $this->getRequest();
$nav = new AphrontSideNavView();
$links = array(
'calls' => 'All Calls',
);
if (empty($links[$this->view])) {
$this->view = key($links);
}
foreach ($links as $slug => $name) {
$nav->addNavItem(
phutil_render_tag(
'a',
array(
'href' => '/conduit/log/view/'.$slug.'/',
'class' => ($slug == $this->view)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($name)));
}
$conn_table = new PhabricatorConduitConnectionLog();
$call_table = new PhabricatorConduitMethodCallLog();
@ -64,7 +36,7 @@ class PhabricatorConduitLogController extends PhabricatorConduitController {
$pager->getOffset(),
$pager->getPageSize() + 1);
$calls = $pager->sliceResults($calls);
$pager->setURI(new PhutilURI('/conduit/log/view/'.$this->view.'/'), 'page');
$pager->setURI(new PhutilURI('/conduit/log/'), 'page');
$pager->setEnableKeyboardShortcuts(true);
$min = $pager->getOffset() + 1;
@ -83,13 +55,13 @@ class PhabricatorConduitLogController extends PhabricatorConduitController {
$panel->setHeader('Conduit Method Calls ('.$min.'-'.$max.')');
$panel->appendChild($table);
$panel->appendChild($pager);
$nav->appendChild($panel);
$this->setFilter('log');
return $this->buildStandardPageResponse(
$nav,
$panel,
array(
'title' => 'Conduit Logs',
'tab' => 'logs',
));
}

View file

@ -12,7 +12,6 @@ phutil_require_module('phabricator', 'applications/conduit/storage/methodcalllog
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup');

View file

@ -1,7 +1,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -56,6 +56,8 @@ class PhabricatorConduitTokenController extends PhabricatorConduitController {
'<p class="aphront-form-instructions">arc will then complete the '.
'install process for you.</p>');
$this->setFilter('token');
$this->setShowSideNav(false);
return $this->buildStandardPageResponse(
$panel,