2018-02-23 04:16:45 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HarbormasterBuildLogView extends AphrontView {
|
|
|
|
|
|
|
|
private $log;
|
2018-02-23 04:35:13 +01:00
|
|
|
private $highlightedLineRange;
|
2018-02-23 04:16:45 +01:00
|
|
|
|
|
|
|
public function setBuildLog(HarbormasterBuildLog $log) {
|
|
|
|
$this->log = $log;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBuildLog() {
|
|
|
|
return $this->log;
|
|
|
|
}
|
|
|
|
|
2018-02-23 04:35:13 +01:00
|
|
|
public function setHighlightedLineRange($range) {
|
|
|
|
$this->highlightedLineRange = $range;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHighlightedLineRange() {
|
|
|
|
return $this->highlightedLineRange;
|
|
|
|
}
|
|
|
|
|
2018-02-23 04:16:45 +01:00
|
|
|
public function render() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$log = $this->getBuildLog();
|
|
|
|
$id = $log->getID();
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setHeader(pht('Build Log %d', $id));
|
|
|
|
|
|
|
|
$download_uri = "/harbormaster/log/download/{$id}/";
|
|
|
|
|
|
|
|
$download_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref($download_uri)
|
|
|
|
->setIcon('fa-download')
|
|
|
|
->setDisabled(!$log->getFilePHID())
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setText(pht('Download Log'));
|
|
|
|
|
|
|
|
$header->addActionLink($download_button);
|
|
|
|
|
2018-02-23 04:35:13 +01:00
|
|
|
$content_id = celerity_generate_unique_node_id();
|
|
|
|
$content_div = javelin_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $content_id,
|
|
|
|
'class' => 'harbormaster-log-view-loading',
|
|
|
|
),
|
|
|
|
pht('Loading...'));
|
|
|
|
|
|
|
|
require_celerity_resource('harbormaster-css');
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'harbormaster-log',
|
|
|
|
array(
|
|
|
|
'contentNodeID' => $content_id,
|
|
|
|
'renderURI' => $log->getRenderURI($this->getHighlightedLineRange()),
|
|
|
|
));
|
|
|
|
|
2018-02-23 04:16:45 +01:00
|
|
|
$box_view = id(new PHUIObjectBoxView())
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
->setHeader($header)
|
2018-02-23 04:35:13 +01:00
|
|
|
->appendChild($content_div);
|
2018-02-23 04:16:45 +01:00
|
|
|
|
|
|
|
return $box_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|