@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

Add Drydock logs to the RepositoryOperation UI

Summary:
Depends on D19671. Ref T13197. See PHI873.

Expose logs in the RepositoryOperation UI. Nothing writes the logs yet, so these interfaces are currently always empty.

Test Plan:
{F5887102}

{F5887103}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13197

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

+79 -4
+2
src/applications/drydock/application/PhabricatorDrydockApplication.php
··· 93 93 '' => 'DrydockRepositoryOperationViewController', 94 94 'status/' => 'DrydockRepositoryOperationStatusController', 95 95 'dismiss/' => 'DrydockRepositoryOperationDismissController', 96 + 'logs/(?:query/(?P<queryKey>[^/]+)/)?' => 97 + 'DrydockLogListController', 96 98 ), 97 99 ), 98 100 ),
+32
src/applications/drydock/controller/DrydockLogController.php
··· 6 6 private $blueprint; 7 7 private $resource; 8 8 private $lease; 9 + private $operation; 9 10 10 11 public function setBlueprint(DrydockBlueprint $blueprint) { 11 12 $this->blueprint = $blueprint; ··· 34 35 return $this->lease; 35 36 } 36 37 38 + public function setOperation(DrydockRepositoryOperation $operation) { 39 + $this->operation = $operation; 40 + return $this; 41 + } 42 + 43 + public function getOperation() { 44 + return $this->operation; 45 + } 46 + 37 47 public function buildSideNavView() { 38 48 $nav = new AphrontSideNavFilterView(); 39 49 $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); ··· 56 66 $engine->setLease($lease); 57 67 } 58 68 69 + $operation = $this->getOperation(); 70 + if ($operation) { 71 + $engine->setOperation($operation); 72 + } 73 + 59 74 $engine->addNavigationItems($nav->getMenu()); 60 75 61 76 $nav->selectFilter(null); ··· 66 81 protected function buildApplicationCrumbs() { 67 82 $crumbs = parent::buildApplicationCrumbs(); 68 83 84 + $viewer = $this->getViewer(); 85 + 69 86 $blueprint = $this->getBlueprint(); 70 87 $resource = $this->getResource(); 71 88 $lease = $this->getLease(); 89 + $operation = $this->getOperation(); 72 90 if ($blueprint) { 73 91 $id = $blueprint->getID(); 74 92 ··· 111 129 $crumbs->addTextCrumb( 112 130 pht('Logs'), 113 131 $this->getApplicationURI("lease/{$id}/logs/")); 132 + } else if ($operation) { 133 + $id = $operation->getID(); 134 + 135 + $crumbs->addTextCrumb( 136 + pht('Operations'), 137 + $this->getApplicationURI('operation/')); 138 + 139 + $crumbs->addTextCrumb( 140 + pht('Repository Operation %d', $id), 141 + $this->getApplicationURI("operation/{$id}/")); 142 + 143 + $crumbs->addTextCrumb( 144 + pht('Logs'), 145 + $this->getApplicationURI("operation/{$id}/logs/")); 114 146 } 115 147 116 148 return $crumbs;
+11
src/applications/drydock/controller/DrydockLogListController.php
··· 46 46 $engine->setLease($lease); 47 47 $this->setLease($lease); 48 48 break; 49 + case 'operation': 50 + $operation = id(new DrydockRepositoryOperationQuery()) 51 + ->setViewer($viewer) 52 + ->withIDs(array($id)) 53 + ->executeOne(); 54 + if (!$operation) { 55 + return new Aphront404Response(); 56 + } 57 + $engine->setOperation($operation); 58 + $this->setOperation($operation); 59 + break; 49 60 default: 50 61 return new Aphront404Response(); 51 62 }
+12 -3
src/applications/drydock/controller/DrydockRepositoryOperationViewController.php
··· 47 47 ->setUser($viewer) 48 48 ->setOperation($operation); 49 49 50 + $log_query = id(new DrydockLogQuery()) 51 + ->withOperationPHIDs(array($operation->getPHID())); 52 + 53 + $logs = $this->buildLogBox( 54 + $log_query, 55 + $this->getApplicationURI("operation/{$id}/logs/query/all/")); 56 + 50 57 $view = id(new PHUITwoColumnView()) 51 58 ->setHeader($header) 52 59 ->setCurtain($curtain) 53 60 ->addPropertySection(pht('Properties'), $properties) 54 - ->setMainColumn(array( 55 - $status_view, 56 - )); 61 + ->setMainColumn( 62 + array( 63 + $status_view, 64 + $logs, 65 + )); 57 66 58 67 return $this->newPage() 59 68 ->setTitle($title)
+22 -1
src/applications/drydock/query/DrydockLogSearchEngine.php
··· 5 5 private $blueprint; 6 6 private $resource; 7 7 private $lease; 8 + private $operation; 8 9 9 10 public function setBlueprint(DrydockBlueprint $blueprint) { 10 11 $this->blueprint = $blueprint; ··· 33 34 return $this->lease; 34 35 } 35 36 37 + public function setOperation(DrydockRepositoryOperation $operation) { 38 + $this->operation = $operation; 39 + return $this; 40 + } 41 + 42 + public function getOperation() { 43 + return $this->operation; 44 + } 45 + 36 46 public function canUseInPanelContext() { 37 47 // Prevent use on Dashboard panels since all log queries currently need a 38 48 // parent object and these don't seem particularly useful in any case. ··· 65 75 $query->withLeasePHIDs(array($lease->getPHID())); 66 76 } 67 77 78 + $operation = $this->getOperation(); 79 + if ($operation) { 80 + $query->withOperationPHIDs(array($operation->getPHID())); 81 + } 82 + 68 83 return $query; 69 84 } 70 85 ··· 97 112 return "/drydock/lease/{$id}/logs/{$path}"; 98 113 } 99 114 115 + $operation = $this->getOperation(); 116 + if ($operation) { 117 + $id = $operation->getID(); 118 + return "/drydock/operation/{$id}/logs/{$path}"; 119 + } 120 + 100 121 throw new Exception( 101 122 pht( 102 - 'Search engine has no blueprint, resource, or lease.')); 123 + 'Search engine has no blueprint, resource, lease, or operation.')); 103 124 } 104 125 105 126 protected function getBuiltinQueryNames() {