Page MenuHomePhabricator

D16201.id38967.diff
No OneTemporary

D16201.id38967.diff

diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -527,22 +527,16 @@
$viewer,
$revision);
- $parent_key = DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY;
- $child_key = DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY;
-
- $revision_submenu = array();
-
- $revision_submenu[] = $relationship_list->getRelationship($parent_key)
- ->newAction($revision);
+ $revision_actions = array(
+ DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY,
+ DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY,
+ );
- $revision_submenu[] = $relationship_list->getRelationship($child_key)
- ->newAction($revision);
+ $revision_submenu = $relationship_list->newActionSubmenu($revision_actions)
+ ->setName(pht('Edit Related Revisions...'))
+ ->setIcon('fa-cog');
- $curtain->addAction(
- id(new PhabricatorActionView())
- ->setName(pht('Edit Related Revisions...'))
- ->setIcon('fa-cog')
- ->setSubmenu($revision_submenu));
+ $curtain->addAction($revision_submenu);
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
--- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php
+++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
@@ -199,28 +199,18 @@
$viewer,
$task);
- $parent_key = ManiphestTaskHasParentRelationship::RELATIONSHIPKEY;
- $subtask_key = ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY;
- $merge_key = ManiphestTaskMergeInRelationship::RELATIONSHIPKEY;
- $close_key = ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY;
-
- $task_submenu[] = $relationship_list->getRelationship($parent_key)
- ->newAction($task);
-
- $task_submenu[] = $relationship_list->getRelationship($subtask_key)
- ->newAction($task);
-
- $task_submenu[] = $relationship_list->getRelationship($merge_key)
- ->newAction($task);
+ $submenu_actions = array(
+ ManiphestTaskHasParentRelationship::RELATIONSHIPKEY,
+ ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY,
+ ManiphestTaskMergeInRelationship::RELATIONSHIPKEY,
+ ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY,
+ );
- $task_submenu[] = $relationship_list->getRelationship($close_key)
- ->newAction($task);
+ $task_submenu = $relationship_list->newActionSubmenu($submenu_actions)
+ ->setName(pht('Edit Related Tasks...'))
+ ->setIcon('fa-anchor');
- $curtain->addAction(
- id(new PhabricatorActionView())
- ->setName(pht('Edit Related Tasks...'))
- ->setIcon('fa-anchor')
- ->setSubmenu($task_submenu));
+ $curtain->addAction($task_submenu);
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
diff --git a/src/applications/search/controller/PhabricatorSearchBaseController.php b/src/applications/search/controller/PhabricatorSearchBaseController.php
--- a/src/applications/search/controller/PhabricatorSearchBaseController.php
+++ b/src/applications/search/controller/PhabricatorSearchBaseController.php
@@ -2,13 +2,6 @@
abstract class PhabricatorSearchBaseController extends PhabricatorController {
-
- const ACTION_ATTACH = 'attach';
- const ACTION_MERGE = 'merge';
- const ACTION_DEPENDENCIES = 'dependencies';
- const ACTION_BLOCKS = 'blocks';
- const ACTION_EDGE = 'edge';
-
protected function loadRelationshipObject() {
$request = $this->getRequest();
$viewer = $this->getViewer();
diff --git a/src/applications/search/relationship/PhabricatorObjectRelationshipList.php b/src/applications/search/relationship/PhabricatorObjectRelationshipList.php
--- a/src/applications/search/relationship/PhabricatorObjectRelationshipList.php
+++ b/src/applications/search/relationship/PhabricatorObjectRelationshipList.php
@@ -46,6 +46,26 @@
return $this->relationships;
}
+ public function newActionSubmenu(array $keys) {
+ $object = $this->getObject();
+
+ $actions = array();
+
+ foreach ($keys as $key) {
+ $relationship = $this->getRelationship($key);
+ if (!$relationship) {
+ throw new Exception(
+ pht(
+ 'No object relationship of type "%s" exists.',
+ $key));
+ }
+
+ $actions[$key] = $relationship->newAction($object);
+ }
+
+ return $this->newMenuWithActions($actions);
+ }
+
public function newActionMenu() {
$relationships = $this->getRelationships();
$object = $this->getObject();
@@ -65,9 +85,22 @@
$actions = msort($actions, 'getName');
- return id(new PhabricatorActionView())
+ return $this->newMenuWithActions($actions)
->setName(pht('Edit Related Objects...'))
- ->setIcon('fa-link')
+ ->setIcon('fa-link');
+ }
+
+ private function newMenuWithActions(array $actions) {
+ $any_enabled = false;
+ foreach ($actions as $action) {
+ if (!$action->getDisabled()) {
+ $any_enabled = true;
+ break;
+ }
+ }
+
+ return id(new PhabricatorActionView())
+ ->setDisabled(!$any_enabled)
->setSubmenu($actions);
}
diff --git a/src/view/layout/PhabricatorActionView.php b/src/view/layout/PhabricatorActionView.php
--- a/src/view/layout/PhabricatorActionView.php
+++ b/src/view/layout/PhabricatorActionView.php
@@ -84,6 +84,10 @@
return $this;
}
+ public function getDisabled() {
+ return $this->disabled;
+ }
+
public function setWorkflow($workflow) {
$this->workflow = $workflow;
return $this;

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 10:31 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704210
Default Alt Text
D16201.id38967.diff (5 KB)

Event Timeline