1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

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
This commit is contained in:
epriestley 2018-09-14 06:48:06 -07:00
parent 10f219fb82
commit 92bcf85974
5 changed files with 79 additions and 4 deletions

View file

@ -93,6 +93,8 @@ final class PhabricatorDrydockApplication extends PhabricatorApplication {
'' => 'DrydockRepositoryOperationViewController', '' => 'DrydockRepositoryOperationViewController',
'status/' => 'DrydockRepositoryOperationStatusController', 'status/' => 'DrydockRepositoryOperationStatusController',
'dismiss/' => 'DrydockRepositoryOperationDismissController', 'dismiss/' => 'DrydockRepositoryOperationDismissController',
'logs/(?:query/(?P<queryKey>[^/]+)/)?' =>
'DrydockLogListController',
), ),
), ),
), ),

View file

@ -6,6 +6,7 @@ abstract class DrydockLogController
private $blueprint; private $blueprint;
private $resource; private $resource;
private $lease; private $lease;
private $operation;
public function setBlueprint(DrydockBlueprint $blueprint) { public function setBlueprint(DrydockBlueprint $blueprint) {
$this->blueprint = $blueprint; $this->blueprint = $blueprint;
@ -34,6 +35,15 @@ abstract class DrydockLogController
return $this->lease; return $this->lease;
} }
public function setOperation(DrydockRepositoryOperation $operation) {
$this->operation = $operation;
return $this;
}
public function getOperation() {
return $this->operation;
}
public function buildSideNavView() { public function buildSideNavView() {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
@ -56,6 +66,11 @@ abstract class DrydockLogController
$engine->setLease($lease); $engine->setLease($lease);
} }
$operation = $this->getOperation();
if ($operation) {
$engine->setOperation($operation);
}
$engine->addNavigationItems($nav->getMenu()); $engine->addNavigationItems($nav->getMenu());
$nav->selectFilter(null); $nav->selectFilter(null);
@ -66,9 +81,12 @@ abstract class DrydockLogController
protected function buildApplicationCrumbs() { protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs(); $crumbs = parent::buildApplicationCrumbs();
$viewer = $this->getViewer();
$blueprint = $this->getBlueprint(); $blueprint = $this->getBlueprint();
$resource = $this->getResource(); $resource = $this->getResource();
$lease = $this->getLease(); $lease = $this->getLease();
$operation = $this->getOperation();
if ($blueprint) { if ($blueprint) {
$id = $blueprint->getID(); $id = $blueprint->getID();
@ -111,6 +129,20 @@ abstract class DrydockLogController
$crumbs->addTextCrumb( $crumbs->addTextCrumb(
pht('Logs'), pht('Logs'),
$this->getApplicationURI("lease/{$id}/logs/")); $this->getApplicationURI("lease/{$id}/logs/"));
} else if ($operation) {
$id = $operation->getID();
$crumbs->addTextCrumb(
pht('Operations'),
$this->getApplicationURI('operation/'));
$crumbs->addTextCrumb(
pht('Repository Operation %d', $id),
$this->getApplicationURI("operation/{$id}/"));
$crumbs->addTextCrumb(
pht('Logs'),
$this->getApplicationURI("operation/{$id}/logs/"));
} }
return $crumbs; return $crumbs;

View file

@ -46,6 +46,17 @@ final class DrydockLogListController extends DrydockLogController {
$engine->setLease($lease); $engine->setLease($lease);
$this->setLease($lease); $this->setLease($lease);
break; break;
case 'operation':
$operation = id(new DrydockRepositoryOperationQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$operation) {
return new Aphront404Response();
}
$engine->setOperation($operation);
$this->setOperation($operation);
break;
default: default:
return new Aphront404Response(); return new Aphront404Response();
} }

View file

@ -47,13 +47,22 @@ final class DrydockRepositoryOperationViewController
->setUser($viewer) ->setUser($viewer)
->setOperation($operation); ->setOperation($operation);
$log_query = id(new DrydockLogQuery())
->withOperationPHIDs(array($operation->getPHID()));
$logs = $this->buildLogBox(
$log_query,
$this->getApplicationURI("operation/{$id}/logs/query/all/"));
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setCurtain($curtain) ->setCurtain($curtain)
->addPropertySection(pht('Properties'), $properties) ->addPropertySection(pht('Properties'), $properties)
->setMainColumn(array( ->setMainColumn(
$status_view, array(
)); $status_view,
$logs,
));
return $this->newPage() return $this->newPage()
->setTitle($title) ->setTitle($title)

View file

@ -5,6 +5,7 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
private $blueprint; private $blueprint;
private $resource; private $resource;
private $lease; private $lease;
private $operation;
public function setBlueprint(DrydockBlueprint $blueprint) { public function setBlueprint(DrydockBlueprint $blueprint) {
$this->blueprint = $blueprint; $this->blueprint = $blueprint;
@ -33,6 +34,15 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
return $this->lease; return $this->lease;
} }
public function setOperation(DrydockRepositoryOperation $operation) {
$this->operation = $operation;
return $this;
}
public function getOperation() {
return $this->operation;
}
public function canUseInPanelContext() { public function canUseInPanelContext() {
// Prevent use on Dashboard panels since all log queries currently need a // Prevent use on Dashboard panels since all log queries currently need a
// parent object and these don't seem particularly useful in any case. // parent object and these don't seem particularly useful in any case.
@ -65,6 +75,11 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
$query->withLeasePHIDs(array($lease->getPHID())); $query->withLeasePHIDs(array($lease->getPHID()));
} }
$operation = $this->getOperation();
if ($operation) {
$query->withOperationPHIDs(array($operation->getPHID()));
}
return $query; return $query;
} }
@ -97,9 +112,15 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
return "/drydock/lease/{$id}/logs/{$path}"; return "/drydock/lease/{$id}/logs/{$path}";
} }
$operation = $this->getOperation();
if ($operation) {
$id = $operation->getID();
return "/drydock/operation/{$id}/logs/{$path}";
}
throw new Exception( throw new Exception(
pht( pht(
'Search engine has no blueprint, resource, or lease.')); 'Search engine has no blueprint, resource, lease, or operation.'));
} }
protected function getBuiltinQueryNames() { protected function getBuiltinQueryNames() {