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:
parent
992dedcadd
commit
3ec07c4987
10 changed files with 89 additions and 27 deletions
|
@ -32,7 +32,7 @@ final class DifferentialAuthorField
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderPropertyViewValue(array $handles) {
|
public function renderPropertyViewValue(array $handles) {
|
||||||
return $handles[$this->getObject()->getAuthorPHID()]->renderLink();
|
return $handles[$this->getObject()->getAuthorPHID()]->renderHovercardLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ final class DifferentialReviewersView extends AphrontView {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->setTarget($handle->renderLink());
|
$item->setTarget($handle->renderHovercardLink());
|
||||||
$view->addItem($item);
|
$view->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,19 +208,26 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
->setObject($task)
|
->setObject($task)
|
||||||
->setActionList($actions);
|
->setActionList($actions);
|
||||||
|
|
||||||
$view->addProperty(
|
$owner_phid = $task->getOwnerPHID();
|
||||||
pht('Assigned To'),
|
if ($owner_phid) {
|
||||||
$task->getOwnerPHID()
|
$assigned_to = $handles
|
||||||
? $handles->renderHandle($task->getOwnerPHID())
|
->renderHandle($owner_phid)
|
||||||
: phutil_tag('em', array(), pht('None')));
|
->setShowHovercard(true);
|
||||||
|
} else {
|
||||||
|
$assigned_to = phutil_tag('em', array(), pht('None'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->addProperty(pht('Assigned To'), $assigned_to);
|
||||||
|
|
||||||
$view->addProperty(
|
$view->addProperty(
|
||||||
pht('Priority'),
|
pht('Priority'),
|
||||||
ManiphestTaskPriority::getTaskPriorityName($task->getPriority()));
|
ManiphestTaskPriority::getTaskPriorityName($task->getPriority()));
|
||||||
|
|
||||||
$view->addProperty(
|
$author = $handles
|
||||||
pht('Author'),
|
->renderHandle($task->getAuthorPHID())
|
||||||
$handles->renderHandle($task->getAuthorPHID()));
|
->setShowHovercard(true);
|
||||||
|
|
||||||
|
$view->addProperty(pht('Author'), $author);
|
||||||
|
|
||||||
$source = $task->getOriginalEmailSource();
|
$source = $task->getOriginalEmailSource();
|
||||||
if ($source) {
|
if ($source) {
|
||||||
|
|
|
@ -248,6 +248,23 @@ final class PhabricatorObjectHandle
|
||||||
|
|
||||||
|
|
||||||
public function renderLink($name = null) {
|
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) {
|
if ($name === null) {
|
||||||
$name = $this->getLinkName();
|
$name = $this->getLinkName();
|
||||||
}
|
}
|
||||||
|
@ -275,13 +292,15 @@ final class PhabricatorObjectHandle
|
||||||
->setIconFont('fa-lock lightgreytext');
|
->setIconFont('fa-lock lightgreytext');
|
||||||
}
|
}
|
||||||
|
|
||||||
return phutil_tag(
|
$attributes = $attributes + array(
|
||||||
|
'href' => $uri,
|
||||||
|
'class' => implode(' ', $classes),
|
||||||
|
'title' => $title,
|
||||||
|
);
|
||||||
|
|
||||||
|
return javelin_tag(
|
||||||
$uri ? 'a' : 'span',
|
$uri ? 'a' : 'span',
|
||||||
array(
|
$attributes,
|
||||||
'href' => $uri,
|
|
||||||
'class' => implode(' ', $classes),
|
|
||||||
'title' => $title,
|
|
||||||
),
|
|
||||||
array($icon, $name));
|
array($icon, $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,14 @@ final class PHUIHandleListView
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTagContent() {
|
protected function getTagContent() {
|
||||||
|
$list = $this->handleList;
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($this->handleList as $handle) {
|
foreach ($list as $handle) {
|
||||||
$items[] = $handle->renderLink();
|
$view = $list->renderHandle($handle->getPHID());
|
||||||
|
|
||||||
|
$view->setShowHovercard(true);
|
||||||
|
|
||||||
|
$items[] = $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getAsInline()) {
|
if ($this->getAsInline()) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ final class PHUIHandleTagListView extends AphrontTagView {
|
||||||
private $limit;
|
private $limit;
|
||||||
private $noDataString;
|
private $noDataString;
|
||||||
private $slim;
|
private $slim;
|
||||||
|
private $showHovercards;
|
||||||
|
|
||||||
public function setHandles(array $handles) {
|
public function setHandles(array $handles) {
|
||||||
$this->handles = $handles;
|
$this->handles = $handles;
|
||||||
|
@ -33,6 +34,11 @@ final class PHUIHandleTagListView extends AphrontTagView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setShowHovercards($show_hovercards) {
|
||||||
|
$this->showHovercards = $show_hovercards;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getTagName() {
|
protected function getTagName() {
|
||||||
return 'ul';
|
return 'ul';
|
||||||
}
|
}
|
||||||
|
@ -62,6 +68,9 @@ final class PHUIHandleTagListView extends AphrontTagView {
|
||||||
$list = array();
|
$list = array();
|
||||||
foreach ($handles as $handle) {
|
foreach ($handles as $handle) {
|
||||||
$tag = $handle->renderTag();
|
$tag = $handle->renderTag();
|
||||||
|
if ($this->showHovercards) {
|
||||||
|
$tag->setPHID($handle->getPHID());
|
||||||
|
}
|
||||||
if ($this->slim) {
|
if ($this->slim) {
|
||||||
$tag->setSlimShady(true);
|
$tag->setSlimShady(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ final class PHUIHandleView
|
||||||
private $handlePHID;
|
private $handlePHID;
|
||||||
private $asTag;
|
private $asTag;
|
||||||
private $useShortName;
|
private $useShortName;
|
||||||
|
private $showHovercard;
|
||||||
|
|
||||||
public function setHandleList(PhabricatorHandleList $list) {
|
public function setHandleList(PhabricatorHandleList $list) {
|
||||||
$this->handleList = $list;
|
$this->handleList = $list;
|
||||||
|
@ -36,17 +37,37 @@ final class PHUIHandleView
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setShowHovercard($hovercard) {
|
||||||
|
$this->showHovercard = $hovercard;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$handle = $this->handleList[$this->handlePHID];
|
$handle = $this->handleList[$this->handlePHID];
|
||||||
|
|
||||||
if ($this->asTag) {
|
if ($this->asTag) {
|
||||||
return $handle->renderTag();
|
$tag = $handle->renderTag();
|
||||||
} else {
|
|
||||||
if ($this->useShortName) {
|
if ($this->showHovercard) {
|
||||||
return $handle->renderLink($handle->getName());
|
$tag->setPHID($handle->getPHID());
|
||||||
} else {
|
|
||||||
return $handle->renderLink();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,8 @@ final class PhabricatorProjectUIEventListener
|
||||||
if ($handles) {
|
if ($handles) {
|
||||||
$list = id(new PHUIHandleTagListView())
|
$list = id(new PHUIHandleTagListView())
|
||||||
->setHandles($handles)
|
->setHandles($handles)
|
||||||
->setAnnotations($annotations);
|
->setAnnotations($annotations)
|
||||||
|
->setShowHovercards(true);
|
||||||
} else {
|
} else {
|
||||||
$list = phutil_tag('em', array(), pht('None'));
|
$list = phutil_tag('em', array(), pht('None'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// link. Instead, render "a, b, c, d" in this case, and then when we get one
|
||||||
// more render "a, b, c, and 2 others".
|
// more render "a, b, c, and 2 others".
|
||||||
if ($subscribers_count <= ($show_count + 1)) {
|
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);
|
$show = array_slice($handles, 0, $show_count);
|
||||||
|
|
|
@ -83,7 +83,7 @@ abstract class PhabricatorStandardCustomFieldPHIDs
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$handles = mpull($handles, 'renderLink');
|
$handles = mpull($handles, 'renderHovercardLink');
|
||||||
$handles = phutil_implode_html(', ', $handles);
|
$handles = phutil_implode_html(', ', $handles);
|
||||||
return $handles;
|
return $handles;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue