diff --git a/src/applications/owners/controller/base/PhabricatorOwnersController.php b/src/applications/owners/controller/base/PhabricatorOwnersController.php index 8202a1dc78..7f643ed1ea 100644 --- a/src/applications/owners/controller/base/PhabricatorOwnersController.php +++ b/src/applications/owners/controller/base/PhabricatorOwnersController.php @@ -66,24 +66,16 @@ abstract class PhabricatorOwnersController extends PhabricatorController { $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->addFilters($package_views); + $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); - } + $nav->addFilters($related_views); $filter = $this->getSideNavFilter(); $nav->selectFilter($filter, 'view/owned'); diff --git a/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php b/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php index 4cd270b137..29639e2a53 100644 --- a/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php +++ b/src/applications/owners/controller/relatedlist/PhabricatorOwnerRelatedListController.php @@ -51,13 +51,13 @@ class PhabricatorOwnerRelatedListController $search_view = $this->renderSearchView(); $list_panel = $this->renderListPanel(); - $side_nav_filter = 'related/view/'.$this->view.$this->getQueryString(); + $side_nav_filter = 'related/view/'.$this->view; $this->setSideNavFilter($side_nav_filter); return $this->buildStandardPageResponse( array( $search_view, - $list_panel + $list_panel, ), array( 'title' => 'Related Commits', @@ -69,7 +69,8 @@ class PhabricatorOwnerRelatedListController if ($this->packagePHID) { $query = $this->getQueryString(); foreach ($related_views as &$view) { - $view['key'] = $view['key'].$query; + $view['uri'] = $view['key'].$query; + $view['relative'] = true; } } return $related_views; diff --git a/src/view/layout/sidenavfilter/AphrontSideNavFilterView.php b/src/view/layout/sidenavfilter/AphrontSideNavFilterView.php index b7febf5be6..5b28c76fa9 100644 --- a/src/view/layout/sidenavfilter/AphrontSideNavFilterView.php +++ b/src/view/layout/sidenavfilter/AphrontSideNavFilterView.php @@ -41,11 +41,24 @@ final class AphrontSideNavFilterView extends AphrontView { private $baseURI; private $selectedFilter = false; - public function addFilter($key, $name, $uri = null) { - $this->items[] = array('filter', $key, $name, 'uri' => $uri); + public function addFilter($key, $name, $uri = null, $relative = false) { + $this->items[] = array( + 'filter', $key, $name, 'uri' => $uri, 'relative' => $relative); return $this; } + public function addFilters(array $views) { + foreach ($views as $view) { + $uri = isset($view['uri']) ? $view['uri'] : null; + $relative = isset($view['relative']) ? $view['relative'] : false; + $this->addFilter( + $view['key'], + $view['name'], + $uri, + $relative); + } + } + public function addLabel($name) { $this->items[] = array('label', null, $name); return $this; @@ -61,6 +74,10 @@ final class AphrontSideNavFilterView extends AphrontView { return $this; } + public function getBaseURI() { + return $this->baseURI; + } + public function selectFilter($key, $default) { $this->selectedFilter = $default; if ($key !== null) { @@ -108,7 +125,13 @@ final class AphrontSideNavFilterView extends AphrontView { $href->setPath($href->getPath().$key.'/'); $href = (string)$href; } else { - $href = $item['uri']; + if (empty($item['relative'])) { + $href = $item['uri']; + } else { + $href = clone $this->baseURI; + $href->setPath($href->getPath().$item['uri']); + $href = (string)$href; + } } $view->addNavItem(