1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +01:00

Probably added app menu for mobile

Summary:
Messy POC. I hope I did this one right :P

Refs T2014

Test Plan: Switched browser forcefully into `device-phone`, saw filters in the menu top right. Browsed around Differential in desktop mode, nothing was broken, I think.

Reviewers: epriestley, chad, btrahan

CC: aran, Korvin

Maniphest Tasks: T2014

Differential Revision: https://secure.phabricator.com/D5693
This commit is contained in:
Anh Nhan Nguyen 2013-04-15 06:52:28 -07:00 committed by epriestley
parent cf4ff8318e
commit bd350abbe9
2 changed files with 64 additions and 50 deletions

View file

@ -10,8 +10,6 @@ abstract class DifferentialController extends PhabricatorController {
require_celerity_resource('differential-core-view-css');
$viewer_is_anonymous = !$this->getRequest()->getUser()->isLoggedIn();
$page = $this->buildStandardPageView();
$page->setApplicationName(pht('Differential'));
$page->setBaseURI('/differential/');
@ -27,7 +25,6 @@ abstract class DifferentialController extends PhabricatorController {
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$create_uri = new PhutilURI('/differential/diff/create/');
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setHref($this->getApplicationURI('/diff/create/'))
@ -37,4 +34,65 @@ abstract class DifferentialController extends PhabricatorController {
return $crumbs;
}
public function buildSideNav($filter = null,
$for_app = false, $username = null) {
$viewer_is_anonymous = !$this->getRequest()->getUser()->isLoggedIn();
$uri = id(new PhutilURI('/differential/filter/'))
->setQueryParams($this->getRequest()->getRequestURI()->getQueryParams());
$filters = $this->getFilters();
$filter = $this->selectFilter($filters, $filter, $viewer_is_anonymous);
$side_nav = new AphrontSideNavFilterView();
$side_nav->setBaseURI($uri);
foreach ($filters as $filter) {
list($filter_name, $display_name) = $filter;
if ($filter_name) {
$side_nav->addFilter($filter_name.'/'.$username, $display_name);
} else {
$side_nav->addLabel($display_name);
}
}
return $side_nav;
}
protected function getFilters() {
return array(
array(null, pht('User Revisions')),
array('active', pht('Active')),
array('revisions', pht('Revisions')),
array('reviews', pht('Reviews')),
array('subscribed', pht('Subscribed')),
array('drafts', pht('Draft Reviews')),
array(null, pht('All Revisions')),
array('all', pht('All')),
);
}
protected function selectFilter(
array $filters,
$requested_filter,
$viewer_is_anonymous) {
$default_filter = ($viewer_is_anonymous ? 'all' : 'active');
// If the user requested a filter, make sure it actually exists.
if ($requested_filter) {
foreach ($filters as $filter) {
if ($filter[0] === $requested_filter) {
return $requested_filter;
}
}
}
// If not, return the default filter.
return $default_filter;
}
public function buildApplicationMenu() {
return $this->buildSideNav(null, true)->getMenu();
}
}

View file

@ -17,7 +17,6 @@ final class DifferentialRevisionListController extends DifferentialController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn();
$params = array_filter(
array(
@ -26,12 +25,9 @@ final class DifferentialRevisionListController extends DifferentialController {
));
$params['participants'] = $request->getArr('participants');
$default_filter = ($viewer_is_anonymous ? 'all' : 'active');
$filters = $this->getFilters();
$this->filter = $this->selectFilter(
$filters,
$this->filter,
$default_filter);
$this->filter = $this->selectFilter($filters,
$this->filter, !$user->isLoggedIn());
// Redirect from search to canonical URL.
$phid_arr = $request->getArr('view_users');
@ -80,16 +76,7 @@ final class DifferentialRevisionListController extends DifferentialController {
'order' => 'modified',
);
$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) {
$side_nav->addFilter($filter_name.'/'.$username, $display_name);
} else {
$side_nav->addLabel($display_name);
}
}
$side_nav = $this->buildSideNav($this->filter, false, $username);
$side_nav->selectFilter($this->filter.'/'.$username, null);
$panels = array();
@ -202,37 +189,6 @@ final class DifferentialRevisionListController extends DifferentialController {
));
}
private function getFilters() {
return array(
array(null, pht('User Revisions')),
array('active', pht('Active')),
array('revisions', pht('Revisions')),
array('reviews', pht('Reviews')),
array('subscribed', pht('Subscribed')),
array('drafts', pht('Draft Reviews')),
array(null, pht('All Revisions')),
array('all', pht('All')),
);
}
private function selectFilter(
array $filters,
$requested_filter,
$default_filter) {
// If the user requested a filter, make sure it actually exists.
if ($requested_filter) {
foreach ($filters as $filter) {
if ($filter[0] === $requested_filter) {
return $requested_filter;
}
}
}
// If not, return the default filter.
return $default_filter;
}
private function getFilterRequiresUser($filter) {
static $requires = array(
'active' => true,