1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-05 05:02:44 +01:00
phorge-phorge/src/applications/harbormaster/view/HarbormasterBuildLogView.php
epriestley 11d1dc484b Sort of make Harbormaster build logs page properly
Summary: Depends on D19139. Ref T13088. This doesn't actually work, but is close enough that a skilled attacker might be able to briefly deceive a small child.

Test Plan:
  - Viewed some very small logs under very controlled conditions, saw content.
  - Larger logs vaguely do something resembling working correctly.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

Differential Revision: https://secure.phabricator.com/D19141
2018-02-26 17:58:33 -08:00

73 lines
1.7 KiB
PHP

<?php
final class HarbormasterBuildLogView extends AphrontView {
private $log;
private $highlightedLineRange;
public function setBuildLog(HarbormasterBuildLog $log) {
$this->log = $log;
return $this;
}
public function getBuildLog() {
return $this->log;
}
public function setHighlightedLineRange($range) {
$this->highlightedLineRange = $range;
return $this;
}
public function getHighlightedLineRange() {
return $this->highlightedLineRange;
}
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);
$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()),
));
$box_view = id(new PHUIObjectBoxView())
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setHeader($header)
->appendChild($content_div);
return $box_view;
}
}