diff --git a/src/applications/differential/customfield/DifferentialAuthorField.php b/src/applications/differential/customfield/DifferentialAuthorField.php --- a/src/applications/differential/customfield/DifferentialAuthorField.php +++ b/src/applications/differential/customfield/DifferentialAuthorField.php @@ -32,7 +32,7 @@ } public function renderPropertyViewValue(array $handles) { - return $handles[$this->getObject()->getAuthorPHID()]->renderLink(); + return $handles[$this->getObject()->getAuthorPHID()]->renderHovercardLink(); } } diff --git a/src/applications/differential/view/DifferentialReviewersView.php b/src/applications/differential/view/DifferentialReviewersView.php --- a/src/applications/differential/view/DifferentialReviewersView.php +++ b/src/applications/differential/view/DifferentialReviewersView.php @@ -120,7 +120,7 @@ } - $item->setTarget($handle->renderLink()); + $item->setTarget($handle->renderHovercardLink()); $view->addItem($item); } diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -208,19 +208,26 @@ ->setObject($task) ->setActionList($actions); - $view->addProperty( - pht('Assigned To'), - $task->getOwnerPHID() - ? $handles->renderHandle($task->getOwnerPHID()) - : phutil_tag('em', array(), pht('None'))); + $owner_phid = $task->getOwnerPHID(); + if ($owner_phid) { + $assigned_to = $handles + ->renderHandle($owner_phid) + ->setShowHovercard(true); + } else { + $assigned_to = phutil_tag('em', array(), pht('None')); + } + + $view->addProperty(pht('Assigned To'), $assigned_to); $view->addProperty( pht('Priority'), ManiphestTaskPriority::getTaskPriorityName($task->getPriority())); - $view->addProperty( - pht('Author'), - $handles->renderHandle($task->getAuthorPHID())); + $author = $handles + ->renderHandle($task->getAuthorPHID()) + ->setShowHovercard(true); + + $view->addProperty(pht('Author'), $author); $source = $task->getOriginalEmailSource(); if ($source) { diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -248,6 +248,23 @@ public function renderLink($name = null) { + return $this->renderLinkWithAttributes($name, array()); + } + + public function renderHovercardLink($name = null) { + Javelin::initBehavior('phabricator-hovercards'); + + $attributes = array( + 'sigil' => 'hovercard', + 'meta' => array( + 'hoverPHID' => $this->getPHID(), + ), + ); + + return $this->renderLinkWithAttributes($name, $attributes); + } + + private function renderLinkWithAttributes($name, array $attributes) { if ($name === null) { $name = $this->getLinkName(); } @@ -275,13 +292,15 @@ ->setIconFont('fa-lock lightgreytext'); } - return phutil_tag( + $attributes = $attributes + array( + 'href' => $uri, + 'class' => implode(' ', $classes), + 'title' => $title, + ); + + return javelin_tag( $uri ? 'a' : 'span', - array( - 'href' => $uri, - 'class' => implode(' ', $classes), - 'title' => $title, - ), + $attributes, array($icon, $name)); } diff --git a/src/applications/phid/view/PHUIHandleListView.php b/src/applications/phid/view/PHUIHandleListView.php --- a/src/applications/phid/view/PHUIHandleListView.php +++ b/src/applications/phid/view/PHUIHandleListView.php @@ -34,9 +34,14 @@ } protected function getTagContent() { + $list = $this->handleList; $items = array(); - foreach ($this->handleList as $handle) { - $items[] = $handle->renderLink(); + foreach ($list as $handle) { + $view = $list->renderHandle($handle->getPHID()); + + $view->setShowHovercard(true); + + $items[] = $view; } if ($this->getAsInline()) { diff --git a/src/applications/phid/view/PHUIHandleTagListView.php b/src/applications/phid/view/PHUIHandleTagListView.php --- a/src/applications/phid/view/PHUIHandleTagListView.php +++ b/src/applications/phid/view/PHUIHandleTagListView.php @@ -7,6 +7,7 @@ private $limit; private $noDataString; private $slim; + private $showHovercards; public function setHandles(array $handles) { $this->handles = $handles; @@ -33,6 +34,11 @@ return $this; } + public function setShowHovercards($show_hovercards) { + $this->showHovercards = $show_hovercards; + return $this; + } + protected function getTagName() { return 'ul'; } @@ -62,6 +68,9 @@ $list = array(); foreach ($handles as $handle) { $tag = $handle->renderTag(); + if ($this->showHovercards) { + $tag->setPHID($handle->getPHID()); + } if ($this->slim) { $tag->setSlimShady(true); } diff --git a/src/applications/phid/view/PHUIHandleView.php b/src/applications/phid/view/PHUIHandleView.php --- a/src/applications/phid/view/PHUIHandleView.php +++ b/src/applications/phid/view/PHUIHandleView.php @@ -15,6 +15,7 @@ private $handlePHID; private $asTag; private $useShortName; + private $showHovercard; public function setHandleList(PhabricatorHandleList $list) { $this->handleList = $list; @@ -36,17 +37,37 @@ return $this; } + public function setShowHovercard($hovercard) { + $this->showHovercard = $hovercard; + return $this; + } + public function render() { $handle = $this->handleList[$this->handlePHID]; + if ($this->asTag) { - return $handle->renderTag(); - } else { - if ($this->useShortName) { - return $handle->renderLink($handle->getName()); - } else { - return $handle->renderLink(); + $tag = $handle->renderTag(); + + if ($this->showHovercard) { + $tag->setPHID($handle->getPHID()); } + + return $tag; } + + if ($this->useShortName) { + $name = $handle->getName(); + } else { + $name = null; + } + + if ($this->showHovercard) { + $link = $handle->renderHovercardLink($name); + } else { + $link = $handle->renderLink($name); + } + + return $link; } } diff --git a/src/applications/project/events/PhabricatorProjectUIEventListener.php b/src/applications/project/events/PhabricatorProjectUIEventListener.php --- a/src/applications/project/events/PhabricatorProjectUIEventListener.php +++ b/src/applications/project/events/PhabricatorProjectUIEventListener.php @@ -101,7 +101,8 @@ if ($handles) { $list = id(new PHUIHandleTagListView()) ->setHandles($handles) - ->setAnnotations($annotations); + ->setAnnotations($annotations) + ->setShowHovercards(true); } else { $list = phutil_tag('em', array(), pht('None')); } diff --git a/src/applications/subscriptions/view/SubscriptionListStringBuilder.php b/src/applications/subscriptions/view/SubscriptionListStringBuilder.php --- a/src/applications/subscriptions/view/SubscriptionListStringBuilder.php +++ b/src/applications/subscriptions/view/SubscriptionListStringBuilder.php @@ -57,7 +57,7 @@ // link. Instead, render "a, b, c, d" in this case, and then when we get one // more render "a, b, c, and 2 others". if ($subscribers_count <= ($show_count + 1)) { - return phutil_implode_html(', ', mpull($handles, 'renderLink')); + return phutil_implode_html(', ', mpull($handles, 'renderHovercardLink')); } $show = array_slice($handles, 0, $show_count); diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -83,7 +83,7 @@ return null; } - $handles = mpull($handles, 'renderLink'); + $handles = mpull($handles, 'renderHovercardLink'); $handles = phutil_implode_html(', ', $handles); return $handles; }