From cefe30d7374d4b8ce5d44eb737ab40ca6db57c98 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Wed, 6 Aug 2014 10:28:13 +1000 Subject: [PATCH] Hide empty build logs Summary: This automatically hides any empty build logs from Harbormaster, so that they do not appear. Test Plan: Viewed a build plan where the logs were empty and didn't see them appear. Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10091 --- resources/celerity/map.php | 4 +- .../HarbormasterBuildViewController.php | 59 ++++++++++++++++++- .../application/harbormaster/harbormaster.css | 8 +++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index e763b32c7d..39a710a0f5 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -67,7 +67,7 @@ return array( 'rsrc/css/application/feed/feed.css' => '4e544db4', 'rsrc/css/application/files/global-drag-and-drop.css' => '697324ad', 'rsrc/css/application/flag/flag.css' => '5337623f', - 'rsrc/css/application/harbormaster/harbormaster.css' => 'cec833b7', + 'rsrc/css/application/harbormaster/harbormaster.css' => '49d64eb4', 'rsrc/css/application/herald/herald-test.css' => '778b008e', 'rsrc/css/application/herald/herald.css' => 'c544dd1c', 'rsrc/css/application/maniphest/batch-editor.css' => '8f380ebc', @@ -538,7 +538,7 @@ return array( 'font-fontawesome' => '73d075c3', 'font-source-sans-pro' => '91d53463', 'global-drag-and-drop-css' => '697324ad', - 'harbormaster-css' => 'cec833b7', + 'harbormaster-css' => '49d64eb4', 'herald-css' => 'c544dd1c', 'herald-rule-editor' => '3fc2c8f2', 'herald-test-css' => '778b008e', diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php index 685c45d8d1..437621e3e2 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php @@ -205,6 +205,8 @@ final class HarbormasterBuildViewController ->withBuildTargetPHIDs(array($build_target->getPHID())) ->execute(); + $empty_logs = array(); + $log_boxes = array(); foreach ($logs as $log) { $start = 1; @@ -217,6 +219,16 @@ final class HarbormasterBuildViewController $start = 1; } } + + $id = null; + $is_empty = false; + if (count($lines) === 1 && trim($lines[0]) === '') { + // Prevent Harbormaster from showing empty build logs. + $id = celerity_generate_unique_node_id(); + $empty_logs[] = $id; + $is_empty = true; + } + $log_view = new ShellLogView(); $log_view->setLines($lines); $log_view->setStart($start); @@ -230,9 +242,54 @@ final class HarbormasterBuildViewController ->setSubheader($this->createLogHeader($build, $log)) ->setUser($viewer); - $log_boxes[] = id(new PHUIObjectBoxView()) + $log_box = id(new PHUIObjectBoxView()) ->setHeader($header) ->setForm($log_view); + + if ($is_empty) { + require_celerity_resource('harbormaster-css'); + + $log_box = phutil_tag( + 'div', + array( + 'style' => 'display: none', + 'id' => $id), + $log_box); + } + + $log_boxes[] = $log_box; + } + + if ($empty_logs) { + $hide_id = celerity_generate_unique_node_id(); + + Javelin::initBehavior('phabricator-reveal-content'); + + $expand = phutil_tag( + 'div', + array( + 'id' => $hide_id, + 'class' => 'harbormaster-empty-logs-are-hidden mlr mlt mll', + ), + array( + pht( + '%s empty logs are hidden.', + new PhutilNumber(count($empty_logs))), + ' ', + javelin_tag( + 'a', + array( + 'href' => '#', + 'sigil' => 'reveal-content', + 'meta' => array( + 'showIDs' => $empty_logs, + 'hideIDs' => array($hide_id), + ), + ), + pht('Show all logs.')), + )); + + array_unshift($log_boxes, $expand); } return $log_boxes; diff --git a/webroot/rsrc/css/application/harbormaster/harbormaster.css b/webroot/rsrc/css/application/harbormaster/harbormaster.css index 15b9ea57ae..9878d3f893 100644 --- a/webroot/rsrc/css/application/harbormaster/harbormaster.css +++ b/webroot/rsrc/css/application/harbormaster/harbormaster.css @@ -17,3 +17,11 @@ margin-bottom: 2px; color: {$darkbluetext}; } + +.harbormaster-empty-logs-are-hidden { + background: {$lightyellow}; + border: 1px solid {$yellow}; + text-align: center; + padding: 12px; + color: {$darkgreytext}; +}