@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.

Remove duplicate inline scaffold in 2up renderer

Summary: Ref T2009. Remove the 4 (!!) copies of this code.

Test Plan:
- Added, edited, and removed inline comments in 2up view.
- Stacked a bunch of comments on the same line and saw the JS place them correctly.
- Created an image diff and added, edited and removed inlines on it.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2009

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

+34 -48
-7
src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
··· 425 425 )); 426 426 } 427 427 428 - protected function renderInlineComment( 429 - PhabricatorInlineCommentInterface $comment, 430 - $on_right = false) { 431 - 432 - return $this->buildInlineComment($comment, $on_right)->render(); 433 - } 434 - 435 428 protected function buildInlineComment( 436 429 PhabricatorInlineCommentInterface $comment, 437 430 $on_right = false) {
+24 -39
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
··· 264 264 265 265 if ($o_num && isset($old_comments[$o_num])) { 266 266 foreach ($old_comments[$o_num] as $comment) { 267 - $comment_html = $this->renderInlineComment($comment, 268 - $on_right = false); 269 - $new = ''; 267 + $inline = $this->buildInlineComment( 268 + $comment, 269 + $on_right = false); 270 + $scaffold = $this->getRowScaffoldForInline($inline); 271 + 270 272 if ($n_num && isset($new_comments[$n_num])) { 271 273 foreach ($new_comments[$n_num] as $key => $new_comment) { 272 274 if ($comment->isCompatible($new_comment)) { 273 - $new = $this->renderInlineComment($new_comment, 274 - $on_right = true); 275 + $companion = $this->buildInlineComment( 276 + $new_comment, 277 + $on_right = true); 278 + 279 + $scaffold->addInlineView($companion); 275 280 unset($new_comments[$n_num][$key]); 276 281 } 277 282 } 278 283 } 279 - $html[] = phutil_tag('tr', array('class' => 'inline'), array( 280 - phutil_tag('th', array()), 281 - phutil_tag('td', array(), $comment_html), 282 - phutil_tag('th', array()), 283 - phutil_tag('td', array('colspan' => 3), $new), 284 - )); 284 + 285 + $html[] = $scaffold; 285 286 } 286 287 } 287 288 if ($n_num && isset($new_comments[$n_num])) { 288 289 foreach ($new_comments[$n_num] as $comment) { 289 - $comment_html = $this->renderInlineComment($comment, 290 - $on_right = true); 291 - $html[] = phutil_tag('tr', array('class' => 'inline'), array( 292 - phutil_tag('th', array()), 293 - phutil_tag('td', array()), 294 - phutil_tag('th', array()), 295 - phutil_tag( 296 - 'td', 297 - array('colspan' => 3), 298 - $comment_html), 299 - )); 290 + $inline = $this->buildInlineComment( 291 + $comment, 292 + $on_right = true); 293 + $html[] = $this->getRowScaffoldForInline($inline); 300 294 } 301 295 } 302 296 } ··· 340 334 $html_new = array(); 341 335 foreach ($this->getOldComments() as $on_line => $comment_group) { 342 336 foreach ($comment_group as $comment) { 343 - $comment_html = $this->renderInlineComment($comment, $on_right = false); 344 - $html_old[] = phutil_tag('tr', array('class' => 'inline'), array( 345 - phutil_tag('th', array()), 346 - phutil_tag('td', array(), $comment_html), 347 - phutil_tag('th', array()), 348 - phutil_tag('td', array('colspan' => 3)), 349 - )); 337 + $inline = $this->buildInlineComment( 338 + $comment, 339 + $on_right = false); 340 + $html_old[] = $this->getRowScaffoldForInline($inline); 350 341 } 351 342 } 352 343 foreach ($this->getNewComments() as $lin_line => $comment_group) { 353 344 foreach ($comment_group as $comment) { 354 - $comment_html = $this->renderInlineComment($comment, $on_right = true); 355 - $html_new[] = phutil_tag('tr', array('class' => 'inline'), array( 356 - phutil_tag('th', array()), 357 - phutil_tag('td', array()), 358 - phutil_tag('th', array()), 359 - phutil_tag( 360 - 'td', 361 - array('colspan' => 3), 362 - $comment_html), 363 - )); 345 + $inline = $this->buildInlineComment( 346 + $comment, 347 + $on_right = true); 348 + $html_new[] = $this->getRowScaffoldForInline($inline); 364 349 } 365 350 } 366 351
+8
src/infrastructure/diff/view/PHUIDiffInlineCommentRowScaffold.php
··· 20 20 return $this; 21 21 } 22 22 23 + protected function getRowAttributes() { 24 + // TODO: This is semantic information used by the JS when placing comments 25 + // and using keyboard navigation; we should move it out of class names. 26 + return array( 27 + 'class' => 'inline', 28 + ); 29 + } 30 + 23 31 }
+1 -1
src/infrastructure/diff/view/PHUIDiffOneUpInlineCommentRowScaffold.php
··· 27 27 phutil_tag('td', $attrs, $inline), 28 28 ); 29 29 30 - return phutil_tag('tr', array(), $cells); 30 + return phutil_tag('tr', $this->getRowAttributes(), $cells); 31 31 } 32 32 33 33 }
+1 -1
src/infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php
··· 66 66 phutil_tag('td', $right_attrs, $right_side), 67 67 ); 68 68 69 - return phutil_tag('tr', array(), $cells); 69 + return phutil_tag('tr', $this->getRowAttributes(), $cells); 70 70 } 71 71 72 72 }