Skip to content

Commit f9cb366

Browse files
author
epriestley
committed
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
1 parent ac60b23 commit f9cb366

File tree

5 files changed

+34
-48
lines changed

5 files changed

+34
-48
lines changed

src/applications/differential/render/DifferentialChangesetHTMLRenderer.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,6 @@ protected function wrapChangeInTable($content) {
425425
));
426426
}
427427

428-
protected function renderInlineComment(
429-
PhabricatorInlineCommentInterface $comment,
430-
$on_right = false) {
431-
432-
return $this->buildInlineComment($comment, $on_right)->render();
433-
}
434-
435428
protected function buildInlineComment(
436429
PhabricatorInlineCommentInterface $comment,
437430
$on_right = false) {

src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -264,39 +264,33 @@ public function renderTextChange(
264264

265265
if ($o_num && isset($old_comments[$o_num])) {
266266
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+
270272
if ($n_num && isset($new_comments[$n_num])) {
271273
foreach ($new_comments[$n_num] as $key => $new_comment) {
272274
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);
275280
unset($new_comments[$n_num][$key]);
276281
}
277282
}
278283
}
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;
285286
}
286287
}
287288
if ($n_num && isset($new_comments[$n_num])) {
288289
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);
300294
}
301295
}
302296
}
@@ -340,27 +334,18 @@ public function renderFileChange($old_file = null,
340334
$html_new = array();
341335
foreach ($this->getOldComments() as $on_line => $comment_group) {
342336
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);
350341
}
351342
}
352343
foreach ($this->getNewComments() as $lin_line => $comment_group) {
353344
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);
364349
}
365350
}
366351

src/infrastructure/diff/view/PHUIDiffInlineCommentRowScaffold.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ public function addInlineView(PHUIDiffInlineCommentView $view) {
2020
return $this;
2121
}
2222

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+
2331
}

src/infrastructure/diff/view/PHUIDiffOneUpInlineCommentRowScaffold.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function render() {
2727
phutil_tag('td', $attrs, $inline),
2828
);
2929

30-
return phutil_tag('tr', array(), $cells);
30+
return phutil_tag('tr', $this->getRowAttributes(), $cells);
3131
}
3232

3333
}

src/infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function render() {
6666
phutil_tag('td', $right_attrs, $right_side),
6767
);
6868

69-
return phutil_tag('tr', array(), $cells);
69+
return phutil_tag('tr', $this->getRowAttributes(), $cells);
7070
}
7171

7272
}

0 commit comments

Comments
 (0)