1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +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'); return pht('Subprojects');
} }
public function shouldEnableForObject($object) {
if ($object->isMilestone()) {
return false;
}
return true;
}
public function getDisplayName( public function getDisplayName(
PhabricatorProfilePanelConfiguration $config) { PhabricatorProfilePanelConfiguration $config) {
$name = $config->getPanelProperty('name'); $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 // Merge the stored panels into the builtin panels. If a builtin panel has
// a stored version, replace the defaults with the stored changes. // a stored version, replace the defaults with the stored changes.
foreach ($stored_panels as $stored_panel) { foreach ($stored_panels as $stored_panel) {
if (!$stored_panel->shouldEnableForObject($object)) {
continue;
}
$builtin_key = $stored_panel->getBuiltinKey(); $builtin_key = $stored_panel->getBuiltinKey();
if ($builtin_key !== null) { if ($builtin_key !== null) {
// If this builtin actually exists, replace the builtin with the // If this builtin actually exists, replace the builtin with the
@ -341,6 +345,10 @@ abstract class PhabricatorProfilePanelEngine extends Phobject {
->attachProfileObject($object) ->attachProfileObject($object)
->setPanelOrder($order); ->setPanelOrder($order);
if (!$builtin->shouldEnableForObject($object)) {
continue;
}
$map[$builtin_key] = $builtin; $map[$builtin_key] = $builtin;
$order++; $order++;

View file

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

View file

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