From 73619c4643c9e3c9111294eb93d779cef4c5bdeb Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 1 Mar 2018 08:02:32 -0800 Subject: [PATCH] Share the Paste line highlighting behavior for Harbormaster build logs Summary: Depends on D19164. Ref T13088. Now that the JS behaviors are generic, use them on the Harbormaster standalone page. Test Plan: Clicked lines and dragged across line ranges. Reloaded pages. Saw expected highlighting behavior in the client and on the server across reloads. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13088 Differential Revision: https://secure.phabricator.com/D19165 --- resources/celerity/map.php | 4 ++-- .../HarbormasterBuildLogRenderController.php | 14 +++++++++----- .../HarbormasterBuildLogViewController.php | 3 ++- .../harbormaster/view/HarbormasterBuildLogView.php | 10 ++++++++++ .../css/application/harbormaster/harbormaster.css | 6 +++++- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index f636013c3b..112c75919b 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -78,7 +78,7 @@ return array( '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' => '5dd4c2de', + 'rsrc/css/application/harbormaster/harbormaster.css' => '2999ccaa', 'rsrc/css/application/herald/herald-test.css' => 'a52e323e', 'rsrc/css/application/herald/herald.css' => 'cd8d0134', 'rsrc/css/application/maniphest/report.css' => '9b9580b7', @@ -579,7 +579,7 @@ return array( 'font-fontawesome' => 'e838e088', 'font-lato' => 'c7ccd872', 'global-drag-and-drop-css' => 'b556a948', - 'harbormaster-css' => '5dd4c2de', + 'harbormaster-css' => '2999ccaa', 'herald-css' => 'cd8d0134', 'herald-rule-editor' => 'dca75c0e', 'herald-test-css' => 'a52e323e', diff --git a/src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php b/src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php index 27a75f288b..4fa826b690 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php @@ -355,11 +355,11 @@ final class HarbormasterBuildLogRenderController $display_line = ($line['line'] + 1); $display_text = ($line['data']); - $cell_attr = array(); + $row_attr = array(); if ($highlight_range) { if (($display_line >= $highlight_range[0]) && ($display_line <= $highlight_range[1])) { - $cell_attr = array( + $row_attr = array( 'class' => 'phabricator-source-highlight', ); } @@ -373,11 +373,11 @@ final class HarbormasterBuildLogRenderController $display_line); $line_cell = phutil_tag('th', array(), $display_line); - $text_cell = phutil_tag('td', $cell_attr, $display_text); + $text_cell = phutil_tag('td', array(), $display_text); $rows[] = phutil_tag( 'tr', - array(), + $row_attr, array( $line_cell, $text_cell, @@ -401,10 +401,14 @@ final class HarbormasterBuildLogRenderController } } - $table = phutil_tag( + $table = javelin_tag( 'table', array( 'class' => 'harbormaster-log-table PhabricatorMonospaced', + 'sigil' => 'phabricator-source', + 'meta' => array( + 'uri' => $log->getURI(), + ), ), $rows); diff --git a/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php index 40641795c5..888b3bddb2 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildLogViewController.php @@ -24,7 +24,8 @@ final class HarbormasterBuildLogViewController $log_view = id(new HarbormasterBuildLogView()) ->setViewer($viewer) ->setBuildLog($log) - ->setHighlightedLineRange($request->getURIData('lines')); + ->setHighlightedLineRange($request->getURIData('lines')) + ->setEnableHighlighter(true); $crumbs = $this->buildApplicationCrumbs() ->addTextCrumb(pht('Build Logs')) diff --git a/src/applications/harbormaster/view/HarbormasterBuildLogView.php b/src/applications/harbormaster/view/HarbormasterBuildLogView.php index 768c55a504..5eb32a84e5 100644 --- a/src/applications/harbormaster/view/HarbormasterBuildLogView.php +++ b/src/applications/harbormaster/view/HarbormasterBuildLogView.php @@ -4,6 +4,7 @@ final class HarbormasterBuildLogView extends AphrontView { private $log; private $highlightedLineRange; + private $enableHighlighter; public function setBuildLog(HarbormasterBuildLog $log) { $this->log = $log; @@ -23,6 +24,11 @@ final class HarbormasterBuildLogView extends AphrontView { return $this->highlightedLineRange; } + public function setEnableHighlighter($enable) { + $this->enableHighlighter = $enable; + return $this; + } + public function render() { $viewer = $this->getViewer(); $log = $this->getBuildLog(); @@ -50,6 +56,10 @@ final class HarbormasterBuildLogView extends AphrontView { ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setHeader($header); + if ($this->enableHighlighter) { + Javelin::initBehavior('phabricator-line-linker'); + } + $has_linemap = $log->getLineMap(); if ($has_linemap) { $content_id = celerity_generate_unique_node_id(); diff --git a/webroot/rsrc/css/application/harbormaster/harbormaster.css b/webroot/rsrc/css/application/harbormaster/harbormaster.css index b22658219a..0e8574464d 100644 --- a/webroot/rsrc/css/application/harbormaster/harbormaster.css +++ b/webroot/rsrc/css/application/harbormaster/harbormaster.css @@ -69,7 +69,11 @@ padding: 4px 0; } -.harbormaster-log-table tr.harbormaster-log-highlighted > td { +.harbormaster-log-table tr.phabricator-source-highlight > th { + background: {$paste.border}; +} + +.harbormaster-log-table tr.phabricator-source-highlight > td { background: {$paste.highlight}; }