From 5caf9fb6da705031df8d4894147187b109938933 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 26 Jan 2012 12:47:23 -0800 Subject: [PATCH] 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 --- ...AphrontDefaultApplicationConfiguration.php | 2 +- .../base/PhabricatorConduitController.php | 104 +++++++++++++++--- .../conduit/controller/base/__init__.php | 5 + .../PhabricatorConduitConsoleController.php | 63 +---------- .../conduit/controller/console/__init__.php | 1 - .../log/PhabricatorConduitLogController.php | 38 +------ .../conduit/controller/log/__init__.php | 1 - .../PhabricatorConduitTokenController.php | 4 +- 8 files changed, 106 insertions(+), 112 deletions(-) diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 1663a76aa2..f9cb0f574e 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -83,7 +83,7 @@ class AphrontDefaultApplicationConfiguration => 'PhabricatorPeopleProfileController', '/conduit/' => array( '$' => 'PhabricatorConduitConsoleController', - 'method/(?P[^/]+)$' => 'PhabricatorConduitConsoleController', + 'method/(?P[^/]+)/$' => 'PhabricatorConduitConsoleController', 'log/$' => 'PhabricatorConduitLogController', 'log/view/(?P[^/]+)/$' => 'PhabricatorConduitLogController', 'token/$' => 'PhabricatorConduitTokenController', diff --git a/src/applications/conduit/controller/base/PhabricatorConduitController.php b/src/applications/conduit/controller/base/PhabricatorConduitController.php index 3bf54fa81f..e8970994f1 100644 --- a/src/applications/conduit/controller/base/PhabricatorConduitController.php +++ b/src/applications/conduit/controller/base/PhabricatorConduitController.php @@ -1,7 +1,7 @@ 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; + } + } diff --git a/src/applications/conduit/controller/base/__init__.php b/src/applications/conduit/controller/base/__init__.php index a2fb05dbbf..cb54446eae 100644 --- a/src/applications/conduit/controller/base/__init__.php +++ b/src/applications/conduit/controller/base/__init__.php @@ -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'); diff --git a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php index 68825fb93d..47307a4e3b 100644 --- a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php +++ b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php @@ -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[] = '
'; - } - // Pop off the last '
'. - 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')); - } - } diff --git a/src/applications/conduit/controller/console/__init__.php b/src/applications/conduit/controller/console/__init__.php index 9f6b0d44b2..f58e4210cc 100644 --- a/src/applications/conduit/controller/console/__init__.php +++ b/src/applications/conduit/controller/console/__init__.php @@ -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'); diff --git a/src/applications/conduit/controller/log/PhabricatorConduitLogController.php b/src/applications/conduit/controller/log/PhabricatorConduitLogController.php index 8213e5c232..91902f1d00 100644 --- a/src/applications/conduit/controller/log/PhabricatorConduitLogController.php +++ b/src/applications/conduit/controller/log/PhabricatorConduitLogController.php @@ -1,7 +1,7 @@ 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', )); } diff --git a/src/applications/conduit/controller/log/__init__.php b/src/applications/conduit/controller/log/__init__.php index d1643a89c4..168205c0be 100644 --- a/src/applications/conduit/controller/log/__init__.php +++ b/src/applications/conduit/controller/log/__init__.php @@ -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'); diff --git a/src/applications/conduit/controller/token/PhabricatorConduitTokenController.php b/src/applications/conduit/controller/token/PhabricatorConduitTokenController.php index 482a4b306f..7579e4192c 100644 --- a/src/applications/conduit/controller/token/PhabricatorConduitTokenController.php +++ b/src/applications/conduit/controller/token/PhabricatorConduitTokenController.php @@ -1,7 +1,7 @@ arc will then complete the '. 'install process for you.

'); + $this->setFilter('token'); + $this->setShowSideNav(false); return $this->buildStandardPageResponse( $panel,