mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-01 18:30:59 +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:
parent
cf4ff8318e
commit
bd350abbe9
2 changed files with 64 additions and 50 deletions
|
@ -10,8 +10,6 @@ abstract class DifferentialController extends PhabricatorController {
|
||||||
|
|
||||||
require_celerity_resource('differential-core-view-css');
|
require_celerity_resource('differential-core-view-css');
|
||||||
|
|
||||||
$viewer_is_anonymous = !$this->getRequest()->getUser()->isLoggedIn();
|
|
||||||
|
|
||||||
$page = $this->buildStandardPageView();
|
$page = $this->buildStandardPageView();
|
||||||
$page->setApplicationName(pht('Differential'));
|
$page->setApplicationName(pht('Differential'));
|
||||||
$page->setBaseURI('/differential/');
|
$page->setBaseURI('/differential/');
|
||||||
|
@ -27,7 +25,6 @@ abstract class DifferentialController extends PhabricatorController {
|
||||||
public function buildApplicationCrumbs() {
|
public function buildApplicationCrumbs() {
|
||||||
$crumbs = parent::buildApplicationCrumbs();
|
$crumbs = parent::buildApplicationCrumbs();
|
||||||
|
|
||||||
$create_uri = new PhutilURI('/differential/diff/create/');
|
|
||||||
$crumbs->addAction(
|
$crumbs->addAction(
|
||||||
id(new PhabricatorMenuItemView())
|
id(new PhabricatorMenuItemView())
|
||||||
->setHref($this->getApplicationURI('/diff/create/'))
|
->setHref($this->getApplicationURI('/diff/create/'))
|
||||||
|
@ -37,4 +34,65 @@ abstract class DifferentialController extends PhabricatorController {
|
||||||
return $crumbs;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
$viewer_is_anonymous = !$user->isLoggedIn();
|
|
||||||
|
|
||||||
$params = array_filter(
|
$params = array_filter(
|
||||||
array(
|
array(
|
||||||
|
@ -26,12 +25,9 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||||
));
|
));
|
||||||
$params['participants'] = $request->getArr('participants');
|
$params['participants'] = $request->getArr('participants');
|
||||||
|
|
||||||
$default_filter = ($viewer_is_anonymous ? 'all' : 'active');
|
|
||||||
$filters = $this->getFilters();
|
$filters = $this->getFilters();
|
||||||
$this->filter = $this->selectFilter(
|
$this->filter = $this->selectFilter($filters,
|
||||||
$filters,
|
$this->filter, !$user->isLoggedIn());
|
||||||
$this->filter,
|
|
||||||
$default_filter);
|
|
||||||
|
|
||||||
// Redirect from search to canonical URL.
|
// Redirect from search to canonical URL.
|
||||||
$phid_arr = $request->getArr('view_users');
|
$phid_arr = $request->getArr('view_users');
|
||||||
|
@ -80,16 +76,7 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||||
'order' => 'modified',
|
'order' => 'modified',
|
||||||
);
|
);
|
||||||
|
|
||||||
$side_nav = new AphrontSideNavFilterView();
|
$side_nav = $this->buildSideNav($this->filter, false, $username);
|
||||||
$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->selectFilter($this->filter.'/'.$username, null);
|
$side_nav->selectFilter($this->filter.'/'.$username, null);
|
||||||
|
|
||||||
$panels = array();
|
$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) {
|
private function getFilterRequiresUser($filter) {
|
||||||
static $requires = array(
|
static $requires = array(
|
||||||
'active' => true,
|
'active' => true,
|
||||||
|
|
Loading…
Reference in a new issue