Automatically build mobile menus from navigation, and clean up external ProfileMenu API
Summary: Depends on D20355. Ref T13275. Ref T13247. Currently, "Hamburger" menus are not automatically built from navigation menus. However, this is (I'm almost completely sure?) a reasonable and appropriate default behavior, and saves us some code around profile menus. With this rule in place, we can remove `setApplicationMenu()` and `getApplicationMenu()` from `StandardPageView`, since they have no callers. This also updates a lot of profile menu callsites to a new API which is added in the next change. Test Plan: See the next two changes. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13275, T13247 Differential Revision: https://secure.phabricator.com/D20356
This commit is contained in:
@@ -172,7 +172,9 @@ final class PhabricatorProjectBoardViewController
|
||||
return $content;
|
||||
}
|
||||
|
||||
$nav = $this->newWorkboardProfileMenu();
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_WORKBOARD);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Workboard'));
|
||||
@@ -719,7 +721,9 @@ final class PhabricatorProjectBoardViewController
|
||||
->appendChild($board)
|
||||
->addClass('project-board-wrapper');
|
||||
|
||||
$nav = $this->newWorkboardProfileMenu();
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_WORKBOARD);
|
||||
|
||||
$divider = id(new PHUIListItemView())
|
||||
->setType(PHUIListItemView::TYPE_DIVIDER);
|
||||
@@ -1503,15 +1507,4 @@ final class PhabricatorProjectBoardViewController
|
||||
->addCancelButton($profile_uri);
|
||||
}
|
||||
|
||||
private function newWorkboardProfileMenu() {
|
||||
$default_item = id(new PhabricatorProfileMenuItemConfiguration())
|
||||
->setBuiltinKey(PhabricatorProject::ITEM_WORKBOARD);
|
||||
|
||||
$menu = parent::getProfileMenu($default_item);
|
||||
|
||||
$menu->addClass('project-board-nav');
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,30 +84,6 @@ abstract class PhabricatorProjectController extends PhabricatorController {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
$menu = $this->newApplicationMenu();
|
||||
|
||||
$profile_menu = $this->getProfileMenu();
|
||||
if ($profile_menu) {
|
||||
$menu->setProfileMenu($profile_menu);
|
||||
}
|
||||
|
||||
$menu->setSearchEngine(new PhabricatorProjectSearchEngine());
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
protected function getProfileMenu($default_item = null) {
|
||||
if (!$this->profileMenu) {
|
||||
$engine = $this->getProfileMenuEngine();
|
||||
if ($engine) {
|
||||
$this->profileMenu = $engine->buildNavigation($default_item);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->profileMenu;
|
||||
}
|
||||
|
||||
protected function buildApplicationCrumbs() {
|
||||
return $this->newApplicationCrumbs('profile');
|
||||
}
|
||||
@@ -207,4 +183,23 @@ abstract class PhabricatorProjectController extends PhabricatorController {
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
final protected function newNavigation(
|
||||
PhabricatorProject $project,
|
||||
$item_identifier) {
|
||||
|
||||
$engine = $this->getProfileMenuEngine();
|
||||
|
||||
$view_list = $engine->newProfileMenuItemViewList();
|
||||
|
||||
$view_list->setSelectedViewWithItemIdentifier($item_identifier);
|
||||
|
||||
$navigation = $view_list->newNavigationView();
|
||||
|
||||
if ($item_identifier === PhabricatorProject::ITEM_WORKBOARD) {
|
||||
$navigation->addClass('project-board-nav');
|
||||
}
|
||||
|
||||
return $navigation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ final class PhabricatorProjectManageController
|
||||
new PhabricatorProjectTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
$nav = $this->getProfileMenu();
|
||||
$nav->selectFilter(PhabricatorProject::ITEM_MANAGE);
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_MANAGE);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Manage'));
|
||||
|
||||
@@ -36,8 +36,9 @@ final class PhabricatorProjectMembersViewController
|
||||
->setUserPHIDs($project->getWatcherPHIDs())
|
||||
->setShowNote(true);
|
||||
|
||||
$nav = $this->getProfileMenu();
|
||||
$nav->selectFilter(PhabricatorProject::ITEM_MEMBERS);
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_MEMBERS);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Members'));
|
||||
|
||||
@@ -74,8 +74,9 @@ final class PhabricatorProjectProfileController
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||
->setUserPHIDs($project->getWatcherPHIDs());
|
||||
|
||||
$nav = $this->getProfileMenu();
|
||||
$nav->selectFilter(PhabricatorProject::ITEM_PROFILE);
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_PROFILE);
|
||||
|
||||
$stories = id(new PhabricatorFeedQuery())
|
||||
->setViewer($viewer)
|
||||
|
||||
@@ -77,8 +77,9 @@ final class PhabricatorProjectSubprojectsController
|
||||
$milestones,
|
||||
$subprojects);
|
||||
|
||||
$nav = $this->getProfileMenu();
|
||||
$nav->selectFilter(PhabricatorProject::ITEM_SUBPROJECTS);
|
||||
$nav = $this->newNavigation(
|
||||
$project,
|
||||
PhabricatorProject::ITEM_SUBPROJECTS);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Subprojects'));
|
||||
|
||||
@@ -18,7 +18,7 @@ final class PhabricatorProjectViewController
|
||||
$project = $this->getProject();
|
||||
|
||||
$engine = $this->getProfileMenuEngine();
|
||||
$default = $engine->getDefaultItem();
|
||||
$default = $engine->getDefaultMenuItemConfiguration();
|
||||
|
||||
// If defaults are broken somehow, serve the manage page. See T13033 for
|
||||
// discussion.
|
||||
|
||||
Reference in New Issue
Block a user