Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / view / HarbormasterUnitPropertyView.php
blob2306f5ba6403810e6baa8f779157870517523142
1 <?php
3 final class HarbormasterUnitPropertyView extends AphrontView {
5 private $pathURIMap = array();
6 private $unitMessages = array();
7 private $limit;
8 private $fullResultsURI;
9 private $notice;
11 public function setPathURIMap(array $map) {
12 $this->pathURIMap = $map;
13 return $this;
16 public function setUnitMessages(array $messages) {
17 assert_instances_of($messages, 'HarbormasterBuildUnitMessage');
18 $this->unitMessages = $messages;
19 return $this;
22 public function setLimit($limit) {
23 $this->limit = $limit;
24 return $this;
27 public function setFullResultsURI($full_results_uri) {
28 $this->fullResultsURI = $full_results_uri;
29 return $this;
32 public function setNotice($notice) {
33 $this->notice = $notice;
34 return $this;
37 public function render() {
38 $viewer = $this->getViewer();
40 $messages = $this->unitMessages;
41 $messages = msort($messages, 'getSortKey');
43 $limit = $this->limit;
45 if ($this->limit) {
46 $display_messages = array_slice($messages, 0, $limit);
47 } else {
48 $display_messages = $messages;
51 $rows = array();
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')
63 ->setMetadata(
64 array(
65 'tip' => $icon_label,
66 ));
68 $duration = $message->getDuration();
69 if ($duration !== null) {
70 $any_duration = true;
71 $duration = pht('%s ms', new PhutilNumber((int)(1000 * $duration)));
74 $name = $message->getUnitMessageDisplayName();
75 $uri = $message->getURI();
77 if ($uri) {
78 $name = phutil_tag(
79 'a',
80 array(
81 'href' => $uri,
83 $name);
86 $name = array(
87 $name,
88 $message->newUnitMessageDetailsView($viewer, true),
91 $rows[] = array(
92 $result_icon,
93 $duration,
94 $name,
98 $full_uri = $this->fullResultsURI;
99 if ($full_uri && (count($messages) > $limit)) {
100 $counts = array();
102 $groups = mgroup($messages, 'getResult');
103 foreach ($groups as $status => $group) {
104 $counts[] = HarbormasterUnitStatus::getUnitStatusCountLabel(
105 $status,
106 count($group));
109 $link_text = pht(
110 'View Full Test Results (%s)',
111 implode(" \xC2\xB7 ", $counts));
113 $full_link = phutil_tag(
114 'a',
115 array(
116 'href' => $full_uri,
118 $link_text);
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))
127 ->setHeaders(
128 array(
129 null,
130 pht('Time'),
131 pht('Test'),
133 ->setColumnClasses(
134 array(
135 'top center',
136 'top right',
137 'top wide',
139 ->setColumnWidths(
140 array(
141 '32px',
142 '64px',
144 ->setColumnVisibility(
145 array(
146 true,
147 $any_duration,
150 if ($this->notice) {
151 $table->setNotice($this->notice);
154 return $table;