Page MenuHomePhabricator

D13687.id33788.diff
No OneTemporary

D13687.id33788.diff

diff --git a/src/applications/drydock/controller/DrydockLeaseViewController.php b/src/applications/drydock/controller/DrydockLeaseViewController.php
--- a/src/applications/drydock/controller/DrydockLeaseViewController.php
+++ b/src/applications/drydock/controller/DrydockLeaseViewController.php
@@ -9,6 +9,7 @@
$lease = id(new DrydockLeaseQuery())
->setViewer($viewer)
->withIDs(array($id))
+ ->needOwnerHandles(true)
->executeOne();
if (!$lease) {
return new Aphront404Response();
@@ -130,6 +131,16 @@
pht('No Resource'));
}
+ if ($lease->getOwnerHandle() !== null) {
+ $view->addProperty(
+ pht('Owner'),
+ $lease->getOwnerHandle()->renderLink());
+ } else {
+ $view->addProperty(
+ pht('Owner'),
+ phutil_tag('em', array(), pht('No Owner')));
+ }
+
$view->addProperty(
pht('Lease Type'),
$lease->getIsTransientLease() ? pht('Transient') : pht('Standard'));
diff --git a/src/applications/drydock/controller/DrydockResourceViewController.php b/src/applications/drydock/controller/DrydockResourceViewController.php
--- a/src/applications/drydock/controller/DrydockResourceViewController.php
+++ b/src/applications/drydock/controller/DrydockResourceViewController.php
@@ -33,6 +33,7 @@
DrydockLeaseStatus::STATUS_ACTIVE,
DrydockLeaseStatus::STATUS_PENDING,
))
+ ->needOwnerHandles(true)
->execute();
$lease_list = id(new DrydockLeaseListView())
diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php
--- a/src/applications/drydock/query/DrydockLeaseQuery.php
+++ b/src/applications/drydock/query/DrydockLeaseQuery.php
@@ -7,6 +7,7 @@
private $resourceIDs;
private $statuses;
private $datasourceQuery;
+ private $needOwnerHandles;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -41,6 +42,11 @@
return $this->loadStandardPage($this->newResultObject());
}
+ public function needOwnerHandles($owner_handles) {
+ $this->needOwnerHandles = $owner_handles;
+ return $this;
+ }
+
protected function willFilterPage(array $leases) {
$resource_ids = array_filter(mpull($leases, 'getResourceID'));
if ($resource_ids) {
@@ -68,6 +74,30 @@
return $leases;
}
+ protected function didFilterPage(array $page) {
+ if ($this->needOwnerHandles) {
+ $owner_phids = mpull($page, 'getOwnerPHID');
+ foreach ($owner_phids as $key => $phid) {
+ if ($phid === null) {
+ unset($owner_phids[$key]);
+ }
+ }
+
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withPHIDs($owner_phids)
+ ->execute();
+ $handles = mpull($handles, null, 'getPHID');
+
+ foreach ($page as $lease) {
+ $lease->attachOwnerHandle(idx($handles, $lease->getOwnerPHID()));
+ }
+ }
+
+ return $page;
+ }
+
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
diff --git a/src/applications/drydock/query/DrydockLeaseSearchEngine.php b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
--- a/src/applications/drydock/query/DrydockLeaseSearchEngine.php
+++ b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
@@ -23,6 +23,7 @@
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new DrydockLeaseQuery());
+ $query->needOwnerHandles(true);
$statuses = $saved->getParameter('statuses', array());
if ($statuses) {
diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -13,6 +13,7 @@
protected $isTransientLease = 0;
private $resource = self::ATTACHABLE;
+ private $ownerHandle = self::ATTACHABLE;
private $releaseOnDestruction;
/**
@@ -93,6 +94,15 @@
return ($this->resource !== null);
}
+ public function getOwnerHandle() {
+ return $this->assertAttached($this->ownerHandle);
+ }
+
+ public function attachOwnerHandle($handle) {
+ $this->ownerHandle = $handle;
+ return $this;
+ }
+
public function loadResource() {
return id(new DrydockResource())->loadOneWhere(
'id = %d',
diff --git a/src/applications/drydock/view/DrydockLeaseListView.php b/src/applications/drydock/view/DrydockLeaseListView.php
--- a/src/applications/drydock/view/DrydockLeaseListView.php
+++ b/src/applications/drydock/view/DrydockLeaseListView.php
@@ -41,6 +41,12 @@
$item->addAttribute($status);
$item->setEpoch($lease->getDateCreated());
+ if ($lease->getOwnerHandle() !== null) {
+ $item->addAttribute($lease->getOwnerHandle()->renderLink());
+ } else {
+ $item->addAttribute(phutil_tag('em', array(), 'No Owner'));
+ }
+
if ($lease->isActive()) {
$item->setStatusIcon('fa-dot-circle-o green');
} else {
diff --git a/src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php b/src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
--- a/src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
+++ b/src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
@@ -35,7 +35,11 @@
$build_id = $build->getID();
$uri = "/harbormaster/build/{$build_id}/";
- $handle->setName(pht('Build Target %d', $target_id));
+ $handle->setName(pht(
+ '\'%s\' on Build %d: %s',
+ $target->getName(),
+ $build_id,
+ $build->getName()));
$handle->setURI($uri);
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 27, 1:28 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225209
Default Alt Text
D13687.id33788.diff (5 KB)

Event Timeline