Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/view/DrydockLogListView.php
12256 views
1
<?php
2
3
final class DrydockLogListView extends AphrontView {
4
5
private $logs;
6
private $hideBlueprints;
7
private $hideResources;
8
private $hideLeases;
9
private $hideOperations;
10
11
public function setHideBlueprints($hide_blueprints) {
12
$this->hideBlueprints = $hide_blueprints;
13
return $this;
14
}
15
16
public function getHideBlueprints() {
17
return $this->hideBlueprints;
18
}
19
20
public function setHideResources($hide_resources) {
21
$this->hideResources = $hide_resources;
22
return $this;
23
}
24
25
public function getHideResources() {
26
return $this->hideResources;
27
}
28
29
public function setHideLeases($hide_leases) {
30
$this->hideLeases = $hide_leases;
31
return $this;
32
}
33
34
public function getHideLeases() {
35
return $this->hideLeases;
36
}
37
38
public function setHideOperations($hide_operations) {
39
$this->hideOperations = $hide_operations;
40
return $this;
41
}
42
43
public function getHideOperations() {
44
return $this->hideOperations;
45
}
46
47
public function setLogs(array $logs) {
48
assert_instances_of($logs, 'DrydockLog');
49
$this->logs = $logs;
50
return $this;
51
}
52
53
public function render() {
54
$logs = $this->logs;
55
$viewer = $this->getUser();
56
57
$view = new PHUIObjectItemListView();
58
59
$types = DrydockLogType::getAllLogTypes();
60
61
$rows = array();
62
foreach ($logs as $log) {
63
$blueprint_phid = $log->getBlueprintPHID();
64
if ($blueprint_phid) {
65
$blueprint = $viewer->renderHandle($blueprint_phid);
66
} else {
67
$blueprint = null;
68
}
69
70
$resource_phid = $log->getResourcePHID();
71
if ($resource_phid) {
72
$resource = $viewer->renderHandle($resource_phid);
73
} else {
74
$resource = null;
75
}
76
77
$lease_phid = $log->getLeasePHID();
78
if ($lease_phid) {
79
$lease = $viewer->renderHandle($lease_phid);
80
} else {
81
$lease = null;
82
}
83
84
$operation_phid = $log->getOperationPHID();
85
if ($operation_phid) {
86
$operation = $viewer->renderHandle($operation_phid);
87
} else {
88
$operation = null;
89
}
90
91
if ($log->isComplete()) {
92
$type_key = $log->getType();
93
if (isset($types[$type_key])) {
94
$type_object = id(clone $types[$type_key])
95
->setLog($log)
96
->setViewer($viewer);
97
98
$log_data = $log->getData();
99
100
$type = $type_object->getLogTypeName();
101
$icon = $type_object->getLogTypeIcon($log_data);
102
$data = $type_object->renderLogForHTML($log_data);
103
$data = phutil_escape_html_newlines($data);
104
} else {
105
$type = pht('<Unknown: %s>', $type_key);
106
$data = null;
107
$icon = 'fa-question-circle red';
108
}
109
} else {
110
$type = phutil_tag('em', array(), pht('Restricted'));
111
$data = phutil_tag(
112
'em',
113
array(),
114
pht('You do not have permission to view this log event.'));
115
$icon = 'fa-lock grey';
116
}
117
118
$rows[] = array(
119
$blueprint,
120
$resource,
121
$lease,
122
$operation,
123
id(new PHUIIconView())->setIcon($icon),
124
$type,
125
$data,
126
phabricator_datetime($log->getEpoch(), $viewer),
127
);
128
}
129
130
$table = id(new AphrontTableView($rows))
131
->setDeviceReadyTable(true)
132
->setHeaders(
133
array(
134
pht('Blueprint'),
135
pht('Resource'),
136
pht('Lease'),
137
pht('Operation'),
138
null,
139
pht('Type'),
140
pht('Data'),
141
pht('Date'),
142
))
143
->setColumnVisibility(
144
array(
145
!$this->getHideBlueprints(),
146
!$this->getHideResources(),
147
!$this->getHideLeases(),
148
!$this->getHideOperations(),
149
))
150
->setColumnClasses(
151
array(
152
'',
153
'',
154
'',
155
'',
156
'icon',
157
'',
158
'wide',
159
'',
160
));
161
162
return $table;
163
}
164
165
}
166
167