@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow profile menu items to be disabled

Summary:
Ref T10054.

I made this a dropdown (currently: "Visible" or "Disabled") since I imagine we //miiiight// want to add a "Hidden, but click 'More' to reveal" state or do other special stuff in this vein. Not 100% sold on that but seemed within the realm of plausibility.

Test Plan: {F1060759}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10054

Differential Revision: https://secure.phabricator.com/D15012

+95 -1
+8
src/applications/search/editor/PhabricatorProfilePanelEditor.php
··· 16 16 17 17 $types[] = PhabricatorProfilePanelConfigurationTransaction::TYPE_PROPERTY; 18 18 $types[] = PhabricatorProfilePanelConfigurationTransaction::TYPE_ORDER; 19 + $types[] = PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY; 19 20 20 21 return $types; 21 22 } ··· 30 31 return $object->getPanelProperty($key, null); 31 32 case PhabricatorProfilePanelConfigurationTransaction::TYPE_ORDER: 32 33 return $object->getPanelOrder(); 34 + case PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY: 35 + return $object->getVisibility(); 33 36 } 34 37 } 35 38 ··· 39 42 40 43 switch ($xaction->getTransactionType()) { 41 44 case PhabricatorProfilePanelConfigurationTransaction::TYPE_PROPERTY: 45 + case PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY: 42 46 return $xaction->getNewValue(); 43 47 case PhabricatorProfilePanelConfigurationTransaction::TYPE_ORDER: 44 48 return (int)$xaction->getNewValue(); ··· 58 62 case PhabricatorProfilePanelConfigurationTransaction::TYPE_ORDER: 59 63 $object->setPanelOrder($xaction->getNewValue()); 60 64 return; 65 + case PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY: 66 + $object->setVisibility($xaction->getNewValue()); 67 + return; 61 68 } 62 69 63 70 return parent::applyCustomInternalTransaction($object, $xaction); ··· 70 77 switch ($xaction->getTransactionType()) { 71 78 case PhabricatorProfilePanelConfigurationTransaction::TYPE_PROPERTY: 72 79 case PhabricatorProfilePanelConfigurationTransaction::TYPE_ORDER: 80 + case PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY: 73 81 return; 74 82 } 75 83
+75 -1
src/applications/search/engine/PhabricatorProfilePanelEngine.php
··· 53 53 $panel_id_int = (int)$panel_id; 54 54 foreach ($panel_list as $panel) { 55 55 if ($panel_id_int) { 56 - if ((int)$panel->getID() === $panel_id) { 56 + if ((int)$panel->getID() === $panel_id_int) { 57 57 $selected_panel = $panel; 58 58 break; 59 59 } ··· 101 101 case 'builtin': 102 102 $content = $this->buildPanelBuiltinContent($selected_panel); 103 103 break; 104 + case 'hide': 105 + $content = $this->buildPanelHideContent($selected_panel); 106 + break; 104 107 case 'edit': 105 108 $content = $this->buildPanelEditContent(); 106 109 break; ··· 134 137 $panels = $this->getPanels(); 135 138 136 139 foreach ($panels as $panel) { 140 + if ($panel->isDisabled()) { 141 + continue; 142 + } 143 + 137 144 $items = $panel->buildNavigationMenuItems(); 138 145 foreach ($items as $item) { 139 146 $this->validateNavigationMenuItem($item); ··· 435 442 436 443 if ($id) { 437 444 $item->setHref($this->getPanelURI("edit/{$id}/")); 445 + $hide_uri = $this->getPanelURI("hide/{$id}/"); 438 446 } else { 439 447 $item->setHref($this->getPanelURI("builtin/{$builtin_key}/")); 448 + $hide_uri = $this->getPanelURI("hide/{$builtin_key}/"); 440 449 } 450 + 451 + $item->addAction( 452 + id(new PHUIListItemView()) 453 + ->setHref($hide_uri) 454 + ->setWorkflow(true) 455 + ->setIcon(pht('fa-eye'))); 456 + } 457 + 458 + if ($panel->isDisabled()) { 459 + $item->setDisabled(true); 460 + $item->addIcon('fa-times grey', pht('Disabled')); 441 461 } 442 462 443 463 $list->addItem($item); ··· 571 591 ->setNewPanelConfiguration($configuration) 572 592 ->setController($controller) 573 593 ->buildResponse(); 594 + } 595 + 596 + private function buildPanelHideContent( 597 + PhabricatorProfilePanelConfiguration $configuration) { 598 + 599 + $controller = $this->getController(); 600 + $request = $controller->getRequest(); 601 + $viewer = $this->getViewer(); 602 + 603 + PhabricatorPolicyFilter::requireCapability( 604 + $viewer, 605 + $configuration, 606 + PhabricatorPolicyCapability::CAN_EDIT); 607 + 608 + $v_visibility = $configuration->getVisibility(); 609 + if ($request->isFormPost()) { 610 + $v_visibility = $request->getStr('visibility'); 611 + 612 + $type_visibility = 613 + PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY; 614 + 615 + $xactions = array(); 616 + 617 + $xactions[] = id(new PhabricatorProfilePanelConfigurationTransaction()) 618 + ->setTransactionType($type_visibility) 619 + ->setNewValue($v_visibility); 620 + 621 + $editor = id(new PhabricatorProfilePanelEditor()) 622 + ->setContentSourceFromRequest($request) 623 + ->setActor($viewer) 624 + ->setContinueOnMissingFields(true) 625 + ->setContinueOnNoEffect(true) 626 + ->applyTransactions($configuration, $xactions); 627 + 628 + return id(new AphrontRedirectResponse()) 629 + ->setURI($this->getConfigureURI()); 630 + } 631 + 632 + $map = PhabricatorProfilePanelConfiguration::getVisibilityNameMap(); 633 + 634 + $form = id(new AphrontFormView()) 635 + ->setUser($viewer) 636 + ->appendControl( 637 + id(new AphrontFormSelectControl()) 638 + ->setName('visibility') 639 + ->setLabel(pht('Visibility')) 640 + ->setValue($v_visibility) 641 + ->setOptions($map)); 642 + 643 + return $controller->newDialog() 644 + ->setTitle(pht('Change Item Visibility')) 645 + ->appendForm($form) 646 + ->addCancelButton($this->getConfigureURI()) 647 + ->addSubmitButton(pht('Save Changes')); 574 648 } 575 649 576 650 }
+11
src/applications/search/storage/PhabricatorProfilePanelConfiguration.php
··· 56 56 ) + parent::getConfiguration(); 57 57 } 58 58 59 + public static function getVisibilityNameMap() { 60 + return array( 61 + self::VISIBILITY_VISIBLE => pht('Visible'), 62 + self::VISIBILITY_DISABLED => pht('Disabled'), 63 + ); 64 + } 65 + 59 66 public function generatePHID() { 60 67 return PhabricatorPHID::generateNewPHID( 61 68 PhabricatorProfilePanelPHIDType::TYPECONST); ··· 113 120 '~%s%020d', 114 121 $order, 115 122 $this->getID()); 123 + } 124 + 125 + public function isDisabled() { 126 + return ($this->getVisibility() === self::VISIBILITY_DISABLED); 116 127 } 117 128 118 129
+1
src/applications/search/storage/PhabricatorProfilePanelConfigurationTransaction.php
··· 5 5 6 6 const TYPE_PROPERTY = 'profilepanel.property'; 7 7 const TYPE_ORDER = 'profilepanel.order'; 8 + const TYPE_VISIBILITY = 'profilepanel.visibility'; 8 9 9 10 public function getApplicationName() { 10 11 return 'search';