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

Simplify how tag lists manage their handles

Summary: Fixes T11493. This code is a little bit weird/clever, simplify it so that we always cast the handles to an array early on.

Test Plan: {F1767668}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11493

Differential Revision: https://secure.phabricator.com/D16422
This commit is contained in:
epriestley 2016-08-19 10:43:41 -07:00
parent e7aa874f5e
commit 4d175ac709

View file

@ -61,15 +61,21 @@ final class PHUIHandleTagListView extends AphrontTagView {
} }
} }
if ($this->limit && (count($handles) > $this->limit)) { // We may be passed a PhabricatorHandleList; if we are, convert it into
if (!is_array($handles)) { // a normal array.
$handles = iterator_to_array($handles); if (!is_array($handles)) {
} $handles = iterator_to_array($handles);
$handles = array_slice($handles, 0, $this->limit); }
$over_limit = $this->limit && (count($handles) > $this->limit);
if ($over_limit) {
$visible = array_slice($handles, 0, $this->limit);
} else {
$visible = $handles;
} }
$list = array(); $list = array();
foreach ($handles as $handle) { foreach ($visible as $handle) {
$tag = $handle->renderTag(); $tag = $handle->renderTag();
if ($this->showHovercards) { if ($this->showHovercards) {
$tag->setPHID($handle->getPHID()); $tag->setPHID($handle->getPHID());
@ -84,21 +90,21 @@ final class PHUIHandleTagListView extends AphrontTagView {
)); ));
} }
if ($this->limit) { if ($over_limit) {
if (count($this->handles) > $this->limit) { $tip_text = implode(', ', mpull($handles, 'getName'));
$tip_text = implode(', ', mpull($this->handles, 'getName'));
$more = $this->newPlaceholderTag() Javelin::initBehavior('phabricator-tooltips');
->setName("\xE2\x80\xA6")
->addSigil('has-tooltip')
->setMetadata(
array(
'tip' => $tip_text,
'size' => 200,
));
$list[] = $this->newItem($more); $more = $this->newPlaceholderTag()
} ->setName("\xE2\x80\xA6")
->addSigil('has-tooltip')
->setMetadata(
array(
'tip' => $tip_text,
'size' => 200,
));
$list[] = $this->newItem($more);
} }
return $list; return $list;