diff --git a/src/applications/owners/controller/base/PhabricatorOwnersController.php b/src/applications/owners/controller/base/PhabricatorOwnersController.php index 32f36922fd..28e6380a9c 100644 --- a/src/applications/owners/controller/base/PhabricatorOwnersController.php +++ b/src/applications/owners/controller/base/PhabricatorOwnersController.php @@ -1,7 +1,7 @@ filter; + } + protected function setSideNavFilter($filter) { + $this->filter = $filter; + return $this; + } public function buildStandardPageResponse($view, array $data) { $page = $this->buildStandardPageView(); @@ -25,22 +34,65 @@ abstract class PhabricatorOwnersController extends PhabricatorController { $page->setApplicationName('Owners'); $page->setBaseURI('/owners/'); $page->setTitle(idx($data, 'title')); - $page->setTabs( - array( - 'index' => array( - 'href' => '/owners/', - 'name' => 'Package Index', - ), - 'related' => array( - 'href' => '/owners/related/', - 'name' => 'Related Commits', - ), - ), - idx($data, 'tab')); $page->setGlyph("\xE2\x98\x81"); - $page->appendChild($view); + $nav = $this->renderSideNav(); + $nav->appendChild($view); + $page->appendChild($nav); $response = new AphrontWebpageResponse(); return $response->setContent($page->render()); } + + public function renderSideNav() { + $package_views = array( + array('name' => 'Owned', + 'key' => 'view/owned'), + array('name' => 'All', + 'key' => 'view/all'), + ); + + $package_views = + array_merge($this->getExtraPackageViews(), + $package_views); + + $base_uri = new PhutilURI('/owners/'); + + $nav = new AphrontSideNavFilterView(); + $nav->setBaseUri($base_uri); + $nav->addLabel('Packages'); + foreach ($package_views as $view) { + $nav->addFilter($view['key'], $view['name']); + } + $nav->addSpacer(); + $nav->addLabel('Related Commits'); + $related_views = $this->getRelatedViews(); + foreach ($related_views as $view) { + $href = clone $base_uri; + $href->setPath($href->getPath().$view['key']); + $href = (string)$href; + $nav->addFilter($view['key'], + $view['name'], + $href); + } + + $filter = $this->getSideNavFilter(); + $nav->selectFilter($filter, 'view/owned'); + + return $nav; + } + + protected function getExtraPackageViews() { + return array(); + } + + protected function getRelatedViews() { + $related_views = array( + array('name' => 'Related to Package', + 'key' => 'related/view/all'), + array('name' => 'Needs Attention', + 'key' => 'related/view/audit') + ); + + return $related_views; + } } diff --git a/src/applications/owners/controller/base/__init__.php b/src/applications/owners/controller/base/__init__.php index 951cd6ce8f..07c823a477 100644 --- a/src/applications/owners/controller/base/__init__.php +++ b/src/applications/owners/controller/base/__init__.php @@ -8,7 +8,9 @@ phutil_require_module('phabricator', 'aphront/response/webpage'); phutil_require_module('phabricator', 'applications/base/controller/base'); +phutil_require_module('phabricator', 'view/layout/sidenavfilter'); +phutil_require_module('phutil', 'parser/uri'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php b/src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php index 499a00fbdb..404d198601 100644 --- a/src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php +++ b/src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php @@ -1,7 +1,7 @@ id = $data['id']; @@ -32,6 +33,7 @@ class PhabricatorOwnersDetailController extends PhabricatorOwnersController { if (!$package) { return new Aphront404Response(); } + $this->package = $package; $paths = $package->loadPaths(); $owners = $package->loadOwners(); @@ -138,22 +140,22 @@ class PhabricatorOwnersDetailController extends PhabricatorOwnersController { 'Edit Package')); $panel->appendChild($table); - $nav = new AphrontSideNavView(); - $nav->appendChild($panel); - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/owners/package/'.$package->getID().'/', - 'class' => 'aphront-side-nav-selected', - ), - 'Package Details')); + $key = 'package/'.$package->getID(); + $this->setSideNavFilter($key); return $this->buildStandardPageResponse( - $nav, + $panel, array( 'title' => "Package '".$package->getName()."'", )); } + protected function getExtraPackageViews() { + $package = $this->package; + return array( + array('name' => 'Details', + 'key' => 'package/'.$package->getID(), + )); + } + } diff --git a/src/applications/owners/controller/detail/__init__.php b/src/applications/owners/controller/detail/__init__.php index f81c2c268e..70f0870455 100644 --- a/src/applications/owners/controller/detail/__init__.php +++ b/src/applications/owners/controller/detail/__init__.php @@ -13,7 +13,6 @@ phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/layout/panel'); -phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/owners/controller/edit/PhabricatorOwnersEditController.php b/src/applications/owners/controller/edit/PhabricatorOwnersEditController.php index 833997f4c1..7a1ba89c2c 100644 --- a/src/applications/owners/controller/edit/PhabricatorOwnersEditController.php +++ b/src/applications/owners/controller/edit/PhabricatorOwnersEditController.php @@ -1,7 +1,7 @@ getID() ? 'Edit Package' : 'New Package'; + if ($package->getID()) { + $title = 'Edit Package'; + $side_nav_filter = 'edit/'.$this->id; + } else { + $title = 'New Package'; + $side_nav_filter = 'new'; + } + $this->setSideNavFilter($side_nav_filter); $repos = id(new PhabricatorRepository())->loadAll(); @@ -268,4 +275,15 @@ class PhabricatorOwnersEditController extends PhabricatorOwnersController { )); } + protected function getExtraPackageViews() { + if ($this->id) { + $extra = array(array('name' => 'Edit', + 'key' => 'edit/'.$this->id)); + } else { + $extra = array(array('name' => 'New', + 'key' => 'new')); + } + + return $extra; + } } diff --git a/src/applications/owners/controller/list/PhabricatorOwnersListController.php b/src/applications/owners/controller/list/PhabricatorOwnersListController.php index 8e154bf217..ce1372e0cd 100644 --- a/src/applications/owners/controller/list/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/list/PhabricatorOwnersListController.php @@ -1,7 +1,7 @@ view = idx($data, 'view'); + $this->view = idx($data, 'view', 'owned'); + $this->setSideNavFilter('view/'.$this->view); } public function processRequest() { @@ -29,35 +30,6 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { $request = $this->getRequest(); $user = $request->getUser(); - $views = array( - 'owned' => 'Owned Packages', - 'all' => 'All Packages', - 'search' => 'Search Results', - ); - - if (empty($views[$this->view])) { - reset($views); - $this->view = key($views); - } - - if ($this->view != 'search') { - unset($views['search']); - } - - $nav = new AphrontSideNavView(); - foreach ($views as $key => $name) { - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/owners/view/'.$key.'/', - 'class' => ($this->view == $key) - ? 'aphront-side-nav-selected' - : null, - ), - phutil_escape_html($name))); - } - $package = new PhabricatorOwnersPackage(); $owner = new PhabricatorOwnersOwner(); $path = new PhabricatorOwnersPath(); @@ -184,14 +156,13 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { $filter->appendChild($form); - $nav->appendChild($filter); - $nav->appendChild($content); - return $this->buildStandardPageResponse( - $nav, + array( + $filter, + $content, + ), array( 'title' => 'Package Index', - 'tab' => 'index', )); } @@ -289,4 +260,17 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController { return $panel; } + protected function getExtraPackageViews() { + switch ($this->view) { + case 'search': + $extra = array(array('name' => 'Search Results', + 'key' => 'view/search')); + break; + default: + $extra = array(); + break; + } + + return $extra; + } } diff --git a/src/applications/owners/controller/list/__init__.php b/src/applications/owners/controller/list/__init__.php index a817fedd42..e7bef95555 100644 --- a/src/applications/owners/controller/list/__init__.php +++ b/src/applications/owners/controller/list/__init__.php @@ -20,7 +20,6 @@ phutil_require_module('phabricator', 'view/form/control/text'); phutil_require_module('phabricator', 'view/form/control/tokenizer'); phutil_require_module('phabricator', 'view/layout/listfilter'); phutil_require_module('phabricator', 'view/layout/panel'); -phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php b/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php index 21b0c8b777..41e4a071a2 100644 --- a/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php +++ b/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php @@ -1,7 +1,7 @@ renderSearchView(); $list_panel = $this->renderListPanel(); - $nav = $this->renderSideNav(); - $nav->appendChild($search_view); - $nav->appendChild($list_panel); + $side_nav_filter = 'related/view/'.$this->view.$this->getQueryString(); + $this->setSideNavFilter($side_nav_filter); return $this->buildStandardPageResponse( - $nav, + array( + $search_view, + $list_panel + ), array( 'title' => 'Related Commits', - 'tab' => 'related', )); } + protected function getRelatedViews() { + $related_views = parent::getRelatedViews(); + if ($this->packagePHID) { + $query = $this->getQueryString(); + foreach ($related_views as &$view) { + $view['key'] = $view['key'].$query; + } + } + return $related_views; + } + + private function getQueryString() { + $query = null; + if ($this->packagePHID) { + $query = '/?phid=' . $this->packagePHID; + } + return $query; + } + private function renderListPanel() { if (!$this->packagePHID) { return id(new AphrontErrorView()) @@ -151,33 +171,6 @@ class PhabricatorOwnerRelatedListController return $status_arr; } - private function renderSideNav() { - $views = array( - 'all' => 'Related to Package', - 'audit' => 'Needs Attention', - ); - - $query = null; - if ($this->packagePHID) { - $query = '?phid=' . $this->packagePHID; - } - - $nav = new AphrontSideNavView(); - foreach ($views as $key => $name) { - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/owners/related/view/'.$key.'/'.$query, - 'class' => ($this->view === $key - ? 'aphront-side-nav-selected' - : null), - ), - phutil_escape_html($name))); - } - return $nav; - } - private function renderSearchView() { if ($this->packagePHID) { $loader = new PhabricatorObjectHandleData(array($this->packagePHID)); diff --git a/src/applications/owners/controller/relatedlist/__init__.php b/src/applications/owners/controller/relatedlist/__init__.php index 0d0690cc9e..2ac40f6e74 100644 --- a/src/applications/owners/controller/relatedlist/__init__.php +++ b/src/applications/owners/controller/relatedlist/__init__.php @@ -23,7 +23,6 @@ phutil_require_module('phabricator', 'view/form/control/tokenizer'); phutil_require_module('phabricator', 'view/form/error'); phutil_require_module('phabricator', 'view/layout/listfilter'); 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');