1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 17:02:41 +01:00

Update PeopleMenu to only show integration with applications if they are installed

Summary: do so via event engine. note different order now...

Test Plan: toggled "show beta applications" to off and noted that Conpherence disappeared. Otherwise noted that links showed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2424

Differential Revision: https://secure.phabricator.com/D4708
This commit is contained in:
Bob Trahan 2013-02-05 13:46:02 -08:00
parent 34b6c32d2e
commit 1d0058abcf
14 changed files with 287 additions and 44 deletions

View file

@ -90,6 +90,7 @@ phutil_register_library_map(array(
'AphrontUsageException' => 'aphront/exception/AphrontUsageException.php', 'AphrontUsageException' => 'aphront/exception/AphrontUsageException.php',
'AphrontView' => 'view/AphrontView.php', 'AphrontView' => 'view/AphrontView.php',
'AphrontWebpageResponse' => 'aphront/response/AphrontWebpageResponse.php', 'AphrontWebpageResponse' => 'aphront/response/AphrontWebpageResponse.php',
'AuditPeopleMenuEventListener' => 'applications/audit/events/AuditPeopleMenuEventListener.php',
'CelerityAPI' => 'infrastructure/celerity/CelerityAPI.php', 'CelerityAPI' => 'infrastructure/celerity/CelerityAPI.php',
'CelerityPhabricatorResourceController' => 'infrastructure/celerity/CelerityPhabricatorResourceController.php', 'CelerityPhabricatorResourceController' => 'infrastructure/celerity/CelerityPhabricatorResourceController.php',
'CelerityResourceController' => 'infrastructure/celerity/CelerityResourceController.php', 'CelerityResourceController' => 'infrastructure/celerity/CelerityResourceController.php',
@ -206,6 +207,7 @@ phutil_register_library_map(array(
'ConpherenceParticipant' => 'applications/conpherence/storage/ConpherenceParticipant.php', 'ConpherenceParticipant' => 'applications/conpherence/storage/ConpherenceParticipant.php',
'ConpherenceParticipantQuery' => 'applications/conpherence/query/ConpherenceParticipantQuery.php', 'ConpherenceParticipantQuery' => 'applications/conpherence/query/ConpherenceParticipantQuery.php',
'ConpherenceParticipationStatus' => 'applications/conpherence/constants/ConpherenceParticipationStatus.php', 'ConpherenceParticipationStatus' => 'applications/conpherence/constants/ConpherenceParticipationStatus.php',
'ConpherencePeopleMenuEventListener' => 'applications/conpherence/events/ConpherencePeopleMenuEventListener.php',
'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php',
'ConpherenceThread' => 'applications/conpherence/storage/ConpherenceThread.php', 'ConpherenceThread' => 'applications/conpherence/storage/ConpherenceThread.php',
'ConpherenceThreadQuery' => 'applications/conpherence/query/ConpherenceThreadQuery.php', 'ConpherenceThreadQuery' => 'applications/conpherence/query/ConpherenceThreadQuery.php',
@ -309,6 +311,7 @@ phutil_register_library_map(array(
'DifferentialNewDiffMail' => 'applications/differential/mail/DifferentialNewDiffMail.php', 'DifferentialNewDiffMail' => 'applications/differential/mail/DifferentialNewDiffMail.php',
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php', 'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php', 'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php',
'DifferentialPeopleMenuEventListener' => 'applications/differential/events/DifferentialPeopleMenuEventListener.php',
'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php', 'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php',
'DifferentialReplyHandler' => 'applications/differential/DifferentialReplyHandler.php', 'DifferentialReplyHandler' => 'applications/differential/DifferentialReplyHandler.php',
'DifferentialResultsTableView' => 'applications/differential/view/DifferentialResultsTableView.php', 'DifferentialResultsTableView' => 'applications/differential/view/DifferentialResultsTableView.php',
@ -422,6 +425,7 @@ phutil_register_library_map(array(
'DiffusionPathQuery' => 'applications/diffusion/query/DiffusionPathQuery.php', 'DiffusionPathQuery' => 'applications/diffusion/query/DiffusionPathQuery.php',
'DiffusionPathQueryTestCase' => 'applications/diffusion/query/pathid/__tests__/DiffusionPathQueryTestCase.php', 'DiffusionPathQueryTestCase' => 'applications/diffusion/query/pathid/__tests__/DiffusionPathQueryTestCase.php',
'DiffusionPathValidateController' => 'applications/diffusion/controller/DiffusionPathValidateController.php', 'DiffusionPathValidateController' => 'applications/diffusion/controller/DiffusionPathValidateController.php',
'DiffusionPeopleMenuEventListener' => 'applications/diffusion/events/DiffusionPeopleMenuEventListener.php',
'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php', 'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php',
'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php', 'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php',
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
@ -565,6 +569,7 @@ phutil_register_library_map(array(
'ManiphestDefaultTaskExtensions' => 'applications/maniphest/extensions/ManiphestDefaultTaskExtensions.php', 'ManiphestDefaultTaskExtensions' => 'applications/maniphest/extensions/ManiphestDefaultTaskExtensions.php',
'ManiphestEdgeEventListener' => 'applications/maniphest/event/ManiphestEdgeEventListener.php', 'ManiphestEdgeEventListener' => 'applications/maniphest/event/ManiphestEdgeEventListener.php',
'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php', 'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php',
'ManiphestPeopleMenuEventListener' => 'applications/maniphest/event/ManiphestPeopleMenuEventListener.php',
'ManiphestReplyHandler' => 'applications/maniphest/ManiphestReplyHandler.php', 'ManiphestReplyHandler' => 'applications/maniphest/ManiphestReplyHandler.php',
'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php', 'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php',
'ManiphestSavedQuery' => 'applications/maniphest/storage/ManiphestSavedQuery.php', 'ManiphestSavedQuery' => 'applications/maniphest/storage/ManiphestSavedQuery.php',
@ -1576,6 +1581,7 @@ phutil_register_library_map(array(
'AphrontUsageException' => 'AphrontException', 'AphrontUsageException' => 'AphrontException',
'AphrontView' => 'Phobject', 'AphrontView' => 'Phobject',
'AphrontWebpageResponse' => 'AphrontHTMLResponse', 'AphrontWebpageResponse' => 'AphrontHTMLResponse',
'AuditPeopleMenuEventListener' => 'PhutilEventListener',
'CelerityPhabricatorResourceController' => 'CelerityResourceController', 'CelerityPhabricatorResourceController' => 'CelerityResourceController',
'CelerityResourceController' => 'PhabricatorController', 'CelerityResourceController' => 'PhabricatorController',
'CelerityResourceGraph' => 'AbstractDirectedGraph', 'CelerityResourceGraph' => 'AbstractDirectedGraph',
@ -1682,6 +1688,7 @@ phutil_register_library_map(array(
'ConpherenceParticipant' => 'ConpherenceDAO', 'ConpherenceParticipant' => 'ConpherenceDAO',
'ConpherenceParticipantQuery' => 'PhabricatorOffsetPagedQuery', 'ConpherenceParticipantQuery' => 'PhabricatorOffsetPagedQuery',
'ConpherenceParticipationStatus' => 'ConpherenceConstants', 'ConpherenceParticipationStatus' => 'ConpherenceConstants',
'ConpherencePeopleMenuEventListener' => 'PhutilEventListener',
'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler',
'ConpherenceThread' => 'ConpherenceThread' =>
array( array(
@ -1781,6 +1788,7 @@ phutil_register_library_map(array(
'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail', 'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail',
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase', 'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',
'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialPeopleMenuEventListener' => 'PhutilEventListener',
'DifferentialPrimaryPaneView' => 'AphrontView', 'DifferentialPrimaryPaneView' => 'AphrontView',
'DifferentialReplyHandler' => 'PhabricatorMailReplyHandler', 'DifferentialReplyHandler' => 'PhabricatorMailReplyHandler',
'DifferentialResultsTableView' => 'AphrontView', 'DifferentialResultsTableView' => 'AphrontView',
@ -1876,6 +1884,7 @@ phutil_register_library_map(array(
'DiffusionPathCompleteController' => 'DiffusionController', 'DiffusionPathCompleteController' => 'DiffusionController',
'DiffusionPathQueryTestCase' => 'PhabricatorTestCase', 'DiffusionPathQueryTestCase' => 'PhabricatorTestCase',
'DiffusionPathValidateController' => 'DiffusionController', 'DiffusionPathValidateController' => 'DiffusionController',
'DiffusionPeopleMenuEventListener' => 'PhutilEventListener',
'DiffusionRawDiffQuery' => 'DiffusionQuery', 'DiffusionRawDiffQuery' => 'DiffusionQuery',
'DiffusionRepositoryController' => 'DiffusionController', 'DiffusionRepositoryController' => 'DiffusionController',
'DiffusionSetupException' => 'AphrontUsageException', 'DiffusionSetupException' => 'AphrontUsageException',
@ -1988,6 +1997,7 @@ phutil_register_library_map(array(
'ManiphestDefaultTaskExtensions' => 'ManiphestTaskExtensions', 'ManiphestDefaultTaskExtensions' => 'ManiphestTaskExtensions',
'ManiphestEdgeEventListener' => 'PhutilEventListener', 'ManiphestEdgeEventListener' => 'PhutilEventListener',
'ManiphestExportController' => 'ManiphestController', 'ManiphestExportController' => 'ManiphestController',
'ManiphestPeopleMenuEventListener' => 'PhutilEventListener',
'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler', 'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler',
'ManiphestReportController' => 'ManiphestController', 'ManiphestReportController' => 'ManiphestController',
'ManiphestSavedQuery' => 'ManiphestDAO', 'ManiphestSavedQuery' => 'ManiphestDAO',

View file

@ -18,6 +18,12 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
return PhabricatorEnv::getDoclink('article/Audit_User_Guide.html'); return PhabricatorEnv::getDoclink('article/Audit_User_Guide.html');
} }
public function getEventListeners() {
return array(
new AuditPeopleMenuEventListener()
);
}
public function getRoutes() { public function getRoutes() {
return array( return array(
'/audit/' => array( '/audit/' => array(

View file

@ -0,0 +1,38 @@
<?php
final class AuditPeopleMenuEventListener extends PhutilEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU);
}
public function handleEvent(PhutilEvent $event) {
switch ($event->getType()) {
case PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU:
$this->handleMenuEvent($event);
break;
}
}
private function handleMenuEvent($event) {
$viewer = $event->getUser();
$menu = $event->getValue('menu');
$person = $event->getValue('person');
$username = phutil_escape_uri($person->getUsername());
$href = '/audit/view/author/'.$username.'/';
$name = pht('Commits');
$menu->addMenuItemToLabel('activity',
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setName($name)
->setHref($href)
->setKey($name)
);
$event->setValue('menu', $menu);
}
}

View file

@ -33,6 +33,12 @@ final class PhabricatorApplicationConpherence extends PhabricatorApplication {
return self::GROUP_COMMUNICATION; return self::GROUP_COMMUNICATION;
} }
public function getEventListeners() {
return array(
new ConpherencePeopleMenuEventListener(),
);
}
public function getRoutes() { public function getRoutes() {
return array( return array(
'/conpherence/' => array( '/conpherence/' => array(

View file

@ -0,0 +1,38 @@
<?php
final class ConpherencePeopleMenuEventListener extends PhutilEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU);
}
public function handleEvent(PhutilEvent $event) {
switch ($event->getType()) {
case PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU:
$this->handleMenuEvent($event);
break;
}
}
private function handleMenuEvent($event) {
$viewer = $event->getUser();
$menu = $event->getValue('menu');
$person = $event->getValue('person');
$conpherence_uri =
new PhutilURI('/conpherence/new/?participant='.$person->getPHID());
$name = pht('Conpherence');
$menu->addMenuItemBefore('activity',
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setName($name)
->setHref($conpherence_uri)
->setKey($name)
);
$event->setValue('menu', $menu);
}
}

View file

@ -28,6 +28,12 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
return "\xE2\x9A\x99"; return "\xE2\x9A\x99";
} }
public function getEventListeners() {
return array(
new DifferentialPeopleMenuEventListener()
);
}
public function getRoutes() { public function getRoutes() {
return array( return array(
'/D(?P<id>[1-9]\d*)' => 'DifferentialRevisionViewController', '/D(?P<id>[1-9]\d*)' => 'DifferentialRevisionViewController',

View file

@ -0,0 +1,38 @@
<?php
final class DifferentialPeopleMenuEventListener extends PhutilEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU);
}
public function handleEvent(PhutilEvent $event) {
switch ($event->getType()) {
case PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU:
$this->handleMenuEvent($event);
break;
}
}
private function handleMenuEvent($event) {
$viewer = $event->getUser();
$menu = $event->getValue('menu');
$person = $event->getValue('person');
$username = phutil_escape_uri($person->getUserName());
$href = '/differential/filter/revisions/'.$username.'/';
$name = pht('Revisions');
$menu->addMenuItemToLabel('activity',
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setHref($href)
->setName($name)
->setKey($name)
);
$event->setValue('menu', $menu);
}
}

View file

@ -24,6 +24,12 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
); );
} }
public function getEventListeners() {
return array(
new DiffusionPeopleMenuEventListener()
);
}
public function getRoutes() { public function getRoutes() {
return array( return array(
'/r(?P<callsign>[A-Z]+)(?P<commit>[a-z0-9]+)' '/r(?P<callsign>[A-Z]+)(?P<commit>[a-z0-9]+)'

View file

@ -0,0 +1,37 @@
<?php
final class DiffusionPeopleMenuEventListener extends PhutilEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU);
}
public function handleEvent(PhutilEvent $event) {
switch ($event->getType()) {
case PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU:
$this->handleMenuEvent($event);
break;
}
}
private function handleMenuEvent($event) {
$viewer = $event->getUser();
$menu = $event->getValue('menu');
$person_phid = $event->getValue('person')->getPHID();
$href = '/diffusion/lint/?owner[0]='.$person_phid;
$name = pht('Lint Messages');
$menu->addMenuItemToLabel('activity',
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setHref($href)
->setName($name)
->setKey($name)
);
$event->setValue('menu', $menu);
}
}

View file

@ -36,6 +36,12 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
return $this->getBaseURI().'task/create/'; return $this->getBaseURI().'task/create/';
} }
public function getEventListeners() {
return array(
new ManiphestPeopleMenuEventListener()
);
}
public function getRoutes() { public function getRoutes() {
return array( return array(
'/T(?P<id>[1-9]\d*)' => 'ManiphestTaskDetailController', '/T(?P<id>[1-9]\d*)' => 'ManiphestTaskDetailController',

View file

@ -0,0 +1,36 @@
<?php
final class ManiphestPeopleMenuEventListener extends PhutilEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU);
}
public function handleEvent(PhutilEvent $event) {
switch ($event->getType()) {
case PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU:
$this->handleMenuEvent($event);
break;
}
}
private function handleMenuEvent($event) {
$viewer = $event->getUser();
$menu = $event->getValue('menu');
$person_phid = $event->getValue('person')->getPHID();
$href = '/maniphest/view/action/?persons='.$person_phid;
$name = pht('Tasks');
$menu->addMenuItemToLabel('activity',
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setHref($href)
->setName($name)
->setKey($name)
);
$event->setValue('menu', $menu);
}
}

View file

@ -16,6 +16,21 @@ final class PhabricatorPeopleProfileController
return $this->profileUser; return $this->profileUser;
} }
private function getMainFilters($username) {
return array(
array(
'key' => 'feed',
'name' => pht('Feed'),
'href' => '/p/'.$username.'/feed/'
),
array(
'key' => 'about',
'name' => pht('About'),
'href' => '/p/'.$username.'/about/'
)
);
}
public function processRequest() { public function processRequest() {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
@ -39,40 +54,14 @@ final class PhabricatorPeopleProfileController
} }
$username = phutil_escape_uri($user->getUserName()); $username = phutil_escape_uri($user->getUserName());
$external_arrow = "\xE2\x86\x97"; $menu = new PhabricatorMenuView();
foreach ($this->getMainFilters($username) as $filter) {
$menu->newLink($filter['name'], $filter['href'], $filter['key']);
}
$conpherence_uri = $menu->newLabel(pht('Activity'), 'activity');
new PhutilURI('/conpherence/new/?participant='.$user->getPHID()); // NOTE: applications install the various links through PhabricatorEvent
$nav = new AphrontSideNavFilterView(); // listeners
$nav->setBaseURI(new PhutilURI('/p/'.$username.'/'));
$nav->addFilter('feed', 'Feed');
$nav->addMenuItem(
id(new PhabricatorMenuItemView())
->setName(pht('Conpherence').' '.$external_arrow)
->setHref($conpherence_uri)
);
$nav->addFilter('about', 'About');
$nav->addLabel('Activity');
$nav->addFilter(
null,
"Revisions {$external_arrow}",
'/differential/filter/revisions/'.$username.'/');
$nav->addFilter(
null,
"Tasks {$external_arrow}",
'/maniphest/view/action/?users='.$user->getPHID());
$nav->addFilter(
null,
"Commits {$external_arrow}",
'/audit/view/author/'.$username.'/');
$nav->addFilter(
null,
"Lint Messages {$external_arrow}",
'/diffusion/lint/?owner[0]='.$user->getPHID());
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere( $oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
'userID = %d', 'userID = %d',
@ -92,18 +81,34 @@ final class PhabricatorPeopleProfileController
continue; continue;
} }
$name = $provider->getProviderName().' Profile'; $name = pht('%s Profile', $provider->getProviderName());
$href = $oauths[$provider_key]->getAccountURI(); $href = $oauths[$provider_key]->getAccountURI();
if ($href) { if ($href) {
if (!$added_label) { if (!$added_label) {
$nav->addLabel('Linked Accounts'); $menu->newLabel(pht('Linked Accounts'), 'linked_accounts');
$added_label = true; $added_label = true;
} }
$nav->addFilter(null, $name.' '.$external_arrow, $href); $menu->addMenuItem(
id(new PhabricatorMenuItemView())
->setIsExternal(true)
->setName($name)
->setHref($href)
->setType(PhabricatorMenuItemView::TYPE_LINK)
);
} }
} }
$event = new PhabricatorEvent(
PhabricatorEventType::TYPE_PEOPLE_DIDRENDERMENU,
array(
'menu' => $menu,
'person' => $user,
));
$event->setUser($viewer);
PhutilEventEngine::dispatchEvent($event);
$nav = AphrontSideNavFilterView::newFromMenu($event->getValue('menu'));
$this->page = $nav->selectFilter($this->page, 'feed'); $this->page = $nav->selectFilter($this->page, 'feed');
switch ($this->page) { switch ($this->page) {
@ -141,14 +146,19 @@ final class PhabricatorPeopleProfileController
$header->appendChild($content); $header->appendChild($content);
if ($user->getPHID() == $viewer->getPHID()) { if ($user->getPHID() == $viewer->getPHID()) {
$nav->addFilter(null, 'Edit Profile...', '/settings/panel/profile/'); $nav->addFilter(
null,
pht('Edit Profile...'),
'/settings/panel/profile/'
);
} }
if ($viewer->getIsAdmin()) { if ($viewer->getIsAdmin()) {
$nav->addFilter( $nav->addFilter(
null, null,
'Administrate User...', pht('Administrate User...'),
'/people/edit/'.$user->getID().'/'); '/people/edit/'.$user->getID().'/'
);
} }
return $this->buildApplicationPage( return $this->buildApplicationPage(
@ -162,7 +172,10 @@ final class PhabricatorPeopleProfileController
$blurb = nonempty( $blurb = nonempty(
$profile->getBlurb(), $profile->getBlurb(),
'//Nothing is known about this rare specimen.//'); '//'.
pht('Nothing is known about this rare specimen.')
.'//'
);
$engine = PhabricatorMarkupEngine::newProfileMarkupEngine(); $engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$blurb = $engine->markupText($blurb); $blurb = $engine->markupText($blurb);

View file

@ -30,4 +30,5 @@ final class PhabricatorEventType extends PhutilEventType {
const TYPE_UI_DDIDRENDEROBJECT = 'ui.didRenderObject'; const TYPE_UI_DDIDRENDEROBJECT = 'ui.didRenderObject';
const TYPE_UI_DIDRENDEROBJECTS = 'ui.didRenderObjects'; const TYPE_UI_DIDRENDEROBJECTS = 'ui.didRenderObjects';
const TYPE_PEOPLE_DIDRENDERMENU = 'people.didRenderMenu';
} }

View file

@ -8,21 +8,23 @@ final class PhabricatorMenuView extends AphrontTagView {
return false; return false;
} }
public function newLabel($name) { public function newLabel($name, $key = null) {
$item = id(new PhabricatorMenuItemView()) $item = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LABEL) ->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName($name); ->setName($name)
->setKey($key);
$this->addMenuItem($item); $this->addMenuItem($item);
return $item; return $item;
} }
public function newLink($name, $href) { public function newLink($name, $href, $key = null) {
$item = id(new PhabricatorMenuItemView()) $item = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LINK) ->setType(PhabricatorMenuItemView::TYPE_LINK)
->setName($name) ->setName($name)
->setHref($href); ->setHref($href)
->setKey($key);
$this->addMenuItem($item); $this->addMenuItem($item);