1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Restore old Home mobile menu behavior, hide crumbs

Summary:
Ref T12174.

  - Go back to the old mobile behavior (full-screen menu by default, click to see content).
  - Hide crumbs from all Home content UIs. I left them on the edit/configure UIs since they feel a little less out-of-place there and some have multiple levels.

Test Plan:
Viewed Home on mobile, viewed `/home/` on mobile.

Also, saw no crumbs.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12174

Differential Revision: https://secure.phabricator.com/D17290
This commit is contained in:
epriestley 2017-02-01 10:16:23 -08:00
parent 6abdae8e73
commit fe33041681
3 changed files with 49 additions and 10 deletions

View file

@ -23,7 +23,12 @@ final class PhabricatorHomeApplication extends PhabricatorApplication {
public function getRoutes() {
return array(
'/' => 'PhabricatorHomeMenuItemController',
'/home/' => array(
// NOTE: If you visit "/" on mobile, you get just the menu. If you visit
// "/home/" on mobile, you get the content. From the normal desktop
// UI, there's no difference between these pages.
'/(?P<content>home)/' => array(
'' => 'PhabricatorHomeMenuItemController',
'menu/' => $this->getProfileMenuRouting(
'PhabricatorHomeMenuItemController'),

View file

@ -14,6 +14,11 @@ final class PhabricatorHomeMenuItemController
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
// Test if we should show mobile users the menu or the page content:
// if you visit "/", you just get the menu. If you visit "/home/", you
// get the content.
$is_content = $request->getURIData('content');
$application = 'PhabricatorHomeApplication';
$home_app = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
@ -24,7 +29,12 @@ final class PhabricatorHomeMenuItemController
$engine = id(new PhabricatorHomeProfileMenuEngine())
->setProfileObject($home_app)
->setCustomPHID($viewer->getPHID())
->setController($this);
->setController($this)
->setShowContentCrumbs(false);
if (!$is_content) {
$engine->addContentPageClass('phabricator-home');
}
return $engine->buildResponse();
}

View file

@ -11,6 +11,8 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
private $navigation;
private $showNavigation = true;
private $editMode;
private $pageClasses = array();
private $showContentCrumbs = true;
const ITEM_CUSTOM_DIVIDER = 'engine.divider';
const ITEM_MANAGE = 'item.configure';
@ -90,6 +92,20 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
return $this->showNavigation;
}
public function addContentPageClass($class) {
$this->pageClasses[] = $class;
return $this;
}
public function setShowContentCrumbs($show_content_crumbs) {
$this->showContentCrumbs = $show_content_crumbs;
return $this;
}
public function getShowContentCrumbs() {
return $this->showContentCrumbs;
}
abstract public function getItemURI($path);
abstract protected function isMenuEngineConfigurable();
@ -118,13 +134,12 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
$item_action = 'view';
}
$is_view = ($item_action == 'view');
// If the engine is not configurable, don't respond to any of the editing
// or configuration routes.
if (!$this->isMenuEngineConfigurable()) {
switch ($item_action) {
case 'view':
break;
default:
if (!$is_view) {
return new Aphront404Response();
}
}
@ -159,7 +174,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
}
if (!$selected_item) {
if ($item_action == 'view') {
if ($is_view) {
$selected_item = $this->getDefaultItem();
}
}
@ -190,7 +205,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
$crumbs = $controller->buildApplicationCrumbsForEditEngine();
if ($item_action != 'view') {
if (!$is_view) {
$navigation->selectFilter(self::ITEM_MANAGE);
if ($selected_item) {
@ -298,13 +313,22 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
$page = $controller->newPage()
->setTitle($page_title)
->setCrumbs($crumbs)
->appendChild($content);
if (!$is_view || $this->getShowContentCrumbs()) {
$page->setCrumbs($crumbs);
}
if ($this->getShowNavigation()) {
$page->setNavigation($navigation);
}
if ($is_view) {
foreach ($this->pageClasses as $class) {
$page->addClass($class);
}
}
return $page;
}