@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Basic structure for MenuItem on Home

Summary: Ref T11957, builds out `/home/menu/` as a basic structure for adding/editing the homepage menu.

Test Plan: visit `/home/menu/` and add items to global and personal. Not wired to anything.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T11957

Differential Revision: https://secure.phabricator.com/D17180

+240
+10
src/__phutil_library_map__.php
··· 2820 2820 'PhabricatorHeraldContentSource' => 'applications/herald/contentsource/PhabricatorHeraldContentSource.php', 2821 2821 'PhabricatorHighSecurityRequestExceptionHandler' => 'aphront/handler/PhabricatorHighSecurityRequestExceptionHandler.php', 2822 2822 'PhabricatorHomeApplication' => 'applications/home/application/PhabricatorHomeApplication.php', 2823 + 'PhabricatorHomeConstants' => 'applications/home/constants/PhabricatorHomeConstants.php', 2823 2824 'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php', 2824 2825 'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php', 2826 + 'PhabricatorHomeManageProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php', 2827 + 'PhabricatorHomeMenuController' => 'applications/home/controller/PhabricatorHomeMenuController.php', 2828 + 'PhabricatorHomeMenuItemController' => 'applications/home/controller/PhabricatorHomeMenuItemController.php', 2825 2829 'PhabricatorHomePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php', 2830 + 'PhabricatorHomeProfileMenuEngine' => 'applications/home/engine/PhabricatorHomeProfileMenuEngine.php', 2826 2831 'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php', 2827 2832 'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php', 2828 2833 'PhabricatorHovercardEngineExtensionModule' => 'applications/search/engineextension/PhabricatorHovercardEngineExtensionModule.php', ··· 7861 7866 'PhabricatorHeraldContentSource' => 'PhabricatorContentSource', 7862 7867 'PhabricatorHighSecurityRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 7863 7868 'PhabricatorHomeApplication' => 'PhabricatorApplication', 7869 + 'PhabricatorHomeConstants' => 'PhabricatorHomeController', 7864 7870 'PhabricatorHomeController' => 'PhabricatorController', 7865 7871 'PhabricatorHomeMainController' => 'PhabricatorHomeController', 7872 + 'PhabricatorHomeManageProfileMenuItem' => 'PhabricatorProfileMenuItem', 7873 + 'PhabricatorHomeMenuController' => 'PhabricatorHomeController', 7874 + 'PhabricatorHomeMenuItemController' => 'PhabricatorHomeController', 7866 7875 'PhabricatorHomePreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 7876 + 'PhabricatorHomeProfileMenuEngine' => 'PhabricatorProfileMenuEngine', 7867 7877 'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController', 7868 7878 'PhabricatorHovercardEngineExtension' => 'Phobject', 7869 7879 'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule',
+5
src/applications/home/application/PhabricatorHomeApplication.php
··· 27 27 '/(?P<only>home)/' => 'PhabricatorHomeMainController', 28 28 '/home/' => array( 29 29 'create/' => 'PhabricatorHomeQuickCreateController', 30 + 'menu/' => array( 31 + '' => 'PhabricatorHomeMenuController', 32 + '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting( 33 + 'PhabricatorHomeMenuItemController'), 34 + ), 30 35 ), 31 36 ); 32 37 }
+9
src/applications/home/constants/PhabricatorHomeConstants.php
··· 1 + <?php 2 + 3 + final class PhabricatorHomeConstants 4 + extends PhabricatorHomeController { 5 + 6 + const ITEM_LAUNCHER = 'home.launcher'; 7 + const ITEM_MANAGE = 'home.manage.menu'; 8 + 9 + }
+57
src/applications/home/controller/PhabricatorHomeMenuController.php
··· 1 + <?php 2 + 3 + final class PhabricatorHomeMenuController extends PhabricatorHomeController { 4 + 5 + public function shouldAllowPublic() { 6 + return false; 7 + } 8 + 9 + public function handleRequest(AphrontRequest $request) { 10 + $viewer = $request->getViewer(); 11 + 12 + $menu = id(new PHUIObjectItemListView()) 13 + ->setUser($viewer); 14 + 15 + $menu->addItem( 16 + id(new PHUIObjectItemView()) 17 + ->setHeader(pht('Personal Menu Items')) 18 + ->setHref($this->getApplicationURI('menu/personal/item/configure/')) 19 + ->setImageURI($viewer->getProfileImageURI()) 20 + ->addAttribute(pht('Edit the menu for your personal account.'))); 21 + 22 + $icon = id(new PHUIIconView()) 23 + ->setIcon('fa-globe') 24 + ->setBackground('bg-blue'); 25 + 26 + $menu->addItem( 27 + id(new PHUIObjectItemView()) 28 + ->setHeader(pht('Global Menu Items')) 29 + ->setHref($this->getApplicationURI('menu/global/item/configure/')) 30 + ->setImageIcon($icon) 31 + ->addAttribute(pht('Edit the global default menu for all users.'))); 32 + 33 + $crumbs = $this->buildApplicationCrumbs(); 34 + $crumbs->addTextCrumb(pht('Manage')); 35 + $crumbs->setBorder(true); 36 + 37 + $box = id(new PHUIObjectBoxView()) 38 + ->setObjectList($menu); 39 + 40 + $header = id(new PHUIHeaderView()) 41 + ->setHeader(pht('Manage Home Menu')) 42 + ->setHeaderIcon('fa-home'); 43 + 44 + $view = id(new PHUITwoColumnView()) 45 + ->setHeader($header) 46 + ->setFooter(array( 47 + $box, 48 + )); 49 + 50 + return $this->newPage() 51 + ->setTitle(pht('Manage Home Menu')) 52 + ->setCrumbs($crumbs) 53 + ->appendChild($view); 54 + 55 + } 56 + 57 + }
+29
src/applications/home/controller/PhabricatorHomeMenuItemController.php
··· 1 + <?php 2 + 3 + final class PhabricatorHomeMenuItemController 4 + extends PhabricatorHomeController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $this->getViewer(); 8 + $type = $request->getURIData('type'); 9 + $custom_phid = null; 10 + if ($type == 'personal') { 11 + $custom_phid = $viewer->getPHID(); 12 + } 13 + 14 + $application = 'PhabricatorHomeApplication'; 15 + $home_app = id(new PhabricatorApplicationQuery()) 16 + ->setViewer($viewer) 17 + ->withClasses(array($application)) 18 + ->withInstalled(true) 19 + ->executeOne(); 20 + 21 + $engine = id(new PhabricatorHomeProfileMenuEngine()) 22 + ->setProfileObject($home_app) 23 + ->setCustomPHID($custom_phid) 24 + ->setController($this); 25 + 26 + return $engine->buildResponse(); 27 + } 28 + 29 + }
+58
src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorHomeProfileMenuEngine 4 + extends PhabricatorProfileMenuEngine { 5 + 6 + protected function isMenuEngineConfigurable() { 7 + return true; 8 + } 9 + 10 + protected function getItemURI($path) { 11 + $object = $this->getProfileObject(); 12 + $custom = $this->getCustomPHID(); 13 + 14 + if ($custom) { 15 + return "/home/menu/personal/item/{$path}"; 16 + } else { 17 + return "/home/menu/global/item/{$path}"; 18 + } 19 + } 20 + 21 + protected function getBuiltinProfileItems($object) { 22 + $viewer = $this->getViewer(); 23 + $items = array(); 24 + $custom_phid = $this->getCustomPHID(); 25 + 26 + $applications = id(new PhabricatorApplicationQuery()) 27 + ->setViewer($viewer) 28 + ->withInstalled(true) 29 + ->withUnlisted(false) 30 + ->withLaunchable(true) 31 + ->execute(); 32 + 33 + foreach ($applications as $application) { 34 + if (!$application->isPinnedByDefault($viewer)) { 35 + continue; 36 + } 37 + 38 + $properties = array( 39 + 'name' => $application->getName(), 40 + 'application' => $application->getPHID(), 41 + ); 42 + 43 + $items[] = $this->newItem() 44 + ->setBuiltinKey($application->getPHID()) 45 + ->setMenuItemKey(PhabricatorApplicationProfileMenuItem::MENUITEMKEY) 46 + ->setMenuItemProperties($properties); 47 + } 48 + 49 + // Single Manage Item, switches URI based on admin/user 50 + $items[] = $this->newItem() 51 + ->setBuiltinKey(PhabricatorHomeConstants::ITEM_MANAGE) 52 + ->setMenuItemKey( 53 + PhabricatorHomeManageProfileMenuItem::MENUITEMKEY); 54 + 55 + return $items; 56 + } 57 + 58 + }
+72
src/applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php
··· 1 + <?php 2 + 3 + final class PhabricatorHomeManageProfileMenuItem 4 + extends PhabricatorProfileMenuItem { 5 + 6 + const MENUITEMKEY = 'home.manage.menu'; 7 + 8 + public function getMenuItemTypeName() { 9 + return pht('Manage Home Menu'); 10 + } 11 + 12 + private function getDefaultName() { 13 + return pht('Manage'); 14 + } 15 + 16 + public function canHideMenuItem( 17 + PhabricatorProfileMenuItemConfiguration $config) { 18 + return false; 19 + } 20 + 21 + public function canMakeDefault( 22 + PhabricatorProfileMenuItemConfiguration $config) { 23 + return false; 24 + } 25 + 26 + public function getDisplayName( 27 + PhabricatorProfileMenuItemConfiguration $config) { 28 + $name = $config->getMenuItemProperty('name'); 29 + 30 + if (strlen($name)) { 31 + return $name; 32 + } 33 + 34 + return $this->getDefaultName(); 35 + } 36 + 37 + public function buildEditEngineFields( 38 + PhabricatorProfileMenuItemConfiguration $config) { 39 + return array( 40 + id(new PhabricatorTextEditField()) 41 + ->setKey('name') 42 + ->setLabel(pht('Name')) 43 + ->setPlaceholder($this->getDefaultName()) 44 + ->setValue($config->getMenuItemProperty('name')), 45 + ); 46 + } 47 + 48 + protected function newNavigationMenuItems( 49 + PhabricatorProfileMenuItemConfiguration $config) { 50 + $viewer = $this->getViewer(); 51 + 52 + if ($viewer->isLoggedIn()) { 53 + $admin = $viewer->getIsAdmin(); 54 + $name = $this->getDisplayName($config); 55 + $icon = 'fa-pencil'; 56 + $href = '/home/menu/personal/item/configure/'; 57 + if ($admin) { 58 + $href = '/home/menu/'; 59 + } 60 + 61 + $item = $this->newItem() 62 + ->setHref($href) 63 + ->setName($name) 64 + ->setIcon($icon); 65 + } 66 + 67 + return array( 68 + $item, 69 + ); 70 + } 71 + 72 + }