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

Remove implode_selected_handle_links()

Summary: Ref T7689. Use the newer, less-janky stuff for rendering handles.

Test Plan:
- Viewed a revision hovercard; viewed "Author", viewed "Reviewers", viewed "Tasks".
- Viewed a task hovercard; viewed "Assigned To"; viewed "Projects"; viewed other edge fields.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7689

Differential Revision: https://secure.phabricator.com/D12209
This commit is contained in:
epriestley 2015-03-30 07:46:17 -07:00
parent e1eafd784e
commit 0f52fc771d
3 changed files with 19 additions and 56 deletions

View file

@ -38,30 +38,21 @@ final class DifferentialHovercardEventListener
$edge_query->execute();
$tasks = $edge_query->getDestinationPHIDs();
$phids = array_merge(
array(
$rev->getAuthorPHID(),
),
$reviewer_phids,
$tasks);
$handles = id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs($phids)
->execute();
$hovercard->setTitle('D'.$rev->getID());
$hovercard->setDetail($rev->getTitle());
$hovercard->addField(pht('Author'),
$handles[$rev->getAuthorPHID()]->renderLink());
$hovercard->addField(
pht('Author'),
$viewer->renderHandle($rev->getAuthorPHID()));
$hovercard->addField(pht('Reviewers'),
implode_selected_handle_links(', ', $handles, $reviewer_phids));
$hovercard->addField(
pht('Reviewers'),
$viewer->renderHandleList($reviewer_phids)->setAsInline(true));
if ($tasks) {
$hovercard->addField(pht('%s Task(s)', new PhutilNumber(count($tasks))),
implode_selected_handle_links(', ', $handles, $tasks));
$hovercard->addField(
pht('Tasks'),
$viewer->renderHandleList($tasks)->setAsInline(true));
}
if ($rev->getSummary()) {

View file

@ -43,21 +43,16 @@ final class ManiphestHovercardEventListener extends PhabricatorEventListener {
$owner_phid = $task->getOwnerPHID();
$phids = array_filter(array_merge(
array($owner_phid),
$edge_phids));
$viewer_handles = $this->loadHandles($phids, $viewer);
$hovercard->setTitle(pht('T%d', $task->getID()))
$hovercard
->setTitle(pht('T%d', $task->getID()))
->setDetail($task->getTitle());
$owner = phutil_tag('em', array(), pht('None'));
if ($owner_phid) {
$owner = $viewer_handles[$owner_phid]->renderLink();
$owner = $viewer->renderHandle($owner_phid);
} else {
$owner = phutil_tag('em', array(), pht('None'));
}
$hovercard->addField(pht('Assigned to'), $owner);
$hovercard->addField(pht('Assigned To'), $owner);
if ($edge_phids) {
$edge_types = array(
@ -79,9 +74,10 @@ final class ManiphestHovercardEventListener extends PhabricatorEventListener {
$hovercard->addField(
$edge_name,
implode_selected_handle_links(', ', $viewer_handles,
array_keys($edges[$edge_type]))
->appendHTML($edge_overflow));
array(
$viewer->renderHandleList(array_keys($edges[$edge_type])),
$edge_overflow,
));
}
}
}
@ -91,11 +87,4 @@ final class ManiphestHovercardEventListener extends PhabricatorEventListener {
$event->setValue('hovercard', $hovercard);
}
protected function loadHandles(array $phids, $viewer) {
return id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs($phids)
->execute();
}
}

View file

@ -1,17 +0,0 @@
<?php
/**
* Implodes selected handles from a pool of handles. Useful if you load handles
* for various phids, but only render a few of them at a time.
*
* @return PhutilSafeHTML
*/
function implode_selected_handle_links($glue, array $handles, array $phids) {
$items = array();
foreach ($phids as $phid) {
$items[] = $handles[$phid]->renderLink();
}
return phutil_implode_html($glue, $items);
}