Changeset View
Changeset View
Standalone View
Standalone View
src/applications/home/application/PhabricatorHomeApplication.php
| <?php | <?php | ||||
| final class PhabricatorHomeApplication extends PhabricatorApplication { | final class PhabricatorHomeApplication extends PhabricatorApplication { | ||||
| private $quickItems; | private $application; | ||||
| const DASHBOARD_DEFAULT = 'dashboard:default'; | const DASHBOARD_DEFAULT = 'dashboard:default'; | ||||
| public function getBaseURI() { | public function getBaseURI() { | ||||
| return '/home/'; | return '/home/'; | ||||
| } | } | ||||
| public function getName() { | public function getName() { | ||||
| return pht('Home'); | return pht('Home'); | ||||
| } | } | ||||
| public function getShortDescription() { | public function getShortDescription() { | ||||
| return pht('Command Center'); | return pht('Command Center'); | ||||
| } | } | ||||
| public function getIcon() { | public function getIcon() { | ||||
| return 'fa-home'; | return 'fa-home'; | ||||
| } | } | ||||
| public function getRoutes() { | public function getRoutes() { | ||||
| return array( | return array( | ||||
| '/' => 'PhabricatorHomeMainController', | '/' => 'PhabricatorHomeMainController', | ||||
| '/(?P<only>home)/' => 'PhabricatorHomeMainController', | '/(?P<only>home)/' => 'PhabricatorHomeMainController', | ||||
| '/home/' => array( | '/home/' => array( | ||||
| 'create/' => 'PhabricatorHomeQuickCreateController', | |||||
| 'menu/' => array( | 'menu/' => array( | ||||
| '' => 'PhabricatorHomeMenuController', | '' => 'PhabricatorHomeMenuController', | ||||
| '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting( | '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting( | ||||
| 'PhabricatorHomeMenuItemController'), | 'PhabricatorHomeMenuItemController'), | ||||
| ), | ), | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| public function isLaunchable() { | public function isLaunchable() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function getApplicationOrder() { | public function getApplicationOrder() { | ||||
| return 9; | return 9; | ||||
| } | } | ||||
| public function buildMainMenuItems( | public function buildMainMenuExtraNodes( | ||||
| PhabricatorUser $user, | PhabricatorUser $viewer, | ||||
| PhabricatorController $controller = null) { | PhabricatorController $controller = null) { | ||||
| $quick_items = $this->getQuickActionItems($user); | if (!$viewer->isLoggedIn()) { | ||||
| if (!$quick_items) { | return; | ||||
| return array(); | |||||
| } | |||||
| $items = array(); | |||||
| $create_id = celerity_generate_unique_node_id(); | |||||
| Javelin::initBehavior( | |||||
| 'aphlict-dropdown', | |||||
| array( | |||||
| 'bubbleID' => $create_id, | |||||
| 'dropdownID' => 'phabricator-quick-create-menu', | |||||
| 'local' => true, | |||||
| 'desktop' => true, | |||||
| 'right' => true, | |||||
| )); | |||||
| $item = id(new PHUIListItemView()) | |||||
| ->setName(pht('Quick Actions')) | |||||
| ->setIcon('fa-plus') | |||||
| ->addClass('core-menu-item') | |||||
| ->setHref('/home/create/') | |||||
| ->addSigil('quick-create-menu') | |||||
| ->setID($create_id) | |||||
| ->setAural(pht('Quick Actions')) | |||||
| ->setOrder(300); | |||||
| $items[] = $item; | |||||
| return $items; | |||||
| } | } | ||||
| public function buildMainMenuExtraNodes( | $image = $viewer->getProfileImageURI(); | ||||
| PhabricatorUser $viewer, | if ($controller) { | ||||
| PhabricatorController $controller = null) { | $this->application = $controller->getCurrentApplication(); | ||||
| } | |||||
| $items = $this->getQuickActionItems($viewer); | $profile_image = id(new PHUIIconView()) | ||||
| ->setImage($image) | |||||
| ->setHeadSize(PHUIIconView::HEAD_SMALL); | |||||
| $view = null; | return id(new PHUIButtonView()) | ||||
| if ($items) { | ->setTag('a') | ||||
| $view = new PHUIListView(); | ->setHref('/p/'.$viewer->getUsername().'/') | ||||
| foreach ($items as $item) { | ->setIcon($profile_image) | ||||
| $view->addMenuItem($item); | ->addClass('phabricator-core-user-menu') | ||||
| ->setNoCSS(true) | |||||
| ->setDropdown(true) | |||||
| ->setDropdownMenu($this->renderUserDropdown($viewer)); | |||||
| } | } | ||||
| return phutil_tag( | private function renderUserDropdown(PhabricatorUser $viewer) { | ||||
| 'div', | |||||
| array( | $view = id(new PhabricatorActionListView()) | ||||
| 'id' => 'phabricator-quick-create-menu', | ->setViewer($viewer); | ||||
| 'class' => 'phabricator-main-menu-dropdown phui-list-sidenav', | |||||
| 'style' => 'display: none', | // User Menu | ||||
| ), | $view->addAction( | ||||
| $view); | id(new PhabricatorActionView()) | ||||
| ->setName($viewer->getRealName()) | |||||
| ->setLabel(true)); | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Profile')) | |||||
| ->setHref('/p/'.$viewer->getUsername().'/')); | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Settings')) | |||||
epriestley: If `$application` isn't a valid aplication, we'll fatal on line 90 when calling `$application… | |||||
Not Done Inline ActionsShould be fixed.... I think.... feels jank, but 404 page works now. chad: Should be fixed.... I think.... feels jank, but `404` page works now. | |||||
| ->setHref('/settings/user/'.$viewer->getUsername().'/')); | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Manage')) | |||||
| ->setHref('/people/manage/'.$viewer->getID().'/')); | |||||
| // Help Menus | |||||
| if ($this->application) { | |||||
| $application = $this->application; | |||||
| $help_links = $application->getHelpMenuItems($viewer); | |||||
| if ($help_links) { | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setType(PhabricatorActionView::TYPE_DIVIDER)); | |||||
| foreach ($help_links as $link) { | |||||
| $link->setOpenInNewWindow(true); | |||||
| $view->addAction($link); | |||||
| } | } | ||||
| return $view; | |||||
| } | } | ||||
| private function getQuickActionItems(PhabricatorUser $viewer) { | |||||
| if ($this->quickItems === null) { | |||||
| $items = PhabricatorQuickActions::loadMenuItemsForUser($viewer); | |||||
| $this->quickItems = $items; | |||||
| } | } | ||||
| return $this->quickItems; | |||||
| // Logout Menu | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setType(PhabricatorActionView::TYPE_DIVIDER)); | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Log Out %s', $viewer->getUsername())) | |||||
Done Inline ActionsThis reads a little weird to me. Maybe Profile ("%s") or something instead, if the goal is to show which account you're logged in as? That seems a little weird too. Maybe an unclickable "Logged in as %s"? Or put icons on all this stuff and do: [ your profile icon ] <epriestley> ...as the first item in the menu, which is either unclickable or takes you to your profile (replacing "profile")? epriestley: This reads a little weird to me. Maybe `Profile ("%s")` or something instead, if the goal is to… | |||||
Not Done Inline ActionsI plan to follow up with more UI around who is logged, but I've added a quick header to it for now. chad: I plan to follow up with more UI around who is logged, but I've added a quick header to it for… | |||||
| ->setHref('/logout/') | |||||
| ->setWorkflow(true)); | |||||
| return $view; | |||||
| } | } | ||||
| } | } | ||||
If $application isn't a valid aplication, we'll fatal on line 90 when calling $application->getHelpMenuItems() (and, in fact, when invoking this function, since it has a PhabricatorApplication typehint), so this if ($application) check on 91 can't ever do anything, I think?