Page MenuHomePhabricator

D17290.diff
No OneTemporary

D17290.diff

diff --git a/src/applications/home/application/PhabricatorHomeApplication.php b/src/applications/home/application/PhabricatorHomeApplication.php
--- a/src/applications/home/application/PhabricatorHomeApplication.php
+++ b/src/applications/home/application/PhabricatorHomeApplication.php
@@ -23,7 +23,12 @@
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'),
diff --git a/src/applications/home/controller/PhabricatorHomeMenuItemController.php b/src/applications/home/controller/PhabricatorHomeMenuItemController.php
--- a/src/applications/home/controller/PhabricatorHomeMenuItemController.php
+++ b/src/applications/home/controller/PhabricatorHomeMenuItemController.php
@@ -14,6 +14,11 @@
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 @@
$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();
}
diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
--- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php
+++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
@@ -11,6 +11,8 @@
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 @@
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,14 +134,13 @@
$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:
- return new Aphront404Response();
+ if (!$is_view) {
+ return new Aphront404Response();
}
}
@@ -159,7 +174,7 @@
}
if (!$selected_item) {
- if ($item_action == 'view') {
+ if ($is_view) {
$selected_item = $this->getDefaultItem();
}
}
@@ -190,7 +205,7 @@
$crumbs = $controller->buildApplicationCrumbsForEditEngine();
- if ($item_action != 'view') {
+ if (!$is_view) {
$navigation->selectFilter(self::ITEM_MANAGE);
if ($selected_item) {
@@ -298,13 +313,22 @@
$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;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 3:18 AM (7 h, 33 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6784801
Default Alt Text
D17290.diff (4 KB)

Event Timeline