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

Allow "Manage" to be the default menu item for projects

Summary:
Fixes T13033. Currently (prior to D18836) all the default items for projects can be hidden. When this occurs, the main project page fatals.

If we fix the fatal narrowly (don't try to call `null->getBuiltinKey()` when `$default` is `null`), it would 404, which is a little better but not by much.

After D18836 you can't hide "Profile", which is pretty sensible, and effectively fixes this. This change doubles down: let "Manage" be a default, and send the user there if we can't find a different default.

Ideally, the MenuEngine itself will do more rendering eventually (as it does for some of the newer Home stuff) and could handle this defaulting behavior with less special casing, but we'd still end up in a similar situation if a project had only one "Link" item to "coolcats.com" or something: redirecting the user to "coolcats.com" is probably better than fataling, but not by a huge margin, and not likely to be what they expect.

Test Plan:
Before D18836, disabled both "Profile" and "Workboard" items on a project. Visited project page.

Before patch: fatal. After patch: manage page.

After D18836, you can't do this and just get the profile, so this is sort of moot and mostly future-proofing/for-completeness.

Reviewers: 20after4, amckinley

Reviewed By: amckinley

Maniphest Tasks: T13033

Differential Revision: https://secure.phabricator.com/D18843
This commit is contained in:
epriestley 2017-12-23 08:36:58 -08:00
parent 393824656f
commit 84cf493879
2 changed files with 16 additions and 0 deletions

View file

@ -20,6 +20,14 @@ final class PhabricatorProjectViewController
$engine = $this->getProfileMenuEngine(); $engine = $this->getProfileMenuEngine();
$default = $engine->getDefaultItem(); $default = $engine->getDefaultItem();
// If defaults are broken somehow, serve the manage page. See T13033 for
// discussion.
if ($default) {
$default_key = $default->getBuiltinKey();
} else {
$default_key = PhabricatorProject::ITEM_MANAGE;
}
switch ($default->getBuiltinKey()) { switch ($default->getBuiltinKey()) {
case PhabricatorProject::ITEM_WORKBOARD: case PhabricatorProject::ITEM_WORKBOARD:
$controller_object = new PhabricatorProjectBoardViewController(); $controller_object = new PhabricatorProjectBoardViewController();
@ -27,6 +35,9 @@ final class PhabricatorProjectViewController
case PhabricatorProject::ITEM_PROFILE: case PhabricatorProject::ITEM_PROFILE:
$controller_object = new PhabricatorProjectProfileController(); $controller_object = new PhabricatorProjectProfileController();
break; break;
case PhabricatorProject::ITEM_MANAGE:
$controller_object = new PhabricatorProjectManageController();
break;
default: default:
return $engine->buildResponse(); return $engine->buildResponse();
} }

View file

@ -18,6 +18,11 @@ final class PhabricatorProjectManageProfileMenuItem
return false; return false;
} }
public function canMakeDefault(
PhabricatorProfileMenuItemConfiguration $config) {
return true;
}
public function getDisplayName( public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
$name = $config->getMenuItemProperty('name'); $name = $config->getMenuItemProperty('name');