1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Add an Owners Package hovercard

Summary: Ref T12600. Basically all the property (not path) information on a hovercard for owner packages.

Test Plan:
Create a package with LOTS OF RULES. Test it as open and archived states.

{F4923441}

{F4923444}

Reviewers: epriestley, jmeador

Reviewed By: jmeador

Subscribers: jmeador, Korvin

Maniphest Tasks: T12600

Differential Revision: https://secure.phabricator.com/D17793
This commit is contained in:
Chad Little 2017-04-25 17:29:47 -07:00
parent d70d09c02c
commit 7824710522
3 changed files with 96 additions and 2 deletions

View file

@ -3204,6 +3204,7 @@ phutil_register_library_map(array(
'PhabricatorOwnersDefaultViewCapability' => 'applications/owners/capability/PhabricatorOwnersDefaultViewCapability.php', 'PhabricatorOwnersDefaultViewCapability' => 'applications/owners/capability/PhabricatorOwnersDefaultViewCapability.php',
'PhabricatorOwnersDetailController' => 'applications/owners/controller/PhabricatorOwnersDetailController.php', 'PhabricatorOwnersDetailController' => 'applications/owners/controller/PhabricatorOwnersDetailController.php',
'PhabricatorOwnersEditController' => 'applications/owners/controller/PhabricatorOwnersEditController.php', 'PhabricatorOwnersEditController' => 'applications/owners/controller/PhabricatorOwnersEditController.php',
'PhabricatorOwnersHovercardEngineExtension' => 'applications/owners/engineextension/PhabricatorOwnersHovercardEngineExtension.php',
'PhabricatorOwnersListController' => 'applications/owners/controller/PhabricatorOwnersListController.php', 'PhabricatorOwnersListController' => 'applications/owners/controller/PhabricatorOwnersListController.php',
'PhabricatorOwnersOwner' => 'applications/owners/storage/PhabricatorOwnersOwner.php', 'PhabricatorOwnersOwner' => 'applications/owners/storage/PhabricatorOwnersOwner.php',
'PhabricatorOwnersPackage' => 'applications/owners/storage/PhabricatorOwnersPackage.php', 'PhabricatorOwnersPackage' => 'applications/owners/storage/PhabricatorOwnersPackage.php',
@ -8406,6 +8407,7 @@ phutil_register_library_map(array(
'PhabricatorOwnersDefaultViewCapability' => 'PhabricatorPolicyCapability', 'PhabricatorOwnersDefaultViewCapability' => 'PhabricatorPolicyCapability',
'PhabricatorOwnersDetailController' => 'PhabricatorOwnersController', 'PhabricatorOwnersDetailController' => 'PhabricatorOwnersController',
'PhabricatorOwnersEditController' => 'PhabricatorOwnersController', 'PhabricatorOwnersEditController' => 'PhabricatorOwnersController',
'PhabricatorOwnersHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'PhabricatorOwnersListController' => 'PhabricatorOwnersController', 'PhabricatorOwnersListController' => 'PhabricatorOwnersController',
'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO',
'PhabricatorOwnersPackage' => array( 'PhabricatorOwnersPackage' => array(

View file

@ -0,0 +1,89 @@
<?php
final class PhabricatorOwnersHovercardEngineExtension
extends PhabricatorHovercardEngineExtension {
const EXTENSIONKEY = 'owners';
public function isExtensionEnabled() {
return PhabricatorApplication::isClassInstalled(
'PhabricatorOwnersApplication');
}
public function getExtensionName() {
return pht('Owner Packages');
}
public function canRenderObjectHovercard($object) {
return ($object instanceof PhabricatorOwnersPackage);
}
public function willRenderHovercards(array $objects) {
$viewer = $this->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);
}
}
}

View file

@ -112,14 +112,17 @@ final class PHUIHovercardView extends AphrontTagView {
$body = array(); $body = array();
$body_title = null;
if ($this->detail) { if ($this->detail) {
$body_title = $this->detail; $body_title = $this->detail;
} else { } else if (!$this->fields) {
// Fallback for object handles // Fallback for object handles
$body_title = $handle->getFullName(); $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) { foreach ($this->fields as $field) {
$item = array( $item = array(