2016-01-14 15:47:06 +01:00
|
|
|
<?php
|
|
|
|
|
2016-12-11 18:00:44 +01:00
|
|
|
final class PhabricatorPeopleProfileMenuEngine
|
|
|
|
extends PhabricatorProfileMenuEngine {
|
2016-01-14 15:47:06 +01:00
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
const ITEM_PROFILE = 'people.profile';
|
|
|
|
const ITEM_MANAGE = 'people.manage';
|
2016-01-14 15:47:06 +01:00
|
|
|
|
2016-12-11 18:00:44 +01:00
|
|
|
protected function isMenuEngineConfigurable() {
|
2016-01-14 15:47:06 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Allow menu items to render their own content; make Dashboard items render on-page
Summary:
Ref T11957. When you click a dashboard item, it now sends you to `/<app>/item/view/123/`, which renders the proper crumbs, navigation, etc., with the dashboard as page content.
This works as you'd expect in Projects:
{F2508568}
It's sliiiightly odd in Favorites since we nuke the nav menu, but seems basically fine?
{F2508571}
Test Plan:
- Created a dashboard panel on a project.
- Clicked it, saw it render.
- Made it the default panel, viewed project default screen, saw dashboard.
- Disabled every panel I could, still saw reasonable behavior (this is silly anyway).
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11957
Differential Revision: https://secure.phabricator.com/D17255
2017-01-26 21:14:02 +01:00
|
|
|
public function getItemURI($path) {
|
2016-01-14 15:47:06 +01:00
|
|
|
$user = $this->getProfileObject();
|
|
|
|
$username = $user->getUsername();
|
|
|
|
$username = phutil_escape_uri($username);
|
2016-12-11 19:08:26 +01:00
|
|
|
return "/p/{$username}/item/{$path}";
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
protected function getBuiltinProfileItems($object) {
|
2016-01-14 15:47:06 +01:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items = array();
|
2016-01-14 15:47:06 +01:00
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
|
|
|
->setBuiltinKey(self::ITEM_PROFILE)
|
|
|
|
->setMenuItemKey(PhabricatorPeopleDetailsProfileMenuItem::MENUITEMKEY);
|
2016-01-14 15:47:06 +01:00
|
|
|
|
|
|
|
$have_maniphest = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorManiphestApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_maniphest) {
|
|
|
|
$uri = urisprintf(
|
|
|
|
'/maniphest/?statuses=open()&assigned=%s#R',
|
|
|
|
$object->getPHID());
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
2016-01-14 15:47:06 +01:00
|
|
|
->setBuiltinKey('tasks')
|
2016-12-11 19:08:26 +01:00
|
|
|
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
|
2016-12-11 18:38:06 +01:00
|
|
|
->setMenuItemProperty('icon', 'maniphest')
|
|
|
|
->setMenuItemProperty('name', pht('Open Tasks'))
|
|
|
|
->setMenuItemProperty('uri', $uri);
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$have_differential = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDifferentialApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_differential) {
|
|
|
|
$uri = urisprintf(
|
|
|
|
'/differential/?authors=%s#R',
|
|
|
|
$object->getPHID());
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
2016-01-14 15:47:06 +01:00
|
|
|
->setBuiltinKey('revisions')
|
2016-12-11 19:08:26 +01:00
|
|
|
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
|
2016-12-11 18:38:06 +01:00
|
|
|
->setMenuItemProperty('icon', 'differential')
|
|
|
|
->setMenuItemProperty('name', pht('Revisions'))
|
|
|
|
->setMenuItemProperty('uri', $uri);
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDiffusionApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_diffusion) {
|
|
|
|
$uri = urisprintf(
|
2017-01-12 00:09:57 +01:00
|
|
|
'/diffusion/commit/?authors=%s#R',
|
2016-01-14 15:47:06 +01:00
|
|
|
$object->getPHID());
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
2016-01-14 15:47:06 +01:00
|
|
|
->setBuiltinKey('commits')
|
2016-12-11 19:08:26 +01:00
|
|
|
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
|
2016-12-11 18:38:06 +01:00
|
|
|
->setMenuItemProperty('icon', 'diffusion')
|
|
|
|
->setMenuItemProperty('name', pht('Commits'))
|
|
|
|
->setMenuItemProperty('uri', $uri);
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
|
|
|
->setBuiltinKey(self::ITEM_MANAGE)
|
|
|
|
->setMenuItemKey(PhabricatorPeopleManageProfileMenuItem::MENUITEMKEY);
|
2016-01-24 16:07:17 +01:00
|
|
|
|
2016-12-11 19:08:26 +01:00
|
|
|
return $items;
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|