From 4d0904ef9527322fb4cd2a102a10a89772811986 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 2 Apr 2019 13:37:57 -0700 Subject: [PATCH] Make "Favorites" work more like other customizable menus Summary: Depends on D20373. Ref T13272. When you put Dashboards in Favorites, the render without a navigation menu, which is kind of weird. Instead, make Favorites display a navigation menu. This effectively turns it into a weird cross between the home page and a portal, but so be it. Also change the icon from "star" to "bookmark" since I think that a clearer hint about how it works. Test Plan: Viewed dashboards in favorites, got a navigation menu. Edited items from portals, home, favorites. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13272 Differential Revision: https://secure.phabricator.com/D20374 --- ...icatorDashboardPortalProfileMenuEngine.php | 2 + .../PhabricatorFavoritesApplication.php | 3 +- ...PhabricatorFavoritesMenuItemController.php | 3 +- .../PhabricatorFavoritesProfileMenuEngine.php | 4 ++ ...abricatorFavoritesMainMenuBarExtension.php | 13 +------ .../PhabricatorHomeProfileMenuEngine.php | 3 +- .../engine/PhabricatorProfileMenuEngine.php | 37 ++++++++++--------- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/applications/dashboard/engine/PhabricatorDashboardPortalProfileMenuEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardPortalProfileMenuEngine.php index 5da4760cd3..9f8afc74dc 100644 --- a/src/applications/dashboard/engine/PhabricatorDashboardPortalProfileMenuEngine.php +++ b/src/applications/dashboard/engine/PhabricatorDashboardPortalProfileMenuEngine.php @@ -20,6 +20,8 @@ final class PhabricatorDashboardPortalProfileMenuEngine protected function getBuiltinProfileItems($object) { $items = array(); + $items[] = $this->newDividerItem('tail'); + $items[] = $this->newManageItem(); $items[] = $this->newItem() diff --git a/src/applications/favorites/application/PhabricatorFavoritesApplication.php b/src/applications/favorites/application/PhabricatorFavoritesApplication.php index 3a6acd4ebc..50f56c5224 100644 --- a/src/applications/favorites/application/PhabricatorFavoritesApplication.php +++ b/src/applications/favorites/application/PhabricatorFavoritesApplication.php @@ -15,12 +15,13 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication { } public function getIcon() { - return 'fa-star'; + return 'fa-bookmark'; } public function getRoutes() { return array( '/favorites/' => array( + '' => 'PhabricatorFavoritesMenuItemController', 'menu/' => $this->getProfileMenuRouting( 'PhabricatorFavoritesMenuItemController'), ), diff --git a/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php b/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php index dd4bf77cf0..54af8908a6 100644 --- a/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php +++ b/src/applications/favorites/controller/PhabricatorFavoritesMenuItemController.php @@ -16,8 +16,7 @@ final class PhabricatorFavoritesMenuItemController $engine = id(new PhabricatorFavoritesProfileMenuEngine()) ->setProfileObject($favorites) ->setCustomPHID($viewer->getPHID()) - ->setController($this) - ->setShowNavigation(false); + ->setController($this); return $engine->buildResponse(); } diff --git a/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php b/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php index 0ac31e7de8..a17c60226b 100644 --- a/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php +++ b/src/applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php @@ -35,6 +35,10 @@ final class PhabricatorFavoritesProfileMenuEngine } } + $items[] = $this->newDividerItem('tail'); + $items[] = $this->newManageItem() + ->setMenuItemProperty('name', pht('Edit Favorites')); + return $items; } diff --git a/src/applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php b/src/applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php index adc272a125..a6cd4fc069 100644 --- a/src/applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php +++ b/src/applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php @@ -26,7 +26,7 @@ final class PhabricatorFavoritesMainMenuBarExtension $favorites_menu = id(new PHUIButtonView()) ->setTag('a') ->setHref('#') - ->setIcon('fa-star') + ->setIcon('fa-bookmark') ->addClass('phabricator-core-user-menu') ->setNoCSS(true) ->setDropdown(true) @@ -71,20 +71,11 @@ final class PhabricatorFavoritesMainMenuBarExtension $action = id(new PhabricatorActionView()) ->setName($item->getName()) ->setHref($item->getHref()) + ->setIcon($item->getIcon()) ->setType($item->getType()); $view->addAction($action); } - if ($viewer->isLoggedIn()) { - $view->addAction( - id(new PhabricatorActionView()) - ->setType(PhabricatorActionView::TYPE_DIVIDER)); - $view->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Edit Favorites')) - ->setHref('/favorites/menu/configure/')); - } - return $view; } diff --git a/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php b/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php index e380af2b6a..d3e338ef26 100644 --- a/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php +++ b/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php @@ -67,11 +67,12 @@ final class PhabricatorHomeProfileMenuEngine ->setMenuItemProperties($properties); } - // Hotlink to More Applications Launcher... $items[] = $this->newItem() ->setBuiltinKey(PhabricatorHomeConstants::ITEM_LAUNCHER) ->setMenuItemKey(PhabricatorHomeLauncherProfileMenuItem::MENUITEMKEY); + $items[] = $this->newDividerItem('tail'); + $items[] = $this->newManageItem(); return $items; diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php index fadb929594..aedbcc787f 100644 --- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php +++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php @@ -8,7 +8,6 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { private $items; private $controller; private $navigation; - private $showNavigation = true; private $editMode; private $pageClasses = array(); private $showContentCrumbs = true; @@ -71,15 +70,6 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { return $this->controller; } - public function setShowNavigation($show) { - $this->showNavigation = $show; - return $this; - } - - public function getShowNavigation() { - return $this->showNavigation; - } - public function addContentPageClass($class) { $this->pageClasses[] = $class; return $this; @@ -181,13 +171,19 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { $crumbs = $controller->buildApplicationCrumbsForEditEngine(); if (!$is_view) { + $edit_mode = null; + if ($selected_item) { - if ($selected_item->getCustomPHID()) { - $edit_mode = 'custom'; - } else { - $edit_mode = 'global'; + if ($selected_item->getBuiltinKey() !== self::ITEM_MANAGE) { + if ($selected_item->getCustomPHID()) { + $edit_mode = 'custom'; + } else { + $edit_mode = 'global'; + } } - } else { + } + + if ($edit_mode === null) { $edit_mode = $request->getURIData('itemEditMode'); } @@ -309,9 +305,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { $page->setCrumbs($crumbs); } - if ($this->getShowNavigation()) { - $page->setNavigation($navigation); - } + $page->setNavigation($navigation); if ($is_view) { foreach ($this->pageClasses as $class) { @@ -1133,6 +1127,13 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { ->setIsTailItem(true); } + protected function newDividerItem($key) { + return $this->newItem() + ->setBuiltinKey($key) + ->setMenuItemKey(PhabricatorDividerProfileMenuItem::MENUITEMKEY) + ->setIsTailItem(true); + } + public function getDefaultMenuItemConfiguration() { $configs = $this->getItems(); foreach ($configs as $config) {