@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update all existing ProfileMenuItems for the more-structured API

Summary:
Depends on D20357. Ref T13275. Now that there's a stronger layer between "stuff in the database" and "stuff on the screen", these subclasses all need to emit intermediate objects instead of raw, HTML-producing view objects.

This update is mostly mechanical.

Test Plan:
- Viewed Home, Favorites, Portals, User Profiles, Project Profiles.
- Clicked each item on each menu/profile type.
- Added every (I think?) type of item to a menu and clicked them all.
- Grepped for obsolete symbols (`newNavigationMenuItems`, `willBuildNavigationItems`).

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13275

Differential Revision: https://secure.phabricator.com/D20358

+232 -211
+4 -4
src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
··· 49 49 ); 50 50 } 51 51 52 - protected function newNavigationMenuItems( 52 + protected function newMenuItemViewList( 53 53 PhabricatorProfileMenuItemConfiguration $config) { 54 54 $viewer = $this->getViewer(); 55 55 ··· 57 57 return array(); 58 58 } 59 59 60 - $href = $this->getItemViewURI($config); 60 + $uri = $this->getItemViewURI($config); 61 61 $name = $this->getDisplayName($config); 62 62 $icon = 'fa-pencil'; 63 63 64 - $item = $this->newItem() 65 - ->setHref($href) 64 + $item = $this->newItemView() 65 + ->setURI($uri) 66 66 ->setName($name) 67 67 ->setIcon($icon); 68 68
+4 -4
src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
··· 49 49 ); 50 50 } 51 51 52 - protected function newNavigationMenuItems( 52 + protected function newMenuItemViewList( 53 53 PhabricatorProfileMenuItemConfiguration $config) { 54 54 $viewer = $this->getViewer(); 55 55 56 56 $name = $this->getDisplayName($config); 57 57 $icon = 'fa-ellipsis-h'; 58 - $href = '/applications/'; 58 + $uri = '/applications/'; 59 59 60 - $item = $this->newItem() 61 - ->setHref($href) 60 + $item = $this->newItemView() 61 + ->setURI($uri) 62 62 ->setName($name) 63 63 ->setIcon($icon); 64 64
+4 -4
src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
··· 52 52 ); 53 53 } 54 54 55 - protected function newNavigationMenuItems( 55 + protected function newMenuItemViewList( 56 56 PhabricatorProfileMenuItemConfiguration $config) { 57 57 $viewer = $this->getViewer(); 58 58 59 59 $name = $this->getDisplayName($config); 60 60 $icon = 'fa-home'; 61 - $href = $this->getItemViewURI($config); 61 + $uri = $this->getItemViewURI($config); 62 62 63 - $item = $this->newItem() 64 - ->setHref($href) 63 + $item = $this->newItemView() 64 + ->setURI($uri) 65 65 ->setName($name) 66 66 ->setIcon($icon); 67 67
+3 -3
src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
··· 40 40 ); 41 41 } 42 42 43 - protected function newNavigationMenuItems( 43 + protected function newMenuItemViewList( 44 44 PhabricatorProfileMenuItemConfiguration $config) { 45 45 46 46 $user = $config->getProfileObject(); 47 47 $id = $user->getID(); 48 48 49 - $item = $this->newItem() 50 - ->setHref("/people/badges/{$id}/") 49 + $item = $this->newItemView() 50 + ->setURI("/people/badges/{$id}/") 51 51 ->setName($this->getDisplayName($config)) 52 52 ->setIcon('fa-trophy'); 53 53
+3 -3
src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
··· 40 40 ); 41 41 } 42 42 43 - protected function newNavigationMenuItems( 43 + protected function newMenuItemViewList( 44 44 PhabricatorProfileMenuItemConfiguration $config) { 45 45 46 46 $user = $config->getProfileObject(); 47 47 $id = $user->getID(); 48 48 49 - $item = $this->newItem() 50 - ->setHref("/people/commits/{$id}/") 49 + $item = $this->newItemView() 50 + ->setURI("/people/commits/{$id}/") 51 51 ->setName($this->getDisplayName($config)) 52 52 ->setIcon('fa-code'); 53 53
+4 -4
src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
··· 35 35 ); 36 36 } 37 37 38 - protected function newNavigationMenuItems( 38 + protected function newMenuItemViewList( 39 39 PhabricatorProfileMenuItemConfiguration $config) { 40 40 41 41 $user = $config->getProfileObject(); 42 - $href = urisprintf( 42 + $uri = urisprintf( 43 43 '/p/%s/', 44 44 $user->getUsername()); 45 45 46 - $item = $this->newItem() 47 - ->setHref($href) 46 + $item = $this->newItemView() 47 + ->setURI($uri) 48 48 ->setName(pht('Profile')) 49 49 ->setIcon('fa-user'); 50 50
+3 -3
src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
··· 40 40 ); 41 41 } 42 42 43 - protected function newNavigationMenuItems( 43 + protected function newMenuItemViewList( 44 44 PhabricatorProfileMenuItemConfiguration $config) { 45 45 46 46 $user = $config->getProfileObject(); 47 47 $id = $user->getID(); 48 48 49 - $item = $this->newItem() 50 - ->setHref("/people/manage/{$id}/") 49 + $item = $this->newItemView() 50 + ->setURI("/people/manage/{$id}/") 51 51 ->setName($this->getDisplayName($config)) 52 52 ->setIcon('fa-gears'); 53 53
+4 -38
src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
··· 28 28 return array(); 29 29 } 30 30 31 - protected function newNavigationMenuItems( 31 + protected function newMenuItemViewList( 32 32 PhabricatorProfileMenuItemConfiguration $config) { 33 33 34 34 $user = $config->getProfileObject(); 35 - require_celerity_resource('people-picture-menu-item-css'); 36 35 37 36 $picture = $user->getProfileImageURI(); 38 37 $name = $user->getUsername(); 39 38 40 - $classes = array(); 41 - $classes[] = 'people-menu-image'; 42 - if ($user->getIsDisabled()) { 43 - $classes[] = 'phui-image-disabled'; 44 - } 45 - 46 - $href = urisprintf( 47 - '/p/%s/', 48 - $user->getUsername()); 49 - 50 - $photo = phutil_tag( 51 - 'img', 52 - array( 53 - 'src' => $picture, 54 - 'class' => implode(' ', $classes), 55 - )); 56 - 57 - $can_edit = PhabricatorPolicyFilter::hasCapability( 58 - $this->getViewer(), 59 - $user, 60 - PhabricatorPolicyCapability::CAN_EDIT); 39 + $item = $this->newItemView() 40 + ->setDisabled($user->getIsDisabled()); 61 41 62 - if ($can_edit) { 63 - $id = $user->getID(); 64 - $href = "/people/picture/{$id}/"; 65 - } 66 - 67 - $view = phutil_tag_div('people-menu-image-container', $photo); 68 - $view = phutil_tag( 69 - 'a', 70 - array( 71 - 'href' => $href, 72 - ), 73 - $view); 74 - 75 - $item = $this->newItem() 76 - ->appendChild($view); 42 + $item->newProfileImage($picture); 77 43 78 44 return array( 79 45 $item,
+3 -3
src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
··· 40 40 ); 41 41 } 42 42 43 - protected function newNavigationMenuItems( 43 + protected function newMenuItemViewList( 44 44 PhabricatorProfileMenuItemConfiguration $config) { 45 45 46 46 $user = $config->getProfileObject(); 47 47 $id = $user->getID(); 48 48 49 - $item = $this->newItem() 50 - ->setHref("/people/revisions/{$id}/") 49 + $item = $this->newItemView() 50 + ->setURI("/people/revisions/{$id}/") 51 51 ->setName($this->getDisplayName($config)) 52 52 ->setIcon('fa-gear'); 53 53
+3 -3
src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
··· 40 40 ); 41 41 } 42 42 43 - protected function newNavigationMenuItems( 43 + protected function newMenuItemViewList( 44 44 PhabricatorProfileMenuItemConfiguration $config) { 45 45 46 46 $user = $config->getProfileObject(); 47 47 $id = $user->getID(); 48 48 49 - $item = $this->newItem() 50 - ->setHref("/people/tasks/{$id}/") 49 + $item = $this->newItemView() 50 + ->setURI("/people/tasks/{$id}/") 51 51 ->setName($this->getDisplayName($config)) 52 52 ->setIcon('fa-anchor'); 53 53
+4 -4
src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
··· 49 49 ); 50 50 } 51 51 52 - protected function newNavigationMenuItems( 52 + protected function newMenuItemViewList( 53 53 PhabricatorProfileMenuItemConfiguration $config) { 54 54 55 55 $project = $config->getProfileObject(); ··· 58 58 $name = $project->getName(); 59 59 $icon = $project->getDisplayIconIcon(); 60 60 61 - $href = "/project/profile/{$id}/"; 61 + $uri = "/project/profile/{$id}/"; 62 62 63 - $item = $this->newItem() 64 - ->setHref($href) 63 + $item = $this->newItemView() 64 + ->setURI($uri) 65 65 ->setName($name) 66 66 ->setIcon($icon); 67 67
+4 -4
src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
··· 49 49 ); 50 50 } 51 51 52 - protected function newNavigationMenuItems( 52 + protected function newMenuItemViewList( 53 53 PhabricatorProfileMenuItemConfiguration $config) { 54 54 55 55 $project = $config->getProfileObject(); ··· 58 58 59 59 $name = $this->getDisplayName($config); 60 60 $icon = 'fa-gears'; 61 - $href = "/project/manage/{$id}/"; 61 + $uri = "/project/manage/{$id}/"; 62 62 63 - $item = $this->newItem() 64 - ->setHref($href) 63 + $item = $this->newItemView() 64 + ->setURI($uri) 65 65 ->setName($name) 66 66 ->setIcon($icon); 67 67
+4 -4
src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
··· 39 39 ); 40 40 } 41 41 42 - protected function newNavigationMenuItems( 42 + protected function newMenuItemViewList( 43 43 PhabricatorProfileMenuItemConfiguration $config) { 44 44 45 45 $project = $config->getProfileObject(); ··· 48 48 49 49 $name = $this->getDisplayName($config); 50 50 $icon = 'fa-group'; 51 - $href = "/project/members/{$id}/"; 51 + $uri = "/project/members/{$id}/"; 52 52 53 - $item = $this->newItem() 54 - ->setHref($href) 53 + $item = $this->newItemView() 54 + ->setURI($uri) 55 55 ->setName($name) 56 56 ->setIcon($icon); 57 57
+4 -26
src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
··· 32 32 return array(); 33 33 } 34 34 35 - protected function newNavigationMenuItems( 35 + protected function newMenuItemViewList( 36 36 PhabricatorProfileMenuItemConfiguration $config) { 37 37 38 38 $project = $config->getProfileObject(); 39 - require_celerity_resource('people-picture-menu-item-css'); 40 - 41 39 $picture = $project->getProfileImageURI(); 42 - $href = $project->getProfileURI(); 43 40 44 - $classes = array(); 45 - $classes[] = 'people-menu-image'; 46 - if ($project->isArchived()) { 47 - $classes[] = 'phui-image-disabled'; 48 - } 49 - 50 - $photo = phutil_tag( 51 - 'img', 52 - array( 53 - 'src' => $picture, 54 - 'class' => implode(' ', $classes), 55 - )); 41 + $item = $this->newItemView() 42 + ->setDisabled($project->isArchived()); 56 43 57 - $view = phutil_tag_div('people-menu-image-container', $photo); 58 - $view = phutil_tag( 59 - 'a', 60 - array( 61 - 'href' => $href, 62 - ), 63 - $view); 64 - 65 - $item = $this->newItem() 66 - ->appendChild($view); 44 + $item->newProfileImage($picture); 67 45 68 46 return array( 69 47 $item,
+3 -3
src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
··· 52 52 ); 53 53 } 54 54 55 - protected function newNavigationMenuItems( 55 + protected function newMenuItemViewList( 56 56 PhabricatorProfileMenuItemConfiguration $config) { 57 57 $viewer = $this->getViewer(); 58 58 $project = $config->getProfileObject(); ··· 165 165 ), 166 166 $bar); 167 167 168 - $item = $this->newItem() 169 - ->appendChild($bar); 168 + $item = $this->newItemView() 169 + ->newProgressBar($bar); 170 170 171 171 return array( 172 172 $item,
+4 -4
src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
··· 47 47 ); 48 48 } 49 49 50 - protected function newNavigationMenuItems( 50 + protected function newMenuItemViewList( 51 51 PhabricatorProfileMenuItemConfiguration $config) { 52 52 53 53 $project = $config->getProfileObject(); ··· 55 55 56 56 $name = $this->getDisplayName($config); 57 57 $icon = 'fa-sitemap'; 58 - $href = "/project/subprojects/{$id}/"; 58 + $uri = "/project/subprojects/{$id}/"; 59 59 60 - $item = $this->newItem() 61 - ->setHref($href) 60 + $item = $this->newItemView() 61 + ->setURI($uri) 62 62 ->setName($name) 63 63 ->setIcon($icon); 64 64
+4 -4
src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
··· 56 56 ); 57 57 } 58 58 59 - protected function newNavigationMenuItems( 59 + protected function newMenuItemViewList( 60 60 PhabricatorProfileMenuItemConfiguration $config) { 61 61 $project = $config->getProfileObject(); 62 62 63 63 $id = $project->getID(); 64 - $href = $project->getWorkboardURI(); 64 + $uri = $project->getWorkboardURI(); 65 65 $name = $this->getDisplayName($config); 66 66 67 - $item = $this->newItem() 68 - ->setHref($href) 67 + $item = $this->newItemView() 68 + ->setURI($uri) 69 69 ->setName($name) 70 70 ->setIcon('fa-columns'); 71 71
+20
src/applications/search/engine/PhabricatorProfileMenuItemView.php
··· 7 7 private $uri; 8 8 private $name; 9 9 private $icon; 10 + private $iconImage; 10 11 private $disabled; 11 12 private $tooltip; 12 13 private $actions = array(); ··· 51 52 52 53 public function getIcon() { 53 54 return $this->icon; 55 + } 56 + 57 + public function setIconImage($icon_image) { 58 + $this->iconImage = $icon_image; 59 + return $this; 60 + } 61 + 62 + public function getIconImage() { 63 + return $this->iconImage; 54 64 } 55 65 56 66 public function setDisabled($disabled) { ··· 146 156 $view->setIcon($icon); 147 157 } 148 158 159 + $icon_image = $this->getIconImage(); 160 + if ($icon_image) { 161 + $view->setProfileImage($icon_image); 162 + } 163 + 149 164 if ($this->getDisabled()) { 150 165 $view->setDisabled(true); 151 166 } ··· 158 173 $view 159 174 ->setType(PHUIListItemView::TYPE_DIVIDER) 160 175 ->addClass('phui-divider'); 176 + } 177 + 178 + $tooltip = $this->getTooltip(); 179 + if (strlen($tooltip)) { 180 + $view->setTooltip($tooltip); 161 181 } 162 182 163 183 if ($this->images) {
+3 -3
src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
··· 68 68 return head($apps); 69 69 } 70 70 71 - protected function newNavigationMenuItems( 71 + protected function newMenuItemViewList( 72 72 PhabricatorProfileMenuItemConfiguration $config) { 73 73 $viewer = $this->getViewer(); 74 74 $app = $this->getApplication($config); ··· 83 83 return array(); 84 84 } 85 85 86 - $item = $this->newItem() 87 - ->setHref($app->getApplicationURI()) 86 + $item = $this->newItemView() 87 + ->setURI($app->getApplicationURI()) 88 88 ->setName($this->getDisplayName($config)) 89 89 ->setIcon($app->getIcon()); 90 90
+8 -15
src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
··· 41 41 return $conpherence; 42 42 } 43 43 44 - public function willBuildNavigationItems(array $items) { 44 + public function willGetMenuItemViewList(array $items) { 45 45 $viewer = $this->getViewer(); 46 46 $room_phids = array(); 47 47 foreach ($items as $item) { ··· 98 98 return $config->getMenuItemProperty('name'); 99 99 } 100 100 101 - protected function newNavigationMenuItems( 101 + protected function newMenuItemViewList( 102 102 PhabricatorProfileMenuItemConfiguration $config) { 103 103 $viewer = $this->getViewer(); 104 104 $room = $this->getConpherence($config); ··· 114 114 $unread_count = $data['unread_count']; 115 115 } 116 116 117 - $count = null; 117 + $item = $this->newItemView() 118 + ->setURI('/'.$room->getMonogram()) 119 + ->setName($this->getDisplayName($config)) 120 + ->setIcon('fa-comments'); 121 + 118 122 if ($unread_count) { 119 - $count = phutil_tag( 120 - 'span', 121 - array( 122 - 'class' => 'phui-list-item-count', 123 - ), 124 - $unread_count); 123 + $item->newCount($unread_count); 125 124 } 126 - 127 - $item = $this->newItem() 128 - ->setHref('/'.$room->getMonogram()) 129 - ->setName($this->getDisplayName($config)) 130 - ->setIcon('fa-comments') 131 - ->appendChild($count); 132 125 133 126 return array( 134 127 $item,
+69 -25
src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
··· 8 8 const FIELD_DASHBOARD = 'dashboardPHID'; 9 9 10 10 private $dashboard; 11 + private $dashboardHandle; 11 12 12 13 public function getMenuItemTypeIcon() { 13 14 return 'fa-dashboard'; ··· 26 27 return true; 27 28 } 28 29 29 - public function attachDashboard($dashboard) { 30 + private function attachDashboard(PhabricatorDashboard $dashboard = null) { 30 31 $this->dashboard = $dashboard; 31 32 return $this; 32 33 } 33 34 34 - public function getDashboard() { 35 - $dashboard = $this->dashboard; 36 - 37 - if (!$dashboard) { 38 - return null; 39 - } else if ($dashboard->isArchived()) { 40 - return null; 41 - } 42 - 43 - return $dashboard; 35 + private function getDashboard() { 36 + return $this->dashboard; 44 37 } 45 38 46 39 public function newPageContent( ··· 56 49 ->needPanels(true) 57 50 ->executeOne(); 58 51 if (!$dashboard) { 59 - return null; 52 + return $this->newEmptyView( 53 + pht('Invalid Dashboard'), 54 + pht('This dashboard is invalid and could not be loaded.')); 55 + } 56 + 57 + if ($dashboard->isArchived()) { 58 + return $this->newEmptyView( 59 + pht('Archived Dashboard'), 60 + pht('This dashboard has been archived.')); 60 61 } 61 62 62 63 $engine = id(new PhabricatorDashboardRenderingEngine()) ··· 66 67 return $engine->renderDashboard(); 67 68 } 68 69 69 - public function willBuildNavigationItems(array $items) { 70 + public function willGetMenuItemViewList(array $items) { 70 71 $viewer = $this->getViewer(); 71 72 $dashboard_phids = array(); 72 73 foreach ($items as $item) { ··· 78 79 ->withPHIDs($dashboard_phids) 79 80 ->execute(); 80 81 82 + $handles = $viewer->loadHandles($dashboard_phids); 83 + 81 84 $dashboards = mpull($dashboards, null, 'getPHID'); 82 85 foreach ($items as $item) { 83 86 $dashboard_phid = $item->getMenuItemProperty('dashboardPHID'); 84 87 $dashboard = idx($dashboards, $dashboard_phid, null); 85 - $item->getMenuItem()->attachDashboard($dashboard); 88 + 89 + $menu_item = $item->getMenuItem(); 90 + 91 + $menu_item 92 + ->attachDashboard($dashboard) 93 + ->setDashboardHandle($handles[$dashboard_phid]); 86 94 } 87 95 } 88 96 ··· 91 99 $dashboard = $this->getDashboard(); 92 100 93 101 if (!$dashboard) { 94 - return pht('(Restricted/Invalid Dashboard)'); 102 + if ($this->getDashboardHandle()->getPolicyFiltered()) { 103 + return pht('Restricted Dashboard'); 104 + } else { 105 + return pht('Invalid Dashboard'); 106 + } 107 + } 108 + 109 + if ($dashboard->isArchived()) { 110 + return pht('Archived Dashboard'); 95 111 } 96 112 97 113 if (strlen($this->getName($config))) { ··· 122 138 return $config->getMenuItemProperty('name'); 123 139 } 124 140 125 - protected function newNavigationMenuItems( 141 + protected function newMenuItemViewList( 126 142 PhabricatorProfileMenuItemConfiguration $config) { 127 143 144 + $is_disabled = true; 145 + $action_uri = null; 146 + 128 147 $dashboard = $this->getDashboard(); 129 - if (!$dashboard) { 130 - return array(); 148 + if ($dashboard) { 149 + if ($dashboard->isArchived()) { 150 + $icon = 'fa-ban'; 151 + $name = $this->getDisplayName($config); 152 + } else { 153 + $icon = $dashboard->getIcon(); 154 + $name = $this->getDisplayName($config); 155 + $is_disabled = false; 156 + $action_uri = '/dashboard/arrange/'.$dashboard->getID().'/'; 157 + } 158 + } else { 159 + $icon = 'fa-ban'; 160 + if ($this->getDashboardHandle()->getPolicyFiltered()) { 161 + $name = pht('Restricted Dashboard'); 162 + } else { 163 + $name = pht('Invalid Dashboard'); 164 + } 131 165 } 132 166 133 - $icon = $dashboard->getIcon(); 134 - $name = $this->getDisplayName($config); 135 - $href = $this->getItemViewURI($config); 136 - $action_href = '/dashboard/arrange/'.$dashboard->getID().'/'; 167 + $uri = $this->getItemViewURI($config); 137 168 138 - $item = $this->newItem() 139 - ->setHref($href) 169 + $item = $this->newItemView() 170 + ->setURI($uri) 140 171 ->setName($name) 141 172 ->setIcon($icon) 142 - ->setActionIcon('fa-pencil', $action_href); 173 + ->setDisabled($is_disabled); 174 + 175 + if ($action_uri) { 176 + $item->newAction($action_uri); 177 + } 143 178 144 179 return array( 145 180 $item, ··· 189 224 } 190 225 191 226 return $errors; 227 + } 228 + 229 + private function getDashboardHandle() { 230 + return $this->dashboardHandle; 231 + } 232 + 233 + private function setDashboardHandle(PhabricatorObjectHandle $handle) { 234 + $this->dashboardHandle = $handle; 235 + return $this; 192 236 } 193 237 194 238 }
+3 -4
src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
··· 34 34 ); 35 35 } 36 36 37 - protected function newNavigationMenuItems( 37 + protected function newMenuItemViewList( 38 38 PhabricatorProfileMenuItemConfiguration $config) { 39 39 40 - $item = $this->newItem() 41 - ->setType(PHUIListItemView::TYPE_DIVIDER) 42 - ->addClass('phui-divider'); 40 + $item = $this->newItemView() 41 + ->setIsDivider(true); 43 42 44 43 return array( 45 44 $item,
+6 -6
src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
··· 34 34 return $form; 35 35 } 36 36 37 - public function willBuildNavigationItems(array $items) { 37 + public function willGetMenuItemViewList(array $items) { 38 38 $viewer = $this->getViewer(); 39 39 $engines = PhabricatorEditEngine::getAllEditEngines(); 40 40 $engine_keys = array_keys($engines); ··· 99 99 return $config->getMenuItemProperty('name'); 100 100 } 101 101 102 - protected function newNavigationMenuItems( 102 + protected function newMenuItemViewList( 103 103 PhabricatorProfileMenuItemConfiguration $config) { 104 104 105 105 $form = $this->getForm(); ··· 110 110 $icon = $form->getIcon(); 111 111 $name = $this->getDisplayName($config); 112 112 113 - $href = $form->getCreateURI(); 114 - if ($href === null) { 113 + $uri = $form->getCreateURI(); 114 + if ($uri === null) { 115 115 return array(); 116 116 } 117 117 118 - $item = $this->newItem() 119 - ->setHref($href) 118 + $item = $this->newItemView() 119 + ->setURI($uri) 120 120 ->setName($name) 121 121 ->setIcon($icon); 122 122
+3 -3
src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
··· 39 39 return $config->getMenuItemProperty('name'); 40 40 } 41 41 42 - protected function newNavigationMenuItems( 42 + protected function newMenuItemViewList( 43 43 PhabricatorProfileMenuItemConfiguration $config) { 44 44 45 45 $name = $this->getLabelName($config); 46 46 47 - $item = $this->newItem() 47 + $item = $this->newItemView() 48 48 ->setName($name) 49 - ->setType(PHUIListItemView::TYPE_LABEL); 49 + ->setIsLabel(true); 50 50 51 51 return array( 52 52 $item,
+6 -14
src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
··· 71 71 return $config->getMenuItemProperty('tooltip'); 72 72 } 73 73 74 - private function isValidLinkURI($uri) { 75 - return PhabricatorEnv::isValidURIForLink($uri); 76 - } 77 - 78 - protected function newNavigationMenuItems( 74 + protected function newMenuItemViewList( 79 75 PhabricatorProfileMenuItemConfiguration $config) { 80 76 81 77 $icon = $this->getLinkIcon($config); 82 78 $name = $this->getLinkName($config); 83 - $href = $this->getLinkURI($config); 79 + $uri = $this->getLinkURI($config); 84 80 $tooltip = $this->getLinkTooltip($config); 85 81 86 - if (!$this->isValidLinkURI($href)) { 87 - $href = '#'; 88 - } 89 - 90 82 $icon_object = id(new PhabricatorProfileMenuItemIconSet()) 91 83 ->getIcon($icon); 92 84 if ($icon_object) { ··· 95 87 $icon_class = 'fa-link'; 96 88 } 97 89 98 - $item = $this->newItem() 99 - ->setHref($href) 90 + $item = $this->newItemView() 91 + ->setURI($uri) 100 92 ->setName($name) 101 93 ->setIcon($icon_class) 102 94 ->setTooltip($tooltip) 103 - ->setRel('noreferrer'); 95 + ->setIsExternalLink(true); 104 96 105 97 return array( 106 98 $item, ··· 142 134 continue; 143 135 } 144 136 145 - if (!$this->isValidLinkURI($new)) { 137 + if (!PhabricatorEnv::isValidURIForLink($new)) { 146 138 $errors[] = $this->newInvalidError( 147 139 pht( 148 140 'URI "%s" is not a valid link URI. It should be a full, valid '.
+4 -4
src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
··· 49 49 ); 50 50 } 51 51 52 - protected function newNavigationMenuItems( 52 + protected function newMenuItemViewList( 53 53 PhabricatorProfileMenuItemConfiguration $config) { 54 54 $viewer = $this->getViewer(); 55 55 ··· 58 58 } 59 59 60 60 $engine = $this->getEngine(); 61 - $href = $engine->getItemURI('configure/'); 61 + $uri = $engine->getItemURI('configure/'); 62 62 63 63 $name = $this->getDisplayName($config); 64 64 $icon = 'fa-pencil'; 65 65 66 - $item = $this->newItem() 67 - ->setHref($href) 66 + $item = $this->newItemView() 67 + ->setURI($uri) 68 68 ->setName($name) 69 69 ->setIcon($icon); 70 70
+2 -2
src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
··· 50 50 ); 51 51 } 52 52 53 - protected function newNavigationMenuItems( 53 + protected function newMenuItemViewList( 54 54 PhabricatorProfileMenuItemConfiguration $config) { 55 55 56 56 $source = $config->getMenuItemProperty('source'); ··· 66 66 67 67 $fact_text = $this->selectFact($facts); 68 68 69 - $item = $this->newItem() 69 + $item = $this->newItemView() 70 70 ->setName($fact_name) 71 71 ->setIcon($fact_icon) 72 72 ->setTooltip($fact_text)
+40 -11
src/applications/search/menuitem/PhabricatorProfileMenuItem.php
··· 5 5 private $viewer; 6 6 private $engine; 7 7 8 - final public function buildNavigationMenuItems( 9 - PhabricatorProfileMenuItemConfiguration $config) { 10 - return $this->newNavigationMenuItems($config); 11 - } 12 - 13 - abstract protected function newNavigationMenuItems( 14 - PhabricatorProfileMenuItemConfiguration $config); 15 - 16 - public function willBuildNavigationItems(array $items) {} 17 8 18 9 public function getMenuItemTypeIcon() { 19 10 return null; ··· 76 67 ->execute(); 77 68 } 78 69 79 - protected function newItem() { 80 - return new PHUIListItemView(); 70 + final protected function newItemView() { 71 + return new PhabricatorProfileMenuItemView(); 72 + } 73 + 74 + public function willGetMenuItemViewList(array $items) {} 75 + 76 + final public function getMenuItemViewList( 77 + PhabricatorProfileMenuItemConfiguration $config) { 78 + $list = $this->newMenuItemViewList($config); 79 + 80 + if (!is_array($list)) { 81 + throw new Exception( 82 + pht( 83 + 'Expected "newMenuItemViewList()" to return a list (in class "%s"), '. 84 + 'but it returned something else ("%s").', 85 + get_class($this), 86 + phutil_describe_type($list))); 87 + } 88 + 89 + assert_instances_of($list, 'PhabricatorProfileMenuItemView'); 90 + 91 + foreach ($list as $view) { 92 + $view->setMenuItemConfiguration($config); 93 + } 94 + 95 + return $list; 81 96 } 97 + 98 + abstract protected function newMenuItemViewList( 99 + PhabricatorProfileMenuItemConfiguration $config); 100 + 82 101 83 102 public function newPageContent( 84 103 PhabricatorProfileMenuItemConfiguration $config) { ··· 129 148 130 149 final protected function newInvalidError($message, $xaction = null) { 131 150 return $this->newError(pht('Invalid'), $message, $xaction); 151 + } 152 + 153 + final protected function newEmptyView($title, $message) { 154 + return id(new PHUIInfoView()) 155 + ->setTitle($title) 156 + ->setSeverity(PHUIInfoView::SEVERITY_NODATA) 157 + ->setErrors( 158 + array( 159 + $message, 160 + )); 132 161 } 133 162 134 163 }
+6 -6
src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
··· 35 35 return $project; 36 36 } 37 37 38 - public function willBuildNavigationItems(array $items) { 38 + public function willGetMenuItemViewList(array $items) { 39 39 $viewer = $this->getViewer(); 40 40 $project_phids = array(); 41 41 foreach ($items as $item) { ··· 90 90 return $config->getMenuItemProperty('name'); 91 91 } 92 92 93 - protected function newNavigationMenuItems( 93 + protected function newMenuItemViewList( 94 94 PhabricatorProfileMenuItemConfiguration $config) { 95 95 96 96 $project = $this->getProject(); ··· 100 100 101 101 $picture = $project->getProfileImageURI(); 102 102 $name = $this->getDisplayName($config); 103 - $href = $project->getURI(); 103 + $uri = $project->getURI(); 104 104 105 - $item = $this->newItem() 106 - ->setHref($href) 105 + $item = $this->newItemView() 106 + ->setURI($uri) 107 107 ->setName($name) 108 - ->setProfileImage($picture); 108 + ->setIconImage($picture); 109 109 110 110 return array( 111 111 $item,