@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.

When all actions in a submenu are disabled, disable the submenu header

Summary: Fixes T11240. Also simplify things a little and share a bit more code.

Test Plan:
- Viewed revisions and tasks, opened submenu.
- Viewed as a user without edit permission, saw the menus greyed out.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11240

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

+57 -43
+8 -14
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 527 527 $viewer, 528 528 $revision); 529 529 530 - $parent_key = DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY; 531 - $child_key = DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY; 532 - 533 - $revision_submenu = array(); 534 - 535 - $revision_submenu[] = $relationship_list->getRelationship($parent_key) 536 - ->newAction($revision); 530 + $revision_actions = array( 531 + DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY, 532 + DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY, 533 + ); 537 534 538 - $revision_submenu[] = $relationship_list->getRelationship($child_key) 539 - ->newAction($revision); 535 + $revision_submenu = $relationship_list->newActionSubmenu($revision_actions) 536 + ->setName(pht('Edit Related Revisions...')) 537 + ->setIcon('fa-cog'); 540 538 541 - $curtain->addAction( 542 - id(new PhabricatorActionView()) 543 - ->setName(pht('Edit Related Revisions...')) 544 - ->setIcon('fa-cog') 545 - ->setSubmenu($revision_submenu)); 539 + $curtain->addAction($revision_submenu); 546 540 547 541 $relationship_submenu = $relationship_list->newActionMenu(); 548 542 if ($relationship_submenu) {
+10 -20
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 199 199 $viewer, 200 200 $task); 201 201 202 - $parent_key = ManiphestTaskHasParentRelationship::RELATIONSHIPKEY; 203 - $subtask_key = ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY; 204 - $merge_key = ManiphestTaskMergeInRelationship::RELATIONSHIPKEY; 205 - $close_key = ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY; 206 - 207 - $task_submenu[] = $relationship_list->getRelationship($parent_key) 208 - ->newAction($task); 209 - 210 - $task_submenu[] = $relationship_list->getRelationship($subtask_key) 211 - ->newAction($task); 212 - 213 - $task_submenu[] = $relationship_list->getRelationship($merge_key) 214 - ->newAction($task); 202 + $submenu_actions = array( 203 + ManiphestTaskHasParentRelationship::RELATIONSHIPKEY, 204 + ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY, 205 + ManiphestTaskMergeInRelationship::RELATIONSHIPKEY, 206 + ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY, 207 + ); 215 208 216 - $task_submenu[] = $relationship_list->getRelationship($close_key) 217 - ->newAction($task); 209 + $task_submenu = $relationship_list->newActionSubmenu($submenu_actions) 210 + ->setName(pht('Edit Related Tasks...')) 211 + ->setIcon('fa-anchor'); 218 212 219 - $curtain->addAction( 220 - id(new PhabricatorActionView()) 221 - ->setName(pht('Edit Related Tasks...')) 222 - ->setIcon('fa-anchor') 223 - ->setSubmenu($task_submenu)); 213 + $curtain->addAction($task_submenu); 224 214 225 215 $relationship_submenu = $relationship_list->newActionMenu(); 226 216 if ($relationship_submenu) {
-7
src/applications/search/controller/PhabricatorSearchBaseController.php
··· 2 2 3 3 abstract class PhabricatorSearchBaseController extends PhabricatorController { 4 4 5 - 6 - const ACTION_ATTACH = 'attach'; 7 - const ACTION_MERGE = 'merge'; 8 - const ACTION_DEPENDENCIES = 'dependencies'; 9 - const ACTION_BLOCKS = 'blocks'; 10 - const ACTION_EDGE = 'edge'; 11 - 12 5 protected function loadRelationshipObject() { 13 6 $request = $this->getRequest(); 14 7 $viewer = $this->getViewer();
+35 -2
src/applications/search/relationship/PhabricatorObjectRelationshipList.php
··· 46 46 return $this->relationships; 47 47 } 48 48 49 + public function newActionSubmenu(array $keys) { 50 + $object = $this->getObject(); 51 + 52 + $actions = array(); 53 + 54 + foreach ($keys as $key) { 55 + $relationship = $this->getRelationship($key); 56 + if (!$relationship) { 57 + throw new Exception( 58 + pht( 59 + 'No object relationship of type "%s" exists.', 60 + $key)); 61 + } 62 + 63 + $actions[$key] = $relationship->newAction($object); 64 + } 65 + 66 + return $this->newMenuWithActions($actions); 67 + } 68 + 49 69 public function newActionMenu() { 50 70 $relationships = $this->getRelationships(); 51 71 $object = $this->getObject(); ··· 65 85 66 86 $actions = msort($actions, 'getName'); 67 87 88 + return $this->newMenuWithActions($actions) 89 + ->setName(pht('Edit Related Objects...')) 90 + ->setIcon('fa-link'); 91 + } 92 + 93 + private function newMenuWithActions(array $actions) { 94 + $any_enabled = false; 95 + foreach ($actions as $action) { 96 + if (!$action->getDisabled()) { 97 + $any_enabled = true; 98 + break; 99 + } 100 + } 101 + 68 102 return id(new PhabricatorActionView()) 69 - ->setName(pht('Edit Related Objects...')) 70 - ->setIcon('fa-link') 103 + ->setDisabled(!$any_enabled) 71 104 ->setSubmenu($actions); 72 105 } 73 106
+4
src/view/layout/PhabricatorActionView.php
··· 84 84 return $this; 85 85 } 86 86 87 + public function getDisabled() { 88 + return $this->disabled; 89 + } 90 + 87 91 public function setWorkflow($workflow) { 88 92 $this->workflow = $workflow; 89 93 return $this;