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

Disable "Subprojects" menu item for milestone projects

Summary:
Ref T10010. Milestones can't have subprojects, so this item isn't very useful.

I think there is also an argument for disabling "Members", but that panel is a little less useless and explains the membership rule, so I'm less certain about removing it. I do generally lean toward removing it at some point, though.

Test Plan:
  - Viewed a milestone, no "Subprojects" menu item.
  - Viewed a normal project, saw item.
  - Edited both menus, saw consistent UI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10010

Differential Revision: https://secure.phabricator.com/D15200
This commit is contained in:
epriestley 2016-02-06 12:48:01 -08:00
parent 7550557e44
commit f097c9c595
4 changed files with 24 additions and 0 deletions

View file

@ -13,6 +13,14 @@ final class PhabricatorProjectSubprojectsProfilePanel
return pht('Subprojects');
}
public function shouldEnableForObject($object) {
if ($object->isMilestone()) {
return false;
}
return true;
}
public function getDisplayName(
PhabricatorProfilePanelConfiguration $config) {
$name = $config->getPanelProperty('name');

View file

@ -239,6 +239,10 @@ abstract class PhabricatorProfilePanelEngine extends Phobject {
// Merge the stored panels into the builtin panels. If a builtin panel has
// a stored version, replace the defaults with the stored changes.
foreach ($stored_panels as $stored_panel) {
if (!$stored_panel->shouldEnableForObject($object)) {
continue;
}
$builtin_key = $stored_panel->getBuiltinKey();
if ($builtin_key !== null) {
// If this builtin actually exists, replace the builtin with the
@ -341,6 +345,10 @@ abstract class PhabricatorProfilePanelEngine extends Phobject {
->attachProfileObject($object)
->setPanelOrder($order);
if (!$builtin->shouldEnableForObject($object)) {
continue;
}
$map[$builtin_key] = $builtin;
$order++;

View file

@ -30,6 +30,10 @@ abstract class PhabricatorProfilePanel extends Phobject {
return false;
}
public function shouldEnableForObject($object) {
return true;
}
public function canHidePanel(
PhabricatorProfilePanelConfiguration $config) {
return true;

View file

@ -109,6 +109,10 @@ final class PhabricatorProfilePanelConfiguration
return $this->getPanel()->canHidePanel($this);
}
public function shouldEnableForObject($object) {
return $this->getPanel()->shouldEnableForObject($object);
}
public function getSortKey() {
$order = $this->getPanelOrder();
if ($order === null) {