3 final class HarbormasterUnitPropertyView
extends AphrontView
{
5 private $pathURIMap = array();
6 private $unitMessages = array();
8 private $fullResultsURI;
11 public function setPathURIMap(array $map) {
12 $this->pathURIMap
= $map;
16 public function setUnitMessages(array $messages) {
17 assert_instances_of($messages, 'HarbormasterBuildUnitMessage');
18 $this->unitMessages
= $messages;
22 public function setLimit($limit) {
23 $this->limit
= $limit;
27 public function setFullResultsURI($full_results_uri) {
28 $this->fullResultsURI
= $full_results_uri;
32 public function setNotice($notice) {
33 $this->notice
= $notice;
37 public function render() {
38 $viewer = $this->getViewer();
40 $messages = $this->unitMessages
;
41 $messages = msort($messages, 'getSortKey');
43 $limit = $this->limit
;
46 $display_messages = array_slice($messages, 0, $limit);
48 $display_messages = $messages;
52 $any_duration = false;
53 foreach ($display_messages as $message) {
54 $status = $message->getResult();
56 $icon_icon = HarbormasterUnitStatus
::getUnitStatusIcon($status);
57 $icon_color = HarbormasterUnitStatus
::getUnitStatusColor($status);
58 $icon_label = HarbormasterUnitStatus
::getUnitStatusLabel($status);
60 $result_icon = id(new PHUIIconView())
61 ->setIcon("{$icon_icon} {$icon_color}")
62 ->addSigil('has-tooltip')
68 $duration = $message->getDuration();
69 if ($duration !== null) {
71 $duration = pht('%s ms', new PhutilNumber((int)(1000 * $duration)));
74 $name = $message->getUnitMessageDisplayName();
75 $uri = $message->getURI();
88 $message->newUnitMessageDetailsView($viewer, true),
98 $full_uri = $this->fullResultsURI
;
99 if ($full_uri && (count($messages) > $limit)) {
102 $groups = mgroup($messages, 'getResult');
103 foreach ($groups as $status => $group) {
104 $counts[] = HarbormasterUnitStatus
::getUnitStatusCountLabel(
110 'View Full Test Results (%s)',
111 implode(" \xC2\xB7 ", $counts));
113 $full_link = phutil_tag(
120 $link_icon = id(new PHUIIconView())
121 ->setIcon('fa-ellipsis-h lightgreytext');
123 $rows[] = array($link_icon, null, $full_link);
126 $table = id(new AphrontTableView($rows))
144 ->setColumnVisibility(
151 $table->setNotice($this->notice
);