From 102eacbfb7b67b64d3637903b59ae6bdf6cc240e Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 12 Jan 2016 14:15:59 -0800 Subject: [PATCH] Make project page/navigation construction more consistent, particularly on mobile Summary: Ref T10054. This mostly makes sure that mobile gets to have the same profile menu that Desktop does. Test Plan: - Viewed menus on mobile, saw all profile menu actions available. - Viewed/used changed pages (column detail, edit column, edit picture). Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15008 --- .../PhabricatorProjectBoardController.php | 13 ++-- .../PhabricatorProjectBoardViewController.php | 2 +- ...abricatorProjectColumnDetailController.php | 17 +++--- ...PhabricatorProjectColumnEditController.php | 12 ++-- .../PhabricatorProjectController.php | 60 +++++++------------ ...habricatorProjectEditPictureController.php | 19 +++--- .../PhabricatorProjectFeedController.php | 2 +- .../PhabricatorProjectListController.php | 16 +---- ...habricatorProjectMembersEditController.php | 4 +- ...PhabricatorProjectMilestonesController.php | 2 +- .../PhabricatorProjectProfileController.php | 2 +- ...habricatorProjectSubprojectsController.php | 2 +- src/view/layout/PHUIApplicationMenuView.php | 20 +++++++ 13 files changed, 85 insertions(+), 86 deletions(-) diff --git a/src/applications/project/controller/PhabricatorProjectBoardController.php b/src/applications/project/controller/PhabricatorProjectBoardController.php index 18028a1bd0..04ab714eb0 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardController.php @@ -3,11 +3,12 @@ abstract class PhabricatorProjectBoardController extends PhabricatorProjectController { - public function buildIconNavView(PhabricatorProject $project) { - $id = $project->getID(); - $nav = parent::buildIconNavView($project); - $nav->selectFilter(PhabricatorProject::PANEL_WORKBOARD); - $nav->addClass('project-board-nav'); - return $nav; + protected function getProfileMenu() { + $menu = parent::getProfileMenu(); + + $menu->selectFilter(PhabricatorProject::PANEL_WORKBOARD); + $menu->addClass('project-board-nav'); + + return $menu; } } diff --git a/src/applications/project/controller/PhabricatorProjectBoardViewController.php b/src/applications/project/controller/PhabricatorProjectBoardViewController.php index 7408e67dd8..571d5b866d 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardViewController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardViewController.php @@ -384,7 +384,7 @@ final class PhabricatorProjectBoardViewController ->appendChild($board) ->addClass('project-board-wrapper'); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); return $this->newPage() ->setTitle(pht('%s Board', $project->getName())) diff --git a/src/applications/project/controller/PhabricatorProjectColumnDetailController.php b/src/applications/project/controller/PhabricatorProjectColumnDetailController.php index 01b520c6c3..ca25c089fb 100644 --- a/src/applications/project/controller/PhabricatorProjectColumnDetailController.php +++ b/src/applications/project/controller/PhabricatorProjectColumnDetailController.php @@ -49,15 +49,16 @@ final class PhabricatorProjectColumnDetailController ->setHeader($header) ->addPropertyList($properties); - $nav = $this->buildIconNavView($project); - $nav->appendChild($box); - $nav->appendChild($timeline); + $nav = $this->getProfileMenu(); - return $this->buildApplicationPage( - $nav, - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->setNavigation($nav) + ->appendChild( + array( + $box, + $timeline, + )); } private function buildHeaderView(PhabricatorProjectColumn $column) { diff --git a/src/applications/project/controller/PhabricatorProjectColumnEditController.php b/src/applications/project/controller/PhabricatorProjectColumnEditController.php index d59c3648fe..77f90b56cb 100644 --- a/src/applications/project/controller/PhabricatorProjectColumnEditController.php +++ b/src/applications/project/controller/PhabricatorProjectColumnEditController.php @@ -144,13 +144,11 @@ final class PhabricatorProjectColumnEditController ->setValidationException($validation_exception) ->setForm($form); - $nav = $this->buildIconNavView($project); - $nav->appendChild($form_box); + $nav = $this->getProfileMenu(); - return $this->buildApplicationPage( - $nav, - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->setNavigation($nav) + ->appendChild($form_box); } } diff --git a/src/applications/project/controller/PhabricatorProjectController.php b/src/applications/project/controller/PhabricatorProjectController.php index c3e333f5fb..0729010480 100644 --- a/src/applications/project/controller/PhabricatorProjectController.php +++ b/src/applications/project/controller/PhabricatorProjectController.php @@ -3,6 +3,7 @@ abstract class PhabricatorProjectController extends PhabricatorController { private $project; + private $profileMenu; protected function setProject(PhabricatorProject $project) { $this->project = $project; @@ -80,50 +81,33 @@ abstract class PhabricatorProjectController extends PhabricatorController { } public function buildApplicationMenu() { - return $this->buildSideNavView(true)->getMenu(); + $menu = $this->newApplicationMenu(); + + $profile_menu = $this->getProfileMenu(); + if ($profile_menu) { + $menu->setProfileMenu($profile_menu); + } + + $menu->setSearchEngine(new PhabricatorProjectSearchEngine()); + + return $menu; } - public function buildSideNavView($for_app = false) { - $project = $this->getProject(); - - - - $nav = new AphrontSideNavFilterView(); - $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - - $viewer = $this->getViewer(); - - $id = null; - if ($for_app) { + protected function getProfileMenu() { + if (!$this->profileMenu) { + $project = $this->getProject(); if ($project) { - $id = $project->getID(); - $nav->addFilter("profile/{$id}/", pht('Profile')); - $nav->addFilter("board/{$id}/", pht('Workboard')); - $nav->addFilter("members/{$id}/", pht('Members')); - $nav->addFilter("feed/{$id}/", pht('Feed')); + $viewer = $this->getViewer(); + + $engine = id(new PhabricatorProfilePanelEngine()) + ->setViewer($viewer) + ->setProfileObject($project); + + $this->profileMenu = $engine->buildNavigation(); } - $nav->addFilter('create', pht('Create Project')); } - if (!$id) { - id(new PhabricatorProjectSearchEngine()) - ->setViewer($viewer) - ->addNavigationItems($nav->getMenu()); - } - - $nav->selectFilter(null); - - return $nav; - } - - public function buildIconNavView(PhabricatorProject $project) { - $viewer = $this->getViewer(); - - $engine = id(new PhabricatorProfilePanelEngine()) - ->setViewer($viewer) - ->setProfileObject($project); - - return $engine->buildNavigation(); + return $this->profileMenu; } protected function buildApplicationCrumbs() { diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php index eff471194f..8828bfae57 100644 --- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php +++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php @@ -21,6 +21,8 @@ final class PhabricatorProjectEditPictureController return new Aphront404Response(); } + $this->setProject($project); + $edit_uri = $this->getApplicationURI('profile/'.$project->getID().'/'); $view_uri = $this->getApplicationURI('profile/'.$project->getID().'/'); @@ -280,15 +282,16 @@ final class PhabricatorProjectEditPictureController ->setHeaderText(pht('Upload New Picture')) ->setForm($upload_form); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_PROFILE); - $nav->appendChild($form_box); - $nav->appendChild($upload_box); - return $this->buildApplicationPage( - $nav, - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->setNavigation($nav) + ->appendChild( + array( + $form_box, + $upload_box, + )); } } diff --git a/src/applications/project/controller/PhabricatorProjectFeedController.php b/src/applications/project/controller/PhabricatorProjectFeedController.php index 80bb3378e8..a108384088 100644 --- a/src/applications/project/controller/PhabricatorProjectFeedController.php +++ b/src/applications/project/controller/PhabricatorProjectFeedController.php @@ -33,7 +33,7 @@ final class PhabricatorProjectFeedController ->setHeaderText(pht('Project Activity')) ->appendChild($feed); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter('feed'); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/project/controller/PhabricatorProjectListController.php b/src/applications/project/controller/PhabricatorProjectListController.php index db4ef5b9f5..021cdfbe3f 100644 --- a/src/applications/project/controller/PhabricatorProjectListController.php +++ b/src/applications/project/controller/PhabricatorProjectListController.php @@ -8,19 +8,9 @@ final class PhabricatorProjectListController } public function handleRequest(AphrontRequest $request) { - $viewer = $request->getViewer(); - $query_key = $request->getURIData('queryKey'); - - $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($query_key) - ->setSearchEngine(new PhabricatorProjectSearchEngine()) - ->setNavigation($this->buildSideNavView()); - - return $this->delegateToController($controller); - } - - public function buildApplicationMenu() { - return $this->buildSideNavView(true)->getMenu(); + return id(new PhabricatorProjectSearchEngine()) + ->setController($this) + ->buildResponse(); } protected function buildApplicationCrumbs() { diff --git a/src/applications/project/controller/PhabricatorProjectMembersEditController.php b/src/applications/project/controller/PhabricatorProjectMembersEditController.php index f45d40d8ae..f485e2997a 100644 --- a/src/applications/project/controller/PhabricatorProjectMembersEditController.php +++ b/src/applications/project/controller/PhabricatorProjectMembersEditController.php @@ -17,6 +17,8 @@ final class PhabricatorProjectMembersEditController return new Aphront404Response(); } + $this->setProject($project); + $member_phids = $project->getMemberPHIDs(); if ($request->isFormPost()) { @@ -95,7 +97,7 @@ final class PhabricatorProjectMembersEditController $member_list = $this->renderMemberList($project, $handles); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_MEMBERS); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/project/controller/PhabricatorProjectMilestonesController.php b/src/applications/project/controller/PhabricatorProjectMilestonesController.php index db0810f819..595035bdb7 100644 --- a/src/applications/project/controller/PhabricatorProjectMilestonesController.php +++ b/src/applications/project/controller/PhabricatorProjectMilestonesController.php @@ -76,7 +76,7 @@ final class PhabricatorProjectMilestonesController ->setProjects($milestones) ->renderList()); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_MILESTONES); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index e588681ef5..a2eb5eebe6 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -43,7 +43,7 @@ final class PhabricatorProjectProfileController new PhabricatorProjectTransactionQuery()); $timeline->setShouldTerminate(true); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_PROFILE); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/project/controller/PhabricatorProjectSubprojectsController.php b/src/applications/project/controller/PhabricatorProjectSubprojectsController.php index 50f3294c71..e512d12a6e 100644 --- a/src/applications/project/controller/PhabricatorProjectSubprojectsController.php +++ b/src/applications/project/controller/PhabricatorProjectSubprojectsController.php @@ -75,7 +75,7 @@ final class PhabricatorProjectSubprojectsController ->setProjects($subprojects) ->renderList()); - $nav = $this->buildIconNavView($project); + $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_SUBPROJECTS); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/view/layout/PHUIApplicationMenuView.php b/src/view/layout/PHUIApplicationMenuView.php index 624b1f982d..f542674de9 100644 --- a/src/view/layout/PHUIApplicationMenuView.php +++ b/src/view/layout/PHUIApplicationMenuView.php @@ -5,6 +5,7 @@ final class PHUIApplicationMenuView extends Phobject { private $viewer; private $crumbs; private $searchEngine; + private $profileMenu; private $items = array(); @@ -32,6 +33,16 @@ final class PHUIApplicationMenuView extends Phobject { return $this->addItem($item); } + public function setProfileMenu( + AphrontSideNavFilterView $nav) { + $this->profileMenu = $nav; + return $this; + } + + public function getProfileMenu() { + return $this->profileMenu; + } + public function addItem(PHUIListItemView $item) { $this->items[] = $item; return $this; @@ -61,6 +72,15 @@ final class PHUIApplicationMenuView extends Phobject { $view = id(new PHUIListView()) ->setUser($viewer); + $profile_menu = $this->getProfileMenu(); + if ($profile_menu) { + foreach ($profile_menu->getMenu()->getItems() as $item) { + $item = clone $item; + $item->setRenderNameAsTooltip(false); + $view->addMenuItem($item); + } + } + $crumbs = $this->getCrumbs(); if ($crumbs) { $actions = $crumbs->getActions();