From d02eb46ad6cad410ee0a97f0f6c703c6a9f62b01 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 14 Aug 2013 13:20:25 -0700 Subject: [PATCH] Add hovercard on/off option to PhabricatorFeedStory Summary: Defaults hovercards off everywhere feed stories are shown. I tried to find where to put this in so /feed/ could display them, but got horribly lost and confused in SearchQueryLandView Test Plan: turn hovercards on and off, inspect elements. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: Korvin, aran Differential Revision: https://secure.phabricator.com/D6757 --- .../feed/builder/PhabricatorFeedBuilder.php | 7 +++++++ .../feed/controller/PhabricatorFeedListController.php | 1 + src/applications/feed/story/PhabricatorFeedStory.php | 10 ++++++++-- .../controller/PhabricatorPeopleProfileController.php | 1 + .../controller/PhabricatorProjectProfileController.php | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/applications/feed/builder/PhabricatorFeedBuilder.php b/src/applications/feed/builder/PhabricatorFeedBuilder.php index c982e5d908..180ca92bfb 100644 --- a/src/applications/feed/builder/PhabricatorFeedBuilder.php +++ b/src/applications/feed/builder/PhabricatorFeedBuilder.php @@ -4,6 +4,7 @@ final class PhabricatorFeedBuilder { private $stories; private $framed; + private $hovercards = false; public function __construct(array $stories) { assert_instances_of($stories, 'PhabricatorFeedStory'); @@ -20,6 +21,11 @@ final class PhabricatorFeedBuilder { return $this; } + public function setShowHovercards($hover) { + $this->hovercards = $hover; + return $this; + } + public function buildView() { if (!$this->user) { throw new Exception('Call setUser() before buildView()!'); @@ -35,6 +41,7 @@ final class PhabricatorFeedBuilder { $last_date = null; foreach ($stories as $story) { $story->setFramed($this->framed); + $story->setHovercard($this->hovercards); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); diff --git a/src/applications/feed/controller/PhabricatorFeedListController.php b/src/applications/feed/controller/PhabricatorFeedListController.php index b5aac9901c..f292735bb6 100644 --- a/src/applications/feed/controller/PhabricatorFeedListController.php +++ b/src/applications/feed/controller/PhabricatorFeedListController.php @@ -28,6 +28,7 @@ final class PhabricatorFeedListController extends PhabricatorFeedController PhabricatorSavedQuery $query) { $builder = new PhabricatorFeedBuilder($feed); + $builder->setShowHovercards(true); $builder->setUser($this->getRequest()->getUser()); $view = $builder->buildView(); diff --git a/src/applications/feed/story/PhabricatorFeedStory.php b/src/applications/feed/story/PhabricatorFeedStory.php index 646799103b..07503e86b4 100644 --- a/src/applications/feed/story/PhabricatorFeedStory.php +++ b/src/applications/feed/story/PhabricatorFeedStory.php @@ -13,6 +13,7 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface { private $data; private $hasViewed; private $framed; + private $hovercard = false; private $handles = array(); private $objects = array(); @@ -116,6 +117,11 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface { return $stories; } + public function setHovercard($hover) { + $this->hovercard = $hover; + return $this; + } + public function setObjects(array $objects) { $this->objects = $objects; return $this; @@ -242,8 +248,8 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface { array( 'href' => $handle->getURI(), 'target' => $this->framed ? '_top' : null, - 'sigil' => 'hovercard', - 'meta' => array('hoverPHID' => $phid), + 'sigil' => $this->hovercard ? 'hovercard' : null, + 'meta' => $this->hovercard ? array('hoverPHID' => $phid) : null, 'class' => $class, ), $handle->getLinkName()); diff --git a/src/applications/people/controller/PhabricatorPeopleProfileController.php b/src/applications/people/controller/PhabricatorPeopleProfileController.php index a15797808d..432fbd5b44 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileController.php @@ -119,6 +119,7 @@ final class PhabricatorPeopleProfileController $builder = new PhabricatorFeedBuilder($stories); $builder->setUser($viewer); + $builder->setShowHovercards(true); $view = $builder->buildView(); return hsprintf( diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index 6142aaf375..12a27cf725 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -137,6 +137,7 @@ final class PhabricatorProjectProfileController $builder = new PhabricatorFeedBuilder($stories); $builder->setUser($this->getRequest()->getUser()); + $builder->setShowHovercards(true); $view = $builder->buildView(); return hsprintf(