From 901328088d25af956159e03751edb39d785c7b62 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 14 Jan 2013 14:20:54 -0800 Subject: [PATCH] Render inline comments somewhat-correctly on 1-up diffs Summary: You can't interact with them yey, but do a less awful job of rendering them. Test Plan: {F29204} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2009 Differential Revision: https://secure.phabricator.com/D4426 --- .../DifferentialChangesetHTMLRenderer.php | 46 +++++++++++++++---- .../DifferentialChangesetOneUpRenderer.php | 9 ++-- .../render/DifferentialChangesetRenderer.php | 22 +-------- .../DifferentialChangesetTestRenderer.php | 2 +- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php index ef95235350..73205aed4b 100644 --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -293,7 +293,7 @@ abstract class DifferentialChangesetHTMLRenderer ''; } - protected function renderShield($message, $force = 'default') { + public function renderShield($message, $force = 'default') { $end = count($this->getOldLines()); $reference = $this->getRenderingReference(); @@ -333,15 +333,16 @@ abstract class DifferentialChangesetHTMLRenderer 'Show File Contents'); } - return javelin_render_tag( - 'tr', - array( - 'sigil' => 'context-target', - ), - ''. - phutil_escape_html($message). - $more. - ''); + return $this->wrapChangeInTable( + javelin_render_tag( + 'tr', + array( + 'sigil' => 'context-target', + ), + ''. + phutil_escape_html($message). + $more. + '')); } protected function wrapChangeInTable($content) { @@ -358,5 +359,30 @@ abstract class DifferentialChangesetHTMLRenderer $content); } + protected function renderInlineComment( + PhabricatorInlineCommentInterface $comment, + $on_right = false) { + + return $this->buildInlineComment($comment, $on_right)->render(); + } + + protected function buildInlineComment( + PhabricatorInlineCommentInterface $comment, + $on_right = false) { + + $user = $this->getUser(); + $edit = $user && + ($comment->getAuthorPHID() == $user->getPHID()) && + ($comment->isDraft()); + $allow_reply = (bool)$user; + + return id(new DifferentialInlineCommentView()) + ->setInlineComment($comment) + ->setOnRight($on_right) + ->setHandles($this->getHandles()) + ->setMarkupEngine($this->getMarkupEngine()) + ->setEditable($edit) + ->setAllowReply($allow_reply); + } } diff --git a/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php b/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php index 5ab1fa07b2..18f49f6eaa 100644 --- a/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php @@ -45,10 +45,13 @@ final class DifferentialChangesetOneUpRenderer break; case 'inline': $out[] = ''; - $out[] = ''; + $out[] = ''; - $out[] = 'INLINE COMMENT
'; - $out[] = phutil_escape_html($p['comment']->getContent()); + $inline = $this->buildInlineComment( + $p['comment'], + $p['right']); + $inline->setBuildScaffolding(false); + $out[] = $inline->render(); $out[] = ''; break; diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php index b592e988eb..3fbd6a916d 100644 --- a/src/applications/differential/render/DifferentialChangesetRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetRenderer.php @@ -298,30 +298,10 @@ abstract class DifferentialChangesetRenderer { * @param string|null Force mode, see above. * @return string Shield markup. */ - abstract protected function renderShield($message, $force = 'default'); + abstract public function renderShield($message, $force = 'default'); abstract protected function renderPropertyChangeHeader(); - protected function renderInlineComment( - PhabricatorInlineCommentInterface $comment, - $on_right = false) { - - $user = $this->getUser(); - $edit = $user && - ($comment->getAuthorPHID() == $user->getPHID()) && - ($comment->isDraft()); - $allow_reply = (bool)$user; - - return id(new DifferentialInlineCommentView()) - ->setInlineComment($comment) - ->setOnRight($on_right) - ->setHandles($this->getHandles()) - ->setMarkupEngine($this->getMarkupEngine()) - ->setEditable($edit) - ->setAllowReply($allow_reply) - ->render(); - } - protected function buildPrimitives($range_start, $range_len) { $primitives = array(); diff --git a/src/applications/differential/render/DifferentialChangesetTestRenderer.php b/src/applications/differential/render/DifferentialChangesetTestRenderer.php index 202b783463..4472eaf246 100644 --- a/src/applications/differential/render/DifferentialChangesetTestRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetTestRenderer.php @@ -17,7 +17,7 @@ abstract class DifferentialChangesetTestRenderer "{$away}\n"; } - protected function renderShield($message, $force = 'default') { + public function renderShield($message, $force = 'default') { return "SHIELD ({$force}) {$message}\n"; }