1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +01:00

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
This commit is contained in:
epriestley 2014-08-13 11:24:56 -07:00
parent bcdadf5947
commit a37dc68b0a
2 changed files with 72 additions and 4 deletions

View file

@ -16,8 +16,9 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
private $hovercard = false; private $hovercard = false;
private $renderingTarget = PhabricatorApplicationTransaction::TARGET_HTML; private $renderingTarget = PhabricatorApplicationTransaction::TARGET_HTML;
private $handles = array(); private $handles = array();
private $objects = array(); private $objects = array();
private $projectPHIDs = array();
/* -( Loading Stories )---------------------------------------------------- */ /* -( Loading Stories )---------------------------------------------------- */
@ -93,6 +94,30 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
$stories[$key]->setObjects($story_objects); $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(); $handle_phids = array();
foreach ($stories as $key => $story) { foreach ($stories as $key => $story) {
foreach ($story->getRequiredHandlePHIDs() as $phid) { foreach ($story->getRequiredHandlePHIDs() as $phid) {
@ -101,6 +126,14 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
if ($story->getAuthorPHID()) { if ($story->getAuthorPHID()) {
$key_phids[$key][$story->getAuthorPHID()] = true; $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]; $handle_phids += $key_phids[$key];
} }
@ -319,10 +352,26 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface {
} }
protected function newStoryView() { protected function newStoryView() {
return id(new PHUIFeedStoryView()) $view = id(new PHUIFeedStoryView())
->setChronologicalKey($this->getChronologicalKey()) ->setChronologicalKey($this->getChronologicalKey())
->setEpoch($this->getEpoch()) ->setEpoch($this->getEpoch())
->setViewed($this->getHasViewed()); ->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;
} }

View file

@ -15,6 +15,16 @@ final class PHUIFeedStoryView extends AphrontView {
private $projects = array(); private $projects = array();
private $actions = array(); private $actions = array();
private $chronologicalKey; private $chronologicalKey;
private $tags;
public function setTags($tags) {
$this->tags = $tags;
return $this;
}
public function getTags() {
return $this->tags;
}
public function setChronologicalKey($chronological_key) { public function setChronologicalKey($chronological_key) {
$this->chronologicalKey = $chronological_key; $this->chronologicalKey = $chronological_key;
@ -235,6 +245,13 @@ final class PHUIFeedStoryView extends AphrontView {
$body_content); $body_content);
} }
$tags = null;
if ($this->tags) {
$tags = array(
" \xC2\xB7 ",
$this->tags);
}
$foot = phutil_tag( $foot = phutil_tag(
'div', 'div',
array( array(
@ -242,7 +259,9 @@ final class PHUIFeedStoryView extends AphrontView {
), ),
array( array(
$icon, $icon,
$foot)); $foot,
$tags,
));
$classes = array('phui-feed-story'); $classes = array('phui-feed-story');