From 7e571994bc7c67f781b231fc566a47b7cb65d209 Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 17 Apr 2012 21:18:30 -0700 Subject: [PATCH] Don't display inline comment's Reply in standalone view Summary: NOTE: This is starting to be too hacky. Test Plan: View revision with inline diffs, verify that Reply is there. View standalone - no Reply. Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2263 --- .../DifferentialChangesetViewController.php | 2 +- .../changeset/DifferentialChangesetParser.php | 2 ++ .../DifferentialInlineCommentView.php | 36 ++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php index db1e383d97..02dd0ca2be 100644 --- a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php @@ -202,7 +202,7 @@ final class DifferentialChangesetViewController extends DifferentialController { if ($request->isAjax()) { // TODO: This is sort of lazy, the effect is just to not render "Edit" - // links on the "standalone view". + // and "Reply" links on the "standalone view". $parser->setUser($request->getUser()); } diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index 8405bfd650..932ff70bc7 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -1497,6 +1497,7 @@ final class DifferentialChangesetParser { $edit = $user && ($comment->getAuthorPHID() == $user->getPHID()) && ($comment->isDraft()); + $allow_reply = (bool)$this->user; $on_right = $this->isCommentOnRightSideWhenDisplayed($comment); @@ -1506,6 +1507,7 @@ final class DifferentialChangesetParser { ->setHandles($this->handles) ->setMarkupEngine($this->markupEngine) ->setEditable($edit) + ->setAllowReply($allow_reply) ->render(); } diff --git a/src/applications/differential/view/inlinecomment/DifferentialInlineCommentView.php b/src/applications/differential/view/inlinecomment/DifferentialInlineCommentView.php index b5f77fc392..0ad9dab0bf 100644 --- a/src/applications/differential/view/inlinecomment/DifferentialInlineCommentView.php +++ b/src/applications/differential/view/inlinecomment/DifferentialInlineCommentView.php @@ -25,6 +25,7 @@ final class DifferentialInlineCommentView extends AphrontView { private $markupEngine; private $editable; private $preview; + private $allowReply; public function setInlineComment(PhabricatorInlineCommentInterface $comment) { $this->inlineComment = $comment; @@ -62,6 +63,11 @@ final class DifferentialInlineCommentView extends AphrontView { return $this; } + public function setAllowReply($allow_reply) { + $this->allowReply = $allow_reply; + return $this; + } + public function render() { $inline = $this->inlineComment; @@ -120,21 +126,25 @@ final class DifferentialInlineCommentView extends AphrontView { ), 'Next'); - if (!$is_synthetic) { + if ($this->allowReply) { - // NOTE: No product reason why you can't reply to these, but the reply - // mechanism currently sends the inline comment ID to the server, not - // file/line information, and synthetic comments don't have an inline - // comment ID. + if (!$is_synthetic) { + + // NOTE: No product reason why you can't reply to these, but the reply + // mechanism currently sends the inline comment ID to the server, not + // file/line information, and synthetic comments don't have an inline + // comment ID. + + $links[] = javelin_render_tag( + 'a', + array( + 'href' => '#', + 'mustcapture' => true, + 'sigil' => 'differential-inline-reply', + ), + 'Reply'); + } - $links[] = javelin_render_tag( - 'a', - array( - 'href' => '#', - 'mustcapture' => true, - 'sigil' => 'differential-inline-reply', - ), - 'Reply'); } }