mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 19:31: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:
parent
6482876cf3
commit
20ee3003b5
7 changed files with 40 additions and 110 deletions
|
@ -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';
|
||||
$side_nav->addFilter($filter_name.'/'.$username, $display_name);
|
||||
} else {
|
||||
$class = null;
|
||||
$side_nav->addLabel($display_name);
|
||||
}
|
||||
$item = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => (string)$href,
|
||||
'class' => $class,
|
||||
),
|
||||
phutil_escape_html($display_name));
|
||||
} else {
|
||||
$item = phutil_render_tag(
|
||||
'span',
|
||||
array(),
|
||||
phutil_escape_html($display_name));
|
||||
}
|
||||
$side_nav->addNavItem($item);
|
||||
}
|
||||
$side_nav->selectFilter($this->filter.'/'.$username, null);
|
||||
|
||||
$panels = array();
|
||||
$handles = array();
|
||||
|
|
|
@ -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,
|
||||
));
|
||||
|
||||
$nav->addNavItem(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $href,
|
||||
'class' =>
|
||||
($action == $selected
|
||||
? 'aphront-side-nav-selected'
|
||||
: null),
|
||||
),
|
||||
$name));
|
||||
if ($action == $selected) {
|
||||
$selected_href = $href;
|
||||
}
|
||||
|
||||
$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/'.
|
||||
$nav->addFilter(
|
||||
'/owners/view/search/'.
|
||||
'?repository='.phutil_escape_uri($drequest->getCallsign()).
|
||||
'&path='.phutil_escape_uri('/'.$drequest->getPath()),
|
||||
),
|
||||
"Search Owners \xE2\x86\x97"));
|
||||
"Search Owners \xE2\x86\x97");
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
'<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 » 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) {
|
||||
// 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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue