Page MenuHomePhabricator

D13687.id33087.diff
No OneTemporary

D13687.id33087.diff

Index: src/applications/drydock/controller/DrydockLeaseViewController.php
===================================================================
--- src/applications/drydock/controller/DrydockLeaseViewController.php
+++ src/applications/drydock/controller/DrydockLeaseViewController.php
@@ -15,6 +15,7 @@
$lease = id(new DrydockLeaseQuery())
->setViewer($viewer)
->withIDs(array($this->id))
+ ->needOwnerHandles(true)
->executeOne();
if (!$lease) {
return new Aphront404Response();
@@ -154,6 +155,16 @@
pht('Unknown 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'));
Index: src/applications/drydock/controller/DrydockResourceViewController.php
===================================================================
--- src/applications/drydock/controller/DrydockResourceViewController.php
+++ src/applications/drydock/controller/DrydockResourceViewController.php
@@ -39,6 +39,7 @@
DrydockLeaseStatus::STATUS_ACTIVE,
DrydockLeaseStatus::STATUS_PENDING,
))
+ ->needOwnerHandles(true)
->execute();
$lease_list = id(new DrydockLeaseListView())
Index: src/applications/drydock/query/DrydockLeaseQuery.php
===================================================================
--- src/applications/drydock/query/DrydockLeaseQuery.php
+++ 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;
@@ -33,6 +34,11 @@
return $this;
}
+ public function needOwnerHandles($owner_handles) {
+ $this->needOwnerHandles = $owner_handles;
+ return $this;
+ }
+
protected function loadPage() {
$table = new DrydockLease();
$conn_r = $table->establishConnection('r');
@@ -75,6 +81,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 buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
Index: src/applications/drydock/query/DrydockLeaseSearchEngine.php
===================================================================
--- src/applications/drydock/query/DrydockLeaseSearchEngine.php
+++ 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) {
Index: src/applications/drydock/storage/DrydockLease.php
===================================================================
--- src/applications/drydock/storage/DrydockLease.php
+++ src/applications/drydock/storage/DrydockLease.php
@@ -14,6 +14,7 @@
protected $isTransientLease = 0;
private $resource = self::ATTACHABLE;
+ private $ownerHandle = self::ATTACHABLE;
private $releaseOnDestruction;
/**
@@ -99,6 +100,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',
Index: src/applications/drydock/view/DrydockLeaseListView.php
===================================================================
--- src/applications/drydock/view/DrydockLeaseListView.php
+++ 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 {
Index: src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
===================================================================
--- src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
+++ src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
@@ -27,6 +27,14 @@
foreach ($handles as $phid => $handle) {
$build_target = $objects[$phid];
+
+ $id = $build_target->getBuild()->getID();
+ $handles[$phid]->setName(pht(
+ '\'%s\' on Build %d: %s',
+ $build_target->getName(),
+ $id,
+ $build_target->getBuild()->getName()));
+ $handles[$phid]->setURI('/harbormaster/build/'.$id.'/');
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 4:08 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7729265
Default Alt Text
D13687.id33087.diff (5 KB)

Event Timeline