@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a detail view for resources in Drydock

Summary: Nothing fancy here, just add a detail page.

Test Plan:
Looked at detail page.

{F24808}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, vrana

Maniphest Tasks: T2015

Differential Revision: https://secure.phabricator.com/D3995

+135 -23
+2
src/__phutil_library_map__.php
··· 437 437 'DrydockResource' => 'applications/drydock/storage/DrydockResource.php', 438 438 'DrydockResourceListController' => 'applications/drydock/controller/DrydockResourceListController.php', 439 439 'DrydockResourceStatus' => 'applications/drydock/constants/DrydockResourceStatus.php', 440 + 'DrydockResourceViewController' => 'applications/drydock/controller/DrydockResourceViewController.php', 440 441 'DrydockSSHCommandInterface' => 'applications/drydock/interface/command/DrydockSSHCommandInterface.php', 441 442 'DrydockWebrootInterface' => 'applications/drydock/interface/webroot/DrydockWebrootInterface.php', 442 443 'FeedPublisherWorker' => 'applications/feed/worker/FeedPublisherWorker.php', ··· 1667 1668 'DrydockResource' => 'DrydockDAO', 1668 1669 'DrydockResourceListController' => 'DrydockController', 1669 1670 'DrydockResourceStatus' => 'DrydockConstants', 1671 + 'DrydockResourceViewController' => 'DrydockController', 1670 1672 'DrydockSSHCommandInterface' => 'DrydockCommandInterface', 1671 1673 'DrydockWebrootInterface' => 'DrydockInterface', 1672 1674 'FeedPublisherWorker' => 'PhabricatorWorker',
+4 -1
src/applications/drydock/application/PhabricatorApplicationDrydock.php
··· 30 30 return array( 31 31 '/drydock/' => array( 32 32 '' => 'DrydockResourceListController', 33 - 'resource/' => 'DrydockResourceListController', 33 + 'resource/' => array( 34 + '' => 'DrydockResourceListController', 35 + '(?P<id>[1-9]\d*)/' => 'DrydockResourceViewController', 36 + ), 34 37 'lease/' => array( 35 38 '' => 'DrydockLeaseListController', 36 39 '(?P<id>[1-9]\d*)/' => 'DrydockLeaseViewController',
+18 -2
src/applications/drydock/controller/DrydockController.php
··· 39 39 40 40 $rows = array(); 41 41 foreach ($logs as $log) { 42 + $resource_uri = '/resource/'.$log->getResourceID().'/'; 43 + $resource_uri = $this->getApplicationURI($resource_uri); 44 + 45 + $lease_uri = '/lease/'.$log->getLeaseID().'/'; 46 + $lease_uri = $this->getApplicationURI($lease_uri); 47 + 42 48 $rows[] = array( 43 - $log->getResourceID(), 44 - $log->getLeaseID(), 49 + phutil_render_tag( 50 + 'a', 51 + array( 52 + 'href' => $resource_uri, 53 + ), 54 + phutil_escape_html($log->getResourceID())), 55 + phutil_render_tag( 56 + 'a', 57 + array( 58 + 'href' => $lease_uri, 59 + ), 60 + phutil_escape_html($log->getLeaseID())), 45 61 phutil_escape_html($log->getMessage()), 46 62 phabricator_datetime($log->getEpoch(), $user), 47 63 );
+15 -11
src/applications/drydock/controller/DrydockLeaseListController.php
··· 18 18 $pager->getPageSize() + 1); 19 19 $data = $pager->sliceResults($data); 20 20 21 - $phids = mpull($data, 'getOwnerPHID'); 22 - $handles = $this->loadViewerHandles($phids); 23 - 24 21 $resource_ids = mpull($data, 'getResourceID'); 25 22 $resources = array(); 26 23 if ($resource_ids) { ··· 32 29 $rows = array(); 33 30 foreach ($data as $lease) { 34 31 $resource = idx($resources, $lease->getResourceID()); 32 + 33 + $lease_uri = '/lease/'.$lease->getID().'/'; 34 + $lease_uri = $this->getApplicationURI($lease_uri); 35 + 36 + $resource_uri = '/resource/'.$lease->getResourceID().'/'; 37 + $resource_uri = $this->getApplicationURI($resource_uri); 38 + 35 39 $rows[] = array( 36 40 phutil_render_tag( 37 41 'a', 38 42 array( 39 - 'href' => $this->getApplicationURI('/lease/'.$lease->getID().'/'), 43 + 'href' => $lease_uri, 40 44 ), 41 45 $lease->getID()), 46 + phutil_render_tag( 47 + 'a', 48 + array( 49 + 'href' => $resource_uri, 50 + ), 51 + $lease->getResourceID()), 42 52 DrydockLeaseStatus::getNameForStatus($lease->getStatus()), 43 53 phutil_escape_html($lease->getResourceType()), 44 - ($lease->getOwnerPHID() 45 - ? $handles[$lease->getOwnerPHID()]->renderLink() 46 - : null), 47 - $lease->getResourceID(), 48 54 ($resource 49 55 ? phutil_escape_html($resource->getName()) 50 56 : null), ··· 56 62 $table->setHeaders( 57 63 array( 58 64 'ID', 65 + 'Resource ID', 59 66 'Status', 60 67 'Resource Type', 61 - 'Resource ID', 62 - 'Owner', 63 68 'Resource', 64 69 'Created', 65 70 )); 66 71 $table->setColumnClasses( 67 72 array( 68 - '', 69 73 '', 70 74 '', 71 75 '',
+9 -9
src/applications/drydock/controller/DrydockResourceListController.php
··· 17 17 $pager->getPageSize() + 1); 18 18 $data = $pager->sliceResults($data); 19 19 20 - $phids = mpull($data, 'getOwnerPHID'); 21 - $handles = $this->loadViewerHandles($phids); 22 - 23 20 $rows = array(); 24 21 foreach ($data as $resource) { 22 + $resource_uri = '/resource/'.$resource->getID().'/'; 23 + $resource_uri = $this->getApplicationURI($resource_uri); 24 + 25 25 $rows[] = array( 26 - $resource->getID(), 27 - ($resource->getOwnerPHID() 28 - ? $handles[$resource->getOwnerPHID()]->renderLink() 29 - : null), 26 + phutil_render_tag( 27 + 'a', 28 + array( 29 + 'href' => $resource_uri, 30 + ), 31 + $resource->getID()), 30 32 phutil_escape_html($resource->getType()), 31 33 DrydockResourceStatus::getNameForStatus($resource->getStatus()), 32 34 phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), ··· 38 40 $table->setHeaders( 39 41 array( 40 42 'ID', 41 - 'Owner', 42 43 'Type', 43 44 'Status', 44 45 'Resource', ··· 46 47 )); 47 48 $table->setColumnClasses( 48 49 array( 49 - '', 50 50 '', 51 51 '', 52 52 '',
+87
src/applications/drydock/controller/DrydockResourceViewController.php
··· 1 + <?php 2 + 3 + final class DrydockResourceViewController extends DrydockController { 4 + 5 + private $id; 6 + 7 + public function willProcessRequest(array $data) { 8 + $this->id = $data['id']; 9 + } 10 + 11 + public function processRequest() { 12 + $request = $this->getRequest(); 13 + $user = $request->getUser(); 14 + 15 + $nav = $this->buildSideNav('resource'); 16 + 17 + $resource = id(new DrydockResource())->load($this->id); 18 + if (!$resource) { 19 + return new Aphront404Response(); 20 + } 21 + 22 + $title = 'Resource '.$resource->getID().' '.$resource->getName(); 23 + 24 + $header = id(new PhabricatorHeaderView()) 25 + ->setHeader($title); 26 + 27 + $actions = $this->buildActionListView($resource); 28 + $properties = $this->buildPropertyListView($resource); 29 + 30 + $resource_uri = 'resource/'.$resource->getID().'/'; 31 + $resource_uri = $this->getApplicationURI($resource_uri); 32 + 33 + $pager = new AphrontPagerView(); 34 + $pager->setURI(new PhutilURI($resource_uri), 'offset'); 35 + $pager->setOffset($request->getInt('offset')); 36 + 37 + $logs = id(new DrydockLogQuery()) 38 + ->withResourceIDs(array($resource->getID())) 39 + ->executeWithOffsetPager($pager); 40 + 41 + $log_table = $this->buildLogTableView($logs); 42 + $log_table->appendChild($pager); 43 + 44 + $nav->appendChild( 45 + array( 46 + $header, 47 + $actions, 48 + $properties, 49 + $log_table, 50 + )); 51 + 52 + return $this->buildApplicationPage( 53 + $nav, 54 + array( 55 + 'device' => true, 56 + 'title' => $title, 57 + )); 58 + 59 + } 60 + 61 + private function buildActionListView(DrydockResource $resource) { 62 + $view = id(new PhabricatorActionListView()) 63 + ->setUser($this->getRequest()->getUser()) 64 + ->setObject($resource); 65 + 66 + return $view; 67 + } 68 + 69 + private function buildPropertyListView(DrydockResource $resource) { 70 + $view = new PhabricatorPropertyListView(); 71 + 72 + $status = $resource->getStatus(); 73 + $status = DrydockResourceStatus::getNameForStatus($status); 74 + $status = phutil_escape_html($status); 75 + 76 + $view->addProperty( 77 + pht('Status'), 78 + $status); 79 + 80 + $view->addProperty( 81 + pht('Resource Type'), 82 + phutil_escape_html($resource->getType())); 83 + 84 + return $view; 85 + } 86 + 87 + }