From 9a270efe8a74c72bfd6f033cc9bdfb94b2c658f1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Sep 2015 04:45:43 -0700 Subject: [PATCH] Tidy up some Drydock UI Summary: Ref T9253. We had some un-modern use of UI elements, clean that up. Add a tab for showing slot locks so you don't have to fish around in the database. Test Plan: Looked at blueprints, resources and leases. Looked at slot locks. Reviewers: chad, hach-que Reviewed By: chad, hach-que Maniphest Tasks: T9253 Differential Revision: https://secure.phabricator.com/D14119 --- .../DrydockBlueprintViewController.php | 6 +++- .../drydock/controller/DrydockController.php | 28 +++++++++++++++++++ .../controller/DrydockLeaseViewController.php | 13 +++++++-- .../DrydockResourceViewController.php | 21 ++++++++++---- .../drydock/phid/DrydockBlueprintPHIDType.php | 1 + 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/applications/drydock/controller/DrydockBlueprintViewController.php b/src/applications/drydock/controller/DrydockBlueprintViewController.php index 33a27264b8..5da92539cf 100644 --- a/src/applications/drydock/controller/DrydockBlueprintViewController.php +++ b/src/applications/drydock/controller/DrydockBlueprintViewController.php @@ -61,6 +61,10 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController { $viewer, $properties); + $resource_box = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Resources')) + ->setObjectList($resource_list); + $timeline = $this->buildTransactionTimeline( $blueprint, new DrydockBlueprintTransactionQuery()); @@ -70,7 +74,7 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController { array( $crumbs, $object_box, - $resource_list, + $resource_box, $timeline, ), array( diff --git a/src/applications/drydock/controller/DrydockController.php b/src/applications/drydock/controller/DrydockController.php index c2fa3dae72..3e3d83cc1d 100644 --- a/src/applications/drydock/controller/DrydockController.php +++ b/src/applications/drydock/controller/DrydockController.php @@ -8,4 +8,32 @@ abstract class DrydockController extends PhabricatorController { return $this->buildSideNavView()->getMenu(); } + protected function buildLocksTab($owner_phid) { + $locks = DrydockSlotLock::loadLocks($owner_phid); + + $rows = array(); + foreach ($locks as $lock) { + $rows[] = array( + $lock->getID(), + $lock->getLockKey(), + ); + } + + $table = id(new AphrontTableView($rows)) + ->setNoDataString(pht('No slot locks held.')) + ->setHeaders( + array( + pht('ID'), + pht('Lock Key'), + )) + ->setColumnClasses( + array( + null, + 'wide', + )); + + return id(new PHUIPropertyListView()) + ->addRawContent($table); + } + } diff --git a/src/applications/drydock/controller/DrydockLeaseViewController.php b/src/applications/drydock/controller/DrydockLeaseViewController.php index 562e466311..aed1f6416f 100644 --- a/src/applications/drydock/controller/DrydockLeaseViewController.php +++ b/src/applications/drydock/controller/DrydockLeaseViewController.php @@ -42,18 +42,25 @@ final class DrydockLeaseViewController extends DrydockLeaseController { $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, $lease_uri); + $locks = $this->buildLocksTab($lease->getPHID()); + $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) - ->addPropertyList($properties); + ->addPropertyList($properties, pht('Properties')) + ->addPropertyList($locks, pht('Slot Locks')); + + $log_box = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Lease Logs')) + ->setTable($log_table); return $this->buildApplicationPage( array( $crumbs, $object_box, - $log_table, + $log_box, ), array( - 'title' => $title, + 'title' => $title, )); } diff --git a/src/applications/drydock/controller/DrydockResourceViewController.php b/src/applications/drydock/controller/DrydockResourceViewController.php index afa0fb49fd..d4a37af33c 100644 --- a/src/applications/drydock/controller/DrydockResourceViewController.php +++ b/src/applications/drydock/controller/DrydockResourceViewController.php @@ -54,16 +54,27 @@ final class DrydockResourceViewController extends DrydockResourceController { $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Resource %d', $resource->getID())); + $locks = $this->buildLocksTab($resource->getPHID()); + $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) - ->addPropertyList($properties); + ->addPropertyList($properties, pht('Properties')) + ->addPropertyList($locks, pht('Slot Locks')); + + $lease_box = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Leases')) + ->setObjectList($lease_list); + + $log_box = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Resource Logs')) + ->setTable($log_table); return $this->buildApplicationPage( array( $crumbs, $object_box, - $lease_list, - $log_table, + $lease_box, + $log_box, ), array( 'title' => $title, @@ -95,6 +106,7 @@ final class DrydockResourceViewController extends DrydockResourceController { private function buildPropertyListView( DrydockResource $resource, PhabricatorActionListView $actions) { + $viewer = $this->getViewer(); $view = new PHUIPropertyListView(); $view->setActionList($actions); @@ -110,10 +122,9 @@ final class DrydockResourceViewController extends DrydockResourceController { pht('Resource Type'), $resource->getType()); - // TODO: Load handle. $view->addProperty( pht('Blueprint'), - $resource->getBlueprintPHID()); + $viewer->renderHandle($resource->getBlueprintPHID())); $attributes = $resource->getAttributes(); if ($attributes) { diff --git a/src/applications/drydock/phid/DrydockBlueprintPHIDType.php b/src/applications/drydock/phid/DrydockBlueprintPHIDType.php index b61eb396b9..86eeb7f3c5 100644 --- a/src/applications/drydock/phid/DrydockBlueprintPHIDType.php +++ b/src/applications/drydock/phid/DrydockBlueprintPHIDType.php @@ -29,6 +29,7 @@ final class DrydockBlueprintPHIDType extends PhabricatorPHIDType { $blueprint = $objects[$phid]; $id = $blueprint->getID(); + $handle->setName($blueprint->getBlueprintName()); $handle->setURI("/drydock/blueprint/{$id}/"); } }