@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 94 lines 2.1 kB view raw
1<?php 2 3final class HarbormasterLintPropertyView extends AphrontView { 4 5 private $pathURIMap = array(); 6 private $lintMessages = array(); 7 private $limit; 8 9 public function setPathURIMap(array $map) { 10 $this->pathURIMap = $map; 11 return $this; 12 } 13 14 /** 15 * @param array<HarbormasterBuildLintMessage> $messages 16 */ 17 public function setLintMessages(array $messages) { 18 assert_instances_of($messages, HarbormasterBuildLintMessage::class); 19 $this->lintMessages = $messages; 20 return $this; 21 } 22 23 public function setLimit($limit) { 24 $this->limit = $limit; 25 return $this; 26 } 27 28 public function render() { 29 $messages = $this->lintMessages; 30 $messages = msort($messages, 'getSortKey'); 31 32 if ($this->limit) { 33 $messages = array_slice($messages, 0, $this->limit); 34 } 35 36 $rows = array(); 37 foreach ($messages as $message) { 38 $path = $message->getPath(); 39 $line = $message->getLine(); 40 41 $href = null; 42 if (phutil_nonempty_string(idx($this->pathURIMap, $path))) { 43 $href = $this->pathURIMap[$path].max($line, 1); 44 } 45 46 $severity = $this->renderSeverity($message->getSeverity()); 47 48 $location = $path.':'.$line; 49 if (phutil_nonempty_string($href)) { 50 $location = phutil_tag( 51 'a', 52 array( 53 'href' => $href, 54 ), 55 $location); 56 } 57 58 $rows[] = array( 59 $severity, 60 $location, 61 $message->getCode(), 62 $message->getName(), 63 ); 64 } 65 66 $table = id(new AphrontTableView($rows)) 67 ->setHeaders( 68 array( 69 pht('Severity'), 70 pht('Location'), 71 pht('Code'), 72 pht('Message'), 73 )) 74 ->setColumnClasses( 75 array( 76 null, 77 'pri', 78 null, 79 'wide', 80 )); 81 82 return $table; 83 } 84 85 private function renderSeverity($severity) { 86 $names = ArcanistLintSeverity::getLintSeverities(); 87 $name = idx($names, $severity, $severity); 88 89 // TODO: Add some color here? 90 91 return $name; 92 } 93 94}