@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow unit test results to specify that their details are formatted with remarkup when reporting to "harbormaster.sendmessage"

Summary: Ref T13189. See PHI710. Ref T13088. Fixes T9951. Allow callers to `harbormaster.sendmessage` to specify that the test details are remarkup so they can use rich formatting and include links, files, etc.

Test Plan: {F5840098}

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13189, T13088, T9951

Differential Revision: https://secure.phabricator.com/D19615

+93 -53
+2 -2
resources/celerity/map.php
··· 75 75 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 76 76 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 77 77 'rsrc/css/application/flag/flag.css' => 'bba8f811', 78 - 'rsrc/css/application/harbormaster/harbormaster.css' => '730a4a3c', 78 + 'rsrc/css/application/harbormaster/harbormaster.css' => '7446ce72', 79 79 'rsrc/css/application/herald/herald-test.css' => 'a52e323e', 80 80 'rsrc/css/application/herald/herald.css' => 'cd8d0134', 81 81 'rsrc/css/application/maniphest/report.css' => '9b9580b7', ··· 554 554 'font-fontawesome' => 'e838e088', 555 555 'font-lato' => 'c7ccd872', 556 556 'global-drag-and-drop-css' => 'b556a948', 557 - 'harbormaster-css' => '730a4a3c', 557 + 'harbormaster-css' => '7446ce72', 558 558 'herald-css' => 'cd8d0134', 559 559 'herald-rule-editor' => 'dca75c0e', 560 560 'herald-test-css' => 'a52e323e',
+1 -1
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 1315 1315 } 1316 1316 1317 1317 return id(new HarbormasterUnitSummaryView()) 1318 - ->setUser($viewer) 1318 + ->setViewer($viewer) 1319 1319 ->setExcuse($excuse) 1320 1320 ->setBuildable($diff->getBuildable()) 1321 1321 ->setUnitMessages($diff->getUnitMessages())
+2 -1
src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
··· 318 318 319 319 if ($lint_data) { 320 320 $lint_table = id(new HarbormasterLintPropertyView()) 321 - ->setUser($viewer) 321 + ->setViewer($viewer) 322 322 ->setLimit(10) 323 323 ->setLintMessages($lint_data); 324 324 ··· 343 343 344 344 if ($unit_data) { 345 345 $unit = id(new HarbormasterUnitSummaryView()) 346 + ->setViewer($viewer) 346 347 ->setBuildable($buildable) 347 348 ->setUnitMessages($unit_data) 348 349 ->setShowViewAll(true)
+1
src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php
··· 39 39 } 40 40 41 41 $unit = id(new HarbormasterUnitSummaryView()) 42 + ->setViewer($viewer) 42 43 ->setBuildable($buildable) 43 44 ->setUnitMessages($unit_data); 44 45
+1 -17
src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php
··· 88 88 pht('Run At'), 89 89 phabricator_datetime($message->getDateCreated(), $viewer)); 90 90 91 - $details = $message->getUnitMessageDetails(); 92 - if (strlen($details)) { 93 - // TODO: Use the log view here, once it gets cleaned up. 94 - // Shenanigans below. 95 - $details = phutil_tag( 96 - 'div', 97 - array( 98 - 'class' => 'PhabricatorMonospaced', 99 - 'style' => 100 - 'white-space: pre-wrap; '. 101 - 'color: #666666; '. 102 - 'overflow-x: auto;', 103 - ), 104 - $details); 105 - } else { 106 - $details = phutil_tag('em', array(), pht('No details provided.')); 107 - } 91 + $details = $message->newUnitMessageDetailsView($viewer); 108 92 109 93 $view->addSectionHeader( 110 94 pht('Details'),
+75
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
··· 13 13 14 14 private $buildTarget = self::ATTACHABLE; 15 15 16 + const FORMAT_TEXT = 'text'; 17 + const FORMAT_REMARKUP = 'remarkup'; 18 + 16 19 public static function initializeNewUnitMessage( 17 20 HarbormasterBuildTarget $build_target) { 18 21 return id(new HarbormasterBuildUnitMessage()) ··· 65 68 'type' => 'optional string', 66 69 'description' => pht( 67 70 'Additional human-readable information about the failure.'), 71 + ), 72 + 'format' => array( 73 + 'type' => 'optional string', 74 + 'description' => pht( 75 + 'Format for the text provided in "details". Valid values are '. 76 + '"text" (default) or "remarkup". This controls how test details '. 77 + 'are rendered when shown to users.'), 68 78 ), 69 79 ); 70 80 } ··· 104 114 $obj->setProperty('details', $details); 105 115 } 106 116 117 + $format = idx($dict, 'format'); 118 + if ($format) { 119 + $obj->setProperty('format', $format); 120 + } 121 + 107 122 return $obj; 108 123 } 109 124 ··· 147 162 148 163 public function getUnitMessageDetails() { 149 164 return $this->getProperty('details', ''); 165 + } 166 + 167 + public function getUnitMessageDetailsFormat() { 168 + return $this->getProperty('format', self::FORMAT_TEXT); 169 + } 170 + 171 + public function newUnitMessageDetailsView( 172 + PhabricatorUser $viewer, 173 + $summarize = false) { 174 + 175 + $format = $this->getUnitMessageDetailsFormat(); 176 + 177 + $is_text = ($format !== self::FORMAT_REMARKUP); 178 + $is_remarkup = ($format === self::FORMAT_REMARKUP); 179 + 180 + $full_details = $this->getUnitMessageDetails(); 181 + 182 + if (!strlen($full_details)) { 183 + if ($summarize) { 184 + return null; 185 + } 186 + $details = phutil_tag('em', array(), pht('No details provided.')); 187 + } else if ($summarize) { 188 + if ($is_text) { 189 + $details = id(new PhutilUTF8StringTruncator()) 190 + ->setMaximumBytes(2048) 191 + ->truncateString($full_details); 192 + $details = phutil_split_lines($details); 193 + 194 + $limit = 3; 195 + if (count($details) > $limit) { 196 + $details = array_slice($details, 0, $limit); 197 + } 198 + 199 + $details = implode('', $details); 200 + } else { 201 + $details = $full_details; 202 + } 203 + } else { 204 + $details = $full_details; 205 + } 206 + 207 + require_celerity_resource('harbormaster-css'); 208 + 209 + $classes = array(); 210 + $classes[] = 'harbormaster-unit-details'; 211 + 212 + if ($is_remarkup) { 213 + $details = new PHUIRemarkupView($viewer, $details); 214 + } else { 215 + $classes[] = 'harbormaster-unit-details-text'; 216 + $classes[] = 'PhabricatorMonospaced'; 217 + } 218 + 219 + return phutil_tag( 220 + 'div', 221 + array( 222 + 'class' => implode(' ', $classes), 223 + ), 224 + $details); 150 225 } 151 226 152 227 public function getUnitMessageDisplayName() {
+5 -30
src/applications/harbormaster/view/HarbormasterUnitPropertyView.php
··· 34 34 return $this; 35 35 } 36 36 37 - 38 37 public function render() { 39 - require_celerity_resource('harbormaster-css'); 38 + $viewer = $this->getViewer(); 40 39 41 40 $messages = $this->unitMessages; 42 41 $messages = msort($messages, 'getSortKey'); ··· 84 83 $name); 85 84 } 86 85 87 - $details = $message->getUnitMessageDetails(); 88 - if (strlen($details)) { 89 - $name = array( 90 - $name, 91 - $this->renderUnitTestDetails($details), 92 - ); 93 - } 86 + $name = array( 87 + $name, 88 + $message->newUnitMessageDetailsView($viewer, true), 89 + ); 94 90 95 91 $rows[] = array( 96 92 $result_icon, ··· 156 152 } 157 153 158 154 return $table; 159 - } 160 - 161 - private function renderUnitTestDetails($full_details) { 162 - $details = id(new PhutilUTF8StringTruncator()) 163 - ->setMaximumBytes(2048) 164 - ->truncateString($full_details); 165 - $details = phutil_split_lines($details); 166 - 167 - $limit = 3; 168 - if (count($details) > $limit) { 169 - $details = array_slice($details, 0, $limit); 170 - } 171 - 172 - $details = implode('', $details); 173 - 174 - return phutil_tag( 175 - 'div', 176 - array( 177 - 'class' => 'PhabricatorMonospaced harbormaster-unit-details', 178 - ), 179 - $details); 180 155 } 181 156 182 157 }
+1
src/applications/harbormaster/view/HarbormasterUnitSummaryView.php
··· 77 77 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 78 78 79 79 $table = id(new HarbormasterUnitPropertyView()) 80 + ->setViewer($this->getViewer()) 80 81 ->setUnitMessages($messages); 81 82 82 83 if ($this->showViewAll) {
+5 -2
webroot/rsrc/css/application/harbormaster/harbormaster.css
··· 26 26 .harbormaster-unit-details { 27 27 margin: 8px 0 4px; 28 28 overflow: hidden; 29 - white-space: pre; 29 + color: {$lightgreytext}; 30 + } 31 + 32 + .harbormaster-unit-details-text { 33 + white-space: pre-wrap; 30 34 text-overflow: ellipsis; 31 - color: {$lightgreytext}; 32 35 } 33 36 34 37 .harbormaster-log-view-loading {