From 20d8b1bdd36ae3bf98af6c23826b22a2c4b7d960 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 7 Aug 2014 15:44:12 -0700 Subject: [PATCH] Implement PhabricatorProjectInterface on ManiphestTask Summary: Ref T5245. This removes some hacks and activates two meaningful interactions: - The "projects" field goes through shared code now. - Mentioning projects in tasks using hashtags now tags them. Test Plan: - Viewed a task with projects. - Viewed a task with no projects. - Viewed a task with projects and board positions. - Viewed a revision with projects. - Made a `#hashtag` comment in Maniphest and got a project association. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D10177 --- src/__phutil_library_map__.php | 1 + .../ManiphestTaskDetailController.php | 46 ------------------ .../maniphest/storage/ManiphestTask.php | 3 +- .../PhabricatorProjectUIEventListener.php | 47 ++++++++++++++++++- ...habricatorApplicationTransactionEditor.php | 16 ++----- 5 files changed, 53 insertions(+), 60 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2ffa6cc8b7..8f48cb4128 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3670,6 +3670,7 @@ phutil_register_library_map(array( 'PhabricatorCustomFieldInterface', 'PhabricatorDestructibleInterface', 'PhabricatorApplicationTransactionInterface', + 'PhabricatorProjectInterface', ), 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 310e011a09..f3905b89a8 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -530,52 +530,6 @@ final class ManiphestTaskDetailController extends ManiphestController { $source)); } - $project_phids = $task->getProjectPHIDs(); - if ($project_phids) { - require_celerity_resource('maniphest-task-summary-css'); - - $positions = id(new PhabricatorProjectColumnPositionQuery()) - ->setViewer($viewer) - ->withBoardPHIDs($project_phids) - ->withObjectPHIDs(array($task->getPHID())) - ->needColumns(true) - ->execute(); - $positions = mpull($positions, null, 'getBoardPHID'); - - $project_handles = array(); - $project_annotations = array(); - foreach ($project_phids as $project_phid) { - $handle = $this->getHandle($project_phid); - $project_handles[] = $handle; - - $position = idx($positions, $project_phid); - if ($position) { - $column = $position->getColumn(); - - $column_name = pht('(%s)', $column->getDisplayName()); - $column_link = phutil_tag( - 'a', - array( - 'href' => $handle->getURI().'board/', - 'class' => 'maniphest-board-link', - ), - $column_name); - - $project_annotations[$project_phid] = array( - ' ', - $column_link); - } - } - - $project_rows = id(new PHUIHandleTagListView()) - ->setHandles($project_handles) - ->setAnnotations($project_annotations); - } else { - $project_rows = phutil_tag('em', array(), pht('None')); - } - - $view->addProperty(pht('Projects'), $project_rows); - $edge_types = array( PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK => pht('Blocks'), diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index d3f30b03c0..d52ad3eecd 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -9,7 +9,8 @@ final class ManiphestTask extends ManiphestDAO PhrequentTrackableInterface, PhabricatorCustomFieldInterface, PhabricatorDestructibleInterface, - PhabricatorApplicationTransactionInterface { + PhabricatorApplicationTransactionInterface, + PhabricatorProjectInterface { const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; diff --git a/src/applications/project/events/PhabricatorProjectUIEventListener.php b/src/applications/project/events/PhabricatorProjectUIEventListener.php index 1462fe456d..0dc7ee8693 100644 --- a/src/applications/project/events/PhabricatorProjectUIEventListener.php +++ b/src/applications/project/events/PhabricatorProjectUIEventListener.php @@ -42,9 +42,54 @@ final class PhabricatorProjectUIEventListener $handles = array(); } + // If this object can appear on boards, build the workboard annotations. + // Some day, this might be a generic interface. For now, only tasks can + // appear on boards. + $can_appear_on_boards = ($object instanceof ManiphestTask); + + $annotations = array(); + if ($handles && $can_appear_on_boards) { + + // TDOO: Generalize this UI and move it out of Maniphest. + + require_celerity_resource('maniphest-task-summary-css'); + + $positions = id(new PhabricatorProjectColumnPositionQuery()) + ->setViewer($user) + ->withBoardPHIDs($project_phids) + ->withObjectPHIDs(array($object->getPHID())) + ->needColumns(true) + ->execute(); + $positions = mpull($positions, null, 'getBoardPHID'); + + foreach ($project_phids as $project_phid) { + $handle = $handles[$project_phid]; + + $position = idx($positions, $project_phid); + if ($position) { + $column = $position->getColumn(); + + $column_name = pht('(%s)', $column->getDisplayName()); + $column_link = phutil_tag( + 'a', + array( + 'href' => $handle->getURI().'board/', + 'class' => 'maniphest-board-link', + ), + $column_name); + + $annotations[$project_phid] = array( + ' ', + $column_link); + } + } + + } + if ($handles) { $list = id(new PHUIHandleTagListView()) - ->setHandles($handles); + ->setHandles($handles) + ->setAnnotations($annotations); } else { $list = phutil_tag('em', array(), pht('None')); } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 39d5225372..471e0f304f 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1959,18 +1959,10 @@ abstract class PhabricatorApplicationTransactionEditor $has_support = true; } - // TODO: The Maniphest legacy stuff should get cleaned up here. - - if (($object instanceof ManiphestTask) || - ($object instanceof PhabricatorProjectInterface)) { - - if ($object instanceof PhabricatorProjectInterface) { - $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( - $object->getPHID(), - PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); - } else { - $project_phids = $object->getProjectPHIDs(); - } + if ($object instanceof PhabricatorProjectInterface) { + $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $object->getPHID(), + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if ($project_phids) { $watcher_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_WATCHER;