@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 101 lines 2.5 kB view raw
1<?php 2 3final class HarbormasterBuildLogView extends AphrontView { 4 5 private $log; 6 private $highlightedLineRange; 7 private $enableHighlighter; 8 9 public function setBuildLog(HarbormasterBuildLog $log) { 10 $this->log = $log; 11 return $this; 12 } 13 14 public function getBuildLog() { 15 return $this->log; 16 } 17 18 public function setHighlightedLineRange($range) { 19 $this->highlightedLineRange = $range; 20 return $this; 21 } 22 23 public function getHighlightedLineRange() { 24 return $this->highlightedLineRange; 25 } 26 27 public function setEnableHighlighter($enable) { 28 $this->enableHighlighter = $enable; 29 return $this; 30 } 31 32 public function render() { 33 $viewer = $this->getViewer(); 34 $log = $this->getBuildLog(); 35 $id = $log->getID(); 36 37 $header = id(new PHUIHeaderView()) 38 ->setViewer($viewer) 39 ->setHeader(pht('Build Log %d', $id)); 40 41 $download_uri = "/harbormaster/log/download/{$id}/"; 42 43 $can_download = (bool)$log->getFilePHID(); 44 45 $download_button = id(new PHUIButtonView()) 46 ->setTag('a') 47 ->setHref($download_uri) 48 ->setIcon('fa-download') 49 ->setDisabled(!$can_download) 50 ->setWorkflow(!$can_download) 51 ->setText(pht('Download Log')); 52 53 $header->addActionLink($download_button); 54 55 $box_view = id(new PHUIObjectBoxView()) 56 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 57 ->setHeader($header); 58 59 if ($this->enableHighlighter) { 60 Javelin::initBehavior('phabricator-line-linker'); 61 } 62 63 $has_linemap = $log->getLineMap(); 64 if ($has_linemap) { 65 $content_id = celerity_generate_unique_node_id(); 66 $content_div = javelin_tag( 67 'div', 68 array( 69 'id' => $content_id, 70 'class' => 'harbormaster-log-view-loading', 71 ), 72 pht('Loading...')); 73 74 require_celerity_resource('harbormaster-css'); 75 76 Javelin::initBehavior( 77 'harbormaster-log', 78 array( 79 'contentNodeID' => $content_id, 80 'initialURI' => $log->getRenderURI($this->getHighlightedLineRange()), 81 'renderURI' => $log->getRenderURI(null), 82 )); 83 84 $box_view->appendChild($content_div); 85 } else { 86 $box_view->setFormErrors( 87 array( 88 pht( 89 'This older log is missing required rendering data. To rebuild '. 90 'rendering data, run: %s', 91 phutil_tag( 92 'tt', 93 array(), 94 '$ bin/harbormaster rebuild-log --force --id '.$log->getID())), 95 )); 96 } 97 98 return $box_view; 99 } 100 101}