diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 1efe9749e7..4d6ef65368 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3204,6 +3204,7 @@ phutil_register_library_map(array( 'PhabricatorOwnersDefaultViewCapability' => 'applications/owners/capability/PhabricatorOwnersDefaultViewCapability.php', 'PhabricatorOwnersDetailController' => 'applications/owners/controller/PhabricatorOwnersDetailController.php', 'PhabricatorOwnersEditController' => 'applications/owners/controller/PhabricatorOwnersEditController.php', + 'PhabricatorOwnersHovercardEngineExtension' => 'applications/owners/engineextension/PhabricatorOwnersHovercardEngineExtension.php', 'PhabricatorOwnersListController' => 'applications/owners/controller/PhabricatorOwnersListController.php', 'PhabricatorOwnersOwner' => 'applications/owners/storage/PhabricatorOwnersOwner.php', 'PhabricatorOwnersPackage' => 'applications/owners/storage/PhabricatorOwnersPackage.php', @@ -8406,6 +8407,7 @@ phutil_register_library_map(array( 'PhabricatorOwnersDefaultViewCapability' => 'PhabricatorPolicyCapability', 'PhabricatorOwnersDetailController' => 'PhabricatorOwnersController', 'PhabricatorOwnersEditController' => 'PhabricatorOwnersController', + 'PhabricatorOwnersHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 'PhabricatorOwnersListController' => 'PhabricatorOwnersController', 'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersPackage' => array( diff --git a/src/applications/owners/engineextension/PhabricatorOwnersHovercardEngineExtension.php b/src/applications/owners/engineextension/PhabricatorOwnersHovercardEngineExtension.php new file mode 100644 index 0000000000..744d3fbea2 --- /dev/null +++ b/src/applications/owners/engineextension/PhabricatorOwnersHovercardEngineExtension.php @@ -0,0 +1,89 @@ +getViewer(); + $phids = mpull($objects, 'getPHID'); + + $packages = id(new PhabricatorOwnersPackageQuery()) + ->setViewer($viewer) + ->withPHIDs($phids) + ->execute(); + $packages = mpull($packages, null, 'getPHID'); + + return array( + 'packages' => $packages, + ); + } + + public function renderHovercard( + PHUIHovercardView $hovercard, + PhabricatorObjectHandle $handle, + $object, + $data) { + + $viewer = $this->getViewer(); + + $package = idx($data['packages'], $object->getPHID()); + if (!$package) { + return; + } + + $title = pht('%s: %s', 'O'.$package->getID(), $package->getName()); + $hovercard->setTitle($title); + + $dominion = $package->getDominion(); + $dominion_map = PhabricatorOwnersPackage::getDominionOptionsMap(); + $spec = idx($dominion_map, $dominion, array()); + $name = idx($spec, 'short', $dominion); + $hovercard->addField(pht('Dominion'), $name); + + $auto = $package->getAutoReview(); + $autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap(); + $spec = idx($autoreview_map, $auto, array()); + $name = idx($spec, 'name', $auto); + $hovercard->addField(pht('Auto Review'), $name); + + if ($package->isArchived()) { + $tag = id(new PHUITagView()) + ->setName(pht('Archived')) + ->setShade(PHUITagView::COLOR_INDIGO) + ->setType(PHUITagView::TYPE_OBJECT); + $hovercard->addTag($tag); + } + + $owner_phids = $package->getOwnerPHIDs(); + + $hovercard->addField( + pht('Owners'), + $viewer->renderHandleList($owner_phids)->setAsInline(true)); + + $description = $package->getDescription(); + if (strlen($description)) { + $description = id(new PhutilUTF8StringTruncator()) + ->setMaximumGlyphs(120) + ->truncateString($description); + + $hovercard->addField(pht('Description'), $description); + } + + } + +} diff --git a/src/view/phui/PHUIHovercardView.php b/src/view/phui/PHUIHovercardView.php index 115964f191..b99fc8153e 100644 --- a/src/view/phui/PHUIHovercardView.php +++ b/src/view/phui/PHUIHovercardView.php @@ -112,14 +112,17 @@ final class PHUIHovercardView extends AphrontTagView { $body = array(); + $body_title = null; if ($this->detail) { $body_title = $this->detail; - } else { + } else if (!$this->fields) { // Fallback for object handles $body_title = $handle->getFullName(); } - $body[] = phutil_tag_div('phui-hovercard-body-header', $body_title); + if ($body_title) { + $body[] = phutil_tag_div('phui-hovercard-body-header', $body_title); + } foreach ($this->fields as $field) { $item = array(