1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

Refactor Owners pages and Improve the Nav Filter

Summary:
Getting ready to support searching for the related commits by
package owner (D1631):

- Add 'relative' option to the Nav Filter
- Refactor Owners page

Test Plan: - owners page still renders with the filter displayed correctly.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1630
This commit is contained in:
jungejason 2012-02-13 10:03:26 -08:00
parent d7bb1f183c
commit fb9d48f38b
3 changed files with 34 additions and 18 deletions

View file

@ -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');

View file

@ -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;

View file

@ -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 {
if (empty($item['relative'])) {
$href = $item['uri'];
} else {
$href = clone $this->baseURI;
$href->setPath($href->getPath().$item['uri']);
$href = (string)$href;
}
}
$view->addNavItem(