1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +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',
'status/' => 'DrydockRepositoryOperationStatusController',
'dismiss/' => 'DrydockRepositoryOperationDismissController',
'logs/(?:query/(?P<queryKey>[^/]+)/)?' =>
'DrydockLogListController',
),
),
),

View file

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

View file

@ -46,6 +46,17 @@ final class DrydockLogListController extends DrydockLogController {
$engine->setLease($lease);
$this->setLease($lease);
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:
return new Aphront404Response();
}

View file

@ -47,12 +47,21 @@ final class DrydockRepositoryOperationViewController
->setUser($viewer)
->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())
->setHeader($header)
->setCurtain($curtain)
->addPropertySection(pht('Properties'), $properties)
->setMainColumn(array(
->setMainColumn(
array(
$status_view,
$logs,
));
return $this->newPage()

View file

@ -5,6 +5,7 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
private $blueprint;
private $resource;
private $lease;
private $operation;
public function setBlueprint(DrydockBlueprint $blueprint) {
$this->blueprint = $blueprint;
@ -33,6 +34,15 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
return $this->lease;
}
public function setOperation(DrydockRepositoryOperation $operation) {
$this->operation = $operation;
return $this;
}
public function getOperation() {
return $this->operation;
}
public function canUseInPanelContext() {
// Prevent use on Dashboard panels since all log queries currently need a
// 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()));
}
$operation = $this->getOperation();
if ($operation) {
$query->withOperationPHIDs(array($operation->getPHID()));
}
return $query;
}
@ -97,9 +112,15 @@ final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine {
return "/drydock/lease/{$id}/logs/{$path}";
}
$operation = $this->getOperation();
if ($operation) {
$id = $operation->getID();
return "/drydock/operation/{$id}/logs/{$path}";
}
throw new Exception(
pht(
'Search engine has no blueprint, resource, or lease.'));
'Search engine has no blueprint, resource, lease, or operation.'));
}
protected function getBuiltinQueryNames() {