diff --git a/src/applications/differential/controller/DifferentialRevisionListController.php b/src/applications/differential/controller/DifferentialRevisionListController.php index f02cd9138b..71bed2ea0b 100644 --- a/src/applications/differential/controller/DifferentialRevisionListController.php +++ b/src/applications/differential/controller/DifferentialRevisionListController.php @@ -82,32 +82,17 @@ final class DifferentialRevisionListController extends DifferentialController { 'order' => 'modified', ); - $side_nav = new AphrontSideNavView(); + $side_nav = new AphrontSideNavFilterView(); + $side_nav->setBaseURI(id(clone $uri)->setPath('/differential/filter/')); foreach ($filters as $filter) { list($filter_name, $display_name) = $filter; if ($filter_name) { - $href = clone $uri; - $href->setPath('/differential/filter/'.$filter_name.'/'.$username); - if ($filter_name == $this->filter) { - $class = 'aphront-side-nav-selected'; - } else { - $class = null; - } - $item = phutil_render_tag( - 'a', - array( - 'href' => (string)$href, - 'class' => $class, - ), - phutil_escape_html($display_name)); + $side_nav->addFilter($filter_name.'/'.$username, $display_name); } else { - $item = phutil_render_tag( - 'span', - array(), - phutil_escape_html($display_name)); + $side_nav->addLabel($display_name); } - $side_nav->addNavItem($item); } + $side_nav->selectFilter($this->filter.'/'.$username, null); $panels = array(); $handles = array(); diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index fa07dd1669..2c16ab2246 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -42,7 +42,8 @@ abstract class DiffusionController extends PhabricatorController { } final protected function buildSideNav($selected, $has_change_view) { - $nav = new AphrontSideNavView(); + $nav = new AphrontSideNavFilterView(); + $nav->setBaseURI(new PhutilURI('')); $navs = array( 'history' => 'History View', @@ -61,36 +62,27 @@ abstract class DiffusionController extends PhabricatorController { $navs['lint'] = 'Lint View'; } + $selected_href = null; foreach ($navs as $action => $name) { $href = $drequest->generateURI( array( 'action' => $action, )); + if ($action == $selected) { + $selected_href = $href; + } - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => $href, - 'class' => - ($action == $selected - ? 'aphront-side-nav-selected' - : null), - ), - $name)); + $nav->addFilter($href, $name); } + $nav->selectFilter($selected_href, null); // TODO: URI encoding might need to be sorted out for this link. - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/owners/view/search/'. - '?repository='.phutil_escape_uri($drequest->getCallsign()). - '&path='.phutil_escape_uri('/'.$drequest->getPath()), - ), - "Search Owners \xE2\x86\x97")); + $nav->addFilter( + '/owners/view/search/'. + '?repository='.phutil_escape_uri($drequest->getCallsign()). + '&path='.phutil_escape_uri('/'.$drequest->getPath()), + "Search Owners \xE2\x86\x97"); return $nav; } diff --git a/src/applications/files/view/PhabricatorFileSideNavView.php b/src/applications/files/view/PhabricatorFileSideNavView.php index 71cbabc626..62e9a533c4 100644 --- a/src/applications/files/view/PhabricatorFileSideNavView.php +++ b/src/applications/files/view/PhabricatorFileSideNavView.php @@ -21,45 +21,26 @@ final class PhabricatorFileSideNavView extends AphrontView { 'Files' => array(), 'upload' => array( 'name' => 'Upload File', - 'href' => '/file/filter/upload/' ), 'my' => array( 'name' => 'My Files', - 'href' => '/file/filter/my/' ), 'all' => array( 'name' => 'All Files', - 'href' => '/file/filter/all/' ), - // TODO: Remove this fairly soon. - '
' => null, - '
NOTE: Macros have moved to a separate '. - 'application. Use the "Search" field to jump to it or choose '. - 'More Stuff » Macros from the home page.' => null, ); - $side_nav = new AphrontSideNavView(); + $side_nav = new AphrontSideNavFilterView(); + $side_nav->setBaseURI(new PhutilURI('/file/filter/')); foreach ($filters as $filter_key => $filter) { // more of a label than a filter if (empty($filter)) { - $side_nav->addNavItem(phutil_render_tag( - 'span', - array(), - $filter_key)); + $side_nav->addLabel($filter_key); continue; } - $selected = $filter_key == $selected_filter; - $side_nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => $filter['href'], - 'class' => $selected ? 'aphront-side-nav-selected': null, - ), - $filter['name']) - ); + $side_nav->addFilter($filter_key, $filter['name']); } + $side_nav->selectFilter($selected_filter, null); $side_nav->appendChild($this->renderChildren()); return $side_nav->render(); diff --git a/src/applications/herald/controller/HeraldTranscriptController.php b/src/applications/herald/controller/HeraldTranscriptController.php index 6ed6e2f3fd..f18e77baf6 100644 --- a/src/applications/herald/controller/HeraldTranscriptController.php +++ b/src/applications/herald/controller/HeraldTranscriptController.php @@ -107,23 +107,15 @@ final class HeraldTranscriptController extends HeraldController { } private function buildSideNav() { - $nav = new AphrontSideNavView(); + $nav = new AphrontSideNavFilterView(); + $nav->setBaseURI(new PhutilURI('/herald/transcript/'.$this->id.'/')); $items = array(); $filters = $this->getFilterMap(); foreach ($filters as $key => $name) { - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/herald/transcript/'.$this->id.'/'.$key.'/', - 'class' => - ($key == $this->filter) - ? 'aphront-side-nav-selected' - : null, - ), - phutil_escape_html($name))); + $nav->addFilter($key, $name); } + $nav->selectFilter($this->filter, null); return $nav; } diff --git a/src/applications/phriction/controller/PhrictionListController.php b/src/applications/phriction/controller/PhrictionListController.php index 45cca58155..2ee98ddedd 100644 --- a/src/applications/phriction/controller/PhrictionListController.php +++ b/src/applications/phriction/controller/PhrictionListController.php @@ -27,19 +27,12 @@ final class PhrictionListController $this->view = 'active'; } - $nav = new AphrontSideNavView(); + $nav = new AphrontSideNavFilterView(); + $nav->setBaseURI(new PhutilURI('/phriction/list/')); foreach ($views as $view => $name) { - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/phriction/list/'.$view.'/', - 'class' => ($this->view == $view) - ? 'aphront-side-nav-selected' - : null, - ), - phutil_escape_html($name))); + $nav->addFilter($view, $name); } + $nav->selectFilter($this->view, null); $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'page'); diff --git a/src/applications/repository/controller/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/PhabricatorRepositoryEditController.php index 077bd9ab25..16ffd4accc 100644 --- a/src/applications/repository/controller/PhabricatorRepositoryEditController.php +++ b/src/applications/repository/controller/PhabricatorRepositoryEditController.php @@ -33,19 +33,13 @@ final class PhabricatorRepositoryEditController $this->view = head_key($views); } - $nav = new AphrontSideNavView(); + $nav = new AphrontSideNavFilterView(); + $base_uri = new PhutilURI('/repository/edit/'.$repository->getID().'/'); + $nav->setBaseURI($base_uri); foreach ($views as $view => $name) { - $nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'class' => ($view == $this->view - ? 'aphront-side-nav-selected' - : null), - 'href' => '/repository/edit/'.$repository->getID().'/'.$view.'/', - ), - phutil_escape_html($name))); + $nav->addFilter($view, $name); } + $nav->selectFilter($this->view, null); $nav->appendChild($this->renderDaemonNotice()); diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php index 2ba2b5fdb0..21ea6948be 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php @@ -143,19 +143,12 @@ final class PhabricatorSlowvoteListController } private function renderSideNav(array $views, $view) { - $side_nav = new AphrontSideNavView(); + $side_nav = new AphrontSideNavFilterView(); + $side_nav->setBaseURI(new PhutilURI('/vote/view/')); foreach ($views as $key => $name) { - $side_nav->addNavItem( - phutil_render_tag( - 'a', - array( - 'href' => '/vote/view/'.$key.'/', - 'class' => ($view == $key) - ? 'aphront-side-nav-selected' - : null, - ), - phutil_escape_html($name))); + $side_nav->addFilter($key, $name); } + $side_nav->selectFilter($view, null); return $side_nav; }