1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +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(
PhabricatorInlineCommentInterface $comment,
$on_right = false) {

View file

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

View file

@ -20,4 +20,12 @@ abstract class PHUIDiffInlineCommentRowScaffold extends AphrontView {
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),
);
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),
);
return phutil_tag('tr', array(), $cells);
return phutil_tag('tr', $this->getRowAttributes(), $cells);
}
}