forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrydockLogController.php
119 lines (90 loc) · 2.67 KB
/
DrydockLogController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
abstract class DrydockLogController
extends DrydockController {
private $blueprint;
private $resource;
private $lease;
public function setBlueprint(DrydockBlueprint $blueprint) {
$this->blueprint = $blueprint;
return $this;
}
public function getBlueprint() {
return $this->blueprint;
}
public function setResource(DrydockResource $resource) {
$this->resource = $resource;
return $this;
}
public function getResource() {
return $this->resource;
}
public function setLease(DrydockLease $lease) {
$this->lease = $lease;
return $this;
}
public function getLease() {
return $this->lease;
}
public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$engine = id(new DrydockLogSearchEngine())
->setViewer($this->getRequest()->getUser());
$blueprint = $this->getBlueprint();
if ($blueprint) {
$engine->setBlueprint($blueprint);
}
$resource = $this->getResource();
if ($resource) {
$engine->setResource($resource);
}
$lease = $this->getLease();
if ($lease) {
$engine->setLease($lease);
}
$engine->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$blueprint = $this->getBlueprint();
$resource = $this->getResource();
$lease = $this->getLease();
if ($blueprint) {
$id = $blueprint->getID();
$crumbs->addTextCrumb(
pht('Blueprints'),
$this->getApplicationURI('blueprint/'));
$crumbs->addTextCrumb(
$blueprint->getBlueprintName(),
$this->getApplicationURI("blueprint/{$id}/"));
$crumbs->addTextCrumb(
pht('Logs'),
$this->getApplicationURI("blueprint/{$id}/logs/"));
} else if ($resource) {
$id = $resource->getID();
$crumbs->addTextCrumb(
pht('Resources'),
$this->getApplicationURI('resource/'));
$crumbs->addTextCrumb(
$resource->getResourceName(),
$this->getApplicationURI("resource/{$id}/"));
$crumbs->addTextCrumb(
pht('Logs'),
$this->getApplicationURI("resource/{$id}/logs/"));
} else if ($lease) {
$id = $lease->getID();
$crumbs->addTextCrumb(
pht('Leases'),
$this->getApplicationURI('lease/'));
$crumbs->addTextCrumb(
$lease->getLeaseName(),
$this->getApplicationURI("lease/{$id}/"));
$crumbs->addTextCrumb(
pht('Logs'),
$this->getApplicationURI("lease/{$id}/logs/"));
}
return $crumbs;
}
}