Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14662653
D19133.id45854.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D19133.id45854.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1227,8 +1227,11 @@
'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php',
'HarbormasterBuildLogChunk' => 'applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php',
'HarbormasterBuildLogChunkIterator' => 'applications/harbormaster/storage/build/HarbormasterBuildLogChunkIterator.php',
+ 'HarbormasterBuildLogDownloadController' => 'applications/harbormaster/controller/HarbormasterBuildLogDownloadController.php',
'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php',
'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php',
+ 'HarbormasterBuildLogView' => 'applications/harbormaster/view/HarbormasterBuildLogView.php',
+ 'HarbormasterBuildLogViewController' => 'applications/harbormaster/controller/HarbormasterBuildLogViewController.php',
'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php',
'HarbormasterBuildMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildMessageQuery.php',
'HarbormasterBuildPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPHIDType.php',
@@ -6511,8 +6514,11 @@
),
'HarbormasterBuildLogChunk' => 'HarbormasterDAO',
'HarbormasterBuildLogChunkIterator' => 'PhutilBufferedIterator',
+ 'HarbormasterBuildLogDownloadController' => 'HarbormasterController',
'HarbormasterBuildLogPHIDType' => 'PhabricatorPHIDType',
'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'HarbormasterBuildLogView' => 'AphrontView',
+ 'HarbormasterBuildLogViewController' => 'HarbormasterController',
'HarbormasterBuildMessage' => array(
'HarbormasterDAO',
'PhabricatorPolicyInterface',
diff --git a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
--- a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
+++ b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
@@ -96,6 +96,10 @@
'circleci/' => 'HarbormasterCircleCIHookController',
'buildkite/' => 'HarbormasterBuildkiteHookController',
),
+ 'log/' => array(
+ 'view/(?P<id>\d+)/' => 'HarbormasterBuildLogViewController',
+ 'download/(?P<id>\d+)/' => 'HarbormasterBuildLogDownloadController',
+ ),
),
);
}
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildLogDownloadController.php b/src/applications/harbormaster/controller/HarbormasterBuildLogDownloadController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/controller/HarbormasterBuildLogDownloadController.php
@@ -0,0 +1,62 @@
+<?php
+
+final class HarbormasterBuildLogDownloadController
+ extends HarbormasterController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $id = $request->getURIData('id');
+
+ $log = id(new HarbormasterBuildLogQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$log) {
+ return new Aphront404Response();
+ }
+
+ $cancel_uri = $log->getURI();
+ $file_phid = $log->getFilePHID();
+
+ if (!$file_phid) {
+ return $this->newDialog()
+ ->setTitle(pht('Log Not Finalized'))
+ ->appendParagraph(
+ pht(
+ 'Logs must be fully written and processed before they can be '.
+ 'downloaded. This log is still being written or processed.'))
+ ->addCancelButton($cancel_uri, pht('Wait Patiently'));
+ }
+
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($file_phid))
+ ->executeOne();
+ if (!$file) {
+ return $this->newDialog()
+ ->setTitle(pht('Unable to Load File'))
+ ->appendParagraph(
+ pht(
+ 'Unable to load the file for this log. The file may have been '.
+ 'destroyed.'))
+ ->addCancelButton($cancel_uri);
+ }
+
+ $size = $file->getByteSize();
+
+ return $this->newDialog()
+ ->setTitle(pht('Download Build Log'))
+ ->appendParagraph(
+ pht(
+ 'This log has a total size of %s. If you insist, you may '.
+ 'download it.',
+ phutil_tag('strong', array(), phutil_format_bytes($size))))
+ ->setDisableWorkflowOnSubmit(true)
+ ->addSubmitButton(pht('Download Log'))
+ ->setSubmitURI($file->getDownloadURI())
+ ->addCancelButton($cancel_uri, pht('Done'));
+ }
+
+}
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php
@@ -0,0 +1,44 @@
+<?php
+
+final class HarbormasterBuildLogViewController
+ extends HarbormasterController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $id = $request->getURIData('id');
+
+ $log = id(new HarbormasterBuildLogQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$log) {
+ return new Aphront404Response();
+ }
+
+ $page_title = pht('Build Log %d', $log->getID());
+
+ $log_view = id(new HarbormasterBuildLogView())
+ ->setViewer($viewer)
+ ->setBuildLog($log);
+
+ $crumbs = $this->buildApplicationCrumbs()
+ ->addTextCrumb(pht('Build Logs'))
+ ->addTextCrumb($page_title)
+ ->setBorder(true);
+
+ $page_header = id(new PHUIHeaderView())
+ ->setHeader($page_title);
+
+ $page_view = id(new PHUITwoColumnView())
+ ->setHeader($page_header)
+ ->setFooter($log_view);
+
+ return $this->newPage()
+ ->setTitle($page_title)
+ ->setCrumbs($crumbs)
+ ->appendChild($page_view);
+ }
+
+}
diff --git a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
--- a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
+++ b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
@@ -44,9 +44,14 @@
$log = HarbormasterBuildLog::initializeNewBuildLog($target);
$log->openBuildLog();
+ echo tsprintf(
+ "%s\n\n __%s__\n\n",
+ pht('Opened a new build log:'),
+ PhabricatorEnv::getURI($log->getURI()));
+
echo tsprintf(
"%s\n",
- pht('Reading log from stdin...'));
+ pht('Reading log content from stdin...'));
$content = file_get_contents('php://stdin');
$log->append($content);
diff --git a/src/applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php b/src/applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php
--- a/src/applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php
+++ b/src/applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php
@@ -32,7 +32,9 @@
foreach ($handles as $phid => $handle) {
$build_log = $objects[$phid];
- $handle->setName(pht('Build Log %d', $build_log->getID()));
+ $handle
+ ->setName(pht('Build Log %d', $build_log->getID()))
+ ->setURI($build_log->getURI());
}
}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
@@ -290,6 +290,11 @@
->save();
}
+ public function getURI() {
+ $id = $this->getID();
+ return "/harbormaster/log/view/{$id}/";
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/harbormaster/view/HarbormasterBuildLogView.php b/src/applications/harbormaster/view/HarbormasterBuildLogView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/view/HarbormasterBuildLogView.php
@@ -0,0 +1,45 @@
+<?php
+
+final class HarbormasterBuildLogView extends AphrontView {
+
+ private $log;
+
+ public function setBuildLog(HarbormasterBuildLog $log) {
+ $this->log = $log;
+ return $this;
+ }
+
+ public function getBuildLog() {
+ return $this->log;
+ }
+
+ 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);
+
+ $box_view = id(new PHUIObjectBoxView())
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->setHeader($header)
+ ->appendChild('...');
+
+ return $box_view;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 13, 8:32 AM (17 h, 41 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6988738
Default Alt Text
D19133.id45854.diff (9 KB)
Attached To
Mode
D19133: Add a very basic standalone view for build logs with a "Download Log" button
Attached
Detach File
Event Timeline
Log In to Comment