From 46baa3b7ae3b058316393b2d9c5d59aff92a2193 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 16 Dec 2011 13:29:32 -0800 Subject: [PATCH] Herald - Kill Tabs Summary: makes a nice side filter for most UI elements. only place this getds a little funky is on the test console; a second, inner filter list appears for the "affected" filters. Test Plan: viewed each side filter and verified ui. for each filter, interacted with the ui and made sure things looked right and there were no errors Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T631 Differential Revision: https://secure.phabricator.com/D1289 --- .../all/HeraldAllRulesController.php | 15 ++++- .../controller/base/HeraldController.php | 64 +++++++++++-------- .../herald/controller/base/__init__.php | 3 + .../delete/HeraldDeleteController.php | 6 ++ .../controller/home/HeraldHomeController.php | 29 ++++----- .../herald/controller/home/__init__.php | 2 - .../controller/new/HeraldNewController.php | 6 +- .../controller/rule/HeraldRuleController.php | 9 +++ .../test/HeraldTestConsoleController.php | 6 +- .../transcript/HeraldTranscriptController.php | 4 ++ .../HeraldTranscriptListController.php | 4 ++ 11 files changed, 100 insertions(+), 48 deletions(-) diff --git a/src/applications/herald/controller/all/HeraldAllRulesController.php b/src/applications/herald/controller/all/HeraldAllRulesController.php index f78ea70ab0..2e69d7bb9f 100644 --- a/src/applications/herald/controller/all/HeraldAllRulesController.php +++ b/src/applications/herald/controller/all/HeraldAllRulesController.php @@ -20,6 +20,15 @@ class HeraldAllRulesController extends HeraldController { private $view; private $viewPHID; + private $filter; + + public function getFilter() { + return $this->filter; + } + public function setFilter($filter) { + $this->filter = 'all/view/'.$filter; + return $this; + } public function shouldRequireAdmin() { return true; @@ -27,6 +36,7 @@ class HeraldAllRulesController extends HeraldController { public function willProcessRequest(array $data) { $this->view = idx($data, 'view'); + $this->setFilter($this->view); } public function processRequest() { @@ -108,7 +118,10 @@ class HeraldAllRulesController extends HeraldController { } return $this->buildStandardPageResponse( - $sidenav, + array( + $filter_view, + $panel + ), array( 'title' => 'Herald', 'tab' => 'all', diff --git a/src/applications/herald/controller/base/HeraldController.php b/src/applications/herald/controller/base/HeraldController.php index fa70b204b7..7a9720b6e4 100644 --- a/src/applications/herald/controller/base/HeraldController.php +++ b/src/applications/herald/controller/base/HeraldController.php @@ -25,43 +25,57 @@ abstract class HeraldController extends PhabricatorController { $page->setBaseURI('/herald/'); $page->setTitle(idx($data, 'title')); $page->setGlyph("\xE2\x98\xBF"); - $page->appendChild($view); $doclink = PhabricatorEnv::getDoclink('article/Herald_User_Guide.html'); + $nav = new AphrontSideNavFilterView(); + $nav + ->setBaseURI(new PhutilURI('/herald/')) + ->addLabel('Rules') + ->addFilter('new', 'Create Rule'); + $rules_map = HeraldContentTypeConfig::getContentTypeMap(); + $first_filter = null; + foreach ($rules_map as $key => $value) { + $nav->addFilter('view/'.$key, $value); + if (!$first_filter) { + $first_filter = 'view/'.$key; + } + } + + $nav + ->addSpacer() + ->addLabel('Utilities') + ->addFilter('test', 'Test Console') + ->addFilter('transcript', 'Transcripts'); + + $user = $this->getRequest()->getUser(); + if ($user->getIsAdmin()) { + $nav + ->addSpacer() + ->addLabel('Admin'); + $view_PHID = nonempty($this->getRequest()->getStr('phid'), null); + foreach ($rules_map as $key => $value) { + $nav + ->addFilter('all/view/'.$key, $value); + } + } + + $nav->selectFilter($this->getFilter(), $first_filter); + $nav->appendChild($view); + $page->appendChild($nav); + $tabs = array( - 'rules' => array( - 'href' => '/herald/', - 'name' => 'Rules', - ), - 'test' => array( - 'href' => '/herald/test/', - 'name' => 'Test Console', - ), - 'transcripts' => array( - 'href' => '/herald/transcript/', - 'name' => 'Transcripts', - ), 'help' => array( 'href' => $doclink, 'name' => 'Help', ), ); - - $user = $this->getRequest()->getUser(); - if ($user->getIsAdmin()) { - $tabs['all'] = array( - 'href' => '/herald/all', - 'name' => 'All Rules', - ); - } - - $page->setTabs( - $tabs, - idx($data, 'tab')); + $page->setTabs($tabs. null); $response = new AphrontWebpageResponse(); return $response->setContent($page->render()); } + + abstract function getFilter(); } diff --git a/src/applications/herald/controller/base/__init__.php b/src/applications/herald/controller/base/__init__.php index d6e0098e21..409c873f20 100644 --- a/src/applications/herald/controller/base/__init__.php +++ b/src/applications/herald/controller/base/__init__.php @@ -8,8 +8,11 @@ phutil_require_module('phabricator', 'aphront/response/webpage'); phutil_require_module('phabricator', 'applications/base/controller/base'); +phutil_require_module('phabricator', 'applications/herald/config/contenttype'); phutil_require_module('phabricator', 'infrastructure/env'); +phutil_require_module('phabricator', 'view/layout/sidenavfilter'); +phutil_require_module('phutil', 'parser/uri'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/herald/controller/delete/HeraldDeleteController.php b/src/applications/herald/controller/delete/HeraldDeleteController.php index 291aed4196..fb5157fd47 100644 --- a/src/applications/herald/controller/delete/HeraldDeleteController.php +++ b/src/applications/herald/controller/delete/HeraldDeleteController.php @@ -20,6 +20,12 @@ class HeraldDeleteController extends HeraldController { private $id; + public function getFilter() { + // note this controller is only used from a dialog-context at the moment + // and there is actually no "delete" filter + return 'delete'; + } + public function willProcessRequest(array $data) { $this->id = $data['id']; } diff --git a/src/applications/herald/controller/home/HeraldHomeController.php b/src/applications/herald/controller/home/HeraldHomeController.php index 0a8293d552..9771c632a9 100644 --- a/src/applications/herald/controller/home/HeraldHomeController.php +++ b/src/applications/herald/controller/home/HeraldHomeController.php @@ -19,9 +19,19 @@ class HeraldHomeController extends HeraldController { private $view; + private $filter; public function willProcessRequest(array $data) { $this->view = idx($data, 'view'); + $this->setFilter($this->view); + } + + public function getFilter() { + return $this->filter; + } + public function setFilter($filter) { + $this->filter = 'view/'.$filter; + return $this; } public function processRequest() { @@ -52,28 +62,11 @@ class HeraldHomeController extends HeraldController { ->setView($this->view); $panel = $list_view->render(); - $sidenav = new AphrontSideNavView(); - $sidenav->appendChild($panel); - - foreach ($map as $key => $value) { - $sidenav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/herald/view/'.$key.'/', - 'class' => ($key == $this->view) - ? 'aphront-side-nav-selected' - : null, - ), - phutil_escape_html($value))); - } return $this->buildStandardPageResponse( - $sidenav, + $panel, array( 'title' => 'Herald', - 'tab' => 'rules', )); } - } diff --git a/src/applications/herald/controller/home/__init__.php b/src/applications/herald/controller/home/__init__.php index 336ecb982f..a4347e6adb 100644 --- a/src/applications/herald/controller/home/__init__.php +++ b/src/applications/herald/controller/home/__init__.php @@ -11,9 +11,7 @@ phutil_require_module('phabricator', 'applications/herald/controller/base'); phutil_require_module('phabricator', 'applications/herald/storage/rule'); phutil_require_module('phabricator', 'applications/herald/view/rulelist'); phutil_require_module('phabricator', 'applications/phid/handle/data'); -phutil_require_module('phabricator', 'view/layout/sidenav'); -phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/herald/controller/new/HeraldNewController.php b/src/applications/herald/controller/new/HeraldNewController.php index 54f765527b..71e34da1cc 100644 --- a/src/applications/herald/controller/new/HeraldNewController.php +++ b/src/applications/herald/controller/new/HeraldNewController.php @@ -20,6 +20,10 @@ class HeraldNewController extends HeraldController { private $type; + public function getFilter() { + return 'new'; + } + public function willProcessRequest(array $data) { $this->type = idx($data, 'type'); } @@ -51,7 +55,7 @@ class HeraldNewController extends HeraldController { $panel = new AphrontPanelView(); $panel->setHeader('Create New Herald Rule'); - $panel->setWidth(AphrontPanelView::WIDTH_FORM); + $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->appendChild($form); return $this->buildStandardPageResponse( diff --git a/src/applications/herald/controller/rule/HeraldRuleController.php b/src/applications/herald/controller/rule/HeraldRuleController.php index 67de87388d..5b8a63d526 100644 --- a/src/applications/herald/controller/rule/HeraldRuleController.php +++ b/src/applications/herald/controller/rule/HeraldRuleController.php @@ -19,6 +19,14 @@ class HeraldRuleController extends HeraldController { private $id; + private $filter; + + public function getFilter() { + return $this->filter; + } + public function setFilter($filter) { + $this->filter = 'view/'.$filter; + } public function willProcessRequest(array $data) { $this->id = (int)idx($data, 'id'); @@ -50,6 +58,7 @@ class HeraldRuleController extends HeraldController { } $rule->setContentType($type); } + $this->setFilter($rule->getContentType()); $local_version = id(new HeraldRule())->getConfigVersion(); if ($rule->getConfigVersion() > $local_version) { diff --git a/src/applications/herald/controller/test/HeraldTestConsoleController.php b/src/applications/herald/controller/test/HeraldTestConsoleController.php index a62395c723..a8eb194e79 100644 --- a/src/applications/herald/controller/test/HeraldTestConsoleController.php +++ b/src/applications/herald/controller/test/HeraldTestConsoleController.php @@ -18,6 +18,10 @@ class HeraldTestConsoleController extends HeraldController { + public function getFilter() { + return 'test'; + } + public function processRequest() { $request = $this->getRequest(); @@ -128,7 +132,7 @@ class HeraldTestConsoleController extends HeraldController { $panel = new AphrontPanelView(); $panel->setHeader('Test Herald Rules'); - $panel->setWidth(AphrontPanelView::WIDTH_FORM); + $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->appendChild($form); return $this->buildStandardPageResponse( diff --git a/src/applications/herald/controller/transcript/HeraldTranscriptController.php b/src/applications/herald/controller/transcript/HeraldTranscriptController.php index bf9f0fcd5d..4840352817 100644 --- a/src/applications/herald/controller/transcript/HeraldTranscriptController.php +++ b/src/applications/herald/controller/transcript/HeraldTranscriptController.php @@ -26,6 +26,10 @@ class HeraldTranscriptController extends HeraldController { private $filter; private $handles; + public function getFilter() { + return 'transcript'; + } + public function willProcessRequest(array $data) { $this->id = $data['id']; $map = $this->getFilterMap(); diff --git a/src/applications/herald/controller/transcriptlist/HeraldTranscriptListController.php b/src/applications/herald/controller/transcriptlist/HeraldTranscriptListController.php index c465655c4d..560c7ad8dc 100644 --- a/src/applications/herald/controller/transcriptlist/HeraldTranscriptListController.php +++ b/src/applications/herald/controller/transcriptlist/HeraldTranscriptListController.php @@ -18,6 +18,10 @@ class HeraldTranscriptListController extends HeraldController { + public function getFilter() { + return 'transcript'; + } + public function processRequest() { $request = $this->getRequest();