Page MenuHomePhabricator

D17180.id41316.diff
No OneTemporary

D17180.id41316.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2820,9 +2820,14 @@
'PhabricatorHeraldContentSource' => 'applications/herald/contentsource/PhabricatorHeraldContentSource.php',
'PhabricatorHighSecurityRequestExceptionHandler' => 'aphront/handler/PhabricatorHighSecurityRequestExceptionHandler.php',
'PhabricatorHomeApplication' => 'applications/home/application/PhabricatorHomeApplication.php',
+ 'PhabricatorHomeConstants' => 'applications/home/constants/PhabricatorHomeConstants.php',
'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php',
'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php',
+ 'PhabricatorHomeManageProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php',
+ 'PhabricatorHomeMenuController' => 'applications/home/controller/PhabricatorHomeMenuController.php',
+ 'PhabricatorHomeMenuItemController' => 'applications/home/controller/PhabricatorHomeMenuItemController.php',
'PhabricatorHomePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php',
+ 'PhabricatorHomeProfileMenuEngine' => 'applications/home/engine/PhabricatorHomeProfileMenuEngine.php',
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php',
'PhabricatorHovercardEngineExtensionModule' => 'applications/search/engineextension/PhabricatorHovercardEngineExtensionModule.php',
@@ -7861,9 +7866,14 @@
'PhabricatorHeraldContentSource' => 'PhabricatorContentSource',
'PhabricatorHighSecurityRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorHomeApplication' => 'PhabricatorApplication',
+ 'PhabricatorHomeConstants' => 'PhabricatorHomeController',
'PhabricatorHomeController' => 'PhabricatorController',
'PhabricatorHomeMainController' => 'PhabricatorHomeController',
+ 'PhabricatorHomeManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
+ 'PhabricatorHomeMenuController' => 'PhabricatorHomeController',
+ 'PhabricatorHomeMenuItemController' => 'PhabricatorHomeController',
'PhabricatorHomePreferencesSettingsPanel' => 'PhabricatorSettingsPanel',
+ 'PhabricatorHomeProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
'PhabricatorHovercardEngineExtension' => 'Phobject',
'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule',
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
@@ -27,6 +27,11 @@
'/(?P<only>home)/' => 'PhabricatorHomeMainController',
'/home/' => array(
'create/' => 'PhabricatorHomeQuickCreateController',
+ 'menu/' => array(
+ '' => 'PhabricatorHomeMenuController',
+ '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting(
+ 'PhabricatorHomeMenuItemController'),
+ ),
),
);
}
diff --git a/src/applications/home/constants/PhabricatorHomeConstants.php b/src/applications/home/constants/PhabricatorHomeConstants.php
new file mode 100644
--- /dev/null
+++ b/src/applications/home/constants/PhabricatorHomeConstants.php
@@ -0,0 +1,22 @@
+<?php
+
+final class PhabricatorHomeConstants
+ extends PhabricatorHomeController {
+
+ // Users
+ const ITEM_MANIPHEST = 'home.maniphest';
+ const ITEM_DIFFERENTIAL = 'home.differential';
+ const ITEM_DIFFUSION = 'home.diffusion';
+ const ITEM_AUDIT = 'home.audit';
+ const ITEM_PHRICTION = 'home.phriction';
+ const ITEM_PROJECTS = 'home.projects';
+
+ // Admins
+ const ITEM_CONFIG = 'home.config';
+ const ITEM_AUTH = 'home.auth';
+
+ // All
+ const ITEM_LAUNCHER = 'home.launcher';
+ const ITEM_MANAGE = 'home.manage.menu';
+
+}
diff --git a/src/applications/home/controller/PhabricatorHomeMenuController.php b/src/applications/home/controller/PhabricatorHomeMenuController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/home/controller/PhabricatorHomeMenuController.php
@@ -0,0 +1,57 @@
+<?php
+
+final class PhabricatorHomeMenuController extends PhabricatorHomeController {
+
+ public function shouldAllowPublic() {
+ return false;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $menu = id(new PHUIObjectItemListView())
+ ->setUser($viewer);
+
+ $menu->addItem(
+ id(new PHUIObjectItemView())
+ ->setHeader(pht('Personal Menu Items'))
+ ->setHref($this->getApplicationURI('menu/personal/item/configure/'))
+ ->setImageURI($viewer->getProfileImageURI())
+ ->addAttribute(pht('Edit the menu for your personal account.')));
+
+ $icon = id(new PHUIIconView())
+ ->setIcon('fa-globe')
+ ->setBackground('bg-blue');
+
+ $menu->addItem(
+ id(new PHUIObjectItemView())
+ ->setHeader(pht('Global Menu Items'))
+ ->setHref($this->getApplicationURI('menu/global/item/configure/'))
+ ->setImageIcon($icon)
+ ->addAttribute(pht('Edit the global default menu for all users.')));
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(pht('Manage'));
+ $crumbs->setBorder(true);
+
+ $box = id(new PHUIObjectBoxView())
+ ->setObjectList($menu);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader(pht('Manage Home Menu'))
+ ->setHeaderIcon('fa-home');
+
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter(array(
+ $box,
+ ));
+
+ return $this->newPage()
+ ->setTitle(pht('Manage Home Menu'))
+ ->setCrumbs($crumbs)
+ ->appendChild($view);
+
+ }
+
+}
diff --git a/src/applications/home/controller/PhabricatorHomeMenuItemController.php b/src/applications/home/controller/PhabricatorHomeMenuItemController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/home/controller/PhabricatorHomeMenuItemController.php
@@ -0,0 +1,29 @@
+<?php
+
+final class PhabricatorHomeMenuItemController
+ extends PhabricatorHomeController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $type = $request->getURIData('type');
+ $custom_phid = null;
+ if ($type == 'personal') {
+ $custom_phid = $viewer->getPHID();
+ }
+
+ $application = 'PhabricatorHomeApplication';
+ $home_app = id(new PhabricatorApplicationQuery())
+ ->setViewer($viewer)
+ ->withClasses(array($application))
+ ->withInstalled(true)
+ ->executeOne();
+
+ $engine = id(new PhabricatorHomeProfileMenuEngine())
+ ->setProfileObject($home_app)
+ ->setCustomPHID($custom_phid)
+ ->setController($this);
+
+ return $engine->buildResponse();
+ }
+
+}
diff --git a/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php b/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/home/engine/PhabricatorHomeProfileMenuEngine.php
@@ -0,0 +1,34 @@
+<?php
+
+final class PhabricatorHomeProfileMenuEngine
+ extends PhabricatorProfileMenuEngine {
+
+ protected function isMenuEngineConfigurable() {
+ return true;
+ }
+
+ protected function getItemURI($path) {
+ $object = $this->getProfileObject();
+ $custom = $this->getCustomPHID();
+
+ if ($custom) {
+ return "/home/menu/personal/item/{$path}";
+ } else {
+ return "/home/menu/global/item/{$path}";
+ }
+ }
+
+ protected function getBuiltinProfileItems($object) {
+ $items = array();
+ $custom_phid = $this->getCustomPHID();
+
+ // Single Manage Item, switches URI based on admin/user
+ $items[] = $this->newItem()
+ ->setBuiltinKey(PhabricatorHomeConstants::ITEM_MANAGE)
+ ->setMenuItemKey(
+ PhabricatorHomeManageProfileMenuItem::MENUITEMKEY);
+
+ return $items;
+ }
+
+}
diff --git a/src/applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php b/src/applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/home/menuitem/PhabricatorHomeManageProfileMenuItem.php
@@ -0,0 +1,72 @@
+<?php
+
+final class PhabricatorHomeManageProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'home.manage.menu';
+
+ public function getMenuItemTypeName() {
+ return pht('Manage Home Menu');
+ }
+
+ private function getDefaultName() {
+ return pht('Manage');
+ }
+
+ public function canHideMenuItem(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return false;
+ }
+
+ public function canMakeDefault(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return false;
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $name = $config->getMenuItemProperty('name');
+
+ if (strlen($name)) {
+ return $name;
+ }
+
+ return $this->getDefaultName();
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setPlaceholder($this->getDefaultName())
+ ->setValue($config->getMenuItemProperty('name')),
+ );
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $viewer = $this->getViewer();
+
+ if ($viewer->isLoggedIn()) {
+ $admin = $viewer->getIsAdmin();
+ $name = $this->getDisplayName($config);
+ $icon = 'fa-pencil';
+ $href = '/home/menu/personal/item/configure/';
+ if ($admin) {
+ $href = '/home/menu/';
+ }
+
+ $item = $this->newItem()
+ ->setHref($href)
+ ->setName($name)
+ ->setIcon($icon);
+ }
+
+ return array(
+ $item,
+ );
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 4:37 AM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7683252
Default Alt Text
D17180.id41316.diff (10 KB)

Event Timeline