mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Replace ProfileMenu bugs with different bugs
Summary: Ref T12174. This fixes more bugs than it creates, I think: - Dashboards now show the whole menu. - Project and home items now show selected state correctly. - The "choose global vs personal" thing is now part of MenuEngine, and the same code builds it for Home and Favorites. - Home now handles defaults correctly, I think. Maybe regression/bad/still buggy?: - Mobile home is now whatever the default thing was, not the menu? - Title for dashboard content or other items that render their own content is incorrectly always "Configure Menu" (this was preexisting). Test Plan: - Created, edited, reordered, disabled, deleted and pinned personal and global items on home, favorites, and projects. - Also checked User profiles. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12174 Differential Revision: https://secure.phabricator.com/D17273
This commit is contained in:
parent
bd99a2b81e
commit
f23bfccc04
20 changed files with 298 additions and 314 deletions
|
@ -1687,6 +1687,7 @@ phutil_register_library_map(array(
|
||||||
'PHUIHandleView' => 'applications/phid/view/PHUIHandleView.php',
|
'PHUIHandleView' => 'applications/phid/view/PHUIHandleView.php',
|
||||||
'PHUIHeadThingView' => 'view/phui/PHUIHeadThingView.php',
|
'PHUIHeadThingView' => 'view/phui/PHUIHeadThingView.php',
|
||||||
'PHUIHeaderView' => 'view/phui/PHUIHeaderView.php',
|
'PHUIHeaderView' => 'view/phui/PHUIHeaderView.php',
|
||||||
|
'PHUIHomeView' => 'applications/home/view/PHUIHomeView.php',
|
||||||
'PHUIHovercardUIExample' => 'applications/uiexample/examples/PHUIHovercardUIExample.php',
|
'PHUIHovercardUIExample' => 'applications/uiexample/examples/PHUIHovercardUIExample.php',
|
||||||
'PHUIHovercardView' => 'view/phui/PHUIHovercardView.php',
|
'PHUIHovercardView' => 'view/phui/PHUIHovercardView.php',
|
||||||
'PHUIIconCircleView' => 'view/phui/PHUIIconCircleView.php',
|
'PHUIIconCircleView' => 'view/phui/PHUIIconCircleView.php',
|
||||||
|
@ -2676,7 +2677,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php',
|
'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php',
|
||||||
'PhabricatorFavoritesApplication' => 'applications/favorites/application/PhabricatorFavoritesApplication.php',
|
'PhabricatorFavoritesApplication' => 'applications/favorites/application/PhabricatorFavoritesApplication.php',
|
||||||
'PhabricatorFavoritesController' => 'applications/favorites/controller/PhabricatorFavoritesController.php',
|
'PhabricatorFavoritesController' => 'applications/favorites/controller/PhabricatorFavoritesController.php',
|
||||||
'PhabricatorFavoritesMainController' => 'applications/favorites/controller/PhabricatorFavoritesMainController.php',
|
|
||||||
'PhabricatorFavoritesMainMenuBarExtension' => 'applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php',
|
'PhabricatorFavoritesMainMenuBarExtension' => 'applications/favorites/engineextension/PhabricatorFavoritesMainMenuBarExtension.php',
|
||||||
'PhabricatorFavoritesMenuItemController' => 'applications/favorites/controller/PhabricatorFavoritesMenuItemController.php',
|
'PhabricatorFavoritesMenuItemController' => 'applications/favorites/controller/PhabricatorFavoritesMenuItemController.php',
|
||||||
'PhabricatorFavoritesProfileMenuEngine' => 'applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php',
|
'PhabricatorFavoritesProfileMenuEngine' => 'applications/favorites/engine/PhabricatorFavoritesProfileMenuEngine.php',
|
||||||
|
@ -2839,9 +2839,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHomeConstants' => 'applications/home/constants/PhabricatorHomeConstants.php',
|
'PhabricatorHomeConstants' => 'applications/home/constants/PhabricatorHomeConstants.php',
|
||||||
'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php',
|
'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php',
|
||||||
'PhabricatorHomeLauncherProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php',
|
'PhabricatorHomeLauncherProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.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',
|
'PhabricatorHomeMenuItemController' => 'applications/home/controller/PhabricatorHomeMenuItemController.php',
|
||||||
'PhabricatorHomeProfileMenuEngine' => 'applications/home/engine/PhabricatorHomeProfileMenuEngine.php',
|
'PhabricatorHomeProfileMenuEngine' => 'applications/home/engine/PhabricatorHomeProfileMenuEngine.php',
|
||||||
'PhabricatorHomeProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeProfileMenuItem.php',
|
'PhabricatorHomeProfileMenuItem' => 'applications/home/menuitem/PhabricatorHomeProfileMenuItem.php',
|
||||||
|
@ -2964,6 +2961,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMainMenuBarExtension' => 'view/page/menu/PhabricatorMainMenuBarExtension.php',
|
'PhabricatorMainMenuBarExtension' => 'view/page/menu/PhabricatorMainMenuBarExtension.php',
|
||||||
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
|
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
|
||||||
'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php',
|
'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php',
|
||||||
|
'PhabricatorManageProfileMenuItem' => 'applications/search/menuitem/PhabricatorManageProfileMenuItem.php',
|
||||||
'PhabricatorManagementWorkflow' => 'infrastructure/management/PhabricatorManagementWorkflow.php',
|
'PhabricatorManagementWorkflow' => 'infrastructure/management/PhabricatorManagementWorkflow.php',
|
||||||
'PhabricatorManiphestApplication' => 'applications/maniphest/application/PhabricatorManiphestApplication.php',
|
'PhabricatorManiphestApplication' => 'applications/maniphest/application/PhabricatorManiphestApplication.php',
|
||||||
'PhabricatorManiphestConfigOptions' => 'applications/maniphest/config/PhabricatorManiphestConfigOptions.php',
|
'PhabricatorManiphestConfigOptions' => 'applications/maniphest/config/PhabricatorManiphestConfigOptions.php',
|
||||||
|
@ -6563,6 +6561,7 @@ phutil_register_library_map(array(
|
||||||
'PHUIHandleView' => 'AphrontView',
|
'PHUIHandleView' => 'AphrontView',
|
||||||
'PHUIHeadThingView' => 'AphrontTagView',
|
'PHUIHeadThingView' => 'AphrontTagView',
|
||||||
'PHUIHeaderView' => 'AphrontTagView',
|
'PHUIHeaderView' => 'AphrontTagView',
|
||||||
|
'PHUIHomeView' => 'AphrontTagView',
|
||||||
'PHUIHovercardUIExample' => 'PhabricatorUIExample',
|
'PHUIHovercardUIExample' => 'PhabricatorUIExample',
|
||||||
'PHUIHovercardView' => 'AphrontTagView',
|
'PHUIHovercardView' => 'AphrontTagView',
|
||||||
'PHUIIconCircleView' => 'AphrontTagView',
|
'PHUIIconCircleView' => 'AphrontTagView',
|
||||||
|
@ -7698,7 +7697,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator',
|
'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator',
|
||||||
'PhabricatorFavoritesApplication' => 'PhabricatorApplication',
|
'PhabricatorFavoritesApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorFavoritesController' => 'PhabricatorController',
|
'PhabricatorFavoritesController' => 'PhabricatorController',
|
||||||
'PhabricatorFavoritesMainController' => 'PhabricatorFavoritesController',
|
|
||||||
'PhabricatorFavoritesMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
|
'PhabricatorFavoritesMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
|
||||||
'PhabricatorFavoritesMenuItemController' => 'PhabricatorFavoritesController',
|
'PhabricatorFavoritesMenuItemController' => 'PhabricatorFavoritesController',
|
||||||
'PhabricatorFavoritesProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
'PhabricatorFavoritesProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
||||||
|
@ -7897,9 +7895,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHomeConstants' => 'PhabricatorHomeController',
|
'PhabricatorHomeConstants' => 'PhabricatorHomeController',
|
||||||
'PhabricatorHomeController' => 'PhabricatorController',
|
'PhabricatorHomeController' => 'PhabricatorController',
|
||||||
'PhabricatorHomeLauncherProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorHomeLauncherProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorHomeMainController' => 'PhabricatorHomeController',
|
|
||||||
'PhabricatorHomeManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
|
||||||
'PhabricatorHomeMenuController' => 'PhabricatorHomeController',
|
|
||||||
'PhabricatorHomeMenuItemController' => 'PhabricatorHomeController',
|
'PhabricatorHomeMenuItemController' => 'PhabricatorHomeController',
|
||||||
'PhabricatorHomeProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
'PhabricatorHomeProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
||||||
'PhabricatorHomeProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorHomeProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
|
@ -8022,6 +8017,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMainMenuBarExtension' => 'Phobject',
|
'PhabricatorMainMenuBarExtension' => 'Phobject',
|
||||||
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
||||||
'PhabricatorMainMenuView' => 'AphrontView',
|
'PhabricatorMainMenuView' => 'AphrontView',
|
||||||
|
'PhabricatorManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorManagementWorkflow' => 'PhutilArgumentWorkflow',
|
'PhabricatorManagementWorkflow' => 'PhutilArgumentWorkflow',
|
||||||
'PhabricatorManiphestApplication' => 'PhabricatorApplication',
|
'PhabricatorManiphestApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorManiphestConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorManiphestConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
|
|
@ -596,14 +596,18 @@ abstract class PhabricatorApplication
|
||||||
protected function getProfileMenuRouting($controller) {
|
protected function getProfileMenuRouting($controller) {
|
||||||
$edit_route = $this->getEditRoutePattern();
|
$edit_route = $this->getEditRoutePattern();
|
||||||
|
|
||||||
|
$mode_route = '(?P<itemEditMode>global|custom)/';
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'(?P<itemAction>view)/(?P<itemID>[^/]+)/' => $controller,
|
'(?P<itemAction>view)/(?P<itemID>[^/]+)/' => $controller,
|
||||||
'(?P<itemAction>hide)/(?P<itemID>[^/]+)/' => $controller,
|
'(?P<itemAction>hide)/(?P<itemID>[^/]+)/' => $controller,
|
||||||
'(?P<itemAction>default)/(?P<itemID>[^/]+)/' => $controller,
|
'(?P<itemAction>default)/(?P<itemID>[^/]+)/' => $controller,
|
||||||
'(?P<itemAction>configure)/' => $controller,
|
'(?P<itemAction>configure)/' => $controller,
|
||||||
'(?P<itemAction>reorder)/' => $controller,
|
'(?P<itemAction>configure)/'.$mode_route => $controller,
|
||||||
|
'(?P<itemAction>reorder)/'.$mode_route => $controller,
|
||||||
'(?P<itemAction>edit)/'.$edit_route => $controller,
|
'(?P<itemAction>edit)/'.$edit_route => $controller,
|
||||||
'(?P<itemAction>new)/(?<itemKey>[^/]+)/'.$edit_route => $controller,
|
'(?P<itemAction>new)/'.$mode_route.'(?<itemKey>[^/]+)/'.$edit_route
|
||||||
|
=> $controller,
|
||||||
'(?P<itemAction>builtin)/(?<itemID>[^/]+)/'.$edit_route
|
'(?P<itemAction>builtin)/(?<itemID>[^/]+)/'.$edit_route
|
||||||
=> $controller,
|
=> $controller,
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,8 +21,7 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication {
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
'/favorites/' => array(
|
'/favorites/' => array(
|
||||||
'' => 'PhabricatorFavoritesMainController',
|
'menu/' => $this->getProfileMenuRouting(
|
||||||
'(?P<type>global|personal)/item/' => $this->getProfileMenuRouting(
|
|
||||||
'PhabricatorFavoritesMenuItemController'),
|
'PhabricatorFavoritesMenuItemController'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorFavoritesMainController
|
|
||||||
extends PhabricatorFavoritesController {
|
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
$viewer = $request->getViewer();
|
|
||||||
|
|
||||||
if (!$viewer->getIsAdmin()) {
|
|
||||||
$uri = '/favorites/personal/item/configure/';
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
$menu = id(new PHUIObjectItemListView())
|
|
||||||
->setUser($viewer);
|
|
||||||
|
|
||||||
$menu->addItem(
|
|
||||||
id(new PHUIObjectItemView())
|
|
||||||
->setHeader(pht('Personal Menu Items'))
|
|
||||||
->setHref($this->getApplicationURI('personal/item/configure/'))
|
|
||||||
->setImageURI($viewer->getProfileImageURI())
|
|
||||||
->addAttribute(pht('Edit favorites 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('global/item/configure/'))
|
|
||||||
->setImageIcon($icon)
|
|
||||||
->addAttribute(pht('Edit global default favorites 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 Favorites'))
|
|
||||||
->setHeaderIcon('fa-star-o');
|
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
|
||||||
->setHeader($header)
|
|
||||||
->setFooter(array(
|
|
||||||
$box,
|
|
||||||
));
|
|
||||||
|
|
||||||
return $this->newPage()
|
|
||||||
->setTitle(pht('Manage'))
|
|
||||||
->setCrumbs($crumbs)
|
|
||||||
->appendChild($view);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -5,13 +5,6 @@ final class PhabricatorFavoritesMenuItemController
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$type = $request->getURIData('type');
|
|
||||||
$custom_phid = null;
|
|
||||||
$menu = PhabricatorProfileMenuEngine::MENU_GLOBAL;
|
|
||||||
if ($type == 'personal') {
|
|
||||||
$custom_phid = $viewer->getPHID();
|
|
||||||
$menu = PhabricatorProfileMenuEngine::MENU_PERSONAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$application = 'PhabricatorFavoritesApplication';
|
$application = 'PhabricatorFavoritesApplication';
|
||||||
$favorites = id(new PhabricatorApplicationQuery())
|
$favorites = id(new PhabricatorApplicationQuery())
|
||||||
|
@ -22,9 +15,8 @@ final class PhabricatorFavoritesMenuItemController
|
||||||
|
|
||||||
$engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
$engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
||||||
->setProfileObject($favorites)
|
->setProfileObject($favorites)
|
||||||
->setCustomPHID($custom_phid)
|
->setCustomPHID($viewer->getPHID())
|
||||||
->setController($this)
|
->setController($this)
|
||||||
->setMenuType($menu)
|
|
||||||
->setShowNavigation(false);
|
->setShowNavigation(false);
|
||||||
|
|
||||||
return $engine->buildResponse();
|
return $engine->buildResponse();
|
||||||
|
|
|
@ -8,14 +8,7 @@ final class PhabricatorFavoritesProfileMenuEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemURI($path) {
|
public function getItemURI($path) {
|
||||||
$object = $this->getProfileObject();
|
return "/favorites/menu/{$path}";
|
||||||
$custom = $this->getCustomPHID();
|
|
||||||
|
|
||||||
if ($custom) {
|
|
||||||
return "/favorites/personal/item/{$path}";
|
|
||||||
} else {
|
|
||||||
return "/favorites/global/item/{$path}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getBuiltinProfileItems($object) {
|
protected function getBuiltinProfileItems($object) {
|
||||||
|
|
|
@ -50,16 +50,8 @@ final class PhabricatorFavoritesMainMenuBarExtension
|
||||||
|
|
||||||
$menu_engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
$menu_engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setProfileObject($favorites);
|
->setProfileObject($favorites)
|
||||||
|
->setCustomPHID($viewer->getPHID());
|
||||||
if ($viewer->getPHID()) {
|
|
||||||
$menu_engine
|
|
||||||
->setCustomPHID($viewer->getPHID())
|
|
||||||
->setMenuType(PhabricatorProfileMenuEngine::MENU_COMBINED);
|
|
||||||
} else {
|
|
||||||
$menu_engine
|
|
||||||
->setMenuType(PhabricatorProfileMenuEngine::MENU_GLOBAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter_view = $menu_engine->buildNavigation();
|
$filter_view = $menu_engine->buildNavigation();
|
||||||
|
|
||||||
|
@ -87,7 +79,7 @@ final class PhabricatorFavoritesMainMenuBarExtension
|
||||||
$view->addAction(
|
$view->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Favorites'))
|
->setName(pht('Edit Favorites'))
|
||||||
->setHref('/favorites/'));
|
->setHref('/favorites/menu/configure/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
|
|
|
@ -22,14 +22,11 @@ final class PhabricatorHomeApplication extends PhabricatorApplication {
|
||||||
|
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
'/' => 'PhabricatorHomeMainController',
|
'/' => 'PhabricatorHomeMenuItemController',
|
||||||
'/(?P<only>home)/' => 'PhabricatorHomeMainController',
|
|
||||||
'/home/' => array(
|
'/home/' => array(
|
||||||
'menu/' => array(
|
'' => 'PhabricatorHomeMenuItemController',
|
||||||
'' => 'PhabricatorHomeMenuController',
|
'menu/' => $this->getProfileMenuRouting(
|
||||||
'(?P<type>global|personal)/item/' => $this->getProfileMenuRouting(
|
|
||||||
'PhabricatorHomeMenuItemController'),
|
'PhabricatorHomeMenuItemController'),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,8 @@ abstract class PhabricatorHomeController extends PhabricatorController {
|
||||||
|
|
||||||
$engine = id(new PhabricatorHomeProfileMenuEngine())
|
$engine = id(new PhabricatorHomeProfileMenuEngine())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setProfileObject($home);
|
->setProfileObject($home)
|
||||||
|
->setCustomPHID($viewer->getPHID());
|
||||||
if ($viewer->getPHID()) {
|
|
||||||
$engine->setCustomPHID($viewer->getPHID())
|
|
||||||
->setMenuType(PhabricatorProfileMenuEngine::MENU_COMBINED);
|
|
||||||
} else {
|
|
||||||
$engine->setMenuType(PhabricatorProfileMenuEngine::MENU_GLOBAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->profileMenu = $engine->buildNavigation();
|
$this->profileMenu = $engine->buildNavigation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorHomeMenuController extends PhabricatorHomeController {
|
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
$viewer = $request->getViewer();
|
|
||||||
|
|
||||||
if (!$viewer->getIsAdmin()) {
|
|
||||||
$uri = '/home/menu/personal/item/configure/';
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,14 +3,21 @@
|
||||||
final class PhabricatorHomeMenuItemController
|
final class PhabricatorHomeMenuItemController
|
||||||
extends PhabricatorHomeController {
|
extends PhabricatorHomeController {
|
||||||
|
|
||||||
|
public function shouldAllowPublic() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isGlobalDragAndDropUploadEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$type = $request->getURIData('type');
|
|
||||||
$custom_phid = null;
|
if ($viewer->getPHID()) {
|
||||||
$menu = PhabricatorProfileMenuEngine::MENU_GLOBAL;
|
|
||||||
if ($type == 'personal') {
|
|
||||||
$custom_phid = $viewer->getPHID();
|
$custom_phid = $viewer->getPHID();
|
||||||
$menu = PhabricatorProfileMenuEngine::MENU_PERSONAL;
|
} else {
|
||||||
|
$custom_phid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$application = 'PhabricatorHomeApplication';
|
$application = 'PhabricatorHomeApplication';
|
||||||
|
@ -23,7 +30,6 @@ final class PhabricatorHomeMenuItemController
|
||||||
$engine = id(new PhabricatorHomeProfileMenuEngine())
|
$engine = id(new PhabricatorHomeProfileMenuEngine())
|
||||||
->setProfileObject($home_app)
|
->setProfileObject($home_app)
|
||||||
->setCustomPHID($custom_phid)
|
->setCustomPHID($custom_phid)
|
||||||
->setMenuType($menu)
|
|
||||||
->setController($this);
|
->setController($this);
|
||||||
|
|
||||||
return $engine->buildResponse();
|
return $engine->buildResponse();
|
||||||
|
|
|
@ -8,14 +8,7 @@ final class PhabricatorHomeProfileMenuEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemURI($path) {
|
public function getItemURI($path) {
|
||||||
$object = $this->getProfileObject();
|
return "/home/menu/{$path}";
|
||||||
$custom = $this->getCustomPHID();
|
|
||||||
|
|
||||||
if ($custom) {
|
|
||||||
return "/home/menu/personal/item/{$path}";
|
|
||||||
} else {
|
|
||||||
return "/home/menu/global/item/{$path}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getBuiltinProfileItems($object) {
|
protected function getBuiltinProfileItems($object) {
|
||||||
|
@ -58,11 +51,7 @@ final class PhabricatorHomeProfileMenuEngine
|
||||||
->setMenuItemKey(
|
->setMenuItemKey(
|
||||||
PhabricatorHomeLauncherProfileMenuItem::MENUITEMKEY);
|
PhabricatorHomeLauncherProfileMenuItem::MENUITEMKEY);
|
||||||
|
|
||||||
// Single Manage Item, switches URI based on admin/user
|
$items[] = $this->newManageItem();
|
||||||
$items[] = $this->newItem()
|
|
||||||
->setBuiltinKey(PhabricatorHomeConstants::ITEM_MANAGE)
|
|
||||||
->setMenuItemKey(
|
|
||||||
PhabricatorHomeManageProfileMenuItem::MENUITEMKEY);
|
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,13 @@ final class PhabricatorHomeProfileMenuItem
|
||||||
return $this->getDefaultName();
|
return $this->getDefaultName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newPageContent() {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
return id(new PHUIHomeView())
|
||||||
|
->setViewer($viewer);
|
||||||
|
}
|
||||||
|
|
||||||
public function buildEditEngineFields(
|
public function buildEditEngineFields(
|
||||||
PhabricatorProfileMenuItemConfiguration $config) {
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
return array(
|
return array(
|
||||||
|
@ -52,7 +59,7 @@ final class PhabricatorHomeProfileMenuItem
|
||||||
if ($viewer->isLoggedIn()) {
|
if ($viewer->isLoggedIn()) {
|
||||||
$name = $this->getDisplayName($config);
|
$name = $this->getDisplayName($config);
|
||||||
$icon = 'fa-home';
|
$icon = 'fa-home';
|
||||||
$href = '/home/';
|
$href = $this->getItemViewURI($config);
|
||||||
|
|
||||||
$item = $this->newItem()
|
$item = $this->newItem()
|
||||||
->setHref($href)
|
->setHref($href)
|
||||||
|
|
|
@ -1,52 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorHomeMainController extends PhabricatorHomeController {
|
final class PHUIHomeView
|
||||||
|
extends AphrontTagView {
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
protected function getTagName() {
|
||||||
return true;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isGlobalDragAndDropUploadEnabled() {
|
protected function getTagAttributes() {
|
||||||
return true;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
protected function getTagContent() {
|
||||||
$viewer = $request->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$dashboard = PhabricatorDashboardInstall::getDashboard(
|
|
||||||
$viewer,
|
|
||||||
$viewer->getPHID(),
|
|
||||||
get_class($this->getCurrentApplication()));
|
|
||||||
|
|
||||||
if (!$dashboard) {
|
|
||||||
$dashboard = PhabricatorDashboardInstall::getDashboard(
|
|
||||||
$viewer,
|
|
||||||
PhabricatorHomeApplication::DASHBOARD_DEFAULT,
|
|
||||||
get_class($this->getCurrentApplication()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dashboard) {
|
|
||||||
$content = id(new PhabricatorDashboardRenderingEngine())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->setDashboard($dashboard)
|
|
||||||
->renderDashboard();
|
|
||||||
} else {
|
|
||||||
$content = $this->buildMainResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
$nav = $this->getProfileMenu();
|
|
||||||
$content =
|
|
||||||
array(
|
|
||||||
$content,
|
|
||||||
id(new PhabricatorGlobalUploadTargetView())->setUser($viewer),
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->newPage()
|
|
||||||
->setTitle('Phabricator')
|
|
||||||
->addClass('phabricator-home')
|
|
||||||
->setNavigation($nav)
|
|
||||||
->appendChild($content);
|
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$this->buildMainResponse(),
|
||||||
|
id(new PhabricatorGlobalUploadTargetView())->setUser($viewer),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildMainResponse() {
|
private function buildMainResponse() {
|
|
@ -7,6 +7,10 @@ final class PhabricatorProjectProfileMenuEngine
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function isMenuEnginePersonalizable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getItemURI($path) {
|
public function getItemURI($path) {
|
||||||
$project = $this->getProfileObject();
|
$project = $this->getProfileObject();
|
||||||
$id = $project->getID();
|
$id = $project->getID();
|
||||||
|
@ -37,9 +41,7 @@ final class PhabricatorProjectProfileMenuEngine
|
||||||
->setMenuItemKey(
|
->setMenuItemKey(
|
||||||
PhabricatorProjectSubprojectsProfileMenuItem::MENUITEMKEY);
|
PhabricatorProjectSubprojectsProfileMenuItem::MENUITEMKEY);
|
||||||
|
|
||||||
$items[] = $this->newItem()
|
$items[] = $this->newManageItem();
|
||||||
->setBuiltinKey(PhabricatorProject::ITEM_MANAGE)
|
|
||||||
->setMenuItemKey(PhabricatorProjectManageProfileMenuItem::MENUITEMKEY);
|
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,18 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
private $profileObject;
|
private $profileObject;
|
||||||
private $customPHID;
|
private $customPHID;
|
||||||
private $items;
|
private $items;
|
||||||
private $menuType = self::MENU_GLOBAL;
|
|
||||||
private $defaultItem;
|
private $defaultItem;
|
||||||
private $controller;
|
private $controller;
|
||||||
private $navigation;
|
private $navigation;
|
||||||
private $showNavigation = true;
|
private $showNavigation = true;
|
||||||
|
private $editMode;
|
||||||
|
|
||||||
const MENU_GLOBAL = 'global';
|
|
||||||
const MENU_PERSONAL = 'personal';
|
|
||||||
const MENU_COMBINED = 'menu';
|
|
||||||
const ITEM_CUSTOM_DIVIDER = 'engine.divider';
|
const ITEM_CUSTOM_DIVIDER = 'engine.divider';
|
||||||
|
const ITEM_MANAGE = 'item.configure';
|
||||||
|
|
||||||
|
const MODE_COMBINED = 'combined';
|
||||||
|
const MODE_GLOBAL = 'global';
|
||||||
|
const MODE_CUSTOM = 'custom';
|
||||||
|
|
||||||
public function setViewer(PhabricatorUser $viewer) {
|
public function setViewer(PhabricatorUser $viewer) {
|
||||||
$this->viewer = $viewer;
|
$this->viewer = $viewer;
|
||||||
|
@ -44,6 +46,21 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return $this->customPHID;
|
return $this->customPHID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getEditModeCustomPHID() {
|
||||||
|
$mode = $this->getEditMode();
|
||||||
|
|
||||||
|
switch ($mode) {
|
||||||
|
case self::MODE_CUSTOM:
|
||||||
|
$custom_phid = $this->getCustomPHID();
|
||||||
|
break;
|
||||||
|
case self::MODE_GLOBAL:
|
||||||
|
$custom_phid = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $custom_phid;
|
||||||
|
}
|
||||||
|
|
||||||
public function setController(PhabricatorController $controller) {
|
public function setController(PhabricatorController $controller) {
|
||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -60,19 +77,10 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultItem() {
|
public function getDefaultItem() {
|
||||||
$this->loadItems();
|
$this->getItems();
|
||||||
return $this->defaultItem;
|
return $this->defaultItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMenuType($type) {
|
|
||||||
$this->menuType = $type;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getMenuType() {
|
|
||||||
return $this->menuType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShowNavigation($show) {
|
public function setShowNavigation($show) {
|
||||||
$this->showNavigation = $show;
|
$this->showNavigation = $show;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -93,6 +101,10 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getEditMode() {
|
||||||
|
return $this->editMode;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildResponse() {
|
public function buildResponse() {
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
|
|
||||||
|
@ -171,24 +183,35 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
|
|
||||||
$crumbs = $controller->buildApplicationCrumbsForEditEngine();
|
$crumbs = $controller->buildApplicationCrumbsForEditEngine();
|
||||||
|
|
||||||
// TODO: This stuff might need a little tweaking at some point, since it
|
|
||||||
// causes "Global" and "Personal" to show up in contexts where they don't
|
|
||||||
// make sense, notably Projects.
|
|
||||||
if ($item_action != 'view') {
|
if ($item_action != 'view') {
|
||||||
$navigation->selectFilter('item.configure');
|
$navigation->selectFilter(self::ITEM_MANAGE);
|
||||||
switch ($this->getMenuType()) {
|
|
||||||
case 'personal':
|
if ($selected_item) {
|
||||||
$crumbs->addTextCrumb(pht('Personal'));
|
if ($selected_item->getCustomPHID()) {
|
||||||
break;
|
$edit_mode = 'custom';
|
||||||
case 'global':
|
} else {
|
||||||
$crumbs->addTextCrumb(pht('Global'));
|
$edit_mode = 'global';
|
||||||
break;
|
}
|
||||||
|
} else {
|
||||||
|
$edit_mode = $request->getURIData('itemEditMode');
|
||||||
|
}
|
||||||
|
|
||||||
|
$available_modes = $this->getViewerEditModes($viewer);
|
||||||
|
if ($available_modes) {
|
||||||
|
$available_modes = array_fuse($available_modes);
|
||||||
|
if (isset($available_modes[$edit_mode])) {
|
||||||
|
$this->editMode = $edit_mode;
|
||||||
|
} else {
|
||||||
|
if ($item_action != 'configure') {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($item_action) {
|
switch ($item_action) {
|
||||||
case 'view':
|
case 'view':
|
||||||
$navigation->selectFilter($selected_item->getItemIdentifier());
|
$navigation->selectFilter($selected_item->getDefaultMenuItemKey());
|
||||||
|
|
||||||
$content = $this->buildItemViewContent($selected_item);
|
$content = $this->buildItemViewContent($selected_item);
|
||||||
$crumbs->addTextCrumb($selected_item->getDisplayName());
|
$crumbs->addTextCrumb($selected_item->getDisplayName());
|
||||||
|
@ -197,15 +220,40 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'configure':
|
case 'configure':
|
||||||
$content = $this->buildItemConfigureContent($item_list);
|
$mode = $this->getEditMode();
|
||||||
$crumbs->addTextCrumb(pht('Configure Menu'));
|
if (!$mode) {
|
||||||
|
$crumbs->addTextCrumb(pht('Configure Menu'));
|
||||||
|
$content = $this->buildMenuEditModeContent();
|
||||||
|
} else {
|
||||||
|
if (count($available_modes) > 1) {
|
||||||
|
$crumbs->addTextCrumb(
|
||||||
|
pht('Configure Menu'),
|
||||||
|
$this->getItemURI('configure/'));
|
||||||
|
|
||||||
|
switch ($mode) {
|
||||||
|
case self::MODE_CUSTOM:
|
||||||
|
$crumbs->addTextCrumb(pht('Personal'));
|
||||||
|
break;
|
||||||
|
case self::MODE_GLOBAL:
|
||||||
|
$crumbs->addTextCrumb(pht('Global'));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$crumbs->addTextCrumb(pht('Configure Menu'));
|
||||||
|
}
|
||||||
|
$edit_list = $this->loadItems($mode);
|
||||||
|
$content = $this->buildItemConfigureContent($edit_list);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'reorder':
|
case 'reorder':
|
||||||
$content = $this->buildItemReorderContent($item_list);
|
$mode = $this->getEditMode();
|
||||||
|
$edit_list = $this->loadItems($mode);
|
||||||
|
$content = $this->buildItemReorderContent($edit_list);
|
||||||
break;
|
break;
|
||||||
case 'new':
|
case 'new':
|
||||||
$item_key = $request->getURIData('itemKey');
|
$item_key = $request->getURIData('itemKey');
|
||||||
$content = $this->buildItemNewContent($item_key);
|
$mode = $this->getEditMode();
|
||||||
|
$content = $this->buildItemNewContent($item_key, $mode);
|
||||||
break;
|
break;
|
||||||
case 'builtin':
|
case 'builtin':
|
||||||
$content = $this->buildItemBuiltinContent($selected_item);
|
$content = $this->buildItemBuiltinContent($selected_item);
|
||||||
|
@ -238,6 +286,8 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
|
|
||||||
$crumbs->setBorder(true);
|
$crumbs->setBorder(true);
|
||||||
|
|
||||||
|
// TODO: This title is not correct when viewing items.
|
||||||
|
|
||||||
$page = $controller->newPage()
|
$page = $controller->newPage()
|
||||||
->setTitle(pht('Configure Menu'))
|
->setTitle(pht('Configure Menu'))
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
|
@ -290,8 +340,8 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
if (count($items) == 1) {
|
if (count($items) == 1) {
|
||||||
$item = head($items);
|
$item = head($items);
|
||||||
if ($item->getKey() === null) {
|
if ($item->getKey() === null) {
|
||||||
$item_identifier = $menu_item->getItemIdentifier();
|
$default_key = $menu_item->getDefaultMenuItemKey();
|
||||||
$item->setKey($item_identifier);
|
$item->setKey($default_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,31 +358,30 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
|
|
||||||
private function getItems() {
|
private function getItems() {
|
||||||
if ($this->items === null) {
|
if ($this->items === null) {
|
||||||
$this->items = $this->loadItems();
|
$this->items = $this->loadItems(self::MODE_COMBINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->items;
|
return $this->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadItems() {
|
private function loadItems($mode) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
|
|
||||||
$items = $this->loadBuiltinProfileItems();
|
$items = $this->loadBuiltinProfileItems($mode);
|
||||||
|
|
||||||
$query = id(new PhabricatorProfileMenuItemConfigurationQuery())
|
$query = id(new PhabricatorProfileMenuItemConfigurationQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withProfilePHIDs(array($object->getPHID()));
|
->withProfilePHIDs(array($object->getPHID()));
|
||||||
|
|
||||||
$menu_type = $this->getMenuType();
|
switch ($mode) {
|
||||||
switch ($menu_type) {
|
case self::MODE_GLOBAL:
|
||||||
case self::MENU_GLOBAL:
|
|
||||||
$query->withCustomPHIDs(array(), true);
|
$query->withCustomPHIDs(array(), true);
|
||||||
break;
|
break;
|
||||||
case self::MENU_PERSONAL:
|
case self::MODE_CUSTOM:
|
||||||
$query->withCustomPHIDs(array($this->getCustomPHID()), false);
|
$query->withCustomPHIDs(array($this->getCustomPHID()), false);
|
||||||
break;
|
break;
|
||||||
case self::MENU_COMBINED:
|
case self::MODE_COMBINED:
|
||||||
$query->withCustomPHIDs(array($this->getCustomPHID()), true);
|
$query->withCustomPHIDs(array($this->getCustomPHID()), true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +417,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = $this->arrangeItems($items);
|
$items = $this->arrangeItems($items, $mode);
|
||||||
|
|
||||||
// Make sure exactly one valid item is marked as default.
|
// Make sure exactly one valid item is marked as default.
|
||||||
$default = null;
|
$default = null;
|
||||||
|
@ -399,20 +448,19 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadBuiltinProfileItems() {
|
private function loadBuiltinProfileItems($mode) {
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
|
|
||||||
$menu_type = $this->getMenuType();
|
switch ($mode) {
|
||||||
switch ($menu_type) {
|
case self::MODE_GLOBAL:
|
||||||
case self::MENU_GLOBAL:
|
|
||||||
$builtins = $this->getBuiltinProfileItems($object);
|
$builtins = $this->getBuiltinProfileItems($object);
|
||||||
break;
|
break;
|
||||||
case self::MENU_PERSONAL:
|
case self::MODE_CUSTOM:
|
||||||
$builtins = $this->getBuiltinCustomProfileItems(
|
$builtins = $this->getBuiltinCustomProfileItems(
|
||||||
$object,
|
$object,
|
||||||
$this->getCustomPHID());
|
$this->getCustomPHID());
|
||||||
break;
|
break;
|
||||||
case self::MENU_COMBINED:
|
case self::MODE_COMBINED:
|
||||||
$builtins = array();
|
$builtins = array();
|
||||||
$builtins[] = $this->getBuiltinCustomProfileItems(
|
$builtins[] = $this->getBuiltinCustomProfileItems(
|
||||||
$object,
|
$object,
|
||||||
|
@ -489,6 +537,15 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigureURI() {
|
public function getConfigureURI() {
|
||||||
|
$mode = $this->getEditMode();
|
||||||
|
|
||||||
|
switch ($mode) {
|
||||||
|
case self::MODE_CUSTOM:
|
||||||
|
return $this->getItemURI('configure/custom/');
|
||||||
|
case self::MODE_GLOBAL:
|
||||||
|
return $this->getItemURI('configure/global/');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getItemURI('configure/');
|
return $this->getItemURI('configure/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +557,8 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
// object the menu appears on. If you're reordering custom items, you only
|
// object the menu appears on. If you're reordering custom items, you only
|
||||||
// need to be able to edit the custom object. Currently, the custom object
|
// need to be able to edit the custom object. Currently, the custom object
|
||||||
// is always the viewing user's own user object.
|
// is always the viewing user's own user object.
|
||||||
$custom_phid = $this->getCustomPHID();
|
$custom_phid = $this->getEditModeCustomPHID();
|
||||||
|
|
||||||
if (!$custom_phid) {
|
if (!$custom_phid) {
|
||||||
PhabricatorPolicyFilter::requireCapability(
|
PhabricatorPolicyFilter::requireCapability(
|
||||||
$viewer,
|
$viewer,
|
||||||
|
@ -593,6 +651,85 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return $item->newPageContent();
|
return $item->newPageContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getViewerEditModes() {
|
||||||
|
$modes = array();
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
if ($viewer->isLoggedIn() && $this->isMenuEnginePersonalizable()) {
|
||||||
|
$modes[] = self::MODE_CUSTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object = $this->getProfileObject();
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$object,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
if ($can_edit) {
|
||||||
|
$modes[] = self::MODE_GLOBAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $modes;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isMenuEnginePersonalizable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildMenuEditModeContent() {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$modes = $this->getViewerEditModes($viewer);
|
||||||
|
if (!$modes) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($modes) == 1) {
|
||||||
|
$mode = head($modes);
|
||||||
|
return id(new AphrontRedirectResponse())
|
||||||
|
->setURI($this->getItemURI("configure/{$mode}/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$menu = id(new PHUIObjectItemListView())
|
||||||
|
->setUser($viewer);
|
||||||
|
|
||||||
|
$modes = array_fuse($modes);
|
||||||
|
|
||||||
|
if (isset($modes['custom'])) {
|
||||||
|
$menu->addItem(
|
||||||
|
id(new PHUIObjectItemView())
|
||||||
|
->setHeader(pht('Personal Menu Items'))
|
||||||
|
->setHref($this->getItemURI('configure/custom/'))
|
||||||
|
->setImageURI($viewer->getProfileImageURI())
|
||||||
|
->addAttribute(pht('Edit the menu for your personal account.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($modes['global'])) {
|
||||||
|
$icon = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-globe')
|
||||||
|
->setBackground('bg-blue');
|
||||||
|
|
||||||
|
$menu->addItem(
|
||||||
|
id(new PHUIObjectItemView())
|
||||||
|
->setHeader(pht('Global Menu Items'))
|
||||||
|
->setHref($this->getItemURI('configure/global/'))
|
||||||
|
->setImageIcon($icon)
|
||||||
|
->addAttribute(pht('Edit the global default menu for all users.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
$box = id(new PHUIObjectBoxView())
|
||||||
|
->setObjectList($menu);
|
||||||
|
|
||||||
|
$header = id(new PHUIHeaderView())
|
||||||
|
->setHeader(pht('Manage Menu'))
|
||||||
|
->setHeaderIcon('fa-list');
|
||||||
|
|
||||||
|
return id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->setFooter($box);
|
||||||
|
}
|
||||||
|
|
||||||
private function buildItemConfigureContent(array $items) {
|
private function buildItemConfigureContent(array $items) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
|
@ -616,11 +753,13 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
|
|
||||||
$list_id = celerity_generate_unique_node_id();
|
$list_id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
|
$mode = $this->getEditMode();
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'reorder-profile-menu-items',
|
'reorder-profile-menu-items',
|
||||||
array(
|
array(
|
||||||
'listID' => $list_id,
|
'listID' => $list_id,
|
||||||
'orderURI' => $this->getItemURI('reorder/'),
|
'orderURI' => $this->getItemURI("reorder/{$mode}/"),
|
||||||
));
|
));
|
||||||
|
|
||||||
$list = id(new PHUIObjectItemListView())
|
$list = id(new PHUIObjectItemListView())
|
||||||
|
@ -738,12 +877,13 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
$item_key = $item_type->getMenuItemKey();
|
$item_key = $item_type->getMenuItemKey();
|
||||||
|
$edit_mode = $this->getEditMode();
|
||||||
|
|
||||||
$action_list->addAction(
|
$action_list->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setIcon($item_type->getMenuItemTypeIcon())
|
->setIcon($item_type->getMenuItemTypeIcon())
|
||||||
->setName($item_type->getMenuItemTypeName())
|
->setName($item_type->getMenuItemTypeName())
|
||||||
->setHref($this->getItemURI("new/{$item_key}/"))
|
->setHref($this->getItemURI("new/{$edit_mode}/{$item_key}/"))
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +928,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildItemNewContent($item_key) {
|
private function buildItemNewContent($item_key, $mode) {
|
||||||
$item_types = PhabricatorProfileMenuItem::getAllMenuItems();
|
$item_types = PhabricatorProfileMenuItem::getAllMenuItems();
|
||||||
$item_type = idx($item_types, $item_key);
|
$item_type = idx($item_types, $item_key);
|
||||||
if (!$item_type) {
|
if (!$item_type) {
|
||||||
|
@ -800,7 +940,8 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom_phid = $this->getCustomPHID();
|
$custom_phid = $this->getEditModeCustomPHID();
|
||||||
|
|
||||||
$configuration = PhabricatorProfileMenuItemConfiguration::initializeNewItem(
|
$configuration = PhabricatorProfileMenuItemConfiguration::initializeNewItem(
|
||||||
$object,
|
$object,
|
||||||
$item_type,
|
$item_type,
|
||||||
|
@ -828,12 +969,13 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
|
$custom_phid = $this->getEditModeCustomPHID();
|
||||||
|
|
||||||
return id(new PhabricatorProfileMenuEditEngine())
|
return id(new PhabricatorProfileMenuEditEngine())
|
||||||
->setMenuEngine($this)
|
->setMenuEngine($this)
|
||||||
->setProfileObject($object)
|
->setProfileObject($object)
|
||||||
->setController($controller)
|
->setController($controller)
|
||||||
->setCustomPHID($this->getCustomPHID())
|
->setCustomPHID($custom_phid)
|
||||||
->buildResponse();
|
->buildResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,6 +1001,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
|
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
|
$custom_phid = $this->getEditModeCustomPHID();
|
||||||
|
|
||||||
return id(new PhabricatorProfileMenuEditEngine())
|
return id(new PhabricatorProfileMenuEditEngine())
|
||||||
->setIsBuiltin(true)
|
->setIsBuiltin(true)
|
||||||
|
@ -866,7 +1009,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
->setProfileObject($object)
|
->setProfileObject($object)
|
||||||
->setNewMenuItemConfiguration($configuration)
|
->setNewMenuItemConfiguration($configuration)
|
||||||
->setController($controller)
|
->setController($controller)
|
||||||
->setCustomPHID($this->getCustomPHID())
|
->setCustomPHID($custom_phid)
|
||||||
->buildResponse();
|
->buildResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,12 +1151,18 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return PhabricatorProfileMenuItemConfiguration::initializeNewBuiltin();
|
return PhabricatorProfileMenuItemConfiguration::initializeNewBuiltin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newManageItem() {
|
||||||
|
return $this->newItem()
|
||||||
|
->setBuiltinKey(self::ITEM_MANAGE)
|
||||||
|
->setMenuItemKey(PhabricatorManageProfileMenuItem::MENUITEMKEY);
|
||||||
|
}
|
||||||
|
|
||||||
public function adjustDefault($key) {
|
public function adjustDefault($key) {
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
$request = $controller->getRequest();
|
$request = $controller->getRequest();
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
|
|
||||||
$items = $this->loadItems();
|
$items = $this->loadItems(self::MODE_COMBINED);
|
||||||
|
|
||||||
// To adjust the default item, we first change any existing items that
|
// To adjust the default item, we first change any existing items that
|
||||||
// are marked as defaults to "visible", then make the new default item
|
// are marked as defaults to "visible", then make the new default item
|
||||||
|
@ -1074,13 +1223,15 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function arrangeItems(array $items) {
|
private function arrangeItems(array $items, $mode) {
|
||||||
// Sort the items.
|
// Sort the items.
|
||||||
$items = msortv($items, 'getSortVector');
|
$items = msortv($items, 'getSortVector');
|
||||||
|
|
||||||
|
$object = $this->getProfileObject();
|
||||||
|
|
||||||
// If we have some global items and some custom items and are in "combined"
|
// If we have some global items and some custom items and are in "combined"
|
||||||
// mode, put a hard-coded divider item between them.
|
// mode, put a hard-coded divider item between them.
|
||||||
if ($this->getMenuType() == self::MENU_COMBINED) {
|
if ($mode == self::MODE_COMBINED) {
|
||||||
$list = array();
|
$list = array();
|
||||||
$seen_custom = false;
|
$seen_custom = false;
|
||||||
$seen_global = false;
|
$seen_global = false;
|
||||||
|
@ -1092,6 +1243,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
|
||||||
$list[] = $this->newItem()
|
$list[] = $this->newItem()
|
||||||
->setBuiltinKey(self::ITEM_CUSTOM_DIVIDER)
|
->setBuiltinKey(self::ITEM_CUSTOM_DIVIDER)
|
||||||
->setMenuItemKey(PhabricatorDividerProfileMenuItem::MENUITEMKEY)
|
->setMenuItemKey(PhabricatorDividerProfileMenuItem::MENUITEMKEY)
|
||||||
|
->attachProfileObject($object)
|
||||||
->attachMenuItem(
|
->attachMenuItem(
|
||||||
new PhabricatorDividerProfileMenuItem());
|
new PhabricatorDividerProfileMenuItem());
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ final class PhabricatorDashboardProfileMenuItem
|
||||||
}
|
}
|
||||||
|
|
||||||
$engine = id(new PhabricatorDashboardRenderingEngine())
|
$engine = id(new PhabricatorDashboardRenderingEngine())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setDashboard($dashboard);
|
->setDashboard($dashboard);
|
||||||
|
|
||||||
return $engine->renderDashboard();
|
return $engine->renderDashboard();
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,11 @@ final class PhabricatorDashboardProfileMenuItem
|
||||||
public function getDisplayName(
|
public function getDisplayName(
|
||||||
PhabricatorProfileMenuItemConfiguration $config) {
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
$dashboard = $this->getDashboard();
|
$dashboard = $this->getDashboard();
|
||||||
|
|
||||||
if (!$dashboard) {
|
if (!$dashboard) {
|
||||||
return pht('(Restricted/Invalid Dashboard)');
|
return pht('(Restricted/Invalid Dashboard)');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($this->getName($config))) {
|
if (strlen($this->getName($config))) {
|
||||||
return $this->getName($config);
|
return $this->getName($config);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorHomeManageProfileMenuItem
|
final class PhabricatorManageProfileMenuItem
|
||||||
extends PhabricatorProfileMenuItem {
|
extends PhabricatorProfileMenuItem {
|
||||||
|
|
||||||
const MENUITEMKEY = 'home.manage.menu';
|
const MENUITEMKEY = 'menu.manage';
|
||||||
|
|
||||||
public function getMenuItemTypeName() {
|
public function getMenuItemTypeName() {
|
||||||
return pht('Manage Home Menu');
|
return pht('Manage Menu');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDefaultName() {
|
private function getDefaultName() {
|
||||||
|
@ -49,17 +49,21 @@ final class PhabricatorHomeManageProfileMenuItem
|
||||||
PhabricatorProfileMenuItemConfiguration $config) {
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
if ($viewer->isLoggedIn()) {
|
if (!$viewer->isLoggedIn()) {
|
||||||
$name = $this->getDisplayName($config);
|
return array();
|
||||||
$icon = 'fa-pencil';
|
|
||||||
$href = '/home/menu/';
|
|
||||||
|
|
||||||
$item = $this->newItem()
|
|
||||||
->setHref($href)
|
|
||||||
->setName($name)
|
|
||||||
->setIcon($icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$engine = $this->getEngine();
|
||||||
|
$href = $engine->getItemURI('configure/');
|
||||||
|
|
||||||
|
$name = $this->getDisplayName($config);
|
||||||
|
$icon = 'fa-pencil';
|
||||||
|
|
||||||
|
$item = $this->newItem()
|
||||||
|
->setHref($href)
|
||||||
|
->setName($name)
|
||||||
|
->setIcon($icon);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$item,
|
$item,
|
||||||
);
|
);
|
|
@ -117,6 +117,7 @@ final class PhabricatorProfileMenuItemConfigurationQuery
|
||||||
unset($page[$key]);
|
unset($page[$key]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->attachProfileObject($profile);
|
$item->attachProfileObject($profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,14 @@ final class PhabricatorProfileMenuItemConfiguration
|
||||||
return $this->getBuiltinKey();
|
return $this->getBuiltinKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDefaultMenuItemKey() {
|
||||||
|
if ($this->getBuiltinKey()) {
|
||||||
|
return $this->getBuiltinKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
public function newPageContent() {
|
public function newPageContent() {
|
||||||
return $this->getMenuItem()->newPageContent($this);
|
return $this->getMenuItem()->newPageContent($this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue