diff --git a/src/applications/feed/story/PhabricatorFeedStory.php b/src/applications/feed/story/PhabricatorFeedStory.php --- a/src/applications/feed/story/PhabricatorFeedStory.php +++ b/src/applications/feed/story/PhabricatorFeedStory.php @@ -16,8 +16,9 @@ private $hovercard = false; private $renderingTarget = PhabricatorApplicationTransaction::TARGET_HTML; - private $handles = array(); - private $objects = array(); + private $handles = array(); + private $objects = array(); + private $projectPHIDs = array(); /* -( Loading Stories )---------------------------------------------------- */ @@ -93,6 +94,30 @@ $stories[$key]->setObjects($story_objects); } + // If stories are about PhabricatorProjectInterface objects, load the + // projects the objects are a part of so we can render project tags + // on the stories. + + $project_phids = array(); + foreach ($objects as $object) { + if ($object instanceof PhabricatorProjectInterface) { + $project_phids[$object->getPHID()] = array(); + } + } + + if ($project_phids) { + $edge_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(array_keys($project_phids)) + ->withEdgeTypes( + array( + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, + )); + $edge_query->execute(); + foreach ($project_phids as $phid => $ignored) { + $project_phids[$phid] = $edge_query->getDestinationPHIDs(array($phid)); + } + } + $handle_phids = array(); foreach ($stories as $key => $story) { foreach ($story->getRequiredHandlePHIDs() as $phid) { @@ -101,6 +126,14 @@ if ($story->getAuthorPHID()) { $key_phids[$key][$story->getAuthorPHID()] = true; } + + $object_phid = $story->getPrimaryObjectPHID(); + $object_project_phids = idx($project_phids, $object_phid, array()); + $story->setProjectPHIDs($object_project_phids); + foreach ($object_project_phids as $dst) { + $key_phids[$key][$dst] = true; + } + $handle_phids += $key_phids[$key]; } @@ -319,10 +352,26 @@ } protected function newStoryView() { - return id(new PHUIFeedStoryView()) + $view = id(new PHUIFeedStoryView()) ->setChronologicalKey($this->getChronologicalKey()) ->setEpoch($this->getEpoch()) ->setViewed($this->getHasViewed()); + + $project_phids = $this->getProjectPHIDs(); + if ($project_phids) { + $view->setTags($this->renderHandleList($project_phids)); + } + + return $view; + } + + public function setProjectPHIDs(array $phids) { + $this->projectPHIDs = $phids; + return $this; + } + + public function getProjectPHIDs() { + return $this->projectPHIDs; } diff --git a/src/view/phui/PHUIFeedStoryView.php b/src/view/phui/PHUIFeedStoryView.php --- a/src/view/phui/PHUIFeedStoryView.php +++ b/src/view/phui/PHUIFeedStoryView.php @@ -15,6 +15,16 @@ private $projects = array(); private $actions = array(); private $chronologicalKey; + private $tags; + + public function setTags($tags) { + $this->tags = $tags; + return $this; + } + + public function getTags() { + return $this->tags; + } public function setChronologicalKey($chronological_key) { $this->chronologicalKey = $chronological_key; @@ -235,6 +245,13 @@ $body_content); } + $tags = null; + if ($this->tags) { + $tags = array( + " \xC2\xB7 ", + $this->tags); + } + $foot = phutil_tag( 'div', array( @@ -242,7 +259,9 @@ ), array( $icon, - $foot)); + $foot, + $tags, + )); $classes = array('phui-feed-story');