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

Show projects on feed stories

Summary: Fixes T1922. When a story is about a primary object associated with projects, show those projects on the feed story.

Test Plan: {F190171}

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T1922

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

+72 -4
+52 -3
src/applications/feed/story/PhabricatorFeedStory.php
··· 16 16 private $hovercard = false; 17 17 private $renderingTarget = PhabricatorApplicationTransaction::TARGET_HTML; 18 18 19 - private $handles = array(); 20 - private $objects = array(); 19 + private $handles = array(); 20 + private $objects = array(); 21 + private $projectPHIDs = array(); 21 22 22 23 /* -( Loading Stories )---------------------------------------------------- */ 23 24 ··· 93 94 $stories[$key]->setObjects($story_objects); 94 95 } 95 96 97 + // If stories are about PhabricatorProjectInterface objects, load the 98 + // projects the objects are a part of so we can render project tags 99 + // on the stories. 100 + 101 + $project_phids = array(); 102 + foreach ($objects as $object) { 103 + if ($object instanceof PhabricatorProjectInterface) { 104 + $project_phids[$object->getPHID()] = array(); 105 + } 106 + } 107 + 108 + if ($project_phids) { 109 + $edge_query = id(new PhabricatorEdgeQuery()) 110 + ->withSourcePHIDs(array_keys($project_phids)) 111 + ->withEdgeTypes( 112 + array( 113 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 114 + )); 115 + $edge_query->execute(); 116 + foreach ($project_phids as $phid => $ignored) { 117 + $project_phids[$phid] = $edge_query->getDestinationPHIDs(array($phid)); 118 + } 119 + } 120 + 96 121 $handle_phids = array(); 97 122 foreach ($stories as $key => $story) { 98 123 foreach ($story->getRequiredHandlePHIDs() as $phid) { ··· 101 126 if ($story->getAuthorPHID()) { 102 127 $key_phids[$key][$story->getAuthorPHID()] = true; 103 128 } 129 + 130 + $object_phid = $story->getPrimaryObjectPHID(); 131 + $object_project_phids = idx($project_phids, $object_phid, array()); 132 + $story->setProjectPHIDs($object_project_phids); 133 + foreach ($object_project_phids as $dst) { 134 + $key_phids[$key][$dst] = true; 135 + } 136 + 104 137 $handle_phids += $key_phids[$key]; 105 138 } 106 139 ··· 319 352 } 320 353 321 354 protected function newStoryView() { 322 - return id(new PHUIFeedStoryView()) 355 + $view = id(new PHUIFeedStoryView()) 323 356 ->setChronologicalKey($this->getChronologicalKey()) 324 357 ->setEpoch($this->getEpoch()) 325 358 ->setViewed($this->getHasViewed()); 359 + 360 + $project_phids = $this->getProjectPHIDs(); 361 + if ($project_phids) { 362 + $view->setTags($this->renderHandleList($project_phids)); 363 + } 364 + 365 + return $view; 366 + } 367 + 368 + public function setProjectPHIDs(array $phids) { 369 + $this->projectPHIDs = $phids; 370 + return $this; 371 + } 372 + 373 + public function getProjectPHIDs() { 374 + return $this->projectPHIDs; 326 375 } 327 376 328 377
+20 -1
src/view/phui/PHUIFeedStoryView.php
··· 15 15 private $projects = array(); 16 16 private $actions = array(); 17 17 private $chronologicalKey; 18 + private $tags; 19 + 20 + public function setTags($tags) { 21 + $this->tags = $tags; 22 + return $this; 23 + } 24 + 25 + public function getTags() { 26 + return $this->tags; 27 + } 18 28 19 29 public function setChronologicalKey($chronological_key) { 20 30 $this->chronologicalKey = $chronological_key; ··· 235 245 $body_content); 236 246 } 237 247 248 + $tags = null; 249 + if ($this->tags) { 250 + $tags = array( 251 + " \xC2\xB7 ", 252 + $this->tags); 253 + } 254 + 238 255 $foot = phutil_tag( 239 256 'div', 240 257 array( ··· 242 259 ), 243 260 array( 244 261 $icon, 245 - $foot)); 262 + $foot, 263 + $tags, 264 + )); 246 265 247 266 $classes = array('phui-feed-story'); 248 267