1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

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
This commit is contained in:
epriestley 2019-03-31 12:07:05 -07:00
parent 950e9d085b
commit 5192ae4750
29 changed files with 233 additions and 212 deletions

View file

@ -49,7 +49,7 @@ final class PhabricatorDashboardPortalMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
@ -57,12 +57,12 @@ final class PhabricatorDashboardPortalMenuItem
return array();
}
$href = $this->getItemViewURI($config);
$uri = $this->getItemViewURI($config);
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -49,16 +49,16 @@ final class PhabricatorHomeLauncherProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-ellipsis-h';
$href = '/applications/';
$uri = '/applications/';
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -52,16 +52,16 @@ final class PhabricatorHomeProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-home';
$href = $this->getItemViewURI($config);
$uri = $this->getItemViewURI($config);
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -40,14 +40,14 @@ final class PhabricatorPeopleBadgesProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
$item = $this->newItem()
->setHref("/people/badges/{$id}/")
$item = $this->newItemView()
->setURI("/people/badges/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-trophy');

View file

@ -40,14 +40,14 @@ final class PhabricatorPeopleCommitsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
$item = $this->newItem()
->setHref("/people/commits/{$id}/")
$item = $this->newItemView()
->setURI("/people/commits/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-code');

View file

@ -35,16 +35,16 @@ final class PhabricatorPeopleDetailsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$href = urisprintf(
$uri = urisprintf(
'/p/%s/',
$user->getUsername());
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName(pht('Profile'))
->setIcon('fa-user');

View file

@ -40,14 +40,14 @@ final class PhabricatorPeopleManageProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
$item = $this->newItem()
->setHref("/people/manage/{$id}/")
$item = $this->newItemView()
->setURI("/people/manage/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gears');

View file

@ -28,52 +28,18 @@ final class PhabricatorPeoplePictureProfileMenuItem
return array();
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
require_celerity_resource('people-picture-menu-item-css');
$picture = $user->getProfileImageURI();
$name = $user->getUsername();
$classes = array();
$classes[] = 'people-menu-image';
if ($user->getIsDisabled()) {
$classes[] = 'phui-image-disabled';
}
$item = $this->newItemView()
->setDisabled($user->getIsDisabled());
$href = urisprintf(
'/p/%s/',
$user->getUsername());
$photo = phutil_tag(
'img',
array(
'src' => $picture,
'class' => implode(' ', $classes),
));
$can_edit = PhabricatorPolicyFilter::hasCapability(
$this->getViewer(),
$user,
PhabricatorPolicyCapability::CAN_EDIT);
if ($can_edit) {
$id = $user->getID();
$href = "/people/picture/{$id}/";
}
$view = phutil_tag_div('people-menu-image-container', $photo);
$view = phutil_tag(
'a',
array(
'href' => $href,
),
$view);
$item = $this->newItem()
->appendChild($view);
$item->newProfileImage($picture);
return array(
$item,

View file

@ -40,14 +40,14 @@ final class PhabricatorPeopleRevisionsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
$item = $this->newItem()
->setHref("/people/revisions/{$id}/")
$item = $this->newItemView()
->setURI("/people/revisions/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gear');

View file

@ -40,14 +40,14 @@ final class PhabricatorPeopleTasksProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
$item = $this->newItem()
->setHref("/people/tasks/{$id}/")
$item = $this->newItemView()
->setURI("/people/tasks/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-anchor');

View file

@ -49,7 +49,7 @@ final class PhabricatorProjectDetailsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@ -58,10 +58,10 @@ final class PhabricatorProjectDetailsProfileMenuItem
$name = $project->getName();
$icon = $project->getDisplayIconIcon();
$href = "/project/profile/{$id}/";
$uri = "/project/profile/{$id}/";
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -49,7 +49,7 @@ final class PhabricatorProjectManageProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@ -58,10 +58,10 @@ final class PhabricatorProjectManageProfileMenuItem
$name = $this->getDisplayName($config);
$icon = 'fa-gears';
$href = "/project/manage/{$id}/";
$uri = "/project/manage/{$id}/";
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -39,7 +39,7 @@ final class PhabricatorProjectMembersProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@ -48,10 +48,10 @@ final class PhabricatorProjectMembersProfileMenuItem
$name = $this->getDisplayName($config);
$icon = 'fa-group';
$href = "/project/members/{$id}/";
$uri = "/project/members/{$id}/";
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -32,38 +32,16 @@ final class PhabricatorProjectPictureProfileMenuItem
return array();
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
require_celerity_resource('people-picture-menu-item-css');
$picture = $project->getProfileImageURI();
$href = $project->getProfileURI();
$classes = array();
$classes[] = 'people-menu-image';
if ($project->isArchived()) {
$classes[] = 'phui-image-disabled';
}
$item = $this->newItemView()
->setDisabled($project->isArchived());
$photo = phutil_tag(
'img',
array(
'src' => $picture,
'class' => implode(' ', $classes),
));
$view = phutil_tag_div('people-menu-image-container', $photo);
$view = phutil_tag(
'a',
array(
'href' => $href,
),
$view);
$item = $this->newItem()
->appendChild($view);
$item->newProfileImage($picture);
return array(
$item,

View file

@ -52,7 +52,7 @@ final class PhabricatorProjectPointsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$project = $config->getProfileObject();
@ -165,8 +165,8 @@ final class PhabricatorProjectPointsProfileMenuItem
),
$bar);
$item = $this->newItem()
->appendChild($bar);
$item = $this->newItemView()
->newProgressBar($bar);
return array(
$item,

View file

@ -47,7 +47,7 @@ final class PhabricatorProjectSubprojectsProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@ -55,10 +55,10 @@ final class PhabricatorProjectSubprojectsProfileMenuItem
$name = $this->getDisplayName($config);
$icon = 'fa-sitemap';
$href = "/project/subprojects/{$id}/";
$uri = "/project/subprojects/{$id}/";
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -56,16 +56,16 @@ final class PhabricatorProjectWorkboardProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
$href = $project->getWorkboardURI();
$uri = $project->getWorkboardURI();
$name = $this->getDisplayName($config);
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon('fa-columns');

View file

@ -7,6 +7,7 @@ final class PhabricatorProfileMenuItemView
private $uri;
private $name;
private $icon;
private $iconImage;
private $disabled;
private $tooltip;
private $actions = array();
@ -53,6 +54,15 @@ final class PhabricatorProfileMenuItemView
return $this->icon;
}
public function setIconImage($icon_image) {
$this->iconImage = $icon_image;
return $this;
}
public function getIconImage() {
return $this->iconImage;
}
public function setDisabled($disabled) {
$this->disabled = $disabled;
return $this;
@ -146,6 +156,11 @@ final class PhabricatorProfileMenuItemView
$view->setIcon($icon);
}
$icon_image = $this->getIconImage();
if ($icon_image) {
$view->setProfileImage($icon_image);
}
if ($this->getDisabled()) {
$view->setDisabled(true);
}
@ -160,6 +175,11 @@ final class PhabricatorProfileMenuItemView
->addClass('phui-divider');
}
$tooltip = $this->getTooltip();
if (strlen($tooltip)) {
$view->setTooltip($tooltip);
}
if ($this->images) {
require_celerity_resource('people-picture-menu-item-css');
foreach ($this->images as $image_src) {

View file

@ -68,7 +68,7 @@ final class PhabricatorApplicationProfileMenuItem
return head($apps);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$app = $this->getApplication($config);
@ -83,8 +83,8 @@ final class PhabricatorApplicationProfileMenuItem
return array();
}
$item = $this->newItem()
->setHref($app->getApplicationURI())
$item = $this->newItemView()
->setURI($app->getApplicationURI())
->setName($this->getDisplayName($config))
->setIcon($app->getIcon());

View file

@ -41,7 +41,7 @@ final class PhabricatorConpherenceProfileMenuItem
return $conpherence;
}
public function willBuildNavigationItems(array $items) {
public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$room_phids = array();
foreach ($items as $item) {
@ -98,7 +98,7 @@ final class PhabricatorConpherenceProfileMenuItem
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$room = $this->getConpherence($config);
@ -114,21 +114,14 @@ final class PhabricatorConpherenceProfileMenuItem
$unread_count = $data['unread_count'];
}
$count = null;
if ($unread_count) {
$count = phutil_tag(
'span',
array(
'class' => 'phui-list-item-count',
),
$unread_count);
}
$item = $this->newItem()
->setHref('/'.$room->getMonogram())
$item = $this->newItemView()
->setURI('/'.$room->getMonogram())
->setName($this->getDisplayName($config))
->setIcon('fa-comments')
->appendChild($count);
->setIcon('fa-comments');
if ($unread_count) {
$item->newCount($unread_count);
}
return array(
$item,

View file

@ -8,6 +8,7 @@ final class PhabricatorDashboardProfileMenuItem
const FIELD_DASHBOARD = 'dashboardPHID';
private $dashboard;
private $dashboardHandle;
public function getMenuItemTypeIcon() {
return 'fa-dashboard';
@ -26,21 +27,13 @@ final class PhabricatorDashboardProfileMenuItem
return true;
}
public function attachDashboard($dashboard) {
private function attachDashboard(PhabricatorDashboard $dashboard = null) {
$this->dashboard = $dashboard;
return $this;
}
public function getDashboard() {
$dashboard = $this->dashboard;
if (!$dashboard) {
return null;
} else if ($dashboard->isArchived()) {
return null;
}
return $dashboard;
private function getDashboard() {
return $this->dashboard;
}
public function newPageContent(
@ -56,7 +49,15 @@ final class PhabricatorDashboardProfileMenuItem
->needPanels(true)
->executeOne();
if (!$dashboard) {
return null;
return $this->newEmptyView(
pht('Invalid Dashboard'),
pht('This dashboard is invalid and could not be loaded.'));
}
if ($dashboard->isArchived()) {
return $this->newEmptyView(
pht('Archived Dashboard'),
pht('This dashboard has been archived.'));
}
$engine = id(new PhabricatorDashboardRenderingEngine())
@ -66,7 +67,7 @@ final class PhabricatorDashboardProfileMenuItem
return $engine->renderDashboard();
}
public function willBuildNavigationItems(array $items) {
public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$dashboard_phids = array();
foreach ($items as $item) {
@ -78,11 +79,18 @@ final class PhabricatorDashboardProfileMenuItem
->withPHIDs($dashboard_phids)
->execute();
$handles = $viewer->loadHandles($dashboard_phids);
$dashboards = mpull($dashboards, null, 'getPHID');
foreach ($items as $item) {
$dashboard_phid = $item->getMenuItemProperty('dashboardPHID');
$dashboard = idx($dashboards, $dashboard_phid, null);
$item->getMenuItem()->attachDashboard($dashboard);
$menu_item = $item->getMenuItem();
$menu_item
->attachDashboard($dashboard)
->setDashboardHandle($handles[$dashboard_phid]);
}
}
@ -91,7 +99,15 @@ final class PhabricatorDashboardProfileMenuItem
$dashboard = $this->getDashboard();
if (!$dashboard) {
return pht('(Restricted/Invalid Dashboard)');
if ($this->getDashboardHandle()->getPolicyFiltered()) {
return pht('Restricted Dashboard');
} else {
return pht('Invalid Dashboard');
}
}
if ($dashboard->isArchived()) {
return pht('Archived Dashboard');
}
if (strlen($this->getName($config))) {
@ -122,24 +138,43 @@ final class PhabricatorDashboardProfileMenuItem
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$is_disabled = true;
$action_uri = null;
$dashboard = $this->getDashboard();
if (!$dashboard) {
return array();
if ($dashboard) {
if ($dashboard->isArchived()) {
$icon = 'fa-ban';
$name = $this->getDisplayName($config);
} else {
$icon = $dashboard->getIcon();
$name = $this->getDisplayName($config);
$is_disabled = false;
$action_uri = '/dashboard/arrange/'.$dashboard->getID().'/';
}
} else {
$icon = 'fa-ban';
if ($this->getDashboardHandle()->getPolicyFiltered()) {
$name = pht('Restricted Dashboard');
} else {
$name = pht('Invalid Dashboard');
}
}
$icon = $dashboard->getIcon();
$name = $this->getDisplayName($config);
$href = $this->getItemViewURI($config);
$action_href = '/dashboard/arrange/'.$dashboard->getID().'/';
$uri = $this->getItemViewURI($config);
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon)
->setActionIcon('fa-pencil', $action_href);
->setDisabled($is_disabled);
if ($action_uri) {
$item->newAction($action_uri);
}
return array(
$item,
@ -191,4 +226,13 @@ final class PhabricatorDashboardProfileMenuItem
return $errors;
}
private function getDashboardHandle() {
return $this->dashboardHandle;
}
private function setDashboardHandle(PhabricatorObjectHandle $handle) {
$this->dashboardHandle = $handle;
return $this;
}
}

View file

@ -34,12 +34,11 @@ final class PhabricatorDividerProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$item = $this->newItem()
->setType(PHUIListItemView::TYPE_DIVIDER)
->addClass('phui-divider');
$item = $this->newItemView()
->setIsDivider(true);
return array(
$item,

View file

@ -34,7 +34,7 @@ final class PhabricatorEditEngineProfileMenuItem
return $form;
}
public function willBuildNavigationItems(array $items) {
public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$engines = PhabricatorEditEngine::getAllEditEngines();
$engine_keys = array_keys($engines);
@ -99,7 +99,7 @@ final class PhabricatorEditEngineProfileMenuItem
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$form = $this->getForm();
@ -110,13 +110,13 @@ final class PhabricatorEditEngineProfileMenuItem
$icon = $form->getIcon();
$name = $this->getDisplayName($config);
$href = $form->getCreateURI();
if ($href === null) {
$uri = $form->getCreateURI();
if ($uri === null) {
return array();
}
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -39,14 +39,14 @@ final class PhabricatorLabelProfileMenuItem
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$name = $this->getLabelName($config);
$item = $this->newItem()
$item = $this->newItemView()
->setName($name)
->setType(PHUIListItemView::TYPE_LABEL);
->setIsLabel(true);
return array(
$item,

View file

@ -71,22 +71,14 @@ final class PhabricatorLinkProfileMenuItem
return $config->getMenuItemProperty('tooltip');
}
private function isValidLinkURI($uri) {
return PhabricatorEnv::isValidURIForLink($uri);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$icon = $this->getLinkIcon($config);
$name = $this->getLinkName($config);
$href = $this->getLinkURI($config);
$uri = $this->getLinkURI($config);
$tooltip = $this->getLinkTooltip($config);
if (!$this->isValidLinkURI($href)) {
$href = '#';
}
$icon_object = id(new PhabricatorProfileMenuItemIconSet())
->getIcon($icon);
if ($icon_object) {
@ -95,12 +87,12 @@ final class PhabricatorLinkProfileMenuItem
$icon_class = 'fa-link';
}
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon_class)
->setTooltip($tooltip)
->setRel('noreferrer');
->setIsExternalLink(true);
return array(
$item,
@ -142,7 +134,7 @@ final class PhabricatorLinkProfileMenuItem
continue;
}
if (!$this->isValidLinkURI($new)) {
if (!PhabricatorEnv::isValidURIForLink($new)) {
$errors[] = $this->newInvalidError(
pht(
'URI "%s" is not a valid link URI. It should be a full, valid '.

View file

@ -49,7 +49,7 @@ final class PhabricatorManageProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
@ -58,13 +58,13 @@ final class PhabricatorManageProfileMenuItem
}
$engine = $this->getEngine();
$href = $engine->getItemURI('configure/');
$uri = $engine->getItemURI('configure/');
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setIcon($icon);

View file

@ -50,7 +50,7 @@ final class PhabricatorMotivatorProfileMenuItem
);
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$source = $config->getMenuItemProperty('source');
@ -66,7 +66,7 @@ final class PhabricatorMotivatorProfileMenuItem
$fact_text = $this->selectFact($facts);
$item = $this->newItem()
$item = $this->newItemView()
->setName($fact_name)
->setIcon($fact_icon)
->setTooltip($fact_text)

View file

@ -5,15 +5,6 @@ abstract class PhabricatorProfileMenuItem extends Phobject {
private $viewer;
private $engine;
final public function buildNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config) {
return $this->newNavigationMenuItems($config);
}
abstract protected function newNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config);
public function willBuildNavigationItems(array $items) {}
public function getMenuItemTypeIcon() {
return null;
@ -76,10 +67,38 @@ abstract class PhabricatorProfileMenuItem extends Phobject {
->execute();
}
protected function newItem() {
return new PHUIListItemView();
final protected function newItemView() {
return new PhabricatorProfileMenuItemView();
}
public function willGetMenuItemViewList(array $items) {}
final public function getMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$list = $this->newMenuItemViewList($config);
if (!is_array($list)) {
throw new Exception(
pht(
'Expected "newMenuItemViewList()" to return a list (in class "%s"), '.
'but it returned something else ("%s").',
get_class($this),
phutil_describe_type($list)));
}
assert_instances_of($list, 'PhabricatorProfileMenuItemView');
foreach ($list as $view) {
$view->setMenuItemConfiguration($config);
}
return $list;
}
abstract protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config);
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
return null;
@ -131,4 +150,14 @@ abstract class PhabricatorProfileMenuItem extends Phobject {
return $this->newError(pht('Invalid'), $message, $xaction);
}
final protected function newEmptyView($title, $message) {
return id(new PHUIInfoView())
->setTitle($title)
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->setErrors(
array(
$message,
));
}
}

View file

@ -35,7 +35,7 @@ final class PhabricatorProjectProfileMenuItem
return $project;
}
public function willBuildNavigationItems(array $items) {
public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$project_phids = array();
foreach ($items as $item) {
@ -90,7 +90,7 @@ final class PhabricatorProjectProfileMenuItem
return $config->getMenuItemProperty('name');
}
protected function newNavigationMenuItems(
protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $this->getProject();
@ -100,12 +100,12 @@ final class PhabricatorProjectProfileMenuItem
$picture = $project->getProfileImageURI();
$name = $this->getDisplayName($config);
$href = $project->getURI();
$uri = $project->getURI();
$item = $this->newItem()
->setHref($href)
$item = $this->newItemView()
->setURI($uri)
->setName($name)
->setProfileImage($picture);
->setIconImage($picture);
return array(
$item,