Differential D17209 Diff 41403 src/applications/favorites/application/PhabricatorFavoritesApplication.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/favorites/application/PhabricatorFavoritesApplication.php
| Show All 9 Lines | public function getName() { | ||||
| return pht('Favorites'); | return pht('Favorites'); | ||||
| } | } | ||||
| public function getShortDescription() { | public function getShortDescription() { | ||||
| return pht('Favorite Items'); | return pht('Favorite Items'); | ||||
| } | } | ||||
| public function getIcon() { | public function getIcon() { | ||||
| return 'fa-star-o'; | return 'fa-star'; | ||||
| } | } | ||||
| public function getRoutes() { | public function getRoutes() { | ||||
| return array( | return array( | ||||
| '/favorites/' => array( | '/favorites/' => array( | ||||
| '' => 'PhabricatorFavoritesMainController', | '' => 'PhabricatorFavoritesMainController', | ||||
| '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting( | '(?P<type>global|personal)/item/' => $this->getProfileMenuRouting( | ||||
| 'PhabricatorFavoritesMenuItemController'), | 'PhabricatorFavoritesMenuItemController'), | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| public function isLaunchable() { | public function isLaunchable() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function getApplicationOrder() { | public function buildMainMenuExtraNodes( | ||||
| return 9; | PhabricatorUser $viewer, | ||||
| PhabricatorController $controller = null) { | |||||
| return id(new PHUIButtonView()) | |||||
epriestley: > Should logged out have Favorites?
Probably show global items only? | |||||
| ->setTag('a') | |||||
| ->setHref('#') | |||||
| ->setIcon('fa-star') | |||||
| ->addClass('phabricator-core-user-menu') | |||||
| ->setNoCSS(true) | |||||
| ->setDropdown(true) | |||||
| ->setDropdownMenu($this->renderFavoritesDropdown($viewer)); | |||||
| } | |||||
| private function renderFavoritesDropdown(PhabricatorUser $viewer) { | |||||
| $application = __CLASS__; | |||||
| $favorites = id(new PhabricatorApplicationQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withClasses(array($application)) | |||||
| ->withInstalled(true) | |||||
| ->executeOne(); | |||||
| $filter_view = id(new PhabricatorFavoritesProfileMenuEngine()) | |||||
| ->setViewer($viewer) | |||||
| ->setProfileObject($favorites) | |||||
| ->setMenuType(PhabricatorProfileMenuEngine::MENU_COMBINED) | |||||
| ->buildNavigation(); | |||||
| $menu_view = $filter_view->getMenu(); | |||||
| $item_views = $menu_view->getItems(); | |||||
| $view = id(new PhabricatorActionListView()) | |||||
| ->setViewer($viewer); | |||||
| foreach ($item_views as $item) { | |||||
| $type = null; | |||||
| if (!strlen($item->getName())) { | |||||
| $type = PhabricatorActionView::TYPE_DIVIDER; | |||||
| } | |||||
| $action = id(new PhabricatorActionView()) | |||||
| ->setName($item->getName()) | |||||
Done Inline ActionsDoes the wrong thing for items named "0". epriestley: Does the wrong thing for items named "0". | |||||
| ->setHref($item->getHref()) | |||||
| ->setType($type); | |||||
| $view->addAction($action); | |||||
| } | |||||
| // Build out edit interface | |||||
| if ($viewer->isLoggedIn()) { | |||||
| $view->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setType(PhabricatorActionView::TYPE_DIVIDER)); | |||||
| $view->addAction( | |||||
Done Inline ActionsMaybe make /favorites/ do this redirect? As a non-admin, I can go there now and see "Edit global stuff", but then I get an edit error. If /favorites/ just sent non-admins directly to /personal/.../ that might be a little cleaner. epriestley: Maybe make `/favorites/` do this redirect? As a non-admin, I can go there now and see "Edit… | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Edit Favorites')) | |||||
| ->setHref('/favorites/')); | |||||
| } | |||||
| return $view; | |||||
| } | } | ||||
| } | } | ||||
Probably show global items only?