1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Show hovercards for most links in object property views

Summary:
Ref T8980. This isn't 100% coverage but should be pretty much all of the common ones.

These feel a touch iffy to me at first glance so I didn't go crazy trying to hunt all of them down. I have some other plans for them so maybe they'll feel better by the end of it.

Test Plan: Hovered over author, reviewers, blocked tasks, projects, etc.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8980

Differential Revision: https://secure.phabricator.com/D14877
This commit is contained in:
epriestley 2015-12-24 10:14:10 -08:00
parent 992dedcadd
commit 3ec07c4987
10 changed files with 89 additions and 27 deletions

View file

@ -32,7 +32,7 @@ final class DifferentialAuthorField
}
public function renderPropertyViewValue(array $handles) {
return $handles[$this->getObject()->getAuthorPHID()]->renderLink();
return $handles[$this->getObject()->getAuthorPHID()]->renderHovercardLink();
}
}

View file

@ -120,7 +120,7 @@ final class DifferentialReviewersView extends AphrontView {
}
$item->setTarget($handle->renderLink());
$item->setTarget($handle->renderHovercardLink());
$view->addItem($item);
}

View file

@ -208,19 +208,26 @@ final class ManiphestTaskDetailController extends ManiphestController {
->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) {

View file

@ -248,6 +248,23 @@ final class PhabricatorObjectHandle
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 @@ final class PhabricatorObjectHandle
->setIconFont('fa-lock lightgreytext');
}
return phutil_tag(
$uri ? 'a' : 'span',
array(
$attributes = $attributes + array(
'href' => $uri,
'class' => implode(' ', $classes),
'title' => $title,
),
);
return javelin_tag(
$uri ? 'a' : 'span',
$attributes,
array($icon, $name));
}

View file

@ -34,9 +34,14 @@ final class PHUIHandleListView
}
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()) {

View file

@ -7,6 +7,7 @@ final class PHUIHandleTagListView extends AphrontTagView {
private $limit;
private $noDataString;
private $slim;
private $showHovercards;
public function setHandles(array $handles) {
$this->handles = $handles;
@ -33,6 +34,11 @@ final class PHUIHandleTagListView extends AphrontTagView {
return $this;
}
public function setShowHovercards($show_hovercards) {
$this->showHovercards = $show_hovercards;
return $this;
}
protected function getTagName() {
return 'ul';
}
@ -62,6 +68,9 @@ final class PHUIHandleTagListView extends AphrontTagView {
$list = array();
foreach ($handles as $handle) {
$tag = $handle->renderTag();
if ($this->showHovercards) {
$tag->setPHID($handle->getPHID());
}
if ($this->slim) {
$tag->setSlimShady(true);
}

View file

@ -15,6 +15,7 @@ final class PHUIHandleView
private $handlePHID;
private $asTag;
private $useShortName;
private $showHovercard;
public function setHandleList(PhabricatorHandleList $list) {
$this->handleList = $list;
@ -36,17 +37,37 @@ final class PHUIHandleView
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 {
$tag = $handle->renderTag();
if ($this->showHovercard) {
$tag->setPHID($handle->getPHID());
}
return $tag;
}
if ($this->useShortName) {
return $handle->renderLink($handle->getName());
$name = $handle->getName();
} else {
return $handle->renderLink();
$name = null;
}
if ($this->showHovercard) {
$link = $handle->renderHovercardLink($name);
} else {
$link = $handle->renderLink($name);
}
return $link;
}
}

View file

@ -101,7 +101,8 @@ final class PhabricatorProjectUIEventListener
if ($handles) {
$list = id(new PHUIHandleTagListView())
->setHandles($handles)
->setAnnotations($annotations);
->setAnnotations($annotations)
->setShowHovercards(true);
} else {
$list = phutil_tag('em', array(), pht('None'));
}

View file

@ -57,7 +57,7 @@ final class SubscriptionListStringBuilder extends Phobject {
// 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);

View file

@ -83,7 +83,7 @@ abstract class PhabricatorStandardCustomFieldPHIDs
return null;
}
$handles = mpull($handles, 'renderLink');
$handles = mpull($handles, 'renderHovercardLink');
$handles = phutil_implode_html(', ', $handles);
return $handles;
}