From b25660bc881250e222030bf4c2200a754d72a11f Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 14 Sep 2015 15:42:52 -0400 Subject: [PATCH] Fix auto-open of build error command Fixes #481 --- static/js/directives/ui/build-logs-view.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/static/js/directives/ui/build-logs-view.js b/static/js/directives/ui/build-logs-view.js index 478481d2e..9f8e1e9fe 100644 --- a/static/js/directives/ui/build-logs-view.js +++ b/static/js/directives/ui/build-logs-view.js @@ -72,17 +72,16 @@ angular.module('quay').directive('buildLogsView', function () { // Process the logs we've received. $scope.logStartIndex = processLogs(logsData['logs'], logsData['start'], logsData['total']); - // If the build status is an error, open the last two log entries. + // If the build status is an error, automatically open the last command run. var currentBuild = $scope.currentBuild; - if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) { - var openLogEntries = function(entry) { - if (entry.logs) { - entry.logs.setVisible(true); + if (currentBuild['phase'] == 'error') { + for (var i = $scope.logEntries.length - 1; i >= 0; i--) { + var currentEntry = $scope.logEntries[i]; + if (currentEntry['type'] == 'command') { + currentEntry['logs'].setVisible(true); + break; } - }; - - openLogEntries($scope.logEntries[$scope.logEntries.length - 2]); - openLogEntries($scope.logEntries[$scope.logEntries.length - 1]); + } } // If the build phase is an error or a complete, then we mark the channel