diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -75,7 +75,7 @@ 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 'rsrc/css/application/flag/flag.css' => 'bba8f811', - 'rsrc/css/application/harbormaster/harbormaster.css' => '730a4a3c', + 'rsrc/css/application/harbormaster/harbormaster.css' => '7446ce72', 'rsrc/css/application/herald/herald-test.css' => 'a52e323e', 'rsrc/css/application/herald/herald.css' => 'cd8d0134', 'rsrc/css/application/maniphest/report.css' => '9b9580b7', @@ -554,7 +554,7 @@ 'font-fontawesome' => 'e838e088', 'font-lato' => 'c7ccd872', 'global-drag-and-drop-css' => 'b556a948', - 'harbormaster-css' => '730a4a3c', + 'harbormaster-css' => '7446ce72', 'herald-css' => 'cd8d0134', 'herald-rule-editor' => 'dca75c0e', 'herald-test-css' => 'a52e323e', diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -1315,7 +1315,7 @@ } return id(new HarbormasterUnitSummaryView()) - ->setUser($viewer) + ->setViewer($viewer) ->setExcuse($excuse) ->setBuildable($diff->getBuildable()) ->setUnitMessages($diff->getUnitMessages()) diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php --- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php @@ -318,7 +318,7 @@ if ($lint_data) { $lint_table = id(new HarbormasterLintPropertyView()) - ->setUser($viewer) + ->setViewer($viewer) ->setLimit(10) ->setLintMessages($lint_data); @@ -343,6 +343,7 @@ if ($unit_data) { $unit = id(new HarbormasterUnitSummaryView()) + ->setViewer($viewer) ->setBuildable($buildable) ->setUnitMessages($unit_data) ->setShowViewAll(true) diff --git a/src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php b/src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php --- a/src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php +++ b/src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php @@ -39,6 +39,7 @@ } $unit = id(new HarbormasterUnitSummaryView()) + ->setViewer($viewer) ->setBuildable($buildable) ->setUnitMessages($unit_data); diff --git a/src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php b/src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php --- a/src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php @@ -88,23 +88,7 @@ pht('Run At'), phabricator_datetime($message->getDateCreated(), $viewer)); - $details = $message->getUnitMessageDetails(); - if (strlen($details)) { - // TODO: Use the log view here, once it gets cleaned up. - // Shenanigans below. - $details = phutil_tag( - 'div', - array( - 'class' => 'PhabricatorMonospaced', - 'style' => - 'white-space: pre-wrap; '. - 'color: #666666; '. - 'overflow-x: auto;', - ), - $details); - } else { - $details = phutil_tag('em', array(), pht('No details provided.')); - } + $details = $message->newUnitMessageDetailsView($viewer); $view->addSectionHeader( pht('Details'), diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php --- a/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php @@ -13,6 +13,9 @@ private $buildTarget = self::ATTACHABLE; + const FORMAT_TEXT = 'text'; + const FORMAT_REMARKUP = 'remarkup'; + public static function initializeNewUnitMessage( HarbormasterBuildTarget $build_target) { return id(new HarbormasterBuildUnitMessage()) @@ -66,6 +69,13 @@ 'description' => pht( 'Additional human-readable information about the failure.'), ), + 'format' => array( + 'type' => 'optional string', + 'description' => pht( + 'Format for the text provided in "details". Valid values are '. + '"text" (default) or "remarkup". This controls how test details '. + 'are rendered when shown to users.'), + ), ); } @@ -104,6 +114,11 @@ $obj->setProperty('details', $details); } + $format = idx($dict, 'format'); + if ($format) { + $obj->setProperty('format', $format); + } + return $obj; } @@ -149,6 +164,66 @@ return $this->getProperty('details', ''); } + public function getUnitMessageDetailsFormat() { + return $this->getProperty('format', self::FORMAT_TEXT); + } + + public function newUnitMessageDetailsView( + PhabricatorUser $viewer, + $summarize = false) { + + $format = $this->getUnitMessageDetailsFormat(); + + $is_text = ($format !== self::FORMAT_REMARKUP); + $is_remarkup = ($format === self::FORMAT_REMARKUP); + + $full_details = $this->getUnitMessageDetails(); + + if (!strlen($full_details)) { + if ($summarize) { + return null; + } + $details = phutil_tag('em', array(), pht('No details provided.')); + } else if ($summarize) { + if ($is_text) { + $details = id(new PhutilUTF8StringTruncator()) + ->setMaximumBytes(2048) + ->truncateString($full_details); + $details = phutil_split_lines($details); + + $limit = 3; + if (count($details) > $limit) { + $details = array_slice($details, 0, $limit); + } + + $details = implode('', $details); + } else { + $details = $full_details; + } + } else { + $details = $full_details; + } + + require_celerity_resource('harbormaster-css'); + + $classes = array(); + $classes[] = 'harbormaster-unit-details'; + + if ($is_remarkup) { + $details = new PHUIRemarkupView($viewer, $details); + } else { + $classes[] = 'harbormaster-unit-details-text'; + $classes[] = 'PhabricatorMonospaced'; + } + + return phutil_tag( + 'div', + array( + 'class' => implode(' ', $classes), + ), + $details); + } + public function getUnitMessageDisplayName() { $name = $this->getName(); diff --git a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php --- a/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php +++ b/src/applications/harbormaster/view/HarbormasterUnitPropertyView.php @@ -34,9 +34,8 @@ return $this; } - public function render() { - require_celerity_resource('harbormaster-css'); + $viewer = $this->getViewer(); $messages = $this->unitMessages; $messages = msort($messages, 'getSortKey'); @@ -84,13 +83,10 @@ $name); } - $details = $message->getUnitMessageDetails(); - if (strlen($details)) { - $name = array( - $name, - $this->renderUnitTestDetails($details), - ); - } + $name = array( + $name, + $message->newUnitMessageDetailsView($viewer, true), + ); $rows[] = array( $result_icon, @@ -158,25 +154,4 @@ return $table; } - private function renderUnitTestDetails($full_details) { - $details = id(new PhutilUTF8StringTruncator()) - ->setMaximumBytes(2048) - ->truncateString($full_details); - $details = phutil_split_lines($details); - - $limit = 3; - if (count($details) > $limit) { - $details = array_slice($details, 0, $limit); - } - - $details = implode('', $details); - - return phutil_tag( - 'div', - array( - 'class' => 'PhabricatorMonospaced harbormaster-unit-details', - ), - $details); - } - } diff --git a/src/applications/harbormaster/view/HarbormasterUnitSummaryView.php b/src/applications/harbormaster/view/HarbormasterUnitSummaryView.php --- a/src/applications/harbormaster/view/HarbormasterUnitSummaryView.php +++ b/src/applications/harbormaster/view/HarbormasterUnitSummaryView.php @@ -77,6 +77,7 @@ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); $table = id(new HarbormasterUnitPropertyView()) + ->setViewer($this->getViewer()) ->setUnitMessages($messages); if ($this->showViewAll) { diff --git a/webroot/rsrc/css/application/harbormaster/harbormaster.css b/webroot/rsrc/css/application/harbormaster/harbormaster.css --- a/webroot/rsrc/css/application/harbormaster/harbormaster.css +++ b/webroot/rsrc/css/application/harbormaster/harbormaster.css @@ -26,11 +26,14 @@ .harbormaster-unit-details { margin: 8px 0 4px; overflow: hidden; - white-space: pre; - text-overflow: ellipsis; color: {$lightgreytext}; } +.harbormaster-unit-details-text { + white-space: pre-wrap; + text-overflow: ellipsis; +} + .harbormaster-log-view-loading { padding: 8px; text-align: center;