1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-05 12:21:02 +01:00

Replace all instances of AphrontSideNavView with AphrontSideNavFilterView

Summary:
AphrontSideNavView is an old class which required you to do a lot of work; it was obsoleted by AphrontSideNavFilterView. Remove all direct callsites so I can clean it up.

This is a precursor to letting me render a filter menu as a dropdown menu for T1960.

Test Plan:
Examined each interface for correct filter construction and selection:

  - Browsed Diffusion
  - Browsed Differential
  - Browsed Files
  - Browsed Slowvote
  - Browsed Phriction
  - Browsed repo edit interface

Grepped for `AphrontSideNavView`. The only remaining instances are in `AphrontSideNavView` itself and `AphrontSideNavFilterView` (which currently uses it).

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1960

Differential Revision: https://secure.phabricator.com/D4034
This commit is contained in:
epriestley 2012-12-07 13:30:31 -08:00
parent 6482876cf3
commit 20ee3003b5
7 changed files with 40 additions and 110 deletions

View file

@ -82,32 +82,17 @@ final class DifferentialRevisionListController extends DifferentialController {
'order' => 'modified', 'order' => 'modified',
); );
$side_nav = new AphrontSideNavView(); $side_nav = new AphrontSideNavFilterView();
$side_nav->setBaseURI(id(clone $uri)->setPath('/differential/filter/'));
foreach ($filters as $filter) { foreach ($filters as $filter) {
list($filter_name, $display_name) = $filter; list($filter_name, $display_name) = $filter;
if ($filter_name) { if ($filter_name) {
$href = clone $uri; $side_nav->addFilter($filter_name.'/'.$username, $display_name);
$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));
} else { } else {
$item = phutil_render_tag( $side_nav->addLabel($display_name);
'span',
array(),
phutil_escape_html($display_name));
} }
$side_nav->addNavItem($item);
} }
$side_nav->selectFilter($this->filter.'/'.$username, null);
$panels = array(); $panels = array();
$handles = array(); $handles = array();

View file

@ -42,7 +42,8 @@ abstract class DiffusionController extends PhabricatorController {
} }
final protected function buildSideNav($selected, $has_change_view) { final protected function buildSideNav($selected, $has_change_view) {
$nav = new AphrontSideNavView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI(''));
$navs = array( $navs = array(
'history' => 'History View', 'history' => 'History View',
@ -61,36 +62,27 @@ abstract class DiffusionController extends PhabricatorController {
$navs['lint'] = 'Lint View'; $navs['lint'] = 'Lint View';
} }
$selected_href = null;
foreach ($navs as $action => $name) { foreach ($navs as $action => $name) {
$href = $drequest->generateURI( $href = $drequest->generateURI(
array( array(
'action' => $action, 'action' => $action,
)); ));
if ($action == $selected) {
$selected_href = $href;
}
$nav->addNavItem( $nav->addFilter($href, $name);
phutil_render_tag(
'a',
array(
'href' => $href,
'class' =>
($action == $selected
? 'aphront-side-nav-selected'
: null),
),
$name));
} }
$nav->selectFilter($selected_href, null);
// TODO: URI encoding might need to be sorted out for this link. // TODO: URI encoding might need to be sorted out for this link.
$nav->addNavItem( $nav->addFilter(
phutil_render_tag( '/owners/view/search/'.
'a', '?repository='.phutil_escape_uri($drequest->getCallsign()).
array( '&path='.phutil_escape_uri('/'.$drequest->getPath()),
'href' => '/owners/view/search/'. "Search Owners \xE2\x86\x97");
'?repository='.phutil_escape_uri($drequest->getCallsign()).
'&path='.phutil_escape_uri('/'.$drequest->getPath()),
),
"Search Owners \xE2\x86\x97"));
return $nav; return $nav;
} }

View file

@ -21,45 +21,26 @@ final class PhabricatorFileSideNavView extends AphrontView {
'Files' => array(), 'Files' => array(),
'upload' => array( 'upload' => array(
'name' => 'Upload File', 'name' => 'Upload File',
'href' => '/file/filter/upload/'
), ),
'my' => array( 'my' => array(
'name' => 'My Files', 'name' => 'My Files',
'href' => '/file/filter/my/'
), ),
'all' => array( 'all' => array(
'name' => 'All Files', 'name' => 'All Files',
'href' => '/file/filter/all/'
), ),
// TODO: Remove this fairly soon.
'<br />' => null,
'<div style="font-weight: normal; font-size: smaller; '.
'white-space: normal;">NOTE: Macros have moved to a separate '.
'application. Use the "Search" field to jump to it or choose '.
'More Stuff &raquo; Macros from the home page.</span>' => null,
); );
$side_nav = new AphrontSideNavView(); $side_nav = new AphrontSideNavFilterView();
$side_nav->setBaseURI(new PhutilURI('/file/filter/'));
foreach ($filters as $filter_key => $filter) { foreach ($filters as $filter_key => $filter) {
// more of a label than a filter // more of a label than a filter
if (empty($filter)) { if (empty($filter)) {
$side_nav->addNavItem(phutil_render_tag( $side_nav->addLabel($filter_key);
'span',
array(),
$filter_key));
continue; continue;
} }
$selected = $filter_key == $selected_filter; $side_nav->addFilter($filter_key, $filter['name']);
$side_nav->addNavItem(
phutil_render_tag(
'a',
array(
'href' => $filter['href'],
'class' => $selected ? 'aphront-side-nav-selected': null,
),
$filter['name'])
);
} }
$side_nav->selectFilter($selected_filter, null);
$side_nav->appendChild($this->renderChildren()); $side_nav->appendChild($this->renderChildren());
return $side_nav->render(); return $side_nav->render();

View file

@ -107,23 +107,15 @@ final class HeraldTranscriptController extends HeraldController {
} }
private function buildSideNav() { private function buildSideNav() {
$nav = new AphrontSideNavView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/herald/transcript/'.$this->id.'/'));
$items = array(); $items = array();
$filters = $this->getFilterMap(); $filters = $this->getFilterMap();
foreach ($filters as $key => $name) { foreach ($filters as $key => $name) {
$nav->addNavItem( $nav->addFilter($key, $name);
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->selectFilter($this->filter, null);
return $nav; return $nav;
} }

View file

@ -27,19 +27,12 @@ final class PhrictionListController
$this->view = 'active'; $this->view = 'active';
} }
$nav = new AphrontSideNavView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/phriction/list/'));
foreach ($views as $view => $name) { foreach ($views as $view => $name) {
$nav->addNavItem( $nav->addFilter($view, $name);
phutil_render_tag(
'a',
array(
'href' => '/phriction/list/'.$view.'/',
'class' => ($this->view == $view)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($name)));
} }
$nav->selectFilter($this->view, null);
$pager = new AphrontPagerView(); $pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'page'); $pager->setURI($request->getRequestURI(), 'page');

View file

@ -33,19 +33,13 @@ final class PhabricatorRepositoryEditController
$this->view = head_key($views); $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) { foreach ($views as $view => $name) {
$nav->addNavItem( $nav->addFilter($view, $name);
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->selectFilter($this->view, null);
$nav->appendChild($this->renderDaemonNotice()); $nav->appendChild($this->renderDaemonNotice());

View file

@ -143,19 +143,12 @@ final class PhabricatorSlowvoteListController
} }
private function renderSideNav(array $views, $view) { 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) { foreach ($views as $key => $name) {
$side_nav->addNavItem( $side_nav->addFilter($key, $name);
phutil_render_tag(
'a',
array(
'href' => '/vote/view/'.$key.'/',
'class' => ($view == $key)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($name)));
} }
$side_nav->selectFilter($view, null);
return $side_nav; return $side_nav;
} }