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';
|
2017-02-02 06:21:08 +01:00
|
|
|
const ITEM_PICTURE = 'people.picture';
|
2017-02-24 22:15:30 +01:00
|
|
|
const ITEM_BADGES = 'people.badges';
|
2017-03-06 18:54:34 +01:00
|
|
|
const ITEM_TASKS = 'people.tasks';
|
|
|
|
const ITEM_COMMITS = 'people.commits';
|
2017-05-21 18:24:26 +02:00
|
|
|
const ITEM_REVISIONS = 'people.revisions';
|
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
|
|
|
|
2017-02-02 06:21:08 +01:00
|
|
|
$items[] = $this->newItem()
|
|
|
|
->setBuiltinKey(self::ITEM_PICTURE)
|
|
|
|
->setMenuItemKey(PhabricatorPeoplePictureProfileMenuItem::MENUITEMKEY);
|
|
|
|
|
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
|
|
|
|
2017-02-24 22:15:30 +01:00
|
|
|
$have_badges = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorBadgesApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_badges) {
|
|
|
|
$items[] = $this->newItem()
|
|
|
|
->setBuiltinKey(self::ITEM_BADGES)
|
|
|
|
->setMenuItemKey(PhabricatorPeopleBadgesProfileMenuItem::MENUITEMKEY);
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
$have_maniphest = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorManiphestApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_maniphest) {
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
2017-03-06 18:54:34 +01:00
|
|
|
->setBuiltinKey(self::ITEM_TASKS)
|
|
|
|
->setMenuItemKey(PhabricatorPeopleTasksProfileMenuItem::MENUITEMKEY);
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
|
|
|
|
2017-05-21 18:24:26 +02:00
|
|
|
$have_differential = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDifferentialApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_differential) {
|
|
|
|
$items[] = $this->newItem()
|
|
|
|
->setBuiltinKey(self::ITEM_REVISIONS)
|
|
|
|
->setMenuItemKey(
|
|
|
|
PhabricatorPeopleRevisionsProfileMenuItem::MENUITEMKEY);
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
$have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDiffusionApplication',
|
|
|
|
$viewer);
|
|
|
|
if ($have_diffusion) {
|
2016-12-11 19:08:26 +01:00
|
|
|
$items[] = $this->newItem()
|
2017-03-06 18:54:34 +01:00
|
|
|
->setBuiltinKey(self::ITEM_COMMITS)
|
|
|
|
->setMenuItemKey(PhabricatorPeopleCommitsProfileMenuItem::MENUITEMKEY);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|