1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

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
This commit is contained in:
epriestley 2015-03-06 05:57:24 -08:00
parent ac60b23ef9
commit f9cb366f00
5 changed files with 34 additions and 48 deletions

View file

@ -425,13 +425,6 @@ abstract class DifferentialChangesetHTMLRenderer
)); ));
} }
protected function renderInlineComment(
PhabricatorInlineCommentInterface $comment,
$on_right = false) {
return $this->buildInlineComment($comment, $on_right)->render();
}
protected function buildInlineComment( protected function buildInlineComment(
PhabricatorInlineCommentInterface $comment, PhabricatorInlineCommentInterface $comment,
$on_right = false) { $on_right = false) {

View file

@ -264,39 +264,33 @@ final class DifferentialChangesetTwoUpRenderer
if ($o_num && isset($old_comments[$o_num])) { if ($o_num && isset($old_comments[$o_num])) {
foreach ($old_comments[$o_num] as $comment) { foreach ($old_comments[$o_num] as $comment) {
$comment_html = $this->renderInlineComment($comment, $inline = $this->buildInlineComment(
$comment,
$on_right = false); $on_right = false);
$new = ''; $scaffold = $this->getRowScaffoldForInline($inline);
if ($n_num && isset($new_comments[$n_num])) { if ($n_num && isset($new_comments[$n_num])) {
foreach ($new_comments[$n_num] as $key => $new_comment) { foreach ($new_comments[$n_num] as $key => $new_comment) {
if ($comment->isCompatible($new_comment)) { if ($comment->isCompatible($new_comment)) {
$new = $this->renderInlineComment($new_comment, $companion = $this->buildInlineComment(
$new_comment,
$on_right = true); $on_right = true);
$scaffold->addInlineView($companion);
unset($new_comments[$n_num][$key]); unset($new_comments[$n_num][$key]);
} }
} }
} }
$html[] = phutil_tag('tr', array('class' => 'inline'), array(
phutil_tag('th', array()), $html[] = $scaffold;
phutil_tag('td', array(), $comment_html),
phutil_tag('th', array()),
phutil_tag('td', array('colspan' => 3), $new),
));
} }
} }
if ($n_num && isset($new_comments[$n_num])) { if ($n_num && isset($new_comments[$n_num])) {
foreach ($new_comments[$n_num] as $comment) { foreach ($new_comments[$n_num] as $comment) {
$comment_html = $this->renderInlineComment($comment, $inline = $this->buildInlineComment(
$comment,
$on_right = true); $on_right = true);
$html[] = phutil_tag('tr', array('class' => 'inline'), array( $html[] = $this->getRowScaffoldForInline($inline);
phutil_tag('th', array()),
phutil_tag('td', array()),
phutil_tag('th', array()),
phutil_tag(
'td',
array('colspan' => 3),
$comment_html),
));
} }
} }
} }
@ -340,27 +334,18 @@ final class DifferentialChangesetTwoUpRenderer
$html_new = array(); $html_new = array();
foreach ($this->getOldComments() as $on_line => $comment_group) { foreach ($this->getOldComments() as $on_line => $comment_group) {
foreach ($comment_group as $comment) { foreach ($comment_group as $comment) {
$comment_html = $this->renderInlineComment($comment, $on_right = false); $inline = $this->buildInlineComment(
$html_old[] = phutil_tag('tr', array('class' => 'inline'), array( $comment,
phutil_tag('th', array()), $on_right = false);
phutil_tag('td', array(), $comment_html), $html_old[] = $this->getRowScaffoldForInline($inline);
phutil_tag('th', array()),
phutil_tag('td', array('colspan' => 3)),
));
} }
} }
foreach ($this->getNewComments() as $lin_line => $comment_group) { foreach ($this->getNewComments() as $lin_line => $comment_group) {
foreach ($comment_group as $comment) { foreach ($comment_group as $comment) {
$comment_html = $this->renderInlineComment($comment, $on_right = true); $inline = $this->buildInlineComment(
$html_new[] = phutil_tag('tr', array('class' => 'inline'), array( $comment,
phutil_tag('th', array()), $on_right = true);
phutil_tag('td', array()), $html_new[] = $this->getRowScaffoldForInline($inline);
phutil_tag('th', array()),
phutil_tag(
'td',
array('colspan' => 3),
$comment_html),
));
} }
} }

View file

@ -20,4 +20,12 @@ abstract class PHUIDiffInlineCommentRowScaffold extends AphrontView {
return $this; return $this;
} }
protected function getRowAttributes() {
// TODO: This is semantic information used by the JS when placing comments
// and using keyboard navigation; we should move it out of class names.
return array(
'class' => 'inline',
);
}
} }

View file

@ -27,7 +27,7 @@ final class PHUIDiffOneUpInlineCommentRowScaffold
phutil_tag('td', $attrs, $inline), phutil_tag('td', $attrs, $inline),
); );
return phutil_tag('tr', array(), $cells); return phutil_tag('tr', $this->getRowAttributes(), $cells);
} }
} }

View file

@ -66,7 +66,7 @@ final class PHUIDiffTwoUpInlineCommentRowScaffold
phutil_tag('td', $right_attrs, $right_side), phutil_tag('td', $right_attrs, $right_side),
); );
return phutil_tag('tr', array(), $cells); return phutil_tag('tr', $this->getRowAttributes(), $cells);
} }
} }