1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

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
This commit is contained in:
epriestley 2018-03-01 08:02:32 -08:00
parent fe3de5dd58
commit 73619c4643
5 changed files with 28 additions and 9 deletions

View file

@ -78,7 +78,7 @@ return array(
'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 'rsrc/css/application/feed/feed.css' => 'ecd4ec57',
'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948',
'rsrc/css/application/flag/flag.css' => 'bba8f811', '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-test.css' => 'a52e323e',
'rsrc/css/application/herald/herald.css' => 'cd8d0134', 'rsrc/css/application/herald/herald.css' => 'cd8d0134',
'rsrc/css/application/maniphest/report.css' => '9b9580b7', 'rsrc/css/application/maniphest/report.css' => '9b9580b7',
@ -579,7 +579,7 @@ return array(
'font-fontawesome' => 'e838e088', 'font-fontawesome' => 'e838e088',
'font-lato' => 'c7ccd872', 'font-lato' => 'c7ccd872',
'global-drag-and-drop-css' => 'b556a948', 'global-drag-and-drop-css' => 'b556a948',
'harbormaster-css' => '5dd4c2de', 'harbormaster-css' => '2999ccaa',
'herald-css' => 'cd8d0134', 'herald-css' => 'cd8d0134',
'herald-rule-editor' => 'dca75c0e', 'herald-rule-editor' => 'dca75c0e',
'herald-test-css' => 'a52e323e', 'herald-test-css' => 'a52e323e',

View file

@ -355,11 +355,11 @@ final class HarbormasterBuildLogRenderController
$display_line = ($line['line'] + 1); $display_line = ($line['line'] + 1);
$display_text = ($line['data']); $display_text = ($line['data']);
$cell_attr = array(); $row_attr = array();
if ($highlight_range) { if ($highlight_range) {
if (($display_line >= $highlight_range[0]) && if (($display_line >= $highlight_range[0]) &&
($display_line <= $highlight_range[1])) { ($display_line <= $highlight_range[1])) {
$cell_attr = array( $row_attr = array(
'class' => 'phabricator-source-highlight', 'class' => 'phabricator-source-highlight',
); );
} }
@ -373,11 +373,11 @@ final class HarbormasterBuildLogRenderController
$display_line); $display_line);
$line_cell = phutil_tag('th', array(), $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( $rows[] = phutil_tag(
'tr', 'tr',
array(), $row_attr,
array( array(
$line_cell, $line_cell,
$text_cell, $text_cell,
@ -401,10 +401,14 @@ final class HarbormasterBuildLogRenderController
} }
} }
$table = phutil_tag( $table = javelin_tag(
'table', 'table',
array( array(
'class' => 'harbormaster-log-table PhabricatorMonospaced', 'class' => 'harbormaster-log-table PhabricatorMonospaced',
'sigil' => 'phabricator-source',
'meta' => array(
'uri' => $log->getURI(),
),
), ),
$rows); $rows);

View file

@ -24,7 +24,8 @@ final class HarbormasterBuildLogViewController
$log_view = id(new HarbormasterBuildLogView()) $log_view = id(new HarbormasterBuildLogView())
->setViewer($viewer) ->setViewer($viewer)
->setBuildLog($log) ->setBuildLog($log)
->setHighlightedLineRange($request->getURIData('lines')); ->setHighlightedLineRange($request->getURIData('lines'))
->setEnableHighlighter(true);
$crumbs = $this->buildApplicationCrumbs() $crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Build Logs')) ->addTextCrumb(pht('Build Logs'))

View file

@ -4,6 +4,7 @@ final class HarbormasterBuildLogView extends AphrontView {
private $log; private $log;
private $highlightedLineRange; private $highlightedLineRange;
private $enableHighlighter;
public function setBuildLog(HarbormasterBuildLog $log) { public function setBuildLog(HarbormasterBuildLog $log) {
$this->log = $log; $this->log = $log;
@ -23,6 +24,11 @@ final class HarbormasterBuildLogView extends AphrontView {
return $this->highlightedLineRange; return $this->highlightedLineRange;
} }
public function setEnableHighlighter($enable) {
$this->enableHighlighter = $enable;
return $this;
}
public function render() { public function render() {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$log = $this->getBuildLog(); $log = $this->getBuildLog();
@ -50,6 +56,10 @@ final class HarbormasterBuildLogView extends AphrontView {
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setHeader($header); ->setHeader($header);
if ($this->enableHighlighter) {
Javelin::initBehavior('phabricator-line-linker');
}
$has_linemap = $log->getLineMap(); $has_linemap = $log->getLineMap();
if ($has_linemap) { if ($has_linemap) {
$content_id = celerity_generate_unique_node_id(); $content_id = celerity_generate_unique_node_id();

View file

@ -69,7 +69,11 @@
padding: 4px 0; 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}; background: {$paste.highlight};
} }